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

Unified Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 267063007: Fix overconstrained behaviour for position: sticky. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated by review comments. Created 6 years, 7 months 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 | « LayoutTests/fast/css/sticky/sticky-vertically-overconstrained-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBoxModelObject.cpp
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index f4dacfa008004a50214b69139cf1b2e848fa3eaf..6750eda2f0c3bac5c4c358aa7281d7f489427863 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -319,23 +319,45 @@ void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo
FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocation, flippedStickyBoxRect.size());
constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect);
- if (!style()->left().isAuto()) {
+ float horizontalOffsets = constraints.rightOffset() + constraints.leftOffset();
+ bool skipRight = false;
+ bool skipLeft = false;
+ if (!style()->left().isAuto() && !style()->right().isAuto()) {
+ if (horizontalOffsets > containerContentRect.width().toFloat()
+ || horizontalOffsets + containerContentRect.width().toFloat() > constrainingRect.width()) {
+ skipRight = style()->isLeftToRightDirection();
+ skipLeft = !skipRight;
+ }
+ }
+
+ if (!style()->left().isAuto() && !skipLeft) {
constraints.setLeftOffset(floatValueForLength(style()->left(), constrainingRect.width()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
}
- if (!style()->right().isAuto()) {
+ if (!style()->right().isAuto() && !skipRight) {
constraints.setRightOffset(floatValueForLength(style()->right(), constrainingRect.width()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
}
+ bool skipBottom = false;
+ // FIXME(ostap): Exclude top or bottom edge offset depending on the writing mode when related
+ // sections are fixed in spec: http://lists.w3.org/Archives/Public/www-style/2014May/0286.html
+ float verticalOffsets = constraints.topOffset() + constraints.bottomOffset();
+ if (!style()->top().isAuto() && !style()->bottom().isAuto()) {
+ if (verticalOffsets > containerContentRect.height().toFloat()
+ || verticalOffsets + containerContentRect.height().toFloat() > constrainingRect.height()) {
+ skipBottom = true;
+ }
+ }
+
if (!style()->top().isAuto()) {
constraints.setTopOffset(floatValueForLength(style()->top(), constrainingRect.height()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
}
- if (!style()->bottom().isAuto()) {
- constraints.setBottomOffset(floatValueForLength(style()->bottom(), constrainingRect.height() ));
+ if (!style()->bottom().isAuto() && !skipBottom) {
+ constraints.setBottomOffset(floatValueForLength(style()->bottom(), constrainingRect.height()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
}
}
« no previous file with comments | « LayoutTests/fast/css/sticky/sticky-vertically-overconstrained-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698