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

Unified Diff: cc/layers/layer_sticky_position_constraint.h

Issue 2733633002: Handle nested position:sticky elements correctly (compositor) (Closed)
Patch Set: Add comment referencing crbug.com/702229 Created 3 years, 9 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
Index: cc/layers/layer_sticky_position_constraint.h
diff --git a/cc/layers/layer_sticky_position_constraint.h b/cc/layers/layer_sticky_position_constraint.h
index 3f43bc7751ab614b2c12b25c18d73a71cd308012..beb841d908d659ae157dea2b7490458e55304b13 100644
--- a/cc/layers/layer_sticky_position_constraint.h
+++ b/cc/layers/layer_sticky_position_constraint.h
@@ -7,7 +7,9 @@
#include "cc/base/cc_export.h"
-#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/geometry/vector2d_f.h"
namespace cc {
@@ -31,18 +33,37 @@ struct CC_EXPORT LayerStickyPositionConstraint {
// The layout offset of the sticky box relative to its containing layer.
// This is used to detect the sticky offset the main thread has applied
// to the layer.
- gfx::Point parent_relative_sticky_box_offset;
+ gfx::PointF parent_relative_sticky_box_offset;
// The rectangle corresponding to original layout position of the sticky box
// relative to the scroll ancestor. The sticky box is only offset once the
// scroll has passed its initial position (e.g. top_offset will only push
// the element down from its original position).
- gfx::Rect scroll_container_relative_sticky_box_rect;
+ gfx::RectF scroll_container_relative_sticky_box_rect;
// The layout rectangle of the sticky box's containing block relative to the
// scroll ancestor. The sticky box is only moved as far as its containing
// block boundary.
- gfx::Rect scroll_container_relative_containing_block_rect;
+ gfx::RectF scroll_container_relative_containing_block_rect;
+
+ // The nearest ancestor sticky layers that affect the sticky box constraint
flackr 2017/03/17 15:01:55 Mention layer id in the comment, and -1 for no suc
smcgruer 2017/03/17 17:36:51 Done.
+ // rect and the containing block constraint rect respectively.
+ int nearest_layer_shifting_sticky_box;
+ int nearest_layer_shifting_containing_block;
+
+ // For performance we cache our accumulated sticky offset to allow descendant
+ // sticky elements to offset their constraint rects. Because we can either
+ // affect the sticky box constraint rect or the containing block constraint
+ // rect, we need to accumulate both.
+ gfx::Vector2dF total_sticky_box_sticky_offset;
+ gfx::Vector2dF total_containing_block_sticky_offset;
+
+ // Returns the nearest sticky ancestor layer, or null if no such layer exists.
flackr 2017/03/17 15:01:55 s/null/-1 ?
smcgruer 2017/03/17 17:36:51 Done.
+ int NearestStickyAncestor() {
+ return (nearest_layer_shifting_sticky_box >= 0)
+ ? nearest_layer_shifting_sticky_box
+ : nearest_layer_shifting_containing_block;
+ }
bool operator==(const LayerStickyPositionConstraint&) const;
bool operator!=(const LayerStickyPositionConstraint&) const;

Powered by Google App Engine
This is Rietveld 408576698