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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/ViewportConstraints.h

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Merge with master and skip anonymous containing blocks for sticky container. Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef ScrollingConstraints_h 26 #ifndef ViewportConstraints_h
27 #define ScrollingConstraints_h 27 #define ViewportConstraints_h
chrishtr 2016/01/30 01:49:03 Rename to ScrollingConstraints? Sorry for going in
28 28
29 #include "platform/geometry/FloatRect.h" 29 #include "platform/geometry/FloatRect.h"
30 #include "wtf/Allocator.h" 30 #include "wtf/Allocator.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 // ViewportConstraints classes encapsulate data and logic required to reposition elements whose layout 34 // ViewportConstraints classes encapsulate data and logic required to reposition elements whose layout
35 // depends on the viewport rect (i.e., position fixed), when scrolling and zoomi ng. 35 // depends on the viewport rect (positioned fixed and sticky), when scrolling an d zooming.
36 class ViewportConstraints { 36 class ViewportConstraints {
37 STACK_ALLOCATED(); 37 STACK_ALLOCATED();
38 public: 38 public:
39 // FIXME: Simplify this code now that position: sticky doesn't exist.
40 enum ConstraintType { 39 enum ConstraintType {
41 FixedPositionConstaint, 40 FixedPositionConstaint,
41 StickyPositionConstraint,
42 }; 42 };
43 43
44 enum AnchorEdgeFlags { 44 enum AnchorEdgeFlags {
45 AnchorEdgeLeft = 1 << 0, 45 AnchorEdgeLeft = 1 << 0,
46 AnchorEdgeRight = 1 << 1, 46 AnchorEdgeRight = 1 << 1,
47 AnchorEdgeTop = 1 << 2, 47 AnchorEdgeTop = 1 << 2,
48 AnchorEdgeBottom = 1 << 3 48 AnchorEdgeBottom = 1 << 3
49 }; 49 };
50 typedef unsigned AnchorEdges; 50 typedef unsigned AnchorEdges;
51 51
(...skipping 25 matching lines...) Expand all
77 77
78 class FixedPositionViewportConstraints final : public ViewportConstraints { 78 class FixedPositionViewportConstraints final : public ViewportConstraints {
79 STACK_ALLOCATED(); 79 STACK_ALLOCATED();
80 public: 80 public:
81 FixedPositionViewportConstraints() 81 FixedPositionViewportConstraints()
82 : ViewportConstraints() 82 : ViewportConstraints()
83 { } 83 { }
84 84
85 FixedPositionViewportConstraints(const FixedPositionViewportConstraints& oth er) 85 FixedPositionViewportConstraints(const FixedPositionViewportConstraints& oth er)
86 : ViewportConstraints(other) 86 : ViewportConstraints(other)
87 , m_viewportRectAtLastLayout(other.m_viewportRectAtLastLayout)
88 , m_layerPositionAtLastLayout(other.m_layerPositionAtLastLayout)
89 { } 87 { }
90 88
91 FloatPoint layerPositionForViewportRect(const FloatRect& viewportRect) const ;
92
93 const FloatRect& viewportRectAtLastLayout() const { return m_viewportRectAtL astLayout; }
94 void setViewportRectAtLastLayout(const FloatRect& rect) { m_viewportRectAtLa stLayout = rect; }
95
96 const FloatPoint& layerPositionAtLastLayout() const { return m_layerPosition AtLastLayout; }
97 void setLayerPositionAtLastLayout(const FloatPoint& point) { m_layerPosition AtLastLayout = point; }
98
99 bool operator==(const FixedPositionViewportConstraints& other) const 89 bool operator==(const FixedPositionViewportConstraints& other) const
100 { 90 {
101 return m_alignmentOffset == other.m_alignmentOffset 91 return m_alignmentOffset == other.m_alignmentOffset
102 && m_anchorEdges == other.m_anchorEdges 92 && m_anchorEdges == other.m_anchorEdges;
103 && m_viewportRectAtLastLayout == other.m_viewportRectAtLastLayout
104 && m_layerPositionAtLastLayout == other.m_layerPositionAtLastLayout;
105 } 93 }
106 94
107 bool operator!=(const FixedPositionViewportConstraints& other) const { retur n !(*this == other); } 95 bool operator!=(const FixedPositionViewportConstraints& other) const { retur n !(*this == other); }
108 96
109 private: 97 private:
110 ConstraintType constraintType() const override { return FixedPositionConstai nt; } 98 ConstraintType constraintType() const override { return FixedPositionConstai nt; }
111
112 FloatRect m_viewportRectAtLastLayout;
113 FloatPoint m_layerPositionAtLastLayout;
114 }; 99 };
115 100
116 } // namespace blink 101 } // namespace blink
117 102
118 #endif // ScrollingConstraints_h 103 #endif // ViewportConstraints_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698