Changeset 109835 in webkit


Ignore:
Timestamp:
Mar 5, 2012 6:42:55 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Update usage of LayoutUnits in RenderBox
https://bugs.webkit.org/show_bug.cgi?id=80039

Reviewed by Julien Chaffraix.

Updating the usage of integers versus LayoutUnits in RenderBox to mirror the
subpixellayout branch. This reverts absoluteRects, intrinsicSize, and focusRingRects
methods to use integers, and flipForWritingMode functions to LayoutUnits.

No new tests. No change in behavior.

  • platform/graphics/FractionalLayoutRect.h:

(WebCore::FractionalLayoutRect::pixelSnappedX): Convenience methods that only calculate
the needed values. This requires less computation than pixelSnappedIntRect(r).x().
(WebCore::FractionalLayoutRect::pixelSnappedY): Ditto.
(WebCore::FractionalLayoutRect::pixelSnappedWidth): Ditto.
(WebCore::FractionalLayoutRect::pixelSnappedHeight): Ditto.
(WebCore::FractionalLayoutRect::pixelSnappedMaxX): Ditto.
(WebCore::FractionalLayoutRect::pixelSnappedMaxY): Ditto.
(FractionalLayoutRect):

  • platform/graphics/IntRect.h:

(IntRect):
(WebCore::IntRect::pixelSnappedX): Stub methods to allow us to use IntRects like we do
FractionalLayoutRects.
(WebCore::IntRect::pixelSnappedY): Ditto.
(WebCore::IntRect::pixelSnappedMaxX): Ditto.
(WebCore::IntRect::pixelSnappedMaxY): Ditto.
(WebCore::IntRect::pixelSnappedWidth): Ditto.
(WebCore::IntRect::pixelSnappedHeight): Ditto.

  • rendering/LayoutTypes.h:

(WebCore::pixelSnappedIntRect): Convenience method for building a pixelSnappedIntRect from
a LayoutPoint and LayoutSize without constructing an intermediate LayoutRect.
(WebCore):
(WebCore::snapSizeToPixel): Stub method for snapping a LayoutUnit representing a size to
its pixel value using its location.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::pixelSnappedClientWidth): Changing to actually call snapSizeToPixel.
(WebCore::RenderBox::pixelSnappedClientHeight): Ditto.
(WebCore::RenderBox::absoluteRects): Switching to return IntRects that represent the actual
rendered location on screen.
(WebCore::RenderBox::addFocusRingRects): Ditto.
(WebCore::RenderBox::paintFillLayer): One-liner switching an IntSize() to LayoutSize() to
avoid unnecessary conversion.
(WebCore::RenderBox::shrinkLogicalWidthToAvoidFloats): Preparing for the conversion by
replacing 0 with zeroLayoutUnit.
(WebCore::RenderBox::positionLineBox): Preparing for conversion by replacing lroundf
with roundedLayoutUnit.
(WebCore::RenderBox::flipForWritingMode): Switching to use LayoutUnits.

  • rendering/RenderBox.h:

(RenderBox):
(WebCore::RenderBox::pixelSnappedBorderBoxRect): Convenience method.
(WebCore::RenderBox::borderBoundingBox): Converting to a pixelSnappedIntRect.
(WebCore::RenderBox::intrinsicSize): Intrinsic sizes should always be integers.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109833 r109835  
     12012-03-05  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update usage of LayoutUnits in RenderBox
     4        https://bugs.webkit.org/show_bug.cgi?id=80039
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Updating the usage of integers versus LayoutUnits in RenderBox to mirror the
     9        subpixellayout branch. This reverts absoluteRects, intrinsicSize, and focusRingRects
     10        methods to use integers, and flipForWritingMode functions to LayoutUnits.
     11
     12        No new tests. No change in behavior.
     13
     14        * platform/graphics/FractionalLayoutRect.h:
     15        (WebCore::FractionalLayoutRect::pixelSnappedX): Convenience methods that only calculate
     16        the needed values. This requires less computation than pixelSnappedIntRect(r).x().
     17        (WebCore::FractionalLayoutRect::pixelSnappedY): Ditto.
     18        (WebCore::FractionalLayoutRect::pixelSnappedWidth): Ditto.
     19        (WebCore::FractionalLayoutRect::pixelSnappedHeight): Ditto.
     20        (WebCore::FractionalLayoutRect::pixelSnappedMaxX): Ditto.
     21        (WebCore::FractionalLayoutRect::pixelSnappedMaxY): Ditto.
     22        (FractionalLayoutRect):
     23        * platform/graphics/IntRect.h:
     24        (IntRect):
     25        (WebCore::IntRect::pixelSnappedX): Stub methods to allow us to use IntRects like we do
     26        FractionalLayoutRects.
     27        (WebCore::IntRect::pixelSnappedY): Ditto.
     28        (WebCore::IntRect::pixelSnappedMaxX): Ditto.
     29        (WebCore::IntRect::pixelSnappedMaxY): Ditto.
     30        (WebCore::IntRect::pixelSnappedWidth): Ditto.
     31        (WebCore::IntRect::pixelSnappedHeight): Ditto.
     32        * rendering/LayoutTypes.h:
     33        (WebCore::pixelSnappedIntRect): Convenience method for building a pixelSnappedIntRect from
     34        a LayoutPoint and LayoutSize without constructing an intermediate LayoutRect.
     35        (WebCore):
     36        (WebCore::snapSizeToPixel): Stub method for snapping a LayoutUnit representing a size to
     37        its pixel value using its location.
     38        * rendering/RenderBox.cpp:
     39        (WebCore::RenderBox::pixelSnappedClientWidth): Changing to actually call snapSizeToPixel.
     40        (WebCore::RenderBox::pixelSnappedClientHeight): Ditto.
     41        (WebCore::RenderBox::absoluteRects): Switching to return IntRects that represent the actual
     42        rendered location on screen.
     43        (WebCore::RenderBox::addFocusRingRects): Ditto.
     44        (WebCore::RenderBox::paintFillLayer): One-liner switching an IntSize() to LayoutSize() to
     45        avoid unnecessary conversion.
     46        (WebCore::RenderBox::shrinkLogicalWidthToAvoidFloats): Preparing for the conversion by
     47        replacing 0 with zeroLayoutUnit.
     48        (WebCore::RenderBox::positionLineBox): Preparing for conversion by replacing lroundf
     49        with roundedLayoutUnit.
     50        (WebCore::RenderBox::flipForWritingMode): Switching to use LayoutUnits.
     51        * rendering/RenderBox.h:
     52        (RenderBox):
     53        (WebCore::RenderBox::pixelSnappedBorderBoxRect): Convenience method.
     54        (WebCore::RenderBox::borderBoundingBox): Converting to a pixelSnappedIntRect.
     55        (WebCore::RenderBox::intrinsicSize): Intrinsic sizes should always be integers.
     56
    1572012-03-05  Adam Barth  <abarth@webkit.org>
    258
  • trunk/Source/WebCore/platform/graphics/FractionalLayoutRect.h

    r108423 r109835  
    6565    FractionalLayoutUnit width() const { return m_size.width(); }
    6666    FractionalLayoutUnit height() const { return m_size.height(); }
     67
     68    int pixelSnappedX() const { return x().round(); }
     69    int pixelSnappedY() const { return y().round(); }
     70    int pixelSnappedWidth() const { return snapSizeToPixel(width(), x()); }
     71    int pixelSnappedHeight() const { return snapSizeToPixel(height(), y()); }
     72    int pixelSnappedMaxX() const { return pixelSnappedX() + pixelSnappedWidth(); }
     73    int pixelSnappedMaxY() const { return pixelSnappedY() + pixelSnappedHeight(); }
    6774
    6875    void setX(FractionalLayoutUnit x) { m_location.setX(x); }
  • trunk/Source/WebCore/platform/graphics/IntRect.h

    r109074 r109835  
    104104    int height() const { return m_size.height(); }
    105105
     106    // FIXME: These methods are here only to ease the transition to sub-pixel layout. They should
     107    // be removed when we close http://webkit.org/b/60318
     108    int pixelSnappedX() const { return m_location.x(); }
     109    int pixelSnappedY() const { return m_location.y(); }
     110    int pixelSnappedMaxX() const { return x() + width(); }
     111    int pixelSnappedMaxY() const { return y() + height(); }
     112    int pixelSnappedWidth() const { return m_size.width(); }
     113    int pixelSnappedHeight() const { return m_size.height(); }
     114
    106115    void setX(int x) { m_location.setX(x); }
    107116    void setY(int y) { m_location.setY(y); }
  • trunk/Source/WebCore/rendering/LayoutTypes.h

    r109642 r109835  
    3939#include "FloatRect.h"
    4040#include "IntRect.h"
     41#include <wtf/UnusedParam.h>
    4142
    4243namespace WebCore {
     
    6465}
    6566
     67inline IntRect pixelSnappedIntRect(const LayoutPoint& location, const LayoutSize& size)
     68{
     69    return IntRect(location, size);
     70}
     71
    6672inline IntRect pixelSnappedIntRectFromEdges(LayoutUnit left, LayoutUnit top, LayoutUnit right, LayoutUnit bottom)
    6773{
    6874    return IntRect(left, top, right - left, bottom - top);
     75}
     76
     77inline int snapSizeToPixel(LayoutUnit size, LayoutUnit location)
     78{
     79    UNUSED_PARAM(location);
     80    return size;
    6981}
    7082
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r109805 r109835  
    481481int RenderBox::pixelSnappedClientWidth() const
    482482{
    483     return clientWidth();
     483    return snapSizeToPixel(clientWidth(), clientLeft());
    484484}
    485485
    486486int RenderBox::pixelSnappedClientHeight() const
    487487{
    488     return clientHeight();
     488    return snapSizeToPixel(clientHeight(), clientTop());
    489489}
    490490
     
    533533void RenderBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
    534534{
    535     rects.append(LayoutRect(accumulatedOffset, size()));
     535    rects.append(pixelSnappedIntRect(accumulatedOffset, size()));
    536536}
    537537
     
    582582}
    583583
    584 void RenderBox::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPoint& additionalOffset)
     584void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset)
    585585{
    586586    if (!size().isEmpty())
    587         rects.append(LayoutRect(additionalOffset, size()));
     587        rects.append(pixelSnappedIntRect(additionalOffset, size()));
    588588}
    589589
     
    10791079    BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject)
    10801080{
    1081     paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, IntSize(), op, backgroundObject);
     1081    paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, LayoutSize(), op, backgroundObject);
    10821082}
    10831083
     
    12771277    LayoutUnit adjustedPageOffsetForContainingBlock = offsetFromLogicalTopOfFirstPage - logicalTop();
    12781278    if (region) {
    1279         LayoutUnit offsetFromLogicalTopOfRegion = region ? region->offsetFromLogicalTopOfFirstPage() - offsetFromLogicalTopOfFirstPage : 0;
     1279        LayoutUnit offsetFromLogicalTopOfRegion = region ? region->offsetFromLogicalTopOfFirstPage() - offsetFromLogicalTopOfFirstPage : zeroLayoutUnit;
    12801280        logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offsetFromLogicalTopOfRegion);
    12811281        containingBlockRegion = cb->clampToStartAndEndRegions(region);
     
    14851485            // the inlines.
    14861486            RootInlineBox* root = box->root();
    1487             root->block()->setStaticInlinePositionForChild(this, root->lineTopWithLeading(), lroundf(box->logicalLeft()));
     1487            root->block()->setStaticInlinePositionForChild(this, root->lineTopWithLeading(), roundedLayoutUnit(box->logicalLeft()));
    14881488            if (style()->hasStaticInlinePosition(box->isHorizontal()))
    14891489                setChildNeedsLayout(true, false); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
     
    38963896}
    38973897
    3898 void RenderBox::flipForWritingMode(IntRect& rect) const
     3898void RenderBox::flipForWritingMode(LayoutRect& rect) const
    38993899{
    39003900    if (!style()->isFlippedBlocksWritingMode())
     
    39073907}
    39083908
    3909 int RenderBox::flipForWritingMode(int position) const
     3909LayoutUnit RenderBox::flipForWritingMode(LayoutUnit position) const
    39103910{
    39113911    if (!style()->isFlippedBlocksWritingMode())
     
    39143914}
    39153915
    3916 IntPoint RenderBox::flipForWritingMode(const IntPoint& position) const
     3916LayoutPoint RenderBox::flipForWritingMode(const LayoutPoint& position) const
    39173917{
    39183918    if (!style()->isFlippedBlocksWritingMode())
    39193919        return position;
    3920     return isHorizontalWritingMode() ? IntPoint(position.x(), height() - position.y()) : IntPoint(width() - position.x(), position.y());
     3920    return isHorizontalWritingMode() ? LayoutPoint(position.x(), height() - position.y()) : LayoutPoint(width() - position.x(), position.y());
    39213921}
    39223922
     
    39283928}
    39293929
    3930 IntSize RenderBox::flipForWritingMode(const IntSize& offset) const
     3930LayoutSize RenderBox::flipForWritingMode(const LayoutSize& offset) const
    39313931{
    39323932    if (!style()->isFlippedBlocksWritingMode())
    39333933        return offset;
    3934     return isHorizontalWritingMode() ? IntSize(offset.width(), height() - offset.height()) : IntSize(width() - offset.width(), offset.height());
     3934    return isHorizontalWritingMode() ? LayoutSize(offset.width(), height() - offset.height()) : LayoutSize(width() - offset.width(), offset.height());
    39353935}
    39363936
  • trunk/Source/WebCore/rendering/RenderBox.h

    r109818 r109835  
    128128    void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; }
    129129
     130    // FIXME: We shouldn't be returning this as a LayoutRect, since it loses its position and won't properly pixel snap.
    130131    LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); }
    131     virtual LayoutRect borderBoundingBox() const { return borderBoxRect(); }
     132    IntRect pixelSnappedBorderBoxRect() const { return IntRect(IntPoint(), IntSize(m_frameRect.pixelSnappedWidth(), m_frameRect.pixelSnappedHeight())); }
     133    virtual IntRect borderBoundingBox() const { return pixelSnappedBorderBoxRect(); }
    132134
    133135    // The content area of the box (excludes padding and border).
     
    140142    // Bounds of the outline box in absolute coords. Respects transforms
    141143    virtual LayoutRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, LayoutPoint* cachedOffsetToRepaintContainer) const;
    142     virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
     144    virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&);
    143145
    144146    // Use this with caution! No type checking is done!
     
    247249    virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); }
    248250
    249     virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset) const;
     251    virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const;
    250252    virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const;
    251253   
     
    322324    }
    323325
    324     virtual LayoutSize intrinsicSize() const { return LayoutSize(); }
     326    virtual IntSize intrinsicSize() const { return IntSize(); }
    325327    LayoutUnit intrinsicLogicalWidth() const { return style()->isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); }
    326328    LayoutUnit intrinsicLogicalHeight() const { return style()->isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); }
     
    425427
    426428    LayoutPoint flipForWritingModeForChild(const RenderBox* child, const LayoutPoint&) const;
    427     int flipForWritingMode(int position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
    428     IntPoint flipForWritingMode(const IntPoint&) const;
     429    LayoutUnit flipForWritingMode(LayoutUnit position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
     430    LayoutPoint flipForWritingMode(const LayoutPoint&) const;
    429431    LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
    430     IntSize flipForWritingMode(const IntSize&) const;
    431     void flipForWritingMode(IntRect&) const;
     432    LayoutSize flipForWritingMode(const LayoutSize&) const;
     433    void flipForWritingMode(LayoutRect&) const;
    432434    FloatPoint flipForWritingMode(const FloatPoint&) const;
    433435    void flipForWritingMode(FloatRect&) const;
Note: See TracChangeset for help on using the changeset viewer.