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

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

Issue 2494933002: Exclude border from overflow scroller in sticky constraints. (Closed)
Patch Set: 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
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 2e28f8dafdf2a5b8ff5906e56a31ab5df652ac7d..e744ca55ee987c85c6b47f3235531baf87cfb5cc 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
@@ -804,9 +804,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,
@@ -827,6 +833,8 @@ void LayoutBoxModelObject::updateStickyPositionConstraints() const {
: FloatSize());
scrollContainerRelativePaddingBoxRect.move(scrollOffset);
}
+ // Remove top-left border offset from overflow scroller.
+ scrollContainerRelativePaddingBoxRect.move(-scrollContainerBorderOffset);
LayoutRect scrollContainerRelativeContainingBlockRect(
scrollContainerRelativePaddingBoxRect);
@@ -862,12 +870,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),
@@ -949,8 +957,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(),

Powered by Google App Engine
This is Rietveld 408576698