WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Factors out a common RenderThemeChromiumSkia class and makes RenderThemeChromiumLinux and RenderThemeChromiumWin depend on it.
factor_out_skia (text/plain), 59.54 KB, created by
Albert J. Wong
on 2009-06-04 17:16:32 PDT
(
hide
)
Description:
Factors out a common RenderThemeChromiumSkia class and makes RenderThemeChromiumLinux and RenderThemeChromiumWin depend on it.
Filename:
MIME Type:
Creator:
Albert J. Wong
Created:
2009-06-04 17:16:32 PDT
Size:
59.54 KB
patch
obsolete
>diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog >index d15e516..a534523 100644 >--- a/WebCore/ChangeLog >+++ b/WebCore/ChangeLog >@@ -1,3 +1,75 @@ >+2009-06-04 Albert J. Wong <ajwong@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ https://bugs.webkit.org/show_bug.cgi?id=26148 >+ Factor out commonalities in RenderThemeChromiumLinux and RenderThemeChromiumWin into RenderThemeChromiumSkia. >+ >+ WARNING: NO TEST CASES ADDED OR CHANGED >+ >+ * rendering/RenderThemeChromiumLinux.cpp: >+ (WebCore::RenderThemeChromiumSkia::RenderThemeChromiumSkia): >+ (WebCore::RenderThemeChromiumSkia::~RenderThemeChromiumSkia): >+ (WebCore::RenderThemeChromiumSkia::extraDefaultStyleSheet): >+ (WebCore::RenderThemeChromiumSkia::extraQuirksStyleSheet): >+ (WebCore::RenderThemeChromiumSkia::extraMediaControlsStyleSheet): >+ (WebCore::RenderThemeChromiumSkia::supportsHover): >+ (WebCore::RenderThemeChromiumSkia::supportsFocusRing): >+ (WebCore::RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor): >+ (WebCore::RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor): >+ (WebCore::RenderThemeChromiumSkia::platformActiveSelectionForegroundColor): >+ (WebCore::RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor): >+ (WebCore::RenderThemeChromiumSkia::platformTextSearchHighlightColor): >+ (WebCore::RenderThemeChromiumSkia::caretBlinkInterval): >+ (WebCore::RenderThemeChromiumSkia::systemFont): >+ (WebCore::RenderThemeChromiumSkia::minimumMenuListSize): >+ (WebCore::RenderThemeChromiumSkia::paintCheckbox): >+ (WebCore::RenderThemeChromiumSkia::setCheckboxSize): >+ (WebCore::RenderThemeChromiumSkia::paintRadio): >+ (WebCore::RenderThemeChromiumSkia::setRadioSize): >+ (WebCore::RenderThemeChromiumSkia::paintButton): >+ (WebCore::RenderThemeChromiumSkia::paintTextField): >+ (WebCore::RenderThemeChromiumSkia::paintTextArea): >+ (WebCore::RenderThemeChromiumSkia::paintSearchField): >+ (WebCore::RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle): >+ (WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton): >+ (WebCore::RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle): >+ (WebCore::RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle): >+ (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration): >+ (WebCore::RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle): >+ (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton): >+ (WebCore::RenderThemeChromiumSkia::paintMediaPlayButton): >+ (WebCore::RenderThemeChromiumSkia::paintMediaMuteButton): >+ (WebCore::RenderThemeChromiumSkia::adjustMenuListStyle): >+ (WebCore::RenderThemeChromiumSkia::paintMenuList): >+ (WebCore::RenderThemeChromiumSkia::adjustMenuListButtonStyle): >+ (WebCore::RenderThemeChromiumSkia::paintMenuListButton): >+ (WebCore::RenderThemeChromiumSkia::popupInternalPaddingLeft): >+ (WebCore::RenderThemeChromiumSkia::popupInternalPaddingRight): >+ (WebCore::RenderThemeChromiumSkia::popupInternalPaddingTop): >+ (WebCore::RenderThemeChromiumSkia::popupInternalPaddingBottom): >+ (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingLeft): >+ (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingRight): >+ (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingTop): >+ (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingBottom): >+ (WebCore::RenderThemeChromiumSkia::caretBlinkIntervalInternal): >+ (WebCore::RenderThemeChromiumSkia::menuListInternalPadding): >+ (WebCore::RenderThemeChromiumSkia::paintMediaButtonInternal): >+ (WebCore::theme): >+ (WebCore::RenderThemeChromiumLinux::RenderThemeChromiumLinux): >+ (WebCore::RenderThemeChromiumLinux::~RenderThemeChromiumLinux): >+ * rendering/RenderThemeChromiumLinux.h: >+ * rendering/RenderThemeChromiumWin.cpp: >+ (WebCore::): >+ (WebCore::RenderThemeChromiumWin::RenderThemeChromiumWin): >+ (WebCore::RenderThemeChromiumWin::~RenderThemeChromiumWin): >+ (WebCore::RenderThemeChromiumWin::systemFont): >+ (WebCore::RenderThemeChromiumWin::paintCheckbox): >+ (WebCore::RenderThemeChromiumWin::paintRadio): >+ (WebCore::RenderThemeChromiumWin::paintSliderThumb): >+ (WebCore::RenderThemeChromiumWin::caretBlinkIntervalInternal): >+ * rendering/RenderThemeChromiumWin.h: >+ > 2009-06-01 Dimitri Glazkov <dglazkov@chromium.org> > > Unreviewed, build fix. >diff --git a/WebCore/rendering/RenderThemeChromiumLinux.cpp b/WebCore/rendering/RenderThemeChromiumLinux.cpp >index 94ee64f..583ea06 100644 >--- a/WebCore/rendering/RenderThemeChromiumLinux.cpp >+++ b/WebCore/rendering/RenderThemeChromiumLinux.cpp >@@ -52,11 +52,6 @@ enum PaddingType { > > static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 }; > >-// The default variable-width font size. We use this as the default font >-// size for the "system font", and as a base size (which we then shrink) for >-// form control fonts. >-static const float defaultFontSize = 16.0; >- > // The background for the media player controls should be a 60% opaque black rectangle. This > // matches the UI mockups for the default UI theme. > static const float defaultMediaControlOpacity = 0.6f; >@@ -71,12 +66,6 @@ static const float minSearchFieldResultsDecorationSize = 9; > static const float maxSearchFieldResultsDecorationSize = 30; > static const float defaultSearchFieldResultsButtonWidth = 18; > >-static bool supportsFocus(ControlPart appearance) >-{ >- // This causes WebKit to draw the focus rings for us. >- return false; >-} >- > static void setSizeIfAuto(RenderStyle* style, const IntSize& size) > { > if (style->width().isIntrinsicOrAuto()) >@@ -85,20 +74,6 @@ static void setSizeIfAuto(RenderStyle* style, const IntSize& size) > style->setHeight(Length(size.height(), Fixed)); > } > >-// We aim to match IE here. >-// -IE uses a font based on the encoding as the default font for form controls. >-// -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT), >-// which returns MS Shell Dlg) >-// -Safari uses Lucida Grande. >-// >-// FIXME: The only case where we know we don't match IE is for ANSI encodings. >-// IE uses MS Shell Dlg there, which we render incorrectly at certain pixel >-// sizes (e.g. 15px). So, for now we just use Arial. >-static const char* defaultGUIFont() >-{ >- return "Arial"; >-} >- > #if ENABLE(VIDEO) > // Attempt to retrieve a HTMLMediaElement from a Node. Returns NULL if one cannot be found. > static HTMLMediaElement* mediaElementParent(Node* node) >@@ -113,76 +88,92 @@ static HTMLMediaElement* mediaElementParent(Node* node) > } > #endif > >-RenderTheme* theme() >+// We aim to match IE here. >+// -IE uses a font based on the encoding as the default font for form controls. >+// -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT), >+// which returns MS Shell Dlg) >+// -Safari uses Lucida Grande. >+// >+// FIXME: The only case where we know we don't match IE is for ANSI encodings. >+// IE uses MS Shell Dlg there, which we render incorrectly at certain pixel >+// sizes (e.g. 15px). So, for now we just use Arial. >+const char* RenderThemeChromiumSkia::defaultGUIFont = "Arial"; >+ >+float RenderThemeChromiumSkia::defaultFontSize = 16.0; >+ >+RenderThemeChromiumSkia::RenderThemeChromiumSkia() > { >- static RenderThemeChromiumLinux theme; >- return &theme; > } > >-RenderThemeChromiumLinux::RenderThemeChromiumLinux() >+RenderThemeChromiumSkia::~RenderThemeChromiumSkia() > { > } > > // Use the Windows style sheets to match their metrics. >-String RenderThemeChromiumLinux::extraDefaultStyleSheet() >+String RenderThemeChromiumSkia::extraDefaultStyleSheet() > { > return String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet)); > } > >-String RenderThemeChromiumLinux::extraQuirksStyleSheet() >+String RenderThemeChromiumSkia::extraQuirksStyleSheet() > { > return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet)); > } > > #if ENABLE(VIDEO) >-String RenderThemeChromiumLinux::extraMediaControlsStyleSheet() >+String RenderThemeChromiumSkia::extraMediaControlsStyleSheet() > { > return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet)); > } > #endif > >-bool RenderThemeChromiumLinux::supportsFocusRing(const RenderStyle* style) const >+bool RenderThemeChromiumSkia::supportsHover(const RenderStyle* style) const > { >- return supportsFocus(style->appearance()); >+ return true; > } > >-Color RenderThemeChromiumLinux::platformActiveSelectionBackgroundColor() const >+bool RenderThemeChromiumSkia::supportsFocusRing(const RenderStyle* style) const >+{ >+ // This causes WebKit to draw the focus rings for us. >+ return false; >+} >+ >+Color RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor() const > { > return Color(0x1e, 0x90, 0xff); > } > >-Color RenderThemeChromiumLinux::platformInactiveSelectionBackgroundColor() const >+Color RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor() const > { > return Color(0xc8, 0xc8, 0xc8); > } > >-Color RenderThemeChromiumLinux::platformActiveSelectionForegroundColor() const >+Color RenderThemeChromiumSkia::platformActiveSelectionForegroundColor() const > { > return Color::black; > } > >-Color RenderThemeChromiumLinux::platformInactiveSelectionForegroundColor() const >+Color RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor() const > { > return Color(0x32, 0x32, 0x32); > } > >-Color RenderThemeChromiumLinux::platformTextSearchHighlightColor() const >+Color RenderThemeChromiumSkia::platformTextSearchHighlightColor() const > { > return Color(0xff, 0xff, 0x96); > } > >-double RenderThemeChromiumLinux::caretBlinkInterval() const >+double RenderThemeChromiumSkia::caretBlinkInterval() const > { > // Disable the blinking caret in layout test mode, as it introduces > // a race condition for the pixel tests. http://b/1198440 > if (ChromiumBridge::layoutTestMode()) > return 0; > >- // We cache the interval so we don't have to repeatedly request it from gtk. >- return 0.5; >+ return caretBlinkIntervalInternal(); > } > >-void RenderThemeChromiumLinux::systemFont(int propId, FontDescription& fontDescription) const >+void RenderThemeChromiumSkia::systemFont(int propId, FontDescription& fontDescription) const > { > float fontSize = defaultFontSize; > >@@ -199,7 +190,7 @@ void RenderThemeChromiumLinux::systemFont(int propId, FontDescription& fontDescr > break; > } > >- fontDescription.firstFamily().setFamily(defaultGUIFont()); >+ fontDescription.firstFamily().setFamily(defaultGUIFont); > fontDescription.setSpecifiedSize(fontSize); > fontDescription.setIsAbsoluteSize(true); > fontDescription.setGenericFamily(FontDescription::NoFamily); >@@ -207,12 +198,12 @@ void RenderThemeChromiumLinux::systemFont(int propId, FontDescription& fontDescr > fontDescription.setItalic(false); > } > >-int RenderThemeChromiumLinux::minimumMenuListSize(RenderStyle* style) const >+int RenderThemeChromiumSkia::minimumMenuListSize(RenderStyle* style) const > { > return 0; > } > >-bool RenderThemeChromiumLinux::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) > { > static Image* const checkedImage = Image::loadPlatformResource("linuxCheckboxOn").releaseRef(); > static Image* const uncheckedImage = Image::loadPlatformResource("linuxCheckboxOff").releaseRef(); >@@ -222,7 +213,7 @@ bool RenderThemeChromiumLinux::paintCheckbox(RenderObject* o, const RenderObject > return false; > } > >-void RenderThemeChromiumLinux::setCheckboxSize(RenderStyle* style) const >+void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const > { > // If the width and height are both specified, then we have nothing to do. > if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) >@@ -237,7 +228,7 @@ void RenderThemeChromiumLinux::setCheckboxSize(RenderStyle* style) const > setSizeIfAuto(style, size); > } > >-bool RenderThemeChromiumLinux::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) > { > static Image* const checkedImage = Image::loadPlatformResource("linuxRadioOn").releaseRef(); > static Image* const uncheckedImage = Image::loadPlatformResource("linuxRadioOff").releaseRef(); >@@ -247,7 +238,7 @@ bool RenderThemeChromiumLinux::paintRadio(RenderObject* o, const RenderObject::P > return false; > } > >-void RenderThemeChromiumLinux::setRadioSize(RenderStyle* style) const >+void RenderThemeChromiumSkia::setRadioSize(RenderStyle* style) const > { > // Use same sizing for radio box as checkbox. > setCheckboxSize(style); >@@ -302,18 +293,28 @@ static void paintButtonLike(RenderTheme* theme, RenderObject* o, const RenderObj > canvas->drawPoint(right - 2, bottom - 2, paint); > } > >-bool RenderThemeChromiumLinux::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) > { > paintButtonLike(this, o, i, rect); > return false; > } > >-bool RenderThemeChromiumLinux::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) > { > return true; > } > >-void RenderThemeChromiumLinux::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >+bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >+{ >+ return paintTextField(o, i, r); >+} >+ >+bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >+{ >+ return paintTextField(o, i, r); >+} >+ >+void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const > { > // Scale the button size based on the font size > float fontScale = style->fontSize() / defaultControlFontPixelSize; >@@ -322,17 +323,17 @@ void RenderThemeChromiumLinux::adjustSearchFieldCancelButtonStyle(CSSStyleSelect > style->setHeight(Length(cancelButtonSize, Fixed)); > } > >-bool RenderThemeChromiumLinux::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >+bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) > { > IntRect bounds = r; > ASSERT(o->parent()); > if (!o->parent() || !o->parent()->isBox()) > return false; >- >+ > RenderBox* parentRenderBox = toRenderBox(o->parent()); > > IntRect parentBox = parentRenderBox->absoluteContentBox(); >- >+ > // Make sure the scaled button stays square and will fit in its parent's box > bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height()))); > bounds.setWidth(bounds.height()); >@@ -347,14 +348,14 @@ bool RenderThemeChromiumLinux::paintSearchFieldCancelButton(RenderObject* o, con > return false; > } > >-void RenderThemeChromiumLinux::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >+void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const > { > IntSize emptySize(1, 11); > style->setWidth(Length(emptySize.width(), Fixed)); > style->setHeight(Length(emptySize.height(), Fixed)); > } > >-void RenderThemeChromiumLinux::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >+void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const > { > // Scale the decoration size based on the font size > float fontScale = style->fontSize() / defaultControlFontPixelSize; >@@ -364,16 +365,16 @@ void RenderThemeChromiumLinux::adjustSearchFieldResultsDecorationStyle(CSSStyleS > style->setHeight(Length(magnifierSize, Fixed)); > } > >-bool RenderThemeChromiumLinux::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >+bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) > { > IntRect bounds = r; > ASSERT(o->parent()); > if (!o->parent() || !o->parent()->isBox()) > return false; >- >+ > RenderBox* parentRenderBox = toRenderBox(o->parent()); > IntRect parentBox = parentRenderBox->absoluteContentBox(); >- >+ > // Make sure the scaled decoration stays square and will fit in its parent's box > bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height()))); > bounds.setWidth(bounds.height()); >@@ -381,13 +382,13 @@ bool RenderThemeChromiumLinux::paintSearchFieldResultsDecoration(RenderObject* o > // Center the decoration vertically. Round up though, so if it has to be one pixel off-center, it will > // be one pixel closer to the bottom of the field. This tends to look better with the text. > bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); >- >+ > static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef(); > i.context->drawImage(magnifierImage, bounds); > return false; > } > >-void RenderThemeChromiumLinux::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >+void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const > { > // Scale the button size based on the font size > float fontScale = style->fontSize() / defaultControlFontPixelSize; >@@ -398,7 +399,7 @@ void RenderThemeChromiumLinux::adjustSearchFieldResultsButtonStyle(CSSStyleSelec > style->setHeight(Length(magnifierHeight, Fixed)); > } > >-bool RenderThemeChromiumLinux::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >+bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) > { > IntRect bounds = r; > ASSERT(o->parent()); >@@ -406,10 +407,10 @@ bool RenderThemeChromiumLinux::paintSearchFieldResultsButton(RenderObject* o, co > return false; > if (!o->parent() || !o->parent()->isBox()) > return false; >- >+ > RenderBox* parentRenderBox = toRenderBox(o->parent()); > IntRect parentBox = parentRenderBox->absoluteContentBox(); >- >+ > // Make sure the scaled decoration will fit in its parent's box > bounds.setHeight(std::min(parentBox.height(), bounds.height())); > bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize))); >@@ -423,33 +424,7 @@ bool RenderThemeChromiumLinux::paintSearchFieldResultsButton(RenderObject* o, co > return false; > } > >-bool RenderThemeChromiumLinux::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image) >-{ >- context->beginTransparencyLayer(defaultMediaControlOpacity); >- >- // Draw background. >- Color oldFill = context->fillColor(); >- Color oldStroke = context->strokeColor(); >- >- context->setFillColor(Color::black); >- context->setStrokeColor(Color::black); >- context->drawRect(rect); >- >- context->setFillColor(oldFill); >- context->setStrokeColor(oldStroke); >- >- // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down. >- IntRect imageRect = image->rect(); >- imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2); >- imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2); >- >- context->drawImage(image, imageRect, CompositeSourceAtop); >- context->endTransparencyLayer(); >- >- return false; >-} >- >-bool RenderThemeChromiumLinux::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) > { > #if ENABLE(VIDEO) > HTMLMediaElement* mediaElement = mediaElementParent(o->node()); >@@ -465,7 +440,7 @@ bool RenderThemeChromiumLinux::paintMediaPlayButton(RenderObject* o, const Rende > #endif > } > >-bool RenderThemeChromiumLinux::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) > { > #if ENABLE(VIDEO) > HTMLMediaElement* mediaElement = mediaElementParent(o->node()); >@@ -481,13 +456,13 @@ bool RenderThemeChromiumLinux::paintMediaMuteButton(RenderObject* o, const Rende > #endif > } > >-void RenderThemeChromiumLinux::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const >+void RenderThemeChromiumSkia::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const > { > // Height is locked to auto on all browsers. > style->setLineHeight(RenderStyle::initialLineHeight()); > } > >-bool RenderThemeChromiumLinux::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) > { > SkCanvas* const canvas = i.context->platformContext()->canvas(); > const int right = rect.x() + rect.width(); >@@ -510,57 +485,120 @@ bool RenderThemeChromiumLinux::paintMenuList(RenderObject* o, const RenderObject > return false; > } > >-void RenderThemeChromiumLinux::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const >+void RenderThemeChromiumSkia::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const > { > adjustMenuListStyle(selector, style, e); > } > > // Used to paint styled menulists (i.e. with a non-default border) >-bool RenderThemeChromiumLinux::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+bool RenderThemeChromiumSkia::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) > { > return paintMenuList(o, i, rect); > } > >-int RenderThemeChromiumLinux::popupInternalPaddingLeft(RenderStyle* style) const >+int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const > { > return menuListInternalPadding(style, LeftPadding); > } > >-int RenderThemeChromiumLinux::popupInternalPaddingRight(RenderStyle* style) const >+int RenderThemeChromiumSkia::popupInternalPaddingRight(RenderStyle* style) const > { > return menuListInternalPadding(style, RightPadding); > } > >-int RenderThemeChromiumLinux::popupInternalPaddingTop(RenderStyle* style) const >+int RenderThemeChromiumSkia::popupInternalPaddingTop(RenderStyle* style) const > { > return menuListInternalPadding(style, TopPadding); > } > >-int RenderThemeChromiumLinux::popupInternalPaddingBottom(RenderStyle* style) const >+int RenderThemeChromiumSkia::popupInternalPaddingBottom(RenderStyle* style) const > { > return menuListInternalPadding(style, BottomPadding); > } > >-int RenderThemeChromiumLinux::buttonInternalPaddingLeft() const >+int RenderThemeChromiumSkia::buttonInternalPaddingLeft() const > { > return 3; > } > >-int RenderThemeChromiumLinux::buttonInternalPaddingRight() const >+int RenderThemeChromiumSkia::buttonInternalPaddingRight() const > { > return 3; > } > >-int RenderThemeChromiumLinux::buttonInternalPaddingTop() const >+int RenderThemeChromiumSkia::buttonInternalPaddingTop() const > { > return 1; > } > >-int RenderThemeChromiumLinux::buttonInternalPaddingBottom() const >+int RenderThemeChromiumSkia::buttonInternalPaddingBottom() const > { > return 1; > } > >+double RenderThemeChromiumSkia::caretBlinkIntervalInternal() const >+{ >+ return RenderTheme::caretBlinkInterval(); >+} >+ >+int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int paddingType) const >+{ >+ // This internal padding is in addition to the user-supplied padding. >+ // Matches the FF behavior. >+ int padding = styledMenuListInternalPadding[paddingType]; >+ >+ // Reserve the space for right arrow here. The rest of the padding is set >+ // by adjustMenuListStyle, since PopupMenuChromium.cpp uses the padding >+ // from RenderMenuList to lay out the individual items in the popup. If >+ // the MenuList actually has appearance "NoAppearance", then that means we >+ // don't draw a button, so don't reserve space for it. >+ const int barType = style->direction() == LTR ? RightPadding : LeftPadding; >+ if (paddingType == barType && style->appearance() != NoControlPart) >+ padding += ScrollbarTheme::nativeTheme()->scrollbarThickness(); >+ >+ return padding; >+} >+ >+bool RenderThemeChromiumSkia::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image) >+{ >+ context->beginTransparencyLayer(defaultMediaControlOpacity); >+ >+ // Draw background. >+ Color oldFill = context->fillColor(); >+ Color oldStroke = context->strokeColor(); >+ >+ context->setFillColor(Color::black); >+ context->setStrokeColor(Color::black); >+ context->drawRect(rect); >+ >+ context->setFillColor(oldFill); >+ context->setStrokeColor(oldStroke); >+ >+ // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down. >+ IntRect imageRect = image->rect(); >+ imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2); >+ imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2); >+ >+ context->drawImage(image, imageRect, CompositeSourceAtop); >+ context->endTransparencyLayer(); >+ >+ return false; >+} >+ >+RenderTheme* theme() >+{ >+ static RenderThemeChromiumLinux theme; >+ return &theme; >+} >+ >+RenderThemeChromiumLinux::RenderThemeChromiumLinux() >+{ >+} >+ >+RenderThemeChromiumLinux::~RenderThemeChromiumLinux() >+{ >+} >+ > bool RenderThemeChromiumLinux::controlSupportsTints(const RenderObject* o) const > { > return isEnabled(o); >@@ -586,22 +624,4 @@ Color RenderThemeChromiumLinux::inactiveListBoxSelectionForegroundColor() const > return Color(0x32, 0x32, 0x32); > } > >-int RenderThemeChromiumLinux::menuListInternalPadding(RenderStyle* style, int paddingType) const >-{ >- // This internal padding is in addition to the user-supplied padding. >- // Matches the FF behavior. >- int padding = styledMenuListInternalPadding[paddingType]; >- >- // Reserve the space for right arrow here. The rest of the padding is >- // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from >- // RenderMenuList to lay out the individual items in the popup. >- // If the MenuList actually has appearance "NoAppearance", then that means >- // we don't draw a button, so don't reserve space for it. >- const int bar_type = style->direction() == LTR ? RightPadding : LeftPadding; >- if (paddingType == bar_type && style->appearance() != NoControlPart) >- padding += ScrollbarTheme::nativeTheme()->scrollbarThickness(); >- >- return padding; >-} >- >-} // namespace WebCore >+} // namespace WebCore >diff --git a/WebCore/rendering/RenderThemeChromiumLinux.h b/WebCore/rendering/RenderThemeChromiumLinux.h >index 7838509..3c7e4c1 100644 >--- a/WebCore/rendering/RenderThemeChromiumLinux.h >+++ b/WebCore/rendering/RenderThemeChromiumLinux.h >@@ -32,10 +32,10 @@ > > namespace WebCore { > >- class RenderThemeChromiumLinux : public RenderTheme { >+ class RenderThemeChromiumSkia : public RenderTheme { > public: >- RenderThemeChromiumLinux(); >- ~RenderThemeChromiumLinux() { } >+ RenderThemeChromiumSkia(); >+ virtual ~RenderThemeChromiumSkia(); > > virtual String extraDefaultStyleSheet(); > virtual String extraQuirksStyleSheet(); >@@ -44,7 +44,7 @@ namespace WebCore { > #endif > > // A method asking if the theme's controls actually care about redrawing when hovered. >- virtual bool supportsHover(const RenderStyle*) const { return true; } >+ virtual bool supportsHover(const RenderStyle*) const; > > // A method asking if the theme is able to draw the focus ring. > virtual bool supportsFocusRing(const RenderStyle*) const; >@@ -56,6 +56,7 @@ namespace WebCore { > virtual Color platformInactiveSelectionForegroundColor() const; > virtual Color platformTextSearchHighlightColor() const; > >+ // To change the blink interval, override caretBlinkIntervalInternal instead of this one so that we may share layout test code an intercepts. > virtual double caretBlinkInterval() const; > > // System fonts. >@@ -73,9 +74,9 @@ namespace WebCore { > > virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > >- virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } >+ virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > >- virtual bool paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } >+ virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > > virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; > virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >@@ -116,21 +117,37 @@ namespace WebCore { > virtual int buttonInternalPaddingTop() const; > virtual int buttonInternalPaddingBottom() const; > >- // A method asking if the control changes its tint when the window has focus or not. >- virtual bool controlSupportsTints(const RenderObject*) const; >- > // A general method asking if any control tinting is supported at all. > virtual bool supportsControlTints() const { return true; } > >+ protected: >+ static const char* defaultGUIFont; >+ >+ // The default variable-width font size. We use this as the default font >+ // size for the "system font", and as a base size (which we then shrink) for >+ // form control fonts. >+ static float defaultFontSize; >+ >+ virtual double caretBlinkIntervalInternal() const; >+ >+ private: >+ int menuListInternalPadding(RenderStyle*, int paddingType) const; >+ bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*); >+ }; >+ >+ class RenderThemeChromiumLinux : public RenderThemeChromiumSkia { >+ public: >+ RenderThemeChromiumLinux(); >+ virtual ~RenderThemeChromiumLinux(); >+ >+ // A method asking if the control changes its tint when the window has focus or not. >+ virtual bool controlSupportsTints(const RenderObject*) const; >+ > // List Box selection color > virtual Color activeListBoxSelectionBackgroundColor() const; > virtual Color activeListBoxSelectionForegroundColor() const; > virtual Color inactiveListBoxSelectionBackgroundColor() const; > virtual Color inactiveListBoxSelectionForegroundColor() const; >- >- private: >- int menuListInternalPadding(RenderStyle*, int paddingType) const; >- bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*); > }; > > } // namespace WebCore >diff --git a/WebCore/rendering/RenderThemeChromiumWin.cpp b/WebCore/rendering/RenderThemeChromiumWin.cpp >index 5288191..9b4f306 100644 >--- a/WebCore/rendering/RenderThemeChromiumWin.cpp >+++ b/WebCore/rendering/RenderThemeChromiumWin.cpp >@@ -58,27 +58,6 @@ namespace WebCore { > > namespace { > >-// The background for the media player controls should be a 60% opaque black rectangle. This >-// matches the UI mockups for the default UI theme. >-static const float defaultMediaControlOpacity = 0.6f; >- >-// These values all match Safari/Win. >-static const float defaultControlFontPixelSize = 13; >-static const float defaultCancelButtonSize = 9; >-static const float minCancelButtonSize = 5; >-static const float maxCancelButtonSize = 21; >-static const float defaultSearchFieldResultsDecorationSize = 13; >-static const float minSearchFieldResultsDecorationSize = 9; >-static const float maxSearchFieldResultsDecorationSize = 30; >-static const float defaultSearchFieldResultsButtonWidth = 18; >- >-bool canvasHasMultipleLayers(const SkCanvas* canvas) >-{ >- SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false); >- iter.next(); // There is always at least one layer. >- return !iter.done(); // There is > 1 layer if the the iterator can stil advance. >-} >- > class ThemePainter : public TransparencyWin { > public: > ThemePainter(GraphicsContext* context, const IntRect& r) >@@ -93,6 +72,13 @@ public: > } > > private: >+ static bool canvasHasMultipleLayers(const SkCanvas* canvas) >+ { >+ SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false); >+ iter.next(); // There is always at least one layer. >+ return !iter.done(); // There is > 1 layer if the the iterator can stil advance. >+ } >+ > static LayerMode getLayerMode(GraphicsContext* context, TransformMode transformMode) > { > if (context->platformContext()->isDrawingToImageBuffer()) // Might have transparent background. >@@ -112,11 +98,11 @@ private: > else // Nothing interesting. > return KeepTransform; > } >-}; > >-} // namespace >+}; > >-static void getNonClientMetrics(NONCLIENTMETRICS* metrics) { >+static void getNonClientMetrics(NONCLIENTMETRICS* metrics) >+{ > static UINT size = WebCore::isVistaOrNewer() ? > sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; > metrics->cbSize = size; >@@ -124,19 +110,7 @@ static void getNonClientMetrics(NONCLIENTMETRICS* metrics) { > ASSERT(success); > } > >-enum PaddingType { >- TopPadding, >- RightPadding, >- BottomPadding, >- LeftPadding >-}; >- >-static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 }; >- >-// The default variable-width font size. We use this as the default font >-// size for the "system font", and as a base size (which we then shrink) for >-// form control fonts. >-static float defaultFontSize = 16.0; >+} // namespace > > static FontDescription smallSystemFont; > static FontDescription menuFont; >@@ -159,14 +133,6 @@ static bool supportsFocus(ControlPart appearance) > return false; > } > >-static void setFixedPadding(RenderStyle* style, const int padding[4]) >-{ >- style->setPaddingLeft(Length(padding[LeftPadding], Fixed)); >- style->setPaddingRight(Length(padding[RightPadding], Fixed)); >- style->setPaddingTop(Length(padding[TopPadding], Fixed)); >- style->setPaddingBottom(Length(padding[BottomPadding], Fixed)); >-} >- > // Return the height of system font |font| in pixels. We use this size by > // default for some non-form-control elements. > static float systemFontSize(const LOGFONT& font) >@@ -201,20 +167,6 @@ static float systemFontSize(const LOGFONT& font) > return ((size < 12.0f) && (GetACP() == 936)) ? 12.0f : size; > } > >-// We aim to match IE here. >-// -IE uses a font based on the encoding as the default font for form controls. >-// -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT), >-// which returns MS Shell Dlg) >-// -Safari uses Lucida Grande. >-// >-// FIXME: The only case where we know we don't match IE is for ANSI encodings. >-// IE uses MS Shell Dlg there, which we render incorrectly at certain pixel >-// sizes (e.g. 15px). So, for now we just use Arial. >-static wchar_t* defaultGUIFont() >-{ >- return L"Arial"; >-} >- > // Converts |points| to pixels. One point is 1/72 of an inch. > static float pointsToPixels(float points) > { >@@ -233,14 +185,6 @@ static float pointsToPixels(float points) > return points / pointsPerInch * pixelsPerInch; > } > >-static void setSizeIfAuto(RenderStyle* style, const IntSize& size) >-{ >- if (style->width().isIntrinsicOrAuto()) >- style->setWidth(Length(size.width(), Fixed)); >- if (style->height().isAuto()) >- style->setHeight(Length(size.height(), Fixed)); >-} >- > static double querySystemBlinkInterval(double defaultInterval) > { > UINT blinkTime = GetCaretBlinkTime(); >@@ -251,20 +195,6 @@ static double querySystemBlinkInterval(double defaultInterval) > return blinkTime / 1000.0; > } > >-#if ENABLE(VIDEO) >-// Attempt to retrieve a HTMLMediaElement from a Node. Returns NULL if one cannot be found. >-static HTMLMediaElement* mediaElementParent(Node* node) >-{ >- if (!node) >- return 0; >- Node* mediaNode = node->shadowAncestorNode(); >- if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag))) >- return 0; >- >- return static_cast<HTMLMediaElement*>(mediaNode); >-} >-#endif >- > // Implement WebCore::theme() for getting the global RenderTheme. > RenderTheme* theme() > { >@@ -272,22 +202,13 @@ RenderTheme* theme() > return &winTheme; > } > >-String RenderThemeChromiumWin::extraDefaultStyleSheet() >-{ >- return String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet)); >-} >- >-String RenderThemeChromiumWin::extraQuirksStyleSheet() >+RenderThemeChromiumWin::RenderThemeChromiumWin() > { >- return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet)); > } > >-#if ENABLE(VIDEO) >-String RenderThemeChromiumWin::extraMediaControlsStyleSheet() >+RenderThemeChromiumWin::~RenderThemeChromiumWin() > { >- return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet)); > } >-#endif > > bool RenderThemeChromiumWin::supportsFocusRing(const RenderStyle* style) const > { >@@ -337,23 +258,11 @@ Color RenderThemeChromiumWin::platformInactiveTextSearchHighlightColor() const > return Color(0xff, 0xff, 0x96); // Yellow. > } > >-double RenderThemeChromiumWin::caretBlinkInterval() const >-{ >- // Disable the blinking caret in layout test mode, as it introduces >- // a race condition for the pixel tests. http://b/1198440 >- if (ChromiumBridge::layoutTestMode()) >- return 0; >- >- // This involves a system call, so we cache the result. >- static double blinkInterval = querySystemBlinkInterval(RenderTheme::caretBlinkInterval()); >- return blinkInterval; >-} >- > void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescription) const > { > // This logic owes much to RenderThemeSafari.cpp. > FontDescription* cachedDesc = NULL; >- wchar_t* faceName = 0; >+ AtomicString faceName; > float fontSize = 0; > switch (propId) { > case CSSValueSmallCaption: >@@ -361,7 +270,7 @@ void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescrip > if (!smallSystemFont.isAbsoluteSize()) { > NONCLIENTMETRICS metrics; > getNonClientMetrics(&metrics); >- faceName = metrics.lfSmCaptionFont.lfFaceName; >+ faceName = AtomicString(metrics.lfSmCaptionFont.lfFaceName, wcslen(metrics.lfSmCaptionFont.lfFaceName)); > fontSize = systemFontSize(metrics.lfSmCaptionFont); > } > break; >@@ -370,7 +279,7 @@ void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescrip > if (!menuFont.isAbsoluteSize()) { > NONCLIENTMETRICS metrics; > getNonClientMetrics(&metrics); >- faceName = metrics.lfMenuFont.lfFaceName; >+ faceName = AtomicString(metrics.lfMenuFont.lfFaceName, wcslen(metrics.lfMenuFont.lfFaceName)); > fontSize = systemFontSize(metrics.lfMenuFont); > } > break; >@@ -386,12 +295,12 @@ void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescrip > case CSSValueWebkitMiniControl: > case CSSValueWebkitSmallControl: > case CSSValueWebkitControl: >- faceName = defaultGUIFont(); >+ faceName = defaultGUIFont; > // Why 2 points smaller? Because that's what Gecko does. > fontSize = defaultFontSize - pointsToPixels(2); > break; > default: >- faceName = defaultGUIFont(); >+ faceName = defaultGUIFont; > fontSize = defaultFontSize; > break; > } >@@ -400,9 +309,7 @@ void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescrip > cachedDesc = &fontDescription; > > if (fontSize) { >- ASSERT(faceName); >- cachedDesc->firstFamily().setFamily(AtomicString(faceName, >- wcslen(faceName))); >+ cachedDesc->firstFamily().setFamily(faceName); > cachedDesc->setIsAbsoluteSize(true); > cachedDesc->setGenericFamily(FontDescription::NoFamily); > cachedDesc->setSpecifiedSize(fontSize); >@@ -412,11 +319,6 @@ void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescrip > fontDescription = *cachedDesc; > } > >-int RenderThemeChromiumWin::minimumMenuListSize(RenderStyle* style) const >-{ >- return 0; >-} >- > void RenderThemeChromiumWin::adjustSliderThumbSize(RenderObject* o) const > { > // These sizes match what WinXP draws for various menus. >@@ -431,25 +333,13 @@ void RenderThemeChromiumWin::adjustSliderThumbSize(RenderObject* o) const > } > } > >-void RenderThemeChromiumWin::setCheckboxSize(RenderStyle* style) const >+bool RenderThemeChromiumWin::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) > { >- // If the width and height are both specified, then we have nothing to do. >- if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) >- return; >- >- // FIXME: A hard-coded size of 13 is used. This is wrong but necessary >- // for now. It matches Firefox. At different DPI settings on Windows, >- // querying the theme gives you a larger size that accounts for the higher >- // DPI. Until our entire engine honors a DPI setting other than 96, we >- // can't rely on the theme's metrics. >- const IntSize size(13, 13); >- setSizeIfAuto(style, size); >+ return paintButton(o, i, r); > } >- >-void RenderThemeChromiumWin::setRadioSize(RenderStyle* style) const >+bool RenderThemeChromiumWin::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) > { >- // Use same sizing for radio box as checkbox. >- setCheckboxSize(style); >+ return paintButton(o, i, r); > } > > bool RenderThemeChromiumWin::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >@@ -483,178 +373,9 @@ bool RenderThemeChromiumWin::paintSliderTrack(RenderObject* o, const RenderObjec > return false; > } > >-void RenderThemeChromiumWin::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >-{ >- // Scale the button size based on the font size >- float fontScale = style->fontSize() / defaultControlFontPixelSize; >- int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize)); >- style->setWidth(Length(cancelButtonSize, Fixed)); >- style->setHeight(Length(cancelButtonSize, Fixed)); >-} >- >-bool RenderThemeChromiumWin::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >-{ >- IntRect bounds = r; >- ASSERT(o->parent()); >- if (!o->parent() || !o->parent()->isBox()) >- return false; >- >- RenderBox* parentRenderBox = toRenderBox(o->parent()); >- >- IntRect parentBox = parentRenderBox->absoluteContentBox(); >- >- // Make sure the scaled button stays square and will fit in its parent's box >- bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height()))); >- bounds.setWidth(bounds.height()); >- >- // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will >- // be one pixel closer to the bottom of the field. This tends to look better with the text. >- bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); >- >- static Image* cancelImage = Image::loadPlatformResource("searchCancel").releaseRef(); >- static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").releaseRef(); >- i.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage, bounds); >- return false; >-} >- >-void RenderThemeChromiumWin::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >-{ >- IntSize emptySize(1, 11); >- style->setWidth(Length(emptySize.width(), Fixed)); >- style->setHeight(Length(emptySize.height(), Fixed)); >-} >- >-void RenderThemeChromiumWin::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >-{ >- // Scale the decoration size based on the font size >- float fontScale = style->fontSize() / defaultControlFontPixelSize; >- int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale), >- maxSearchFieldResultsDecorationSize)); >- style->setWidth(Length(magnifierSize, Fixed)); >- style->setHeight(Length(magnifierSize, Fixed)); >-} >- >-bool RenderThemeChromiumWin::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >-{ >- IntRect bounds = r; >- ASSERT(o->parent()); >- if (!o->parent() || !o->parent()->isBox()) >- return false; >- >- RenderBox* parentRenderBox = toRenderBox(o->parent()); >- IntRect parentBox = parentRenderBox->absoluteContentBox(); >- >- // Make sure the scaled decoration stays square and will fit in its parent's box >- bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height()))); >- bounds.setWidth(bounds.height()); >- >- // Center the decoration vertically. Round up though, so if it has to be one pixel off-center, it will >- // be one pixel closer to the bottom of the field. This tends to look better with the text. >- bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); >- >- static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef(); >- i.context->drawImage(magnifierImage, bounds); >- return false; >-} >- >-void RenderThemeChromiumWin::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const >-{ >- // Scale the button size based on the font size >- float fontScale = style->fontSize() / defaultControlFontPixelSize; >- int magnifierHeight = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale), >- maxSearchFieldResultsDecorationSize)); >- int magnifierWidth = lroundf(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize); >- style->setWidth(Length(magnifierWidth, Fixed)); >- style->setHeight(Length(magnifierHeight, Fixed)); >-} >- >-bool RenderThemeChromiumWin::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >-{ >- IntRect bounds = r; >- ASSERT(o->parent()); >- if (!o->parent()) >- return false; >- if (!o->parent() || !o->parent()->isBox()) >- return false; >- >- RenderBox* parentRenderBox = toRenderBox(o->parent()); >- IntRect parentBox = parentRenderBox->absoluteContentBox(); >- >- // Make sure the scaled decoration will fit in its parent's box >- bounds.setHeight(std::min(parentBox.height(), bounds.height())); >- bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize))); >- >- // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will >- // be one pixel closer to the bottom of the field. This tends to look better with the text. >- bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); >- >- static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").releaseRef(); >- i.context->drawImage(magnifierImage, bounds); >- return false; >-} >- >-bool RenderThemeChromiumWin::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image) >-{ >- context->beginTransparencyLayer(defaultMediaControlOpacity); >- >- // Draw background. >- Color oldFill = context->fillColor(); >- Color oldStroke = context->strokeColor(); >- >- context->setFillColor(Color::black); >- context->setStrokeColor(Color::black); >- context->drawRect(rect); >- >- context->setFillColor(oldFill); >- context->setStrokeColor(oldStroke); >- >- // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down. >- IntRect imageRect = image->rect(); >- imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2); >- imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2); >- >- context->drawImage(image, imageRect, CompositeSourceAtop); >- context->endTransparencyLayer(); >- >- return false; >-} >- >-bool RenderThemeChromiumWin::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) >-{ >-#if ENABLE(VIDEO) >- HTMLMediaElement* mediaElement = mediaElementParent(o->node()); >- if (!mediaElement) >- return false; >- >- static Image* mediaPlay = Image::loadPlatformResource("mediaPlay").releaseRef(); >- static Image* mediaPause = Image::loadPlatformResource("mediaPause").releaseRef(); >- >- return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause); >-#else >- return false; >-#endif >-} >- >-bool RenderThemeChromiumWin::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) >+bool RenderThemeChromiumWin::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) > { >-#if ENABLE(VIDEO) >- HTMLMediaElement* mediaElement = mediaElementParent(o->node()); >- if (!mediaElement) >- return false; >- >- static Image* soundFull = Image::loadPlatformResource("mediaSoundFull").releaseRef(); >- static Image* soundNone = Image::loadPlatformResource("mediaSoundNone").releaseRef(); >- >- return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); >-#else >- return false; >-#endif >-} >- >-void RenderThemeChromiumWin::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const >-{ >- // Height is locked to auto on all browsers. >- style->setLineHeight(RenderStyle::initialLineHeight()); >+ return paintSliderTrack(o, i, r); > } > > // Used to paint unstyled menulists (i.e. with the default border) >@@ -709,57 +430,6 @@ bool RenderThemeChromiumWin::paintMenuList(RenderObject* o, const RenderObject:: > return false; > } > >-void RenderThemeChromiumWin::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const >-{ >- adjustMenuListStyle(selector, style, e); >-} >- >-// Used to paint styled menulists (i.e. with a non-default border) >-bool RenderThemeChromiumWin::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) >-{ >- return paintMenuList(o, i, r); >-} >- >-int RenderThemeChromiumWin::popupInternalPaddingLeft(RenderStyle* style) const >-{ >- return menuListInternalPadding(style, LeftPadding); >-} >- >-int RenderThemeChromiumWin::popupInternalPaddingRight(RenderStyle* style) const >-{ >- return menuListInternalPadding(style, RightPadding); >-} >- >-int RenderThemeChromiumWin::popupInternalPaddingTop(RenderStyle* style) const >-{ >- return menuListInternalPadding(style, TopPadding); >-} >- >-int RenderThemeChromiumWin::popupInternalPaddingBottom(RenderStyle* style) const >-{ >- return menuListInternalPadding(style, BottomPadding); >-} >- >-int RenderThemeChromiumWin::buttonInternalPaddingLeft() const >-{ >- return 3; >-} >- >-int RenderThemeChromiumWin::buttonInternalPaddingRight() const >-{ >- return 3; >-} >- >-int RenderThemeChromiumWin::buttonInternalPaddingTop() const >-{ >- return 1; >-} >- >-int RenderThemeChromiumWin::buttonInternalPaddingBottom() const >-{ >- return 1; >-} >- > // static > void RenderThemeChromiumWin::setDefaultFontSize(int fontSize) > { >@@ -769,6 +439,14 @@ void RenderThemeChromiumWin::setDefaultFontSize(int fontSize) > smallSystemFont = menuFont = labelFont = FontDescription(); > } > >+double RenderThemeChromiumWin::caretBlinkIntervalInternal() const >+{ >+ // This involves a system call, so we cache the result. >+ static double blinkInterval = querySystemBlinkInterval(RenderTheme::caretBlinkInterval()); >+ // FIXME: merge with skia blink info. >+ return blinkInterval; >+} >+ > unsigned RenderThemeChromiumWin::determineState(RenderObject* o) > { > unsigned result = TS_NORMAL; >@@ -909,22 +587,4 @@ bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o, > return false; > } > >-int RenderThemeChromiumWin::menuListInternalPadding(RenderStyle* style, int paddingType) const >-{ >- // This internal padding is in addition to the user-supplied padding. >- // Matches the FF behavior. >- int padding = styledMenuListInternalPadding[paddingType]; >- >- // Reserve the space for right arrow here. The rest of the padding is set >- // by adjustMenuListStyle, since PopupMenuChromium.cpp uses the padding >- // from RenderMenuList to lay out the individual items in the popup. If >- // the MenuList actually has appearance "NoAppearance", then that means we >- // don't draw a button, so don't reserve space for it. >- const int barType = style->direction() == LTR ? RightPadding : LeftPadding; >- if (paddingType == barType && style->appearance() != NoControlPart) >- padding += ScrollbarTheme::nativeTheme()->scrollbarThickness(); >- >- return padding; >-} >- > } // namespace WebCore >diff --git a/WebCore/rendering/RenderThemeChromiumWin.h b/WebCore/rendering/RenderThemeChromiumWin.h >index 6ba6595..67b6675 100644 >--- a/WebCore/rendering/RenderThemeChromiumWin.h >+++ b/WebCore/rendering/RenderThemeChromiumWin.h >@@ -24,7 +24,7 @@ > #ifndef RenderThemeChromiumWin_h > #define RenderThemeChromiumWin_h > >-#include "RenderTheme.h" >+#include "RenderThemeChromiumLinux.h" > > #if WIN32 > typedef void* HANDLE; >@@ -42,19 +42,10 @@ namespace WebCore { > unsigned m_classicState; > }; > >- class RenderThemeChromiumWin : public RenderTheme { >+ class RenderThemeChromiumWin : public RenderThemeChromiumSkia { > public: >- RenderThemeChromiumWin() { } >- ~RenderThemeChromiumWin() { } >- >- virtual String extraDefaultStyleSheet(); >- virtual String extraQuirksStyleSheet(); >-#if ENABLE(VIDEO) >- virtual String extraMediaControlsStyleSheet(); >-#endif >- >- // A method asking if the theme's controls actually care about redrawing when hovered. >- virtual bool supportsHover(const RenderStyle*) const { return true; } >+ RenderThemeChromiumWin(); >+ virtual ~RenderThemeChromiumWin(); > > // A method asking if the theme is able to draw the focus ring. > virtual bool supportsFocusRing(const RenderStyle*) const; >@@ -67,46 +58,20 @@ namespace WebCore { > virtual Color platformActiveTextSearchHighlightColor() const; > virtual Color platformInactiveTextSearchHighlightColor() const; > >- virtual double caretBlinkInterval() const; >- > // System fonts. > virtual void systemFont(int propId, FontDescription&) const; > >- virtual int minimumMenuListSize(RenderStyle*) const; >- > virtual void adjustSliderThumbSize(RenderObject*) const; > >- virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintButton(o, i, r); } >- virtual void setCheckboxSize(RenderStyle*) const; >- >- virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintButton(o, i, r); } >- virtual void setRadioSize(RenderStyle*) const; >- >+ // Various paint functions. >+ virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >+ virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- > virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- >- virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } >- > virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- >- virtual bool paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintSliderTrack(o, i, r); } >- >- virtual bool paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); } >+ virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > > virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; >- virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- >- virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; >- >- virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; >- virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- >- virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; >- virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- >- virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > > // MenuList refers to an unstyled menulist (meaning a menulist without > // background-color or border set) and MenuListButton refers to a styled >@@ -117,21 +82,7 @@ namespace WebCore { > // In short, we either go down the MenuList code path or the MenuListButton > // codepath. We never go down both. And in both cases, they render the > // entire menulist. >- virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; > virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; >- virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >- >- // These methods define the padding for the MenuList's inner block. >- virtual int popupInternalPaddingLeft(RenderStyle*) const; >- virtual int popupInternalPaddingRight(RenderStyle*) const; >- virtual int popupInternalPaddingTop(RenderStyle*) const; >- virtual int popupInternalPaddingBottom(RenderStyle*) const; >- >- virtual int buttonInternalPaddingLeft() const; >- virtual int buttonInternalPaddingRight() const; >- virtual int buttonInternalPaddingTop() const; >- virtual int buttonInternalPaddingBottom() const; > > // Provide a way to pass the default font size from the Settings object > // to the render theme. FIXME: http://b/1129186 A cleaner way would be >@@ -140,6 +91,9 @@ namespace WebCore { > // object. > static void setDefaultFontSize(int); > >+ protected: >+ virtual double caretBlinkIntervalInternal() const; >+ > private: > unsigned determineState(RenderObject*); > unsigned determineSliderThumbState(RenderObject*); >@@ -149,8 +103,6 @@ namespace WebCore { > > bool paintTextFieldInternal(RenderObject*, const RenderObject::PaintInfo&, const IntRect&, bool); > bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*); >- >- int menuListInternalPadding(RenderStyle*, int paddingType) const; > }; > > } // namespace WebCore
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
eric
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 26148
:
30882
|
30884
|
30958
|
30974
|
30983
|
31007
|
31015
|
31119
|
31297
|
31299
|
31302
|
31303