Changeset 44775 in webkit


Ignore:
Timestamp:
Jun 17, 2009 12:18:01 PM (15 years ago)
Author:
levin@chromium.org
Message:

2009-06-17 Albert J. Wong <ajwong@chromium.org>

Reviewed by Eric Seidel.

https://bugs.webkit.org/show_bug.cgi?id=26148
Move RenderThemeChromiumSkia into its own file. This is purely a code move.

  • rendering/RenderThemeChromiumLinux.cpp:
  • rendering/RenderThemeChromiumLinux.h:
  • rendering/RenderThemeChromiumSkia.cpp: (WebCore::): (WebCore::setSizeIfAuto): (WebCore::mediaElementParent): (WebCore::RenderThemeChromiumSkia::defaultGUIFont): (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::brightenColor): (WebCore::paintButtonLike): (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::paintMediaButtonInternal): (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):
  • rendering/RenderThemeChromiumSkia.h: (WebCore::RenderThemeChromiumSkia::supportsControlTints):
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r44774 r44775  
     12009-06-17  Albert J. Wong  <ajwong@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=26148
     6        Move RenderThemeChromiumSkia into its own file.  This is purely a code move.
     7
     8        * rendering/RenderThemeChromiumLinux.cpp:
     9        * rendering/RenderThemeChromiumLinux.h:
     10        * rendering/RenderThemeChromiumSkia.cpp:
     11        (WebCore::):
     12        (WebCore::setSizeIfAuto):
     13        (WebCore::mediaElementParent):
     14        (WebCore::RenderThemeChromiumSkia::defaultGUIFont):
     15        (WebCore::RenderThemeChromiumSkia::RenderThemeChromiumSkia):
     16        (WebCore::RenderThemeChromiumSkia::~RenderThemeChromiumSkia):
     17        (WebCore::RenderThemeChromiumSkia::extraDefaultStyleSheet):
     18        (WebCore::RenderThemeChromiumSkia::extraQuirksStyleSheet):
     19        (WebCore::RenderThemeChromiumSkia::extraMediaControlsStyleSheet):
     20        (WebCore::RenderThemeChromiumSkia::supportsHover):
     21        (WebCore::RenderThemeChromiumSkia::supportsFocusRing):
     22        (WebCore::RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor):
     23        (WebCore::RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor):
     24        (WebCore::RenderThemeChromiumSkia::platformActiveSelectionForegroundColor):
     25        (WebCore::RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor):
     26        (WebCore::RenderThemeChromiumSkia::platformTextSearchHighlightColor):
     27        (WebCore::RenderThemeChromiumSkia::caretBlinkInterval):
     28        (WebCore::RenderThemeChromiumSkia::systemFont):
     29        (WebCore::RenderThemeChromiumSkia::minimumMenuListSize):
     30        (WebCore::RenderThemeChromiumSkia::paintCheckbox):
     31        (WebCore::RenderThemeChromiumSkia::setCheckboxSize):
     32        (WebCore::RenderThemeChromiumSkia::paintRadio):
     33        (WebCore::RenderThemeChromiumSkia::setRadioSize):
     34        (WebCore::brightenColor):
     35        (WebCore::paintButtonLike):
     36        (WebCore::RenderThemeChromiumSkia::paintButton):
     37        (WebCore::RenderThemeChromiumSkia::paintTextField):
     38        (WebCore::RenderThemeChromiumSkia::paintTextArea):
     39        (WebCore::RenderThemeChromiumSkia::paintSearchField):
     40        (WebCore::RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle):
     41        (WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton):
     42        (WebCore::RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle):
     43        (WebCore::RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle):
     44        (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration):
     45        (WebCore::RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle):
     46        (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton):
     47        (WebCore::RenderThemeChromiumSkia::paintMediaButtonInternal):
     48        (WebCore::RenderThemeChromiumSkia::paintMediaPlayButton):
     49        (WebCore::RenderThemeChromiumSkia::paintMediaMuteButton):
     50        (WebCore::RenderThemeChromiumSkia::adjustMenuListStyle):
     51        (WebCore::RenderThemeChromiumSkia::paintMenuList):
     52        (WebCore::RenderThemeChromiumSkia::adjustMenuListButtonStyle):
     53        (WebCore::RenderThemeChromiumSkia::paintMenuListButton):
     54        (WebCore::RenderThemeChromiumSkia::popupInternalPaddingLeft):
     55        (WebCore::RenderThemeChromiumSkia::popupInternalPaddingRight):
     56        (WebCore::RenderThemeChromiumSkia::popupInternalPaddingTop):
     57        (WebCore::RenderThemeChromiumSkia::popupInternalPaddingBottom):
     58        (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingLeft):
     59        (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingRight):
     60        (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingTop):
     61        (WebCore::RenderThemeChromiumSkia::buttonInternalPaddingBottom):
     62        (WebCore::RenderThemeChromiumSkia::caretBlinkIntervalInternal):
     63        (WebCore::RenderThemeChromiumSkia::menuListInternalPadding):
     64        * rendering/RenderThemeChromiumSkia.h:
     65        (WebCore::RenderThemeChromiumSkia::supportsControlTints):
     66
    1672009-06-17  Albert J. Wong  <ajwong@chromium.org>
    268
  • trunk/WebCore/rendering/RenderThemeChromiumLinux.cpp

    r44774 r44775  
    2626#include "RenderThemeChromiumLinux.h"
    2727
    28 #include "ChromiumBridge.h"
    29 #include "CSSValueKeywords.h"
    30 #include "GraphicsContext.h"
    31 #include "HTMLMediaElement.h"
    32 #include "HTMLNames.h"
    33 #include "Image.h"
    34 #include "MediaControlElements.h"
    35 #include "PlatformContextSkia.h"
    36 #include "RenderBox.h"
     28#include "Color.h"
    3729#include "RenderObject.h"
    38 #include "ScrollbarTheme.h"
    39 #include "TransformationMatrix.h"
    4030#include "UserAgentStyleSheets.h"
    4131
    42 #include "SkShader.h"
    43 #include "SkGradientShader.h"
    44 
    4532namespace WebCore {
    46 
    47 enum PaddingType {
    48     TopPadding,
    49     RightPadding,
    50     BottomPadding,
    51     LeftPadding
    52 };
    53 
    54 static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
    55 
    56 // The background for the media player controls should be a 60% opaque black rectangle. This
    57 // matches the UI mockups for the default UI theme.
    58 static const float defaultMediaControlOpacity = 0.6f;
    59 
    60 // These values all match Safari/Win.
    61 static const float defaultControlFontPixelSize = 13;
    62 static const float defaultCancelButtonSize = 9;
    63 static const float minCancelButtonSize = 5;
    64 static const float maxCancelButtonSize = 21;
    65 static const float defaultSearchFieldResultsDecorationSize = 13;
    66 static const float minSearchFieldResultsDecorationSize = 9;
    67 static const float maxSearchFieldResultsDecorationSize = 30;
    68 static const float defaultSearchFieldResultsButtonWidth = 18;
    69 
    70 static void setSizeIfAuto(RenderStyle* style, const IntSize& size)
    71 {
    72     if (style->width().isIntrinsicOrAuto())
    73         style->setWidth(Length(size.width(), Fixed));
    74     if (style->height().isAuto())
    75         style->setHeight(Length(size.height(), Fixed));
    76 }
    77 
    78 #if ENABLE(VIDEO)
    79 // Attempt to retrieve a HTMLMediaElement from a Node. Returns NULL if one cannot be found.
    80 static HTMLMediaElement* mediaElementParent(Node* node)
    81 {
    82     if (!node)
    83         return 0;
    84     Node* mediaNode = node->shadowAncestorNode();
    85     if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag)))
    86         return 0;
    87 
    88     return static_cast<HTMLMediaElement*>(mediaNode);
    89 }
    90 #endif
    91 
    92 // We aim to match IE here.
    93 // -IE uses a font based on the encoding as the default font for form controls.
    94 // -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT),
    95 // which returns MS Shell Dlg)
    96 // -Safari uses Lucida Grande.
    97 //
    98 // FIXME: The only case where we know we don't match IE is for ANSI encodings.
    99 // IE uses MS Shell Dlg there, which we render incorrectly at certain pixel
    100 // sizes (e.g. 15px). So, for now we just use Arial.
    101 const String& RenderThemeChromiumSkia::defaultGUIFont()
    102 {
    103     DEFINE_STATIC_LOCAL(String, fontface, ("Arial"));
    104     return fontFace;
    105 }
    106 
    107 float RenderThemeChromiumSkia::defaultFontSize = 16.0;
    108 
    109 RenderThemeChromiumSkia::RenderThemeChromiumSkia()
    110 {
    111 }
    112 
    113 RenderThemeChromiumSkia::~RenderThemeChromiumSkia()
    114 {
    115 }
    116 
    117 // Use the Windows style sheets to match their metrics.
    118 String RenderThemeChromiumSkia::extraDefaultStyleSheet()
    119 {
    120     return String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet));
    121 }
    122 
    123 String RenderThemeChromiumSkia::extraQuirksStyleSheet()
    124 {
    125     return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet));
    126 }
    127 
    128 #if ENABLE(VIDEO)
    129 String RenderThemeChromiumSkia::extraMediaControlsStyleSheet()
    130 {
    131     return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet));
    132 }
    133 #endif
    134 
    135 bool RenderThemeChromiumSkia::supportsHover(const RenderStyle*) const
    136 {
    137     return true;
    138 }
    139 
    140 bool RenderThemeChromiumSkia::supportsFocusRing(const RenderStyle*) const
    141 {
    142     // This causes WebKit to draw the focus rings for us.
    143     return false;
    144 }
    145 
    146 Color RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor() const
    147 {
    148     return Color(0x1e, 0x90, 0xff);
    149 }
    150 
    151 Color RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor() const
    152 {
    153     return Color(0xc8, 0xc8, 0xc8);
    154 }
    155 
    156 Color RenderThemeChromiumSkia::platformActiveSelectionForegroundColor() const
    157 {
    158     return Color::black;
    159 }
    160 
    161 Color RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor() const
    162 {
    163     return Color(0x32, 0x32, 0x32);
    164 }
    165 
    166 Color RenderThemeChromiumSkia::platformTextSearchHighlightColor() const
    167 {
    168     return Color(0xff, 0xff, 0x96);
    169 }
    170 
    171 double RenderThemeChromiumSkia::caretBlinkInterval() const
    172 {
    173     // Disable the blinking caret in layout test mode, as it introduces
    174     // a race condition for the pixel tests. http://b/1198440
    175     if (ChromiumBridge::layoutTestMode())
    176         return 0;
    177 
    178     return caretBlinkIntervalInternal();
    179 }
    180 
    181 void RenderThemeChromiumSkia::systemFont(int propId, FontDescription& fontDescription) const
    182 {
    183     float fontSize = defaultFontSize;
    184 
    185     switch (propId) {
    186     case CSSValueWebkitMiniControl:
    187     case CSSValueWebkitSmallControl:
    188     case CSSValueWebkitControl:
    189         // Why 2 points smaller? Because that's what Gecko does. Note that we
    190         // are assuming a 96dpi screen, which is the default that we use on
    191         // Windows.
    192         static const float pointsPerInch = 72.0f;
    193         static const float pixelsPerInch = 96.0f;
    194         fontSize -= (2.0f / pointsPerInch) * pixelsPerInch;
    195         break;
    196     }
    197 
    198     fontDescription.firstFamily().setFamily(defaultGUIFont());
    199     fontDescription.setSpecifiedSize(fontSize);
    200     fontDescription.setIsAbsoluteSize(true);
    201     fontDescription.setGenericFamily(FontDescription::NoFamily);
    202     fontDescription.setWeight(FontWeightNormal);
    203     fontDescription.setItalic(false);
    204 }
    205 
    206 int RenderThemeChromiumSkia::minimumMenuListSize(RenderStyle* style) const
    207 {
    208     return 0;
    209 }
    210 
    211 bool RenderThemeChromiumSkia::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    212 {
    213     static Image* const checkedImage = Image::loadPlatformResource("linuxCheckboxOn").releaseRef();
    214     static Image* const uncheckedImage = Image::loadPlatformResource("linuxCheckboxOff").releaseRef();
    215 
    216     Image* image = this->isChecked(o) ? checkedImage : uncheckedImage;
    217     i.context->drawImage(image, rect);
    218     return false;
    219 }
    220 
    221 void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const
    222 {
    223     // If the width and height are both specified, then we have nothing to do.
    224     if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
    225         return;
    226 
    227     // FIXME:  A hard-coded size of 13 is used.  This is wrong but necessary
    228     // for now.  It matches Firefox.  At different DPI settings on Windows,
    229     // querying the theme gives you a larger size that accounts for the higher
    230     // DPI.  Until our entire engine honors a DPI setting other than 96, we
    231     // can't rely on the theme's metrics.
    232     const IntSize size(13, 13);
    233     setSizeIfAuto(style, size);
    234 }
    235 
    236 bool RenderThemeChromiumSkia::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    237 {
    238     static Image* const checkedImage = Image::loadPlatformResource("linuxRadioOn").releaseRef();
    239     static Image* const uncheckedImage = Image::loadPlatformResource("linuxRadioOff").releaseRef();
    240 
    241     Image* image = this->isChecked(o) ? checkedImage : uncheckedImage;
    242     i.context->drawImage(image, rect);
    243     return false;
    244 }
    245 
    246 void RenderThemeChromiumSkia::setRadioSize(RenderStyle* style) const
    247 {
    248     // Use same sizing for radio box as checkbox.
    249     setCheckboxSize(style);
    250 }
    251 
    252 static SkColor brightenColor(double h, double s, double l, float brightenAmount)
    253 {
    254     l += brightenAmount;
    255     if (l > 1.0)
    256         l = 1.0;
    257     if (l < 0.0)
    258         l = 0.0;
    259 
    260     return makeRGBAFromHSLA(h, s, l, 1.0);
    261 }
    262 
    263 static void paintButtonLike(RenderTheme* theme, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    264 {
    265     SkCanvas* const canvas = i.context->platformContext()->canvas();
    266     SkPaint paint;
    267     SkRect skrect;
    268     const int right = rect.x() + rect.width();
    269     const int bottom = rect.y() + rect.height();
    270     SkColor baseColor = SkColorSetARGB(0xff, 0xdd, 0xdd, 0xdd);
    271     if (o->style()->hasBackground())
    272         baseColor = o->style()->backgroundColor().rgb();
    273     double h, s, l;
    274     Color(baseColor).getHSL(h, s, l);
    275     // Our standard gradient is from 0xdd to 0xf8. This is the amount of
    276     // increased luminance between those values.
    277     SkColor lightColor(brightenColor(h, s, l, 0.105));
    278 
    279     // If the button is too small, fallback to drawing a single, solid color
    280     if (rect.width() < 5 || rect.height() < 5) {
    281         paint.setColor(baseColor);
    282         skrect.set(rect.x(), rect.y(), right, bottom);
    283         canvas->drawRect(skrect, paint);
    284         return;
    285     }
    286 
    287     const int borderAlpha = theme->isHovered(o) ? 0x80 : 0x55;
    288     paint.setARGB(borderAlpha, 0, 0, 0);
    289     canvas->drawLine(rect.x() + 1, rect.y(), right - 1, rect.y(), paint);
    290     canvas->drawLine(right - 1, rect.y() + 1, right - 1, bottom - 1, paint);
    291     canvas->drawLine(rect.x() + 1, bottom - 1, right - 1, bottom - 1, paint);
    292     canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), bottom - 1, paint);
    293 
    294     paint.setARGB(0xff, 0, 0, 0);
    295     SkPoint p[2];
    296     const int lightEnd = theme->isPressed(o) ? 1 : 0;
    297     const int darkEnd = !lightEnd;
    298     p[lightEnd].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()));
    299     p[darkEnd].set(SkIntToScalar(rect.x()), SkIntToScalar(bottom - 1));
    300     SkColor colors[2];
    301     colors[0] = lightColor;
    302     colors[1] = baseColor;
    303 
    304     SkShader* shader = SkGradientShader::CreateLinear(
    305         p, colors, NULL, 2, SkShader::kClamp_TileMode, NULL);
    306     paint.setStyle(SkPaint::kFill_Style);
    307     paint.setShader(shader);
    308     shader->unref();
    309 
    310     skrect.set(rect.x() + 1, rect.y() + 1, right - 1, bottom - 1);
    311     canvas->drawRect(skrect, paint);
    312 
    313     paint.setShader(NULL);
    314     paint.setColor(brightenColor(h, s, l, -0.0588));
    315     canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint);
    316     canvas->drawPoint(right - 2, rect.y() + 1, paint);
    317     canvas->drawPoint(rect.x() + 1, bottom - 2, paint);
    318     canvas->drawPoint(right - 2, bottom - 2, paint);
    319 }
    320 
    321 bool RenderThemeChromiumSkia::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    322 {
    323     paintButtonLike(this, o, i, rect);
    324     return false;
    325 }
    326 
    327 bool RenderThemeChromiumSkia::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    328 {
    329     return true;
    330 }
    331 
    332 bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    333 {
    334     return paintTextField(o, i, r);
    335 }
    336 
    337 bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    338 {
    339     return paintTextField(o, i, r);
    340 }
    341 
    342 void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
    343 {
    344     // Scale the button size based on the font size
    345     float fontScale = style->fontSize() / defaultControlFontPixelSize;
    346     int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
    347     style->setWidth(Length(cancelButtonSize, Fixed));
    348     style->setHeight(Length(cancelButtonSize, Fixed));
    349 }
    350 
    351 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    352 {
    353     IntRect bounds = r;
    354     ASSERT(o->parent());
    355     if (!o->parent() || !o->parent()->isBox())
    356         return false;
    357 
    358     RenderBox* parentRenderBox = toRenderBox(o->parent());
    359 
    360     IntRect parentBox = parentRenderBox->absoluteContentBox();
    361 
    362     // Make sure the scaled button stays square and will fit in its parent's box
    363     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
    364     bounds.setWidth(bounds.height());
    365 
    366     // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
    367     // be one pixel closer to the bottom of the field.  This tends to look better with the text.
    368     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
    369 
    370     static Image* cancelImage = Image::loadPlatformResource("searchCancel").releaseRef();
    371     static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").releaseRef();
    372     i.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage, bounds);
    373     return false;
    374 }
    375 
    376 void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
    377 {
    378     IntSize emptySize(1, 11);
    379     style->setWidth(Length(emptySize.width(), Fixed));
    380     style->setHeight(Length(emptySize.height(), Fixed));
    381 }
    382 
    383 void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
    384 {
    385     // Scale the decoration size based on the font size
    386     float fontScale = style->fontSize() / defaultControlFontPixelSize;
    387     int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
    388                                          maxSearchFieldResultsDecorationSize));
    389     style->setWidth(Length(magnifierSize, Fixed));
    390     style->setHeight(Length(magnifierSize, Fixed));
    391 }
    392 
    393 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    394 {
    395     IntRect bounds = r;
    396     ASSERT(o->parent());
    397     if (!o->parent() || !o->parent()->isBox())
    398         return false;
    399 
    400     RenderBox* parentRenderBox = toRenderBox(o->parent());
    401     IntRect parentBox = parentRenderBox->absoluteContentBox();
    402 
    403     // Make sure the scaled decoration stays square and will fit in its parent's box
    404     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
    405     bounds.setWidth(bounds.height());
    406 
    407     // Center the decoration vertically.  Round up though, so if it has to be one pixel off-center, it will
    408     // be one pixel closer to the bottom of the field.  This tends to look better with the text.
    409     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
    410 
    411     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef();
    412     i.context->drawImage(magnifierImage, bounds);
    413     return false;
    414 }
    415 
    416 void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
    417 {
    418     // Scale the button size based on the font size
    419     float fontScale = style->fontSize() / defaultControlFontPixelSize;
    420     int magnifierHeight = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
    421                                            maxSearchFieldResultsDecorationSize));
    422     int magnifierWidth = lroundf(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
    423     style->setWidth(Length(magnifierWidth, Fixed));
    424     style->setHeight(Length(magnifierHeight, Fixed));
    425 }
    426 
    427 bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    428 {
    429     IntRect bounds = r;
    430     ASSERT(o->parent());
    431     if (!o->parent())
    432         return false;
    433     if (!o->parent() || !o->parent()->isBox())
    434         return false;
    435 
    436     RenderBox* parentRenderBox = toRenderBox(o->parent());
    437     IntRect parentBox = parentRenderBox->absoluteContentBox();
    438 
    439     // Make sure the scaled decoration will fit in its parent's box
    440     bounds.setHeight(std::min(parentBox.height(), bounds.height()));
    441     bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)));
    442 
    443     // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
    444     // be one pixel closer to the bottom of the field.  This tends to look better with the text.
    445     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
    446 
    447     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").releaseRef();
    448     i.context->drawImage(magnifierImage, bounds);
    449     return false;
    450 }
    451 
    452 bool RenderThemeChromiumSkia::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image)
    453 {
    454     context->beginTransparencyLayer(defaultMediaControlOpacity);
    455 
    456     // Draw background.
    457     Color oldFill = context->fillColor();
    458     Color oldStroke = context->strokeColor();
    459 
    460     context->setFillColor(Color::black);
    461     context->setStrokeColor(Color::black);
    462     context->drawRect(rect);
    463 
    464     context->setFillColor(oldFill);
    465     context->setStrokeColor(oldStroke);
    466 
    467     // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down.
    468     IntRect imageRect = image->rect();
    469     imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2);
    470     imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2);
    471 
    472     context->drawImage(image, imageRect, CompositeSourceAtop);
    473     context->endTransparencyLayer();
    474 
    475     return false;
    476 }
    477 
    478 bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
    479 {
    480 #if ENABLE(VIDEO)
    481     HTMLMediaElement* mediaElement = mediaElementParent(o->node());
    482     if (!mediaElement)
    483         return false;
    484 
    485     static Image* mediaPlay = Image::loadPlatformResource("mediaPlay").releaseRef();
    486     static Image* mediaPause = Image::loadPlatformResource("mediaPause").releaseRef();
    487 
    488     return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause);
    489 #else
    490     return false;
    491 #endif
    492 }
    493 
    494 bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
    495 {
    496 #if ENABLE(VIDEO)
    497     HTMLMediaElement* mediaElement = mediaElementParent(o->node());
    498     if (!mediaElement)
    499         return false;
    500 
    501     static Image* soundFull = Image::loadPlatformResource("mediaSoundFull").releaseRef();
    502     static Image* soundNone = Image::loadPlatformResource("mediaSoundNone").releaseRef();
    503 
    504     return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull);
    505 #else
    506     return false;
    507 #endif
    508 }
    509 
    510 void RenderThemeChromiumSkia::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
    511 {
    512     // Height is locked to auto on all browsers.
    513     style->setLineHeight(RenderStyle::initialLineHeight());
    514 }
    515 
    516 bool RenderThemeChromiumSkia::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    517 {
    518     SkCanvas* const canvas = i.context->platformContext()->canvas();
    519     const int right = rect.x() + rect.width();
    520     const int middle = rect.y() + rect.height() / 2;
    521 
    522     paintButtonLike(this, o, i, rect);
    523 
    524     SkPaint paint;
    525     paint.setARGB(0xff, 0, 0, 0);
    526     paint.setAntiAlias(true);
    527     paint.setStyle(SkPaint::kFill_Style);
    528 
    529     SkPath path;
    530     path.moveTo(right - 13, middle - 3);
    531     path.rLineTo(6, 0);
    532     path.rLineTo(-3, 6);
    533     path.close();
    534     canvas->drawPath(path, paint);
    535 
    536     return false;
    537 }
    538 
    539 void RenderThemeChromiumSkia::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
    540 {
    541     adjustMenuListStyle(selector, style, e);
    542 }
    543 
    544 // Used to paint styled menulists (i.e. with a non-default border)
    545 bool RenderThemeChromiumSkia::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
    546 {
    547     return paintMenuList(o, i, rect);
    548 }
    549 
    550 int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const
    551 {
    552     return menuListInternalPadding(style, LeftPadding);
    553 }
    554 
    555 int RenderThemeChromiumSkia::popupInternalPaddingRight(RenderStyle* style) const
    556 {
    557     return menuListInternalPadding(style, RightPadding);
    558 }
    559 
    560 int RenderThemeChromiumSkia::popupInternalPaddingTop(RenderStyle* style) const
    561 {
    562     return menuListInternalPadding(style, TopPadding);
    563 }
    564 
    565 int RenderThemeChromiumSkia::popupInternalPaddingBottom(RenderStyle* style) const
    566 {
    567     return menuListInternalPadding(style, BottomPadding);
    568 }
    569 
    570 int RenderThemeChromiumSkia::buttonInternalPaddingLeft() const
    571 {
    572     return 3;
    573 }
    574 
    575 int RenderThemeChromiumSkia::buttonInternalPaddingRight() const
    576 {
    577     return 3;
    578 }
    579 
    580 int RenderThemeChromiumSkia::buttonInternalPaddingTop() const
    581 {
    582     return 1;
    583 }
    584 
    585 int RenderThemeChromiumSkia::buttonInternalPaddingBottom() const
    586 {
    587     return 1;
    588 }
    589 
    590 double RenderThemeChromiumSkia::caretBlinkIntervalInternal() const
    591 {
    592     return RenderTheme::caretBlinkInterval();
    593 }
    594 
    595 PassRefPtr<RenderTheme> RenderThemeChromiumLinux::create()
    596 {
    597     return adoptRef(new RenderThemeChromiumLinux());
    598 }
    59933
    60034PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page)
     
    65286}
    65387
    654 int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int paddingType) const
    655 {
    656     // This internal padding is in addition to the user-supplied padding.
    657     // Matches the FF behavior.
    658     int padding = styledMenuListInternalPadding[paddingType];
    659 
    660     // Reserve the space for right arrow here. The rest of the padding is
    661     // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from
    662     // RenderMenuList to lay out the individual items in the popup.
    663     // If the MenuList actually has appearance "NoAppearance", then that means
    664     // we don't draw a button, so don't reserve space for it.
    665     const int barType = style->direction() == LTR ? RightPadding : LeftPadding;
    666     if (paddingType == barType && style->appearance() != NoControlPart)
    667         padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
    668 
    669     return padding;
    670 }
    671 
    67288} // namespace WebCore
  • trunk/WebCore/rendering/RenderThemeChromiumLinux.h

    r44774 r44775  
    3030#define RenderThemeChromiumLinux_h
    3131
    32 #include "RenderTheme.h"
     32#include "RenderThemeChromiumSkia.h"
    3333
    3434namespace WebCore {
    35 
    36     class RenderThemeChromiumSkia : public RenderTheme {
    37     public:
    38 
    39         virtual String extraDefaultStyleSheet();
    40         virtual String extraQuirksStyleSheet();
    41 #if ENABLE(VIDEO)
    42         virtual String extraMediaControlsStyleSheet();
    43 #endif
    44 
    45         // A method asking if the theme's controls actually care about redrawing when hovered.
    46         virtual bool supportsHover(const RenderStyle*) const;
    47 
    48         // A method asking if the theme is able to draw the focus ring.
    49         virtual bool supportsFocusRing(const RenderStyle*) const;
    50 
    51         // The platform selection color.
    52         virtual Color platformActiveSelectionBackgroundColor() const;
    53         virtual Color platformInactiveSelectionBackgroundColor() const;
    54         virtual Color platformActiveSelectionForegroundColor() const;
    55         virtual Color platformInactiveSelectionForegroundColor() const;
    56         virtual Color platformTextSearchHighlightColor() const;
    57 
    58         // To change the blink interval, override caretBlinkIntervalInternal instead of this one so that we may share layout test code an intercepts.
    59         virtual double caretBlinkInterval() const;
    60 
    61         // System fonts.
    62         virtual void systemFont(int propId, FontDescription&) const;
    63 
    64         virtual int minimumMenuListSize(RenderStyle*) const;
    65 
    66         virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    67         virtual void setCheckboxSize(RenderStyle*) const;
    68 
    69         virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    70         virtual void setRadioSize(RenderStyle*) const;
    71 
    72         virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    73 
    74         virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    75 
    76         virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    77 
    78         virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    79 
    80         virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    81         virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    82 
    83         virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    84 
    85         virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    86         virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    87 
    88         virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    89         virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    90 
    91         virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    92         virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    93 
    94         // MenuList refers to an unstyled menulist (meaning a menulist without
    95         // background-color or border set) and MenuListButton refers to a styled
    96         // menulist (a menulist with background-color or border set). They have
    97         // this distinction to support showing aqua style themes whenever they
    98         // possibly can, which is something we don't want to replicate.
    99         //
    100         // In short, we either go down the MenuList code path or the MenuListButton
    101         // codepath. We never go down both. And in both cases, they render the
    102         // entire menulist.
    103         virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    104         virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    105         virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    106         virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    107 
    108         // These methods define the padding for the MenuList's inner block.
    109         virtual int popupInternalPaddingLeft(RenderStyle*) const;
    110         virtual int popupInternalPaddingRight(RenderStyle*) const;
    111         virtual int popupInternalPaddingTop(RenderStyle*) const;
    112         virtual int popupInternalPaddingBottom(RenderStyle*) const;
    113 
    114         virtual int buttonInternalPaddingLeft() const;
    115         virtual int buttonInternalPaddingRight() const;
    116         virtual int buttonInternalPaddingTop() const;
    117         virtual int buttonInternalPaddingBottom() const;
    118 
    119         // A general method asking if any control tinting is supported at all.
    120         virtual bool supportsControlTints() const { return true; }
    121 
    122     protected:
    123         static const String& defaultGUIFont();
    124 
    125         // The default variable-width font size.  We use this as the default font
    126         // size for the "system font", and as a base size (which we then shrink) for
    127         // form control fonts.
    128         static float defaultFontSize;
    129 
    130         virtual double caretBlinkIntervalInternal() const;
    131 
    132     private:
    133         RenderThemeChromiumSkia();
    134         virtual ~RenderThemeChromiumSkia();
    135 
    136         int menuListInternalPadding(RenderStyle*, int paddingType) const;
    137         bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
    138     };
    13935
    14036    class RenderThemeChromiumLinux : public RenderThemeChromiumSkia {
     
    16157} // namespace WebCore
    16258
    163 #endif
     59#endif // RenderThemeChromiumLinux_h
  • trunk/WebCore/rendering/RenderThemeChromiumSkia.cpp

    r44426 r44775  
    1 // FIXME: This is a placeholder to avoid some issues with webkit.gyp in the chromium tree. Having this placeholder until we can factor out
    2 // RenderThemeChromiumSkia from RenderThemeChromiumLinux will keep the HEAD of both trees compatible.
     1/*
     2 * Copyright (C) 2007 Apple Inc.
     3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     4 * Copyright (C) 2008 Collabora Ltd.
     5 * Copyright (C) 2008, 2009 Google Inc.
     6 *
     7 * This library is free software; you can redistribute it and/or
     8 * modify it under the terms of the GNU Library General Public
     9 * License as published by the Free Software Foundation; either
     10 * version 2 of the License, or (at your option) any later version.
     11 *
     12 * This library is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 * Library General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU Library General Public License
     18 * along with this library; see the file COPYING.LIB.  If not, write to
     19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20 * Boston, MA 02110-1301, USA.
     21 *
     22 */
     23
     24#include "config.h"
     25#include "RenderThemeChromiumSkia.h"
     26
     27#include "ChromiumBridge.h"
     28#include "CSSValueKeywords.h"
     29#include "GraphicsContext.h"
     30#include "HTMLMediaElement.h"
     31#include "HTMLNames.h"
     32#include "Image.h"
     33#include "MediaControlElements.h"
     34#include "PlatformContextSkia.h"
     35#include "RenderBox.h"
     36#include "RenderObject.h"
     37#include "ScrollbarTheme.h"
     38#include "TransformationMatrix.h"
     39#include "UserAgentStyleSheets.h"
     40
     41#include "SkShader.h"
     42#include "SkGradientShader.h"
     43
     44namespace WebCore {
     45
     46enum PaddingType {
     47    TopPadding,
     48    RightPadding,
     49    BottomPadding,
     50    LeftPadding
     51};
     52
     53static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
     54
     55// The background for the media player controls should be a 60% opaque black rectangle. This
     56// matches the UI mockups for the default UI theme.
     57static const float defaultMediaControlOpacity = 0.6f;
     58
     59// These values all match Safari/Win.
     60static const float defaultControlFontPixelSize = 13;
     61static const float defaultCancelButtonSize = 9;
     62static const float minCancelButtonSize = 5;
     63static const float maxCancelButtonSize = 21;
     64static const float defaultSearchFieldResultsDecorationSize = 13;
     65static const float minSearchFieldResultsDecorationSize = 9;
     66static const float maxSearchFieldResultsDecorationSize = 30;
     67static const float defaultSearchFieldResultsButtonWidth = 18;
     68
     69static void setSizeIfAuto(RenderStyle* style, const IntSize& size)
     70{
     71    if (style->width().isIntrinsicOrAuto())
     72        style->setWidth(Length(size.width(), Fixed));
     73    if (style->height().isAuto())
     74        style->setHeight(Length(size.height(), Fixed));
     75}
     76
     77#if ENABLE(VIDEO)
     78// Attempt to retrieve a HTMLMediaElement from a Node. Returns NULL if one cannot be found.
     79static HTMLMediaElement* mediaElementParent(Node* node)
     80{
     81    if (!node)
     82        return 0;
     83    Node* mediaNode = node->shadowAncestorNode();
     84    if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag)))
     85        return 0;
     86
     87    return static_cast<HTMLMediaElement*>(mediaNode);
     88}
     89#endif
     90
     91// We aim to match IE here.
     92// -IE uses a font based on the encoding as the default font for form controls.
     93// -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT),
     94// which returns MS Shell Dlg)
     95// -Safari uses Lucida Grande.
     96//
     97// FIXME: The only case where we know we don't match IE is for ANSI encodings.
     98// IE uses MS Shell Dlg there, which we render incorrectly at certain pixel
     99// sizes (e.g. 15px). So, for now we just use Arial.
     100const String& RenderThemeChromiumSkia::defaultGUIFont()
     101{
     102    DEFINE_STATIC_LOCAL(String, fontface, ("Arial"));
     103    return fontFace;
     104}
     105
     106float RenderThemeChromiumSkia::defaultFontSize = 16.0;
     107
     108RenderThemeChromiumSkia::RenderThemeChromiumSkia()
     109{
     110}
     111
     112RenderThemeChromiumSkia::~RenderThemeChromiumSkia()
     113{
     114}
     115
     116// Use the Windows style sheets to match their metrics.
     117String RenderThemeChromiumSkia::extraDefaultStyleSheet()
     118{
     119    return String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet));
     120}
     121
     122String RenderThemeChromiumSkia::extraQuirksStyleSheet()
     123{
     124    return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet));
     125}
     126
     127#if ENABLE(VIDEO)
     128String RenderThemeChromiumSkia::extraMediaControlsStyleSheet()
     129{
     130    return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet));
     131}
     132#endif
     133
     134bool RenderThemeChromiumSkia::supportsHover(const RenderStyle* style) const
     135{
     136  return true;
     137}
     138
     139bool RenderThemeChromiumSkia::supportsFocusRing(const RenderStyle* style) const
     140{
     141    // This causes WebKit to draw the focus rings for us.
     142    return false;
     143}
     144
     145Color RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor() const
     146{
     147    return Color(0x1e, 0x90, 0xff);
     148}
     149
     150Color RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor() const
     151{
     152    return Color(0xc8, 0xc8, 0xc8);
     153}
     154
     155Color RenderThemeChromiumSkia::platformActiveSelectionForegroundColor() const
     156{
     157    return Color::black;
     158}
     159
     160Color RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor() const
     161{
     162    return Color(0x32, 0x32, 0x32);
     163}
     164
     165Color RenderThemeChromiumSkia::platformTextSearchHighlightColor() const
     166{
     167    return Color(0xff, 0xff, 0x96);
     168}
     169
     170double RenderThemeChromiumSkia::caretBlinkInterval() const
     171{
     172    // Disable the blinking caret in layout test mode, as it introduces
     173    // a race condition for the pixel tests. http://b/1198440
     174    if (ChromiumBridge::layoutTestMode())
     175        return 0;
     176
     177    return caretBlinkIntervalInternal();
     178}
     179
     180void RenderThemeChromiumSkia::systemFont(int propId, FontDescription& fontDescription) const
     181{
     182    float fontSize = defaultFontSize;
     183
     184    switch (propId) {
     185    case CSSValueWebkitMiniControl:
     186    case CSSValueWebkitSmallControl:
     187    case CSSValueWebkitControl:
     188        // Why 2 points smaller? Because that's what Gecko does. Note that we
     189        // are assuming a 96dpi screen, which is the default that we use on
     190        // Windows.
     191        static const float pointsPerInch = 72.0f;
     192        static const float pixelsPerInch = 96.0f;
     193        fontSize -= (2.0f / pointsPerInch) * pixelsPerInch;
     194        break;
     195    }
     196
     197    fontDescription.firstFamily().setFamily(defaultGUIFont());
     198    fontDescription.setSpecifiedSize(fontSize);
     199    fontDescription.setIsAbsoluteSize(true);
     200    fontDescription.setGenericFamily(FontDescription::NoFamily);
     201    fontDescription.setWeight(FontWeightNormal);
     202    fontDescription.setItalic(false);
     203}
     204
     205int RenderThemeChromiumSkia::minimumMenuListSize(RenderStyle* style) const
     206{
     207    return 0;
     208}
     209
     210bool RenderThemeChromiumSkia::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     211{
     212    static Image* const checkedImage = Image::loadPlatformResource("linuxCheckboxOn").releaseRef();
     213    static Image* const uncheckedImage = Image::loadPlatformResource("linuxCheckboxOff").releaseRef();
     214
     215    Image* image = this->isChecked(o) ? checkedImage : uncheckedImage;
     216    i.context->drawImage(image, rect);
     217    return false;
     218}
     219
     220void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const
     221{
     222    // If the width and height are both specified, then we have nothing to do.
     223    if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
     224        return;
     225
     226    // FIXME:  A hard-coded size of 13 is used.  This is wrong but necessary
     227    // for now.  It matches Firefox.  At different DPI settings on Windows,
     228    // querying the theme gives you a larger size that accounts for the higher
     229    // DPI.  Until our entire engine honors a DPI setting other than 96, we
     230    // can't rely on the theme's metrics.
     231    const IntSize size(13, 13);
     232    setSizeIfAuto(style, size);
     233}
     234
     235bool RenderThemeChromiumSkia::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     236{
     237    static Image* const checkedImage = Image::loadPlatformResource("linuxRadioOn").releaseRef();
     238    static Image* const uncheckedImage = Image::loadPlatformResource("linuxRadioOff").releaseRef();
     239
     240    Image* image = this->isChecked(o) ? checkedImage : uncheckedImage;
     241    i.context->drawImage(image, rect);
     242    return false;
     243}
     244
     245void RenderThemeChromiumSkia::setRadioSize(RenderStyle* style) const
     246{
     247    // Use same sizing for radio box as checkbox.
     248    setCheckboxSize(style);
     249}
     250
     251static SkColor brightenColor(double h, double s, double l, float brightenAmount)
     252{
     253    l += brightenAmount;
     254    if (l > 1.0)
     255        l = 1.0;
     256    if (l < 0.0)
     257        l = 0.0;
     258
     259    return makeRGBAFromHSLA(h, s, l, 1.0);
     260}
     261
     262static void paintButtonLike(RenderTheme* theme, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     263{
     264    SkCanvas* const canvas = i.context->platformContext()->canvas();
     265    SkPaint paint;
     266    SkRect skrect;
     267    const int right = rect.x() + rect.width();
     268    const int bottom = rect.y() + rect.height();
     269    SkColor baseColor = SkColorSetARGB(0xff, 0xdd, 0xdd, 0xdd);
     270    if (o->style()->hasBackground())
     271        baseColor = o->style()->backgroundColor().rgb();
     272    double h, s, l;
     273    Color(baseColor).getHSL(h, s, l);
     274    // Our standard gradient is from 0xdd to 0xf8. This is the amount of
     275    // increased luminance between those values.
     276    SkColor lightColor(brightenColor(h, s, l, 0.105));
     277
     278    // If the button is too small, fallback to drawing a single, solid color
     279    if (rect.width() < 5 || rect.height() < 5) {
     280        paint.setColor(baseColor);
     281        skrect.set(rect.x(), rect.y(), right, bottom);
     282        canvas->drawRect(skrect, paint);
     283        return;
     284    }
     285
     286    const int borderAlpha = theme->isHovered(o) ? 0x80 : 0x55;
     287    paint.setARGB(borderAlpha, 0, 0, 0);
     288    canvas->drawLine(rect.x() + 1, rect.y(), right - 1, rect.y(), paint);
     289    canvas->drawLine(right - 1, rect.y() + 1, right - 1, bottom - 1, paint);
     290    canvas->drawLine(rect.x() + 1, bottom - 1, right - 1, bottom - 1, paint);
     291    canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), bottom - 1, paint);
     292
     293    paint.setARGB(0xff, 0, 0, 0);
     294    SkPoint p[2];
     295    const int lightEnd = theme->isPressed(o) ? 1 : 0;
     296    const int darkEnd = !lightEnd;
     297    p[lightEnd].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()));
     298    p[darkEnd].set(SkIntToScalar(rect.x()), SkIntToScalar(bottom - 1));
     299    SkColor colors[2];
     300    colors[0] = lightColor;
     301    colors[1] = baseColor;
     302
     303    SkShader* shader = SkGradientShader::CreateLinear(
     304        p, colors, NULL, 2, SkShader::kClamp_TileMode, NULL);
     305    paint.setStyle(SkPaint::kFill_Style);
     306    paint.setShader(shader);
     307    shader->unref();
     308
     309    skrect.set(rect.x() + 1, rect.y() + 1, right - 1, bottom - 1);
     310    canvas->drawRect(skrect, paint);
     311
     312    paint.setShader(NULL);
     313    paint.setColor(brightenColor(h, s, l, -0.0588));
     314    canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint);
     315    canvas->drawPoint(right - 2, rect.y() + 1, paint);
     316    canvas->drawPoint(rect.x() + 1, bottom - 2, paint);
     317    canvas->drawPoint(right - 2, bottom - 2, paint);
     318}
     319
     320bool RenderThemeChromiumSkia::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     321{
     322    paintButtonLike(this, o, i, rect);
     323    return false;
     324}
     325
     326bool RenderThemeChromiumSkia::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     327{
     328    return true;
     329}
     330
     331bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     332{
     333    return paintTextField(o, i, r);
     334}
     335
     336bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     337{
     338    return paintTextField(o, i, r);
     339}
     340
     341void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
     342{
     343    // Scale the button size based on the font size
     344    float fontScale = style->fontSize() / defaultControlFontPixelSize;
     345    int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
     346    style->setWidth(Length(cancelButtonSize, Fixed));
     347    style->setHeight(Length(cancelButtonSize, Fixed));
     348}
     349
     350bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     351{
     352    IntRect bounds = r;
     353    ASSERT(o->parent());
     354    if (!o->parent() || !o->parent()->isBox())
     355        return false;
     356
     357    RenderBox* parentRenderBox = toRenderBox(o->parent());
     358
     359    IntRect parentBox = parentRenderBox->absoluteContentBox();
     360
     361    // Make sure the scaled button stays square and will fit in its parent's box
     362    bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
     363    bounds.setWidth(bounds.height());
     364
     365    // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
     366    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
     367    bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
     368
     369    static Image* cancelImage = Image::loadPlatformResource("searchCancel").releaseRef();
     370    static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").releaseRef();
     371    i.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage, bounds);
     372    return false;
     373}
     374
     375void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
     376{
     377    IntSize emptySize(1, 11);
     378    style->setWidth(Length(emptySize.width(), Fixed));
     379    style->setHeight(Length(emptySize.height(), Fixed));
     380}
     381
     382void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
     383{
     384    // Scale the decoration size based on the font size
     385    float fontScale = style->fontSize() / defaultControlFontPixelSize;
     386    int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
     387                                         maxSearchFieldResultsDecorationSize));
     388    style->setWidth(Length(magnifierSize, Fixed));
     389    style->setHeight(Length(magnifierSize, Fixed));
     390}
     391
     392bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     393{
     394    IntRect bounds = r;
     395    ASSERT(o->parent());
     396    if (!o->parent() || !o->parent()->isBox())
     397        return false;
     398
     399    RenderBox* parentRenderBox = toRenderBox(o->parent());
     400    IntRect parentBox = parentRenderBox->absoluteContentBox();
     401
     402    // Make sure the scaled decoration stays square and will fit in its parent's box
     403    bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
     404    bounds.setWidth(bounds.height());
     405
     406    // Center the decoration vertically.  Round up though, so if it has to be one pixel off-center, it will
     407    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
     408    bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
     409
     410    static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef();
     411    i.context->drawImage(magnifierImage, bounds);
     412    return false;
     413}
     414
     415void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
     416{
     417    // Scale the button size based on the font size
     418    float fontScale = style->fontSize() / defaultControlFontPixelSize;
     419    int magnifierHeight = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
     420                                           maxSearchFieldResultsDecorationSize));
     421    int magnifierWidth = lroundf(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
     422    style->setWidth(Length(magnifierWidth, Fixed));
     423    style->setHeight(Length(magnifierHeight, Fixed));
     424}
     425
     426bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     427{
     428    IntRect bounds = r;
     429    ASSERT(o->parent());
     430    if (!o->parent())
     431        return false;
     432    if (!o->parent() || !o->parent()->isBox())
     433        return false;
     434
     435    RenderBox* parentRenderBox = toRenderBox(o->parent());
     436    IntRect parentBox = parentRenderBox->absoluteContentBox();
     437
     438    // Make sure the scaled decoration will fit in its parent's box
     439    bounds.setHeight(std::min(parentBox.height(), bounds.height()));
     440    bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)));
     441
     442    // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
     443    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
     444    bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
     445
     446    static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").releaseRef();
     447    i.context->drawImage(magnifierImage, bounds);
     448    return false;
     449}
     450
     451bool RenderThemeChromiumSkia::paintMediaButtonInternal(GraphicsContext* context, const IntRect& rect, Image* image)
     452{
     453    context->beginTransparencyLayer(defaultMediaControlOpacity);
     454
     455    // Draw background.
     456    Color oldFill = context->fillColor();
     457    Color oldStroke = context->strokeColor();
     458
     459    context->setFillColor(Color::black);
     460    context->setStrokeColor(Color::black);
     461    context->drawRect(rect);
     462
     463    context->setFillColor(oldFill);
     464    context->setStrokeColor(oldStroke);
     465
     466    // Create a destination rectangle for the image that is centered in the drawing rectangle, rounded left, and down.
     467    IntRect imageRect = image->rect();
     468    imageRect.setY(rect.y() + (rect.height() - image->height() + 1) / 2);
     469    imageRect.setX(rect.x() + (rect.width() - image->width() + 1) / 2);
     470
     471    context->drawImage(image, imageRect, CompositeSourceAtop);
     472    context->endTransparencyLayer();
     473
     474    return false;
     475}
     476
     477bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
     478{
     479#if ENABLE(VIDEO)
     480    HTMLMediaElement* mediaElement = mediaElementParent(o->node());
     481    if (!mediaElement)
     482        return false;
     483
     484    static Image* mediaPlay = Image::loadPlatformResource("mediaPlay").releaseRef();
     485    static Image* mediaPause = Image::loadPlatformResource("mediaPause").releaseRef();
     486
     487    return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause);
     488#else
     489    return false;
     490#endif
     491}
     492
     493bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
     494{
     495#if ENABLE(VIDEO)
     496    HTMLMediaElement* mediaElement = mediaElementParent(o->node());
     497    if (!mediaElement)
     498        return false;
     499
     500    static Image* soundFull = Image::loadPlatformResource("mediaSoundFull").releaseRef();
     501    static Image* soundNone = Image::loadPlatformResource("mediaSoundNone").releaseRef();
     502
     503    return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull);
     504#else
     505    return false;
     506#endif
     507}
     508
     509void RenderThemeChromiumSkia::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
     510{
     511    // Height is locked to auto on all browsers.
     512    style->setLineHeight(RenderStyle::initialLineHeight());
     513}
     514
     515bool RenderThemeChromiumSkia::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     516{
     517    SkCanvas* const canvas = i.context->platformContext()->canvas();
     518    const int right = rect.x() + rect.width();
     519    const int middle = rect.y() + rect.height() / 2;
     520
     521    paintButtonLike(this, o, i, rect);
     522
     523    SkPaint paint;
     524    paint.setARGB(0xff, 0, 0, 0);
     525    paint.setAntiAlias(true);
     526    paint.setStyle(SkPaint::kFill_Style);
     527
     528    SkPath path;
     529    path.moveTo(right - 13, middle - 3);
     530    path.rLineTo(6, 0);
     531    path.rLineTo(-3, 6);
     532    path.close();
     533    canvas->drawPath(path, paint);
     534
     535    return false;
     536}
     537
     538void RenderThemeChromiumSkia::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
     539{
     540    adjustMenuListStyle(selector, style, e);
     541}
     542
     543// Used to paint styled menulists (i.e. with a non-default border)
     544bool RenderThemeChromiumSkia::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
     545{
     546    return paintMenuList(o, i, rect);
     547}
     548
     549int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const
     550{
     551    return menuListInternalPadding(style, LeftPadding);
     552}
     553
     554int RenderThemeChromiumSkia::popupInternalPaddingRight(RenderStyle* style) const
     555{
     556    return menuListInternalPadding(style, RightPadding);
     557}
     558
     559int RenderThemeChromiumSkia::popupInternalPaddingTop(RenderStyle* style) const
     560{
     561    return menuListInternalPadding(style, TopPadding);
     562}
     563
     564int RenderThemeChromiumSkia::popupInternalPaddingBottom(RenderStyle* style) const
     565{
     566    return menuListInternalPadding(style, BottomPadding);
     567}
     568
     569int RenderThemeChromiumSkia::buttonInternalPaddingLeft() const
     570{
     571    return 3;
     572}
     573
     574int RenderThemeChromiumSkia::buttonInternalPaddingRight() const
     575{
     576    return 3;
     577}
     578
     579int RenderThemeChromiumSkia::buttonInternalPaddingTop() const
     580{
     581    return 1;
     582}
     583
     584int RenderThemeChromiumSkia::buttonInternalPaddingBottom() const
     585{
     586    return 1;
     587}
     588
     589double RenderThemeChromiumSkia::caretBlinkIntervalInternal() const
     590{
     591    return RenderTheme::caretBlinkInterval();
     592}
     593
     594int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int paddingType) const
     595{
     596    // This internal padding is in addition to the user-supplied padding.
     597    // Matches the FF behavior.
     598    int padding = styledMenuListInternalPadding[paddingType];
     599
     600    // Reserve the space for right arrow here. The rest of the padding is
     601    // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from
     602    // RenderMenuList to lay out the individual items in the popup.
     603    // If the MenuList actually has appearance "NoAppearance", then that means
     604    // we don't draw a button, so don't reserve space for it.
     605    const int barType = style->direction() == LTR ? RightPadding : LeftPadding;
     606    if (paddingType == barType && style->appearance() != NoControlPart)
     607        padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
     608
     609    return padding;
     610}
     611
     612} // namespace WebCore
  • trunk/WebCore/rendering/RenderThemeChromiumSkia.h

    r44426 r44775  
    1 // FIXME: This is a placeholder to avoid some issues with webkit.gyp in the chromium tree. Having this placeholder until we can factor out
    2 // RenderThemeChromiumSkia from RenderThemeChromiumLinux will keep the HEAD of both trees compatible.
     1/*
     2 * This file is part of the WebKit project.
     3 *
     4 * Copyright (C) 2006 Apple Computer, Inc.
     5 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
     6 * Copyright (C) 2007 Holger Hans Peter Freyther
     7 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     8 * Copyright (C) 2008, 2009 Google, Inc.
     9 * All rights reserved.
     10 *
     11 * This library is free software; you can redistribute it and/or
     12 * modify it under the terms of the GNU Library General Public
     13 * License as published by the Free Software Foundation; either
     14 * version 2 of the License, or (at your option) any later version.
     15 *
     16 * This library is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19 * Library General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Library General Public License
     22 * along with this library; see the file COPYING.LIB.  If not, write to
     23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     24 * Boston, MA 02110-1301, USA.
     25 *
     26 */
     27
     28#ifndef RenderThemeChromiumSkia_h
     29#define RenderThemeChromiumSkia_h
     30
     31#include "RenderTheme.h"
     32
     33namespace WebCore {
     34
     35    class RenderThemeChromiumSkia : public RenderTheme {
     36    public:
     37        RenderThemeChromiumSkia();
     38        virtual ~RenderThemeChromiumSkia();
     39
     40        virtual String extraDefaultStyleSheet();
     41        virtual String extraQuirksStyleSheet();
     42#if ENABLE(VIDEO)
     43        virtual String extraMediaControlsStyleSheet();
     44#endif
     45
     46        // A method asking if the theme's controls actually care about redrawing when hovered.
     47        virtual bool supportsHover(const RenderStyle*) const;
     48
     49        // A method asking if the theme is able to draw the focus ring.
     50        virtual bool supportsFocusRing(const RenderStyle*) const;
     51
     52        // The platform selection color.
     53        virtual Color platformActiveSelectionBackgroundColor() const;
     54        virtual Color platformInactiveSelectionBackgroundColor() const;
     55        virtual Color platformActiveSelectionForegroundColor() const;
     56        virtual Color platformInactiveSelectionForegroundColor() const;
     57        virtual Color platformTextSearchHighlightColor() const;
     58
     59        // To change the blink interval, override caretBlinkIntervalInternal instead of this one so that we may share layout test code an intercepts.
     60        virtual double caretBlinkInterval() const;
     61
     62        // System fonts.
     63        virtual void systemFont(int propId, FontDescription&) const;
     64
     65        virtual int minimumMenuListSize(RenderStyle*) const;
     66
     67        virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     68        virtual void setCheckboxSize(RenderStyle*) const;
     69
     70        virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     71        virtual void setRadioSize(RenderStyle*) const;
     72
     73        virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     74
     75        virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     76
     77        virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     78
     79        virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     80
     81        virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     82        virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     83
     84        virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     85
     86        virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     87        virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     88
     89        virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     90        virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     91
     92        virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     93        virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     94
     95        // MenuList refers to an unstyled menulist (meaning a menulist without
     96        // background-color or border set) and MenuListButton refers to a styled
     97        // menulist (a menulist with background-color or border set). They have
     98        // this distinction to support showing aqua style themes whenever they
     99        // possibly can, which is something we don't want to replicate.
     100        //
     101        // In short, we either go down the MenuList code path or the MenuListButton
     102        // codepath. We never go down both. And in both cases, they render the
     103        // entire menulist.
     104        virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     105        virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     106        virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     107        virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     108
     109        // These methods define the padding for the MenuList's inner block.
     110        virtual int popupInternalPaddingLeft(RenderStyle*) const;
     111        virtual int popupInternalPaddingRight(RenderStyle*) const;
     112        virtual int popupInternalPaddingTop(RenderStyle*) const;
     113        virtual int popupInternalPaddingBottom(RenderStyle*) const;
     114
     115        virtual int buttonInternalPaddingLeft() const;
     116        virtual int buttonInternalPaddingRight() const;
     117        virtual int buttonInternalPaddingTop() const;
     118        virtual int buttonInternalPaddingBottom() const;
     119
     120        // A general method asking if any control tinting is supported at all.
     121        virtual bool supportsControlTints() const { return true; }
     122
     123    protected:
     124        static const String& defaultGUIFont();
     125
     126        // The default variable-width font size.  We use this as the default font
     127        // size for the "system font", and as a base size (which we then shrink) for
     128        // form control fonts.
     129        static float defaultFontSize;
     130
     131        virtual double caretBlinkIntervalInternal() const;
     132
     133    private:
     134        int menuListInternalPadding(RenderStyle*, int paddingType) const;
     135        bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
     136    };
     137
     138} // namespace WebCore
     139
     140#endif // RenderThemeChromiumSkia_h
Note: See TracChangeset for help on using the changeset viewer.