Changeset 110505 in webkit


Ignore:
Timestamp:
Mar 12, 2012 4:51:09 PM (12 years ago)
Author:
eae@chromium.org
Message:

Fix rounding in scrollbar rect calculations
https://bugs.webkit.org/show_bug.cgi?id=80894

Reviewed by Eric Seidel.

Fix usage of subpixel units in RenderScrollbar::buttonRect and
RenderScrollbar::trackRect.

No new tests, no new functionality.

  • rendering/LayoutTypes.h:

(WebCore::isIntegerValue):
Add dummy isIntegerValue function, will be replaced with actual
implementation once LayoutUnit is remapped to FractionalLayoutUnit.

  • rendering/RenderScrollbar.cpp:

(WebCore::RenderScrollbar::buttonRect):
(WebCore::RenderScrollbar::trackRect):
Change rect calculations to use pixel snapped values.

  • rendering/RenderScrollbarPart.h:

(RenderScrollbarPart):
(WebCore::RenderScrollbarPart::marginTop):
(WebCore::RenderScrollbarPart::marginBottom):
(WebCore::RenderScrollbarPart::marginLeft):
(WebCore::RenderScrollbarPart::marginRight):
Add ASSERT to ensure that scrollbar parts are always aligned to device
pixels.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r110504 r110505  
     12012-03-12  Emil A Eklund  <eae@chromium.org>
     2
     3        Fix rounding in scrollbar rect calculations
     4        https://bugs.webkit.org/show_bug.cgi?id=80894
     5
     6        Reviewed by Eric Seidel.
     7
     8        Fix usage of subpixel units in RenderScrollbar::buttonRect and
     9        RenderScrollbar::trackRect.
     10
     11        No new tests, no new functionality.
     12
     13        * rendering/LayoutTypes.h:
     14        (WebCore::isIntegerValue):
     15        Add dummy isIntegerValue function, will be replaced with actual
     16        implementation once LayoutUnit is remapped to FractionalLayoutUnit.
     17       
     18        * rendering/RenderScrollbar.cpp:
     19        (WebCore::RenderScrollbar::buttonRect):
     20        (WebCore::RenderScrollbar::trackRect):
     21        Change rect calculations to use pixel snapped values.
     22
     23        * rendering/RenderScrollbarPart.h:
     24        (RenderScrollbarPart):
     25        (WebCore::RenderScrollbarPart::marginTop):
     26        (WebCore::RenderScrollbarPart::marginBottom):
     27        (WebCore::RenderScrollbarPart::marginLeft):
     28        (WebCore::RenderScrollbarPart::marginRight):
     29        Add ASSERT to ensure that scrollbar parts are always aligned to device
     30        pixels.
     31
    1322012-03-12  C Anthony Risinger  <anthony@xtfx.me>
    233
  • trunk/Source/WebCore/rendering/LayoutTypes.h

    r110322 r110505  
    151151}
    152152
     153inline bool isIntegerValue(const LayoutUnit)
     154{
     155    return true;
     156}
     157
    153158} // namespace WebCore
    154159
  • trunk/Source/WebCore/rendering/RenderScrollbar.cpp

    r110135 r110505  
    298298    bool isHorizontal = orientation() == HorizontalScrollbar;
    299299    if (partType == BackButtonStartPart)
    300         return IntRect(location(), IntSize(isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()));
     300        return IntRect(location(), IntSize(isHorizontal ? partRenderer->pixelSnappedWidth() : width(), isHorizontal ? height() : partRenderer->pixelSnappedHeight()));
    301301    if (partType == ForwardButtonEndPart)
    302         return IntRect(isHorizontal ? x() + width() - partRenderer->width() : x(),
    303        
    304                        isHorizontal ? y() : y() + height() - partRenderer->height(),
    305                        isHorizontal ? partRenderer->width() : width(),
    306                        isHorizontal ? height() : partRenderer->height());
     302        return IntRect(isHorizontal ? x() + width() - partRenderer->pixelSnappedWidth() : x(),
     303                       isHorizontal ? y() : y() + height() - partRenderer->pixelSnappedHeight(),
     304                       isHorizontal ? partRenderer->pixelSnappedWidth() : width(),
     305                       isHorizontal ? height() : partRenderer->pixelSnappedHeight());
    307306   
    308307    if (partType == ForwardButtonStartPart) {
     
    310309        return IntRect(isHorizontal ? x() + previousButton.width() : x(),
    311310                       isHorizontal ? y() : y() + previousButton.height(),
    312                        isHorizontal ? partRenderer->width() : width(),
    313                        isHorizontal ? height() : partRenderer->height());
     311                       isHorizontal ? partRenderer->pixelSnappedWidth() : width(),
     312                       isHorizontal ? height() : partRenderer->pixelSnappedHeight());
    314313    }
    315314   
    316315    IntRect followingButton = buttonRect(ForwardButtonEndPart);
    317     return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->width() : x(),
    318                    isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->height(),
    319                    isHorizontal ? partRenderer->width() : width(),
    320                    isHorizontal ? height() : partRenderer->height());
     316    return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->pixelSnappedWidth() : x(),
     317                   isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->pixelSnappedHeight(),
     318                   isHorizontal ? partRenderer->pixelSnappedWidth() : width(),
     319                   isHorizontal ? height() : partRenderer->pixelSnappedHeight());
    321320}
    322321
     
    328327
    329328    if (orientation() == HorizontalScrollbar) {
    330         int marginLeft = part ? part->marginLeft() : 0;
    331         int marginRight = part ? part->marginRight() : 0;
     329        int marginLeft = part ? static_cast<int>(part->marginLeft()) : 0;
     330        int marginRight = part ? static_cast<int>(part->marginRight()) : 0;
    332331        startLength += marginLeft;
    333332        endLength += marginRight;
     
    336335    }
    337336   
    338     int marginTop = part ? part->marginTop() : 0;
    339     int marginBottom = part ? part->marginBottom() : 0;
     337    int marginTop = part ? static_cast<int>(part->marginTop()) : 0;
     338    int marginBottom = part ? static_cast<int>(part->marginBottom()) : 0;
    340339    startLength += marginTop;
    341340    endLength += marginBottom;
  • trunk/Source/WebCore/rendering/RenderScrollbarPart.h

    r95901 r110505  
    4747   
    4848    void paintIntoRect(GraphicsContext*, const LayoutPoint&, const LayoutRect&);
    49    
     49
     50    // Scrollbar parts needs to be rendered at device pixel boundaries.
     51    virtual LayoutUnit marginTop() const { ASSERT(isIntegerValue(m_marginTop)); return m_marginTop; }
     52    virtual LayoutUnit marginBottom() const { ASSERT(isIntegerValue(m_marginBottom)); return m_marginBottom; }
     53    virtual LayoutUnit marginLeft() const { ASSERT(isIntegerValue(m_marginLeft)); return m_marginLeft; }
     54    virtual LayoutUnit marginRight() const { ASSERT(isIntegerValue(m_marginRight)); return m_marginRight; }
     55
    5056protected:
    5157    virtual void styleWillChange(StyleDifference diff, const RenderStyle* newStyle);
Note: See TracChangeset for help on using the changeset viewer.