Changeset 129041 in webkit


Ignore:
Timestamp:
Sep 19, 2012 1:52:43 PM (12 years ago)
Author:
rwlbuis@webkit.org
Message:

[BlackBerry] Fix vertical positioning problem for 'X' in search field
https://bugs.webkit.org/show_bug.cgi?id=97126

Reviewed by Antonio Gomes.

We have the same problem as described in bug 30245, so integrate that code.

  • platform/blackberry/RenderThemeBlackBerry.cpp:

(WebCore::RenderThemeBlackBerry::convertToPaintingRect):
(WebCore):
(WebCore::RenderThemeBlackBerry::paintSearchFieldCancelButton):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r129038 r129041  
    144144        * bindings/v8/WorkerContextExecutionProxy.h:
    145145        (WorkerContextExecutionProxy):
     146
     1472012-09-19  Rob Buis  <rbuis@rim.com>
     148
     149        [BlackBerry] Fix vertical positioning problem for 'X' in search field
     150        https://bugs.webkit.org/show_bug.cgi?id=97126
     151
     152        Reviewed by Antonio Gomes.
     153
     154        We have the same problem as described in bug 30245, so integrate that code.
     155
     156        * platform/blackberry/RenderThemeBlackBerry.cpp:
     157        (WebCore::RenderThemeBlackBerry::convertToPaintingRect):
     158        (WebCore):
     159        (WebCore::RenderThemeBlackBerry::paintSearchFieldCancelButton):
    146160
    1471612012-09-19  Rob Buis  <rbuis@rim.com>
  • trunk/Source/WebCore/platform/blackberry/RenderThemeBlackBerry.cpp

    r129001 r129041  
    333333}
    334334
    335 bool RenderThemeBlackBerry::paintSearchFieldCancelButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
    336 {
    337     ASSERT(object->parent());
    338     if (!object->parent() || !object->parent()->isBox())
     335IntRect RenderThemeBlackBerry::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const
     336{
     337    // Compute an offset between the part renderer and the input renderer.
     338    LayoutSize offsetFromInputRenderer = -partRenderer->offsetFromAncestorContainer(inputRenderer);
     339    // Move the rect into partRenderer's coords.
     340    partRect.move(offsetFromInputRenderer);
     341    // Account for the local drawing offset.
     342    partRect.move(localOffset.x(), localOffset.y());
     343
     344    return pixelSnappedIntRect(partRect);
     345}
     346
     347
     348bool RenderThemeBlackBerry::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r)
     349{
     350    Node* input = cancelButtonObject->node()->shadowAncestorNode();
     351    if (!input->renderer()->isBox())
    339352        return false;
    340353
    341     RenderBox* parentRenderBox = toRenderBox(object->parent());
    342 
    343     IntRect parentBox = parentRenderBox->absoluteContentBox();
    344     IntRect bounds = rect;
    345     // Make sure the scaled button stays square and fits in its parent's box.
    346     bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
    347     bounds.setWidth(bounds.height());
    348 
    349     // Put the button in the middle vertically, and round up the value.
    350     // So if it has to be one pixel off-center, it would be one pixel closer
    351     // to the bottom of the field. This would look better with the text.
    352     bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
     354    RenderBox* inputRenderBox = toRenderBox(input->renderer());
     355    LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
     356
     357    // Make sure the scaled button stays square and will fit in its parent's box.
     358    LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height()));
     359    // Calculate cancel button's coordinates relative to the input element.
     360    // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will
     361    // be one pixel closer to the bottom of the field. This tends to look better with the text.
     362    LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
     363                                inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
     364                                cancelButtonSize, cancelButtonSize);
     365    IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r);
    353366
    354367    static Image* cancelImage = Image::loadPlatformResource("searchCancel").leakRef();
    355368    static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").leakRef();
    356     paintInfo.context->drawImage(isPressed(object) ? cancelPressedImage : cancelImage, object->style()->colorSpace(), bounds);
     369    paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage,
     370                                 cancelButtonObject->style()->colorSpace(), paintingRect);
    357371    return false;
    358372}
Note: See TracChangeset for help on using the changeset viewer.