Skip to content
Permalink
Browse files
Fix usage of LayoutUnits and snapping for scrolling in RenderBox
https://bugs.webkit.org/show_bug.cgi?id=83073

Reviewed by Eric Seidel.

Fix usage of LayoutUnits and snapping/rounding logic in RenderBox.

No new tests, no change in functionality.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::scrollWidth):
Change scrollWidth to properly pixel snap values.

(WebCore::RenderBox::scrollHeight):
Change scrollHeight to properly pixel snap values.

(WebCore::RenderBox::scrolledContentOffset):
Change to return IntSize to match function definition.

(WebCore::RenderBox::cachedSizeForOverflowClip):
Changed cachedSizeForOverflowClip to LayoutSize as the overflow and clip
rects all have subpixel precision.

* rendering/RenderBox.h:
(WebCore::RenderBox::pixelSnappedWidth):
(WebCore::RenderBox::pixelSnappedHeight):
Removed FIXME comment as the implementation

(WebCore::RenderBox::minYLayoutOverflow):
(WebCore::RenderBox::maxYLayoutOverflow):
(WebCore::RenderBox::minXLayoutOverflow):
(WebCore::RenderBox::maxXLayoutOverflow):
Added static_cast for border values.

(WebCore::RenderBox::hasVisualOverflow):
Changed to compare two pixel snapped values as we don't want to indicate
overflow in cases where the the size is rounded down resulting in no
visual overflow.


Canonical link: https://commits.webkit.org/100560@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@113223 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eaenet committed Apr 4, 2012
1 parent da4eab8 commit 756fc17d6ef1cf0d631f0dce96c2689b7e8ae4ac
Showing 3 changed files with 53 additions and 13 deletions.
@@ -1,3 +1,44 @@
2012-04-04 Emil A Eklund <eae@chromium.org>

Fix usage of LayoutUnits and snapping for scrolling in RenderBox
https://bugs.webkit.org/show_bug.cgi?id=83073

Reviewed by Eric Seidel.

Fix usage of LayoutUnits and snapping/rounding logic in RenderBox.

No new tests, no change in functionality.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::scrollWidth):
Change scrollWidth to properly pixel snap values.

(WebCore::RenderBox::scrollHeight):
Change scrollHeight to properly pixel snap values.

(WebCore::RenderBox::scrolledContentOffset):
Change to return IntSize to match function definition.

(WebCore::RenderBox::cachedSizeForOverflowClip):
Changed cachedSizeForOverflowClip to LayoutSize as the overflow and clip
rects all have subpixel precision.

* rendering/RenderBox.h:
(WebCore::RenderBox::pixelSnappedWidth):
(WebCore::RenderBox::pixelSnappedHeight):
Removed FIXME comment as the implementation

(WebCore::RenderBox::minYLayoutOverflow):
(WebCore::RenderBox::maxYLayoutOverflow):
(WebCore::RenderBox::minXLayoutOverflow):
(WebCore::RenderBox::maxXLayoutOverflow):
Added static_cast for border values.

(WebCore::RenderBox::hasVisualOverflow):
Changed to compare two pixel snapped values as we don't want to indicate
overflow in cases where the the size is rounded down resulting in no
visual overflow.

2012-04-04 Emil A Eklund <eae@chromium.org>

Fix types for location, size and rect calculations for render objects
@@ -502,7 +502,7 @@ int RenderBox::scrollWidth() const
// For objects with visible overflow, this matches IE.
// FIXME: Need to work right with writing modes.
if (style()->isLeftToRightDirection())
return max(clientWidth(), maxXLayoutOverflow() - borderLeft());
return snapSizeToPixel(max(clientWidth(), maxXLayoutOverflow() - borderLeft()), clientLeft());
return clientWidth() - min(0, minXLayoutOverflow() - borderLeft());
}

@@ -512,7 +512,7 @@ int RenderBox::scrollHeight() const
return layer()->scrollHeight();
// For objects with visible overflow, this matches IE.
// FIXME: Need to work right with writing modes.
return max(pixelSnappedClientHeight(), maxYLayoutOverflow() - borderTop());
return snapSizeToPixel(max(clientHeight(), maxYLayoutOverflow() - borderTop()), clientTop());
}

int RenderBox::scrollLeft() const
@@ -764,7 +764,7 @@ IntSize RenderBox::scrolledContentOffset() const
// If we have no layer, it means that we have no overflowing content as we lazily
// allocate it on demand. Thus we don't have any scroll offset.
ASSERT(!requiresLayerForOverflowClip());
return LayoutSize();
return IntSize();
}

typedef HashMap<const RenderBox*, LayoutSize> RendererSizeCache;
@@ -774,7 +774,7 @@ static RendererSizeCache& cachedSizeForOverflowClipMap()
return cachedSizeForOverflowClipMap;
}

IntSize RenderBox::cachedSizeForOverflowClip() const
LayoutSize RenderBox::cachedSizeForOverflowClip() const
{
ASSERT(hasOverflowClip());
if (hasLayer())
@@ -56,9 +56,8 @@ class RenderBox : public RenderBoxModelObject {
LayoutUnit width() const { return m_frameRect.width(); }
LayoutUnit height() const { return m_frameRect.height(); }

// FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318.
int pixelSnappedWidth() const { return m_frameRect.width(); }
int pixelSnappedHeight() const { return m_frameRect.height(); }
int pixelSnappedWidth() const { return m_frameRect.pixelSnappedWidth(); }
int pixelSnappedHeight() const { return m_frameRect.pixelSnappedHeight(); }

// These represent your location relative to your container as a physical offset.
// In layout related methods you almost always want the logical location (e.g. x() and y()).
@@ -159,10 +158,10 @@ class RenderBox : public RenderBoxModelObject {
// but it is on the right in vertical-rl.
LayoutRect layoutOverflowRect() const { return m_overflow ? m_overflow->layoutOverflowRect() : clientBoxRect(); }
IntRect pixelSnappedLayoutOverflowRect() const { return pixelSnappedIntRect(layoutOverflowRect()); }
LayoutUnit minYLayoutOverflow() const { return m_overflow? m_overflow->minYLayoutOverflow() : borderTop(); }
LayoutUnit maxYLayoutOverflow() const { return m_overflow ? m_overflow->maxYLayoutOverflow() : borderTop() + clientHeight(); }
LayoutUnit minXLayoutOverflow() const { return m_overflow ? m_overflow->minXLayoutOverflow() : borderLeft(); }
LayoutUnit maxXLayoutOverflow() const { return m_overflow ? m_overflow->maxXLayoutOverflow() : borderLeft() + clientWidth(); }
LayoutUnit minYLayoutOverflow() const { return m_overflow? m_overflow->minYLayoutOverflow() : static_cast<LayoutUnit>(borderTop()); }
LayoutUnit maxYLayoutOverflow() const { return m_overflow ? m_overflow->maxYLayoutOverflow() : static_cast<LayoutUnit>(borderTop()) + clientHeight(); }
LayoutUnit minXLayoutOverflow() const { return m_overflow ? m_overflow->minXLayoutOverflow() : static_cast<LayoutUnit>(borderLeft()); }
LayoutUnit maxXLayoutOverflow() const { return m_overflow ? m_overflow->maxXLayoutOverflow() : static_cast<LayoutUnit>(borderLeft()) + clientWidth(); }
LayoutSize maxLayoutOverflow() const { return LayoutSize(maxXLayoutOverflow(), maxYLayoutOverflow()); }
LayoutUnit logicalLeftLayoutOverflow() const { return style()->isHorizontalWritingMode() ? minXLayoutOverflow() : minYLayoutOverflow(); }
LayoutUnit logicalRightLayoutOverflow() const { return style()->isHorizontalWritingMode() ? maxXLayoutOverflow() : maxYLayoutOverflow(); }
@@ -450,13 +449,13 @@ class RenderBox : public RenderBoxModelObject {
LayoutRect layoutOverflowRectForPropagation(RenderStyle*) const;

RenderOverflow* hasRenderOverflow() const { return m_overflow.get(); }
bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); }
bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(pixelSnappedIntRect(m_overflow->visualOverflowRect())); }

virtual bool needsPreferredWidthsRecalculation() const;
virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }

IntSize scrolledContentOffset() const;
IntSize cachedSizeForOverflowClip() const;
LayoutSize cachedSizeForOverflowClip() const;
void updateCachedSizeForOverflowClip();
void clearCachedSizeForOverflowClip();

0 comments on commit 756fc17

Please sign in to comment.