| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright (C) 2007 Apple Inc. |    2  * Copyright (C) 2007 Apple Inc. | 
|    3  * Copyright (C) 2007 Alp Toker <alp@atoker.com> |    3  * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 
|    4  * Copyright (C) 2008 Collabora Ltd. |    4  * Copyright (C) 2008 Collabora Ltd. | 
|    5  * Copyright (C) 2008, 2009 Google Inc. |    5  * Copyright (C) 2008, 2009 Google Inc. | 
|    6  * |    6  * | 
|    7  * This library is free software; you can redistribute it and/or |    7  * This library is free software; you can redistribute it and/or | 
|    8  * modify it under the terms of the GNU Library General Public |    8  * modify it under the terms of the GNU Library General Public | 
|    9  * License as published by the Free Software Foundation; either |    9  * License as published by the Free Software Foundation; either | 
|   10  * version 2 of the License, or (at your option) any later version. |   10  * version 2 of the License, or (at your option) any later version. | 
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  365  |  365  | 
|  366 void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelecto
     r*, RenderStyle* style, Element*) const |  366 void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelecto
     r*, RenderStyle* style, Element*) const | 
|  367 { |  367 { | 
|  368     // Scale the button size based on the font size |  368     // Scale the button size based on the font size | 
|  369     float fontScale = style->fontSize() / defaultControlFontPixelSize; |  369     float fontScale = style->fontSize() / defaultControlFontPixelSize; | 
|  370     int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaul
     tCancelButtonSize * fontScale), maxCancelButtonSize)); |  370     int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaul
     tCancelButtonSize * fontScale), maxCancelButtonSize)); | 
|  371     style->setWidth(Length(cancelButtonSize, Fixed)); |  371     style->setWidth(Length(cancelButtonSize, Fixed)); | 
|  372     style->setHeight(Length(cancelButtonSize, Fixed)); |  372     style->setHeight(Length(cancelButtonSize, Fixed)); | 
|  373 } |  373 } | 
|  374  |  374  | 
 |  375 IntRect RenderThemeChromiumSkia::calculateParentBoxOfSearchFieldItem(RenderObjec
     t* o, const IntRect& r) | 
 |  376 { | 
 |  377     ASSERT(o->parent()); | 
 |  378     if (!o->isBox() || !o->parent() || !o->parent()->isBox()) | 
 |  379         return IntRect(); | 
 |  380  | 
 |  381     RenderBox* renderBox = toRenderBox(o); | 
 |  382     RenderBox* parentRenderBox = toRenderBox(o->parent()); | 
 |  383  | 
 |  384     IntPoint parentBoxPoint = r.location(); | 
 |  385     parentBoxPoint.move(-renderBox->x(), -renderBox->y());  // Restore parent bo
     x's location from r. | 
 |  386     IntRect parentBox(parentBoxPoint, parentRenderBox->contentBoxRect().size()); | 
 |  387     return parentBox; | 
 |  388 } | 
 |  389  | 
|  375 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, cons
     t RenderObject::PaintInfo& i, const IntRect& r) |  390 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, cons
     t RenderObject::PaintInfo& i, const IntRect& r) | 
|  376 { |  391 { | 
|  377     IntRect bounds = r; |  392     IntRect bounds = r; | 
|  378     ASSERT(o->parent()); |  393     IntRect parentBox = calculateParentBoxOfSearchFieldItem(o, r); | 
|  379     if (!o->parent() || !o->parent()->isBox()) |  394     if (parentBox.isEmpty()) | 
|  380         return false; |  395         return false; | 
|  381  |  396  | 
|  382     RenderBox* parentRenderBox = toRenderBox(o->parent()); |  | 
|  383  |  | 
|  384     IntRect parentBox = parentRenderBox->absoluteContentBox(); |  | 
|  385  |  | 
|  386     // Make sure the scaled button stays square and will fit in its parent's box |  397     // Make sure the scaled button stays square and will fit in its parent's box | 
|  387     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bo
     unds.height()))); |  398     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bo
     unds.height()))); | 
|  388     bounds.setWidth(bounds.height()); |  399     bounds.setWidth(bounds.height()); | 
|  389  |  400  | 
|  390     // Center the button vertically.  Round up though, so if it has to be one pi
     xel off-center, it will |  401     // Center the button vertically.  Round up though, so if it has to be one pi
     xel off-center, it will | 
|  391     // be one pixel closer to the bottom of the field.  This tends to look bette
     r with the text. |  402     // be one pixel closer to the bottom of the field.  This tends to look bette
     r with the text. | 
|  392     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); |  403     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); | 
|  393  |  404  | 
|  394     static Image* cancelImage = Image::loadPlatformResource("searchCancel").rele
     aseRef(); |  405     static Image* cancelImage = Image::loadPlatformResource("searchCancel").rele
     aseRef(); | 
|  395     static Image* cancelPressedImage = Image::loadPlatformResource("searchCancel
     Pressed").releaseRef(); |  406     static Image* cancelPressedImage = Image::loadPlatformResource("searchCancel
     Pressed").releaseRef(); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  410     float fontScale = style->fontSize() / defaultControlFontPixelSize; |  421     float fontScale = style->fontSize() / defaultControlFontPixelSize; | 
|  411     int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecoratio
     nSize, defaultSearchFieldResultsDecorationSize * fontScale), |  422     int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecoratio
     nSize, defaultSearchFieldResultsDecorationSize * fontScale), | 
|  412                                          maxSearchFieldResultsDecorationSize)); |  423                                          maxSearchFieldResultsDecorationSize)); | 
|  413     style->setWidth(Length(magnifierSize, Fixed)); |  424     style->setWidth(Length(magnifierSize, Fixed)); | 
|  414     style->setHeight(Length(magnifierSize, Fixed)); |  425     style->setHeight(Length(magnifierSize, Fixed)); | 
|  415 } |  426 } | 
|  416  |  427  | 
|  417 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o,
      const RenderObject::PaintInfo& i, const IntRect& r) |  428 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o,
      const RenderObject::PaintInfo& i, const IntRect& r) | 
|  418 { |  429 { | 
|  419     IntRect bounds = r; |  430     IntRect bounds = r; | 
|  420     ASSERT(o->parent()); |  431     IntRect parentBox = calculateParentBoxOfSearchFieldItem(o, r); | 
|  421     if (!o->parent() || !o->parent()->isBox()) |  432     if (parentBox.isEmpty()) | 
|  422         return false; |  433         return false; | 
|  423  |  434  | 
|  424     RenderBox* parentRenderBox = toRenderBox(o->parent()); |  | 
|  425     IntRect parentBox = parentRenderBox->absoluteContentBox(); |  | 
|  426  |  | 
|  427     // Make sure the scaled decoration stays square and will fit in its parent's
      box |  435     // Make sure the scaled decoration stays square and will fit in its parent's
      box | 
|  428     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bo
     unds.height()))); |  436     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bo
     unds.height()))); | 
|  429     bounds.setWidth(bounds.height()); |  437     bounds.setWidth(bounds.height()); | 
|  430  |  438  | 
|  431     // Center the decoration vertically.  Round up though, so if it has to be on
     e pixel off-center, it will |  439     // Center the decoration vertically.  Round up though, so if it has to be on
     e pixel off-center, it will | 
|  432     // be one pixel closer to the bottom of the field.  This tends to look bette
     r with the text. |  440     // be one pixel closer to the bottom of the field.  This tends to look bette
     r with the text. | 
|  433     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); |  441     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); | 
|  434  |  442  | 
|  435     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier"
     ).releaseRef(); |  443     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier"
     ).releaseRef(); | 
|  436     i.context->drawImage(magnifierImage, bounds); |  444     i.context->drawImage(magnifierImage, bounds); | 
|  437     return false; |  445     return false; | 
|  438 } |  446 } | 
|  439  |  447  | 
|  440 void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelect
     or*, RenderStyle* style, Element*) const |  448 void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelect
     or*, RenderStyle* style, Element*) const | 
|  441 { |  449 { | 
|  442     // Scale the button size based on the font size |  450     // Scale the button size based on the font size | 
|  443     float fontScale = style->fontSize() / defaultControlFontPixelSize; |  451     float fontScale = style->fontSize() / defaultControlFontPixelSize; | 
|  444     int magnifierHeight = lroundf(std::min(std::max(minSearchFieldResultsDecorat
     ionSize, defaultSearchFieldResultsDecorationSize * fontScale), |  452     int magnifierHeight = lroundf(std::min(std::max(minSearchFieldResultsDecorat
     ionSize, defaultSearchFieldResultsDecorationSize * fontScale), | 
|  445                                            maxSearchFieldResultsDecorationSize))
     ; |  453                                            maxSearchFieldResultsDecorationSize))
     ; | 
|  446     int magnifierWidth = lroundf(magnifierHeight * defaultSearchFieldResultsButt
     onWidth / defaultSearchFieldResultsDecorationSize); |  454     int magnifierWidth = lroundf(magnifierHeight * defaultSearchFieldResultsButt
     onWidth / defaultSearchFieldResultsDecorationSize); | 
|  447     style->setWidth(Length(magnifierWidth, Fixed)); |  455     style->setWidth(Length(magnifierWidth, Fixed)); | 
|  448     style->setHeight(Length(magnifierHeight, Fixed)); |  456     style->setHeight(Length(magnifierHeight, Fixed)); | 
|  449 } |  457 } | 
|  450  |  458  | 
|  451 bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, con
     st RenderObject::PaintInfo& i, const IntRect& r) |  459 bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, con
     st RenderObject::PaintInfo& i, const IntRect& r) | 
|  452 { |  460 { | 
|  453     IntRect bounds = r; |  461     IntRect bounds = r; | 
|  454     ASSERT(o->parent()); |  462     IntRect parentBox = calculateParentBoxOfSearchFieldItem(o, r); | 
|  455     if (!o->parent()) |  463     if (parentBox.isEmpty()) | 
|  456         return false; |  464         return false; | 
|  457     if (!o->parent() || !o->parent()->isBox()) |  | 
|  458         return false; |  | 
|  459  |  | 
|  460     RenderBox* parentRenderBox = toRenderBox(o->parent()); |  | 
|  461     IntRect parentBox = parentRenderBox->absoluteContentBox(); |  | 
|  462  |  465  | 
|  463     // Make sure the scaled decoration will fit in its parent's box |  466     // Make sure the scaled decoration will fit in its parent's box | 
|  464     bounds.setHeight(std::min(parentBox.height(), bounds.height())); |  467     bounds.setHeight(std::min(parentBox.height(), bounds.height())); | 
|  465     bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height()
      * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSiz
     e))); |  468     bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height()
      * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSiz
     e))); | 
|  466  |  469  | 
|  467     // Center the button vertically.  Round up though, so if it has to be one pi
     xel off-center, it will |  470     // Center the button vertically.  Round up though, so if it has to be one pi
     xel off-center, it will | 
|  468     // be one pixel closer to the bottom of the field.  This tends to look bette
     r with the text. |  471     // be one pixel closer to the bottom of the field.  This tends to look bette
     r with the text. | 
|  469     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); |  472     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); | 
|  470  |  473  | 
|  471     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierR
     esults").releaseRef(); |  474     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierR
     esults").releaseRef(); | 
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  739     // If the MenuList actually has appearance "NoAppearance", then that means |  742     // If the MenuList actually has appearance "NoAppearance", then that means | 
|  740     // we don't draw a button, so don't reserve space for it. |  743     // we don't draw a button, so don't reserve space for it. | 
|  741     const int barType = style->direction() == LTR ? RightPadding : LeftPadding; |  744     const int barType = style->direction() == LTR ? RightPadding : LeftPadding; | 
|  742     if (paddingType == barType && style->appearance() != NoControlPart) |  745     if (paddingType == barType && style->appearance() != NoControlPart) | 
|  743         padding += ScrollbarTheme::nativeTheme()->scrollbarThickness(); |  746         padding += ScrollbarTheme::nativeTheme()->scrollbarThickness(); | 
|  744  |  747  | 
|  745     return padding; |  748     return padding; | 
|  746 } |  749 } | 
|  747  |  750  | 
|  748 } // namespace WebCore |  751 } // namespace WebCore | 
| OLD | NEW |