Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp

Issue 2494933002: Exclude border from overflow scroller in sticky constraints. (Closed)
Patch Set: Add RTL sticky constraint test. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
index 84204c41463507b7e6b8e9d9fcf276eadb017c5b..30f0a51a72c21f70271c21518c537cf8c8eb94ea 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
@@ -784,9 +784,15 @@ void LayoutBoxModelObject::updateStickyPositionConstraints() const {
// allowed to move.
LayoutUnit maxWidth = containingBlock->availableLogicalWidth();
- // Map the containing block to the scroll ancestor without transforms.
+ // Map the containing block to the inner corner of the scroll ancestor without
+ // transforms.
FloatRect scrollContainerRelativePaddingBoxRect(
containingBlock->layoutOverflowRect());
+ FloatSize scrollContainerBorderOffset;
+ if (scrollAncestor) {
+ scrollContainerBorderOffset =
+ FloatSize(scrollAncestor->borderLeft(), scrollAncestor->borderTop());
+ }
if (containingBlock != scrollAncestor) {
FloatQuad localQuad(FloatRect(containingBlock->paddingBoxRect()));
TransformState transformState(TransformState::ApplyTransformDirection,
@@ -807,6 +813,8 @@ void LayoutBoxModelObject::updateStickyPositionConstraints() const {
: FloatSize());
scrollContainerRelativePaddingBoxRect.move(scrollOffset);
}
+ // Remove top-left border offset from overflow scroller.
+ scrollContainerRelativePaddingBoxRect.move(-scrollContainerBorderOffset);
LayoutRect scrollContainerRelativeContainingBlockRect(
scrollContainerRelativePaddingBoxRect);
@@ -842,12 +850,12 @@ void LayoutBoxModelObject::updateStickyPositionConstraints() const {
// The scrollContainerRelativePaddingBoxRect's position is the padding box so
// we need to remove the border when finding the position of the sticky box
- // within the scroll ancestor if the container is not our scroll ancestor.
- if (containingBlock != scrollAncestor) {
- FloatSize containerBorderOffset(containingBlock->borderLeft(),
- containingBlock->borderTop());
- stickyLocation -= containerBorderOffset;
- }
+ // within the scroll ancestor if the container is not our scroll ancestor. If
+ // the container is our scroll ancestor, we also need to remove the border
+ // box because we want the position from within the scroller border.
+ FloatSize containerBorderOffset(containingBlock->borderLeft(),
+ containingBlock->borderTop());
+ stickyLocation -= containerBorderOffset;
constraints.setScrollContainerRelativeStickyBoxRect(
FloatRect(scrollContainerRelativePaddingBoxRect.location() +
toFloatSize(stickyLocation),
@@ -929,8 +937,9 @@ FloatRect LayoutBoxModelObject::computeStickyConstrainingRect() const {
constrainingRect =
FloatRect(enclosingClippingBox->overflowClipRect(LayoutPoint(DoublePoint(
enclosingClippingBox->getScrollableArea()->scrollPosition()))));
- constrainingRect.move(enclosingClippingBox->paddingLeft(),
- enclosingClippingBox->paddingTop());
+ constrainingRect.move(
+ -enclosingClippingBox->borderLeft() + enclosingClippingBox->paddingLeft(),
+ -enclosingClippingBox->borderTop() + enclosingClippingBox->paddingTop());
constrainingRect.contract(
FloatSize(enclosingClippingBox->paddingLeft() +
enclosingClippingBox->paddingRight(),
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698