Changeset 109835 in webkit
- Timestamp:
- Mar 5, 2012 6:42:55 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109833 r109835 1 2012-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 1 57 2012-03-05 Adam Barth <abarth@webkit.org> 2 58 -
trunk/Source/WebCore/platform/graphics/FractionalLayoutRect.h
r108423 r109835 65 65 FractionalLayoutUnit width() const { return m_size.width(); } 66 66 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(); } 67 74 68 75 void setX(FractionalLayoutUnit x) { m_location.setX(x); } -
trunk/Source/WebCore/platform/graphics/IntRect.h
r109074 r109835 104 104 int height() const { return m_size.height(); } 105 105 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 106 115 void setX(int x) { m_location.setX(x); } 107 116 void setY(int y) { m_location.setY(y); } -
trunk/Source/WebCore/rendering/LayoutTypes.h
r109642 r109835 39 39 #include "FloatRect.h" 40 40 #include "IntRect.h" 41 #include <wtf/UnusedParam.h> 41 42 42 43 namespace WebCore { … … 64 65 } 65 66 67 inline IntRect pixelSnappedIntRect(const LayoutPoint& location, const LayoutSize& size) 68 { 69 return IntRect(location, size); 70 } 71 66 72 inline IntRect pixelSnappedIntRectFromEdges(LayoutUnit left, LayoutUnit top, LayoutUnit right, LayoutUnit bottom) 67 73 { 68 74 return IntRect(left, top, right - left, bottom - top); 75 } 76 77 inline int snapSizeToPixel(LayoutUnit size, LayoutUnit location) 78 { 79 UNUSED_PARAM(location); 80 return size; 69 81 } 70 82 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r109805 r109835 481 481 int RenderBox::pixelSnappedClientWidth() const 482 482 { 483 return clientWidth();483 return snapSizeToPixel(clientWidth(), clientLeft()); 484 484 } 485 485 486 486 int RenderBox::pixelSnappedClientHeight() const 487 487 { 488 return clientHeight();488 return snapSizeToPixel(clientHeight(), clientTop()); 489 489 } 490 490 … … 533 533 void RenderBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const 534 534 { 535 rects.append( LayoutRect(accumulatedOffset, size()));535 rects.append(pixelSnappedIntRect(accumulatedOffset, size())); 536 536 } 537 537 … … 582 582 } 583 583 584 void RenderBox::addFocusRingRects(Vector< LayoutRect>& rects, const LayoutPoint& additionalOffset)584 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset) 585 585 { 586 586 if (!size().isEmpty()) 587 rects.append( LayoutRect(additionalOffset, size()));587 rects.append(pixelSnappedIntRect(additionalOffset, size())); 588 588 } 589 589 … … 1079 1079 BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject) 1080 1080 { 1081 paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, IntSize(), op, backgroundObject);1081 paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, LayoutSize(), op, backgroundObject); 1082 1082 } 1083 1083 … … 1277 1277 LayoutUnit adjustedPageOffsetForContainingBlock = offsetFromLogicalTopOfFirstPage - logicalTop(); 1278 1278 if (region) { 1279 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->offsetFromLogicalTopOfFirstPage() - offsetFromLogicalTopOfFirstPage : 0;1279 LayoutUnit offsetFromLogicalTopOfRegion = region ? region->offsetFromLogicalTopOfFirstPage() - offsetFromLogicalTopOfFirstPage : zeroLayoutUnit; 1280 1280 logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offsetFromLogicalTopOfRegion); 1281 1281 containingBlockRegion = cb->clampToStartAndEndRegions(region); … … 1485 1485 // the inlines. 1486 1486 RootInlineBox* root = box->root(); 1487 root->block()->setStaticInlinePositionForChild(this, root->lineTopWithLeading(), lroundf(box->logicalLeft()));1487 root->block()->setStaticInlinePositionForChild(this, root->lineTopWithLeading(), roundedLayoutUnit(box->logicalLeft())); 1488 1488 if (style()->hasStaticInlinePosition(box->isHorizontal())) 1489 1489 setChildNeedsLayout(true, false); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly. … … 3896 3896 } 3897 3897 3898 void RenderBox::flipForWritingMode( IntRect& rect) const3898 void RenderBox::flipForWritingMode(LayoutRect& rect) const 3899 3899 { 3900 3900 if (!style()->isFlippedBlocksWritingMode()) … … 3907 3907 } 3908 3908 3909 int RenderBox::flipForWritingMode(int position) const3909 LayoutUnit RenderBox::flipForWritingMode(LayoutUnit position) const 3910 3910 { 3911 3911 if (!style()->isFlippedBlocksWritingMode()) … … 3914 3914 } 3915 3915 3916 IntPoint RenderBox::flipForWritingMode(const IntPoint& position) const3916 LayoutPoint RenderBox::flipForWritingMode(const LayoutPoint& position) const 3917 3917 { 3918 3918 if (!style()->isFlippedBlocksWritingMode()) 3919 3919 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()); 3921 3921 } 3922 3922 … … 3928 3928 } 3929 3929 3930 IntSize RenderBox::flipForWritingMode(const IntSize& offset) const3930 LayoutSize RenderBox::flipForWritingMode(const LayoutSize& offset) const 3931 3931 { 3932 3932 if (!style()->isFlippedBlocksWritingMode()) 3933 3933 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()); 3935 3935 } 3936 3936 -
trunk/Source/WebCore/rendering/RenderBox.h
r109818 r109835 128 128 void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; } 129 129 130 // FIXME: We shouldn't be returning this as a LayoutRect, since it loses its position and won't properly pixel snap. 130 131 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(); } 132 134 133 135 // The content area of the box (excludes padding and border). … … 140 142 // Bounds of the outline box in absolute coords. Respects transforms 141 143 virtual LayoutRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, LayoutPoint* cachedOffsetToRepaintContainer) const; 142 virtual void addFocusRingRects(Vector< LayoutRect>&, const LayoutPoint&);144 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&); 143 145 144 146 // Use this with caution! No type checking is done! … … 247 249 virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); } 248 250 249 virtual void absoluteRects(Vector< LayoutRect>&, const LayoutPoint& accumulatedOffset) const;251 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const; 250 252 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const; 251 253 … … 322 324 } 323 325 324 virtual LayoutSize intrinsicSize() const { return LayoutSize(); }326 virtual IntSize intrinsicSize() const { return IntSize(); } 325 327 LayoutUnit intrinsicLogicalWidth() const { return style()->isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); } 326 328 LayoutUnit intrinsicLogicalHeight() const { return style()->isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); } … … 425 427 426 428 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; 429 431 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; 432 434 FloatPoint flipForWritingMode(const FloatPoint&) const; 433 435 void flipForWritingMode(FloatRect&) const;
Note: See TracChangeset
for help on using the changeset viewer.