Changeset 114471 in webkit


Ignore:
Timestamp:
Apr 17, 2012 5:31:32 PM (12 years ago)
Author:
eae@chromium.org
Message:

Change RenderThemeChromiumSkia paint methods to use pixel snapping
https://bugs.webkit.org/show_bug.cgi?id=84175

Reviewed by Eric Seidel.

No new tests, no change in functionality.

Change RenderThemeChromiumSkia to use subpixel types and pixel snap
values just before painting.

  • rendering/RenderThemeChromiumSkia.cpp:

(WebCore::RenderThemeChromiumSkia::convertToPaintingRect):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton):

  • rendering/RenderThemeChromiumSkia.h:

2012-04-17 Levi Weintraub <leviw@chromium.org>

Clean up outstanding LayoutUnit misuse in WebCore
https://bugs.webkit.org/show_bug.cgi?id=84209

Reviewed by Eric Seidel.

Small changes to a handful of files to prepare trunk for FractionalLayoutUnits.
For more details, see https://trac.webkit.org/wiki/LayoutUnit

No new tests. No change in behavior.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): minimumValueForLength preserves
sub-pixel precision, so we should avoid unnecessarily using integers.

  • platform/graphics/FractionalLayoutPoint.h:

(WebCore::FractionalLayoutPoint::FractionalLayoutPoint): Adding an explicit constructor from
FractionalLayoutSizes. This mirrors a method in IntPoint.

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintBorder): The rects that change come from roundedRects,
which are already pixel-snapped.

  • rendering/RenderBoxModelObject.h: Removing a comment that is no longer applicable.
  • rendering/RenderTable.cpp:

(WebCore::RenderTable::computeLogicalWidth): Since we layout tables using integers, we
need to explicitly calculate the width to be integral as well to avoid pushing the next element
over by a pixel that we won't later paint with our own box decorations.

  • rendering/RenderText.h:

(RenderText): Correcting an unfortunate mismatch between in the return value of linesBoundingBox
between the header and implementation.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::getRoundedBorderFor): We were incorrectly not using the snapped border
rect to pass to calcRadiiFor (which takes an IntRect). Correcting this.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r114470 r114471  
     12012-04-17  Emil A Eklund  <eae@chromium.org>
     2
     3        Change RenderThemeChromiumSkia paint methods to use pixel snapping
     4        https://bugs.webkit.org/show_bug.cgi?id=84175
     5
     6        Reviewed by Eric Seidel.
     7
     8        No new tests, no change in functionality.
     9
     10        Change RenderThemeChromiumSkia to use subpixel types and pixel snap
     11        values just before painting.
     12
     13        * rendering/RenderThemeChromiumSkia.cpp:
     14        (WebCore::RenderThemeChromiumSkia::convertToPaintingRect):
     15        (WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton):
     16        (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration):
     17        (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton):
     18        * rendering/RenderThemeChromiumSkia.h:
     19
    120 2012-04-17  Levi Weintraub  <leviw@chromium.org>
    221
  • trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp

    r113030 r114471  
    262262}
    263263
    264 IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
     264IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const
    265265{
    266266    // Compute an offset between the part renderer and the input renderer.
    267     IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
     267    LayoutSize offsetFromInputRenderer = -partRenderer->offsetFromAncestorContainer(inputRenderer);
    268268    // Move the rect into partRenderer's coords.
    269269    partRect.move(offsetFromInputRenderer);
     
    271271    partRect.move(localOffset.x(), localOffset.y());
    272272
    273     return partRect;
     273    return pixelSnappedIntRect(partRect);
    274274}
    275275
     
    281281        return false;
    282282    RenderBox* inputRenderBox = toRenderBox(input->renderer());
    283     IntRect inputContentBox = inputRenderBox->contentBoxRect();
     283    LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
    284284
    285285    // Make sure the scaled button stays square and will fit in its parent's box.
    286     int cancelButtonSize = std::min(inputContentBox.width(), std::min<int>(inputContentBox.height(), r.height()));
     286    LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height()));
    287287    // Calculate cancel button's coordinates relative to the input element.
    288288    // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
    289289    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
    290     IntRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
    291                              inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
    292                              cancelButtonSize, cancelButtonSize);
     290    LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
     291                                inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
     292                                cancelButtonSize, cancelButtonSize);
    293293    IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r);
    294294
     
    324324        return false;
    325325    RenderBox* inputRenderBox = toRenderBox(input->renderer());
    326     IntRect inputContentBox = inputRenderBox->contentBoxRect();
     326    LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
    327327
    328328    // Make sure the scaled decoration stays square and will fit in its parent's box.
    329     int magnifierSize = std::min(inputContentBox.width(), std::min<int>(inputContentBox.height(), r.height()));
     329    LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height()));
    330330    // Calculate decoration's coordinates relative to the input element.
    331331    // Center the decoration vertically.  Round up though, so if it has to be one pixel off-center, it will
    332332    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
    333     IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
    334                           inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
    335                           magnifierSize, magnifierSize);
     333    LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
     334                             inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
     335                             magnifierSize, magnifierSize);
    336336    IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
    337337
     
    359359        return false;
    360360    RenderBox* inputRenderBox = toRenderBox(input->renderer());
    361     IntRect inputContentBox = inputRenderBox->contentBoxRect();
     361    LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
    362362
    363363    // Make sure the scaled decoration will fit in its parent's box.
    364     int magnifierHeight = std::min<int>(inputContentBox.height(), r.height());
    365     int magnifierWidth = std::min<int>(inputContentBox.width(), magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
    366     IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
    367                           inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2,
    368                           magnifierWidth, magnifierHeight);
     364    LayoutUnit magnifierHeight = std::min(inputContentBox.height(), r.height());
     365    LayoutUnit magnifierWidth = std::min<LayoutUnit>(inputContentBox.width(), magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
     366    LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
     367                             inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2,
     368                             magnifierWidth, magnifierHeight);
    369369    IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
    370370
  • trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h

    r113030 r114471  
    158158    int menuListInternalPadding(RenderStyle*, int paddingType) const;
    159159    bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
    160     IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
     160    IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const;
    161161};
    162162
Note: See TracChangeset for help on using the changeset viewer.