Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/scrolling/ScrollingConstraints.h |
| diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingConstraints.h b/third_party/WebKit/Source/core/page/scrolling/ScrollingConstraints.h |
| index 6b3dca6ed15f4f13cb52653d392476c18f874ecc..6c786a631e91182fbb8b91ef0699099d0865ada5 100644 |
| --- a/third_party/WebKit/Source/core/page/scrolling/ScrollingConstraints.h |
| +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingConstraints.h |
| @@ -26,19 +26,19 @@ |
| #ifndef ScrollingConstraints_h |
| #define ScrollingConstraints_h |
| -#include "platform/geometry/FloatRect.h" |
| +#include "platform/geometry/LayoutRect.h" |
| #include "wtf/Allocator.h" |
| namespace blink { |
| // ViewportConstraints classes encapsulate data and logic required to reposition elements whose layout |
| -// depends on the viewport rect (i.e., position fixed), when scrolling and zooming. |
| +// depends on the viewport rect (positioned fixed and sticky), when scrolling and zooming. |
| class ViewportConstraints { |
| STACK_ALLOCATED(); |
| public: |
| - // FIXME: Simplify this code now that position: sticky doesn't exist. |
| enum ConstraintType { |
| FixedPositionConstaint, |
| + StickyPositionConstraint, |
| }; |
| enum AnchorEdgeFlags { |
| @@ -63,15 +63,15 @@ public: |
| void addAnchorEdge(AnchorEdgeFlags edgeFlag) { m_anchorEdges |= edgeFlag; } |
| void setAnchorEdges(AnchorEdges edges) { m_anchorEdges = edges; } |
| - FloatSize alignmentOffset() const { return m_alignmentOffset; } |
| - void setAlignmentOffset(const FloatSize& offset) { m_alignmentOffset = offset; } |
| + LayoutSize alignmentOffset() const { return m_alignmentOffset; } |
| + void setAlignmentOffset(const LayoutSize& offset) { m_alignmentOffset = offset; } |
| protected: |
| ViewportConstraints() |
| : m_anchorEdges(0) |
| { } |
| - FloatSize m_alignmentOffset; |
| + LayoutSize m_alignmentOffset; |
| AnchorEdges m_anchorEdges; |
| }; |
| @@ -88,13 +88,13 @@ public: |
| , m_layerPositionAtLastLayout(other.m_layerPositionAtLastLayout) |
| { } |
| - FloatPoint layerPositionForViewportRect(const FloatRect& viewportRect) const; |
|
chrishtr
2015/12/09 19:12:21
Not called, remove.
flackr
2015/12/10 23:43:15
Done.
|
| + LayoutPoint layerPositionForViewportRect(const LayoutRect& viewportRect) const; |
| - const FloatRect& viewportRectAtLastLayout() const { return m_viewportRectAtLastLayout; } |
|
chrishtr
2015/12/09 19:12:21
Maybe a bunch of these are never called?
flackr
2015/12/10 23:43:15
Done.
|
| - void setViewportRectAtLastLayout(const FloatRect& rect) { m_viewportRectAtLastLayout = rect; } |
| + const LayoutRect& viewportRectAtLastLayout() const { return m_viewportRectAtLastLayout; } |
| + void setViewportRectAtLastLayout(const LayoutRect& rect) { m_viewportRectAtLastLayout = rect; } |
| - const FloatPoint& layerPositionAtLastLayout() const { return m_layerPositionAtLastLayout; } |
| - void setLayerPositionAtLastLayout(const FloatPoint& point) { m_layerPositionAtLastLayout = point; } |
| + const LayoutPoint& layerPositionAtLastLayout() const { return m_layerPositionAtLastLayout; } |
| + void setLayerPositionAtLastLayout(const LayoutPoint& point) { m_layerPositionAtLastLayout = point; } |
| bool operator==(const FixedPositionViewportConstraints& other) const |
| { |
| @@ -109,8 +109,82 @@ public: |
| private: |
| ConstraintType constraintType() const override { return FixedPositionConstaint; } |
| - FloatRect m_viewportRectAtLastLayout; |
|
chrishtr
2015/12/09 19:12:21
Remove these if not called.
flackr
2015/12/10 23:43:15
Done.
|
| - FloatPoint m_layerPositionAtLastLayout; |
| + LayoutRect m_viewportRectAtLastLayout; |
| + LayoutPoint m_layerPositionAtLastLayout; |
| +}; |
| + |
| +class StickyPositionViewportConstraints final : public ViewportConstraints { |
| +public: |
| + StickyPositionViewportConstraints() |
| + : m_leftOffset(0) |
| + , m_rightOffset(0) |
| + , m_topOffset(0) |
| + , m_bottomOffset(0) |
| + { } |
| + |
| + StickyPositionViewportConstraints(const StickyPositionViewportConstraints& other) |
| + : ViewportConstraints(other) |
| + , m_leftOffset(other.m_leftOffset) |
| + , m_rightOffset(other.m_rightOffset) |
| + , m_topOffset(other.m_topOffset) |
| + , m_bottomOffset(other.m_bottomOffset) |
| + , m_absoluteContainingBlockRect(other.m_absoluteContainingBlockRect) |
| + , m_absoluteStickyBoxRect(other.m_absoluteStickyBoxRect) |
| + , m_stickyOffsetAtLastLayout(other.m_stickyOffsetAtLastLayout) |
| + , m_layerPositionAtLastLayout(other.m_layerPositionAtLastLayout) |
| + { } |
| + |
| + LayoutSize computeStickyOffset(const LayoutRect& viewportRect) const; |
| + |
| + const LayoutSize stickyOffsetAtLastLayout() const { return m_stickyOffsetAtLastLayout; } |
|
chrishtr
2015/12/09 19:12:21
Remove the unused accessor functions for now.
flackr
2015/12/10 23:43:15
Done.
|
| + void setStickyOffsetAtLastLayout(const LayoutSize& offset) { m_stickyOffsetAtLastLayout = offset; } |
| + |
| + LayoutPoint layerPositionForViewportRect(const LayoutRect& viewportRect) const; |
| + |
| + const LayoutPoint& layerPositionAtLastLayout() const { return m_layerPositionAtLastLayout; } |
| + void setLayerPositionAtLastLayout(const LayoutPoint& point) { m_layerPositionAtLastLayout = point; } |
| + |
| + LayoutUnit leftOffset() const { return m_leftOffset; } |
| + LayoutUnit rightOffset() const { return m_rightOffset; } |
| + LayoutUnit topOffset() const { return m_topOffset; } |
| + LayoutUnit bottomOffset() const { return m_bottomOffset; } |
| + |
| + void setLeftOffset(LayoutUnit offset) { m_leftOffset = offset; } |
| + void setRightOffset(LayoutUnit offset) { m_rightOffset = offset; } |
| + void setTopOffset(LayoutUnit offset) { m_topOffset = offset; } |
| + void setBottomOffset(LayoutUnit offset) { m_bottomOffset = offset; } |
| + |
| + LayoutRect absoluteContainingBlockRect() const { return m_absoluteContainingBlockRect; } |
|
chrishtr
2015/12/09 19:12:21
Remove the accesssor function, not used.
flackr
2015/12/10 23:43:15
Done, as well as absoluteStickyBoxRect().
|
| + void setAbsoluteContainingBlockRect(const LayoutRect& rect) { m_absoluteContainingBlockRect = rect; } |
| + |
| + LayoutRect absoluteStickyBoxRect() const { return m_absoluteStickyBoxRect; } |
| + void setAbsoluteStickyBoxRect(const LayoutRect& rect) { m_absoluteStickyBoxRect = rect; } |
| + |
| + bool operator==(const StickyPositionViewportConstraints& other) const |
| + { |
| + return m_leftOffset == other.m_leftOffset |
| + && m_rightOffset == other.m_rightOffset |
| + && m_topOffset == other.m_topOffset |
| + && m_bottomOffset == other.m_bottomOffset |
| + && m_absoluteContainingBlockRect == other.m_absoluteContainingBlockRect |
| + && m_absoluteStickyBoxRect == other.m_absoluteStickyBoxRect |
| + && m_stickyOffsetAtLastLayout == other.m_stickyOffsetAtLastLayout |
| + && m_layerPositionAtLastLayout == other.m_layerPositionAtLastLayout; |
| + } |
| + |
| + bool operator!=(const StickyPositionViewportConstraints& other) const { return !(*this == other); } |
| + |
| +private: |
| + ConstraintType constraintType() const override { return StickyPositionConstraint; } |
| + |
| + LayoutUnit m_leftOffset; |
| + LayoutUnit m_rightOffset; |
| + LayoutUnit m_topOffset; |
| + LayoutUnit m_bottomOffset; |
| + LayoutRect m_absoluteContainingBlockRect; |
| + LayoutRect m_absoluteStickyBoxRect; |
| + LayoutSize m_stickyOffsetAtLastLayout; |
| + LayoutPoint m_layerPositionAtLastLayout; |
| }; |
| } // namespace blink |