| OLD | NEW |
| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef ScrollingConstraints_h | 26 #ifndef ScrollingConstraints_h |
| 27 #define ScrollingConstraints_h | 27 #define ScrollingConstraints_h |
| 28 | 28 |
| 29 #include "platform/geometry/FloatRect.h" | 29 #include "platform/geometry/FloatRect.h" |
| 30 | 30 |
| 31 namespace WebCore { | 31 namespace WebCore { |
| 32 | 32 |
| 33 // ViewportConstraints classes encapsulate data and logic required to reposition
elements whose layout | 33 // ViewportConstraints classes encapsulate data and logic required to reposition
elements whose layout |
| 34 // depends on the viewport rect (positions fixed and sticky), when scrolling and
zooming. | 34 // depends on the viewport rect (i.e., position fixed), when scrolling and zoomi
ng. |
| 35 class ViewportConstraints { | 35 class ViewportConstraints { |
| 36 public: | 36 public: |
| 37 // FIXME: Simplify this code now that position: sticky doesn't exist. |
| 37 enum ConstraintType { | 38 enum ConstraintType { |
| 38 FixedPositionConstaint, | 39 FixedPositionConstaint, |
| 39 StickyPositionConstraint | |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 enum AnchorEdgeFlags { | 42 enum AnchorEdgeFlags { |
| 43 AnchorEdgeLeft = 1 << 0, | 43 AnchorEdgeLeft = 1 << 0, |
| 44 AnchorEdgeRight = 1 << 1, | 44 AnchorEdgeRight = 1 << 1, |
| 45 AnchorEdgeTop = 1 << 2, | 45 AnchorEdgeTop = 1 << 2, |
| 46 AnchorEdgeBottom = 1 << 3 | 46 AnchorEdgeBottom = 1 << 3 |
| 47 }; | 47 }; |
| 48 typedef unsigned AnchorEdges; | 48 typedef unsigned AnchorEdges; |
| 49 | 49 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 bool operator!=(const FixedPositionViewportConstraints& other) const { retur
n !(*this == other); } | 104 bool operator!=(const FixedPositionViewportConstraints& other) const { retur
n !(*this == other); } |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 virtual ConstraintType constraintType() const OVERRIDE { return FixedPositio
nConstaint; } | 107 virtual ConstraintType constraintType() const OVERRIDE { return FixedPositio
nConstaint; } |
| 108 | 108 |
| 109 FloatRect m_viewportRectAtLastLayout; | 109 FloatRect m_viewportRectAtLastLayout; |
| 110 FloatPoint m_layerPositionAtLastLayout; | 110 FloatPoint m_layerPositionAtLastLayout; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 class StickyPositionViewportConstraints FINAL : public ViewportConstraints { | |
| 114 public: | |
| 115 StickyPositionViewportConstraints() | |
| 116 : m_leftOffset(0) | |
| 117 , m_rightOffset(0) | |
| 118 , m_topOffset(0) | |
| 119 , m_bottomOffset(0) | |
| 120 { } | |
| 121 | |
| 122 StickyPositionViewportConstraints(const StickyPositionViewportConstraints& o
ther) | |
| 123 : ViewportConstraints(other) | |
| 124 , m_leftOffset(other.m_leftOffset) | |
| 125 , m_rightOffset(other.m_rightOffset) | |
| 126 , m_topOffset(other.m_topOffset) | |
| 127 , m_bottomOffset(other.m_bottomOffset) | |
| 128 , m_absoluteContainingBlockRect(other.m_absoluteContainingBlockRect) | |
| 129 , m_absoluteStickyBoxRect(other.m_absoluteStickyBoxRect) | |
| 130 , m_stickyOffsetAtLastLayout(other.m_stickyOffsetAtLastLayout) | |
| 131 , m_layerPositionAtLastLayout(other.m_layerPositionAtLastLayout) | |
| 132 { } | |
| 133 | |
| 134 FloatSize computeStickyOffset(const FloatRect& viewportRect) const; | |
| 135 | |
| 136 const FloatSize stickyOffsetAtLastLayout() const { return m_stickyOffsetAtLa
stLayout; } | |
| 137 void setStickyOffsetAtLastLayout(const FloatSize& offset) { m_stickyOffsetAt
LastLayout = offset; } | |
| 138 | |
| 139 FloatPoint layerPositionForViewportRect(const FloatRect& viewportRect) const
; | |
| 140 | |
| 141 const FloatPoint& layerPositionAtLastLayout() const { return m_layerPosition
AtLastLayout; } | |
| 142 void setLayerPositionAtLastLayout(const FloatPoint& point) { m_layerPosition
AtLastLayout = point; } | |
| 143 | |
| 144 float leftOffset() const { return m_leftOffset; } | |
| 145 float rightOffset() const { return m_rightOffset; } | |
| 146 float topOffset() const { return m_topOffset; } | |
| 147 float bottomOffset() const { return m_bottomOffset; } | |
| 148 | |
| 149 void setLeftOffset(float offset) { m_leftOffset = offset; } | |
| 150 void setRightOffset(float offset) { m_rightOffset = offset; } | |
| 151 void setTopOffset(float offset) { m_topOffset = offset; } | |
| 152 void setBottomOffset(float offset) { m_bottomOffset = offset; } | |
| 153 | |
| 154 FloatRect absoluteContainingBlockRect() const { return m_absoluteContainingB
lockRect; } | |
| 155 void setAbsoluteContainingBlockRect(const FloatRect& rect) { m_absoluteConta
iningBlockRect = rect; } | |
| 156 | |
| 157 FloatRect absoluteStickyBoxRect() const { return m_absoluteStickyBoxRect; } | |
| 158 void setAbsoluteStickyBoxRect(const FloatRect& rect) { m_absoluteStickyBoxRe
ct = rect; } | |
| 159 | |
| 160 bool operator==(const StickyPositionViewportConstraints& other) const | |
| 161 { | |
| 162 return m_leftOffset == other.m_leftOffset | |
| 163 && m_rightOffset == other.m_rightOffset | |
| 164 && m_topOffset == other.m_topOffset | |
| 165 && m_bottomOffset == other.m_bottomOffset | |
| 166 && m_absoluteContainingBlockRect == other.m_absoluteContainingBlockR
ect | |
| 167 && m_absoluteStickyBoxRect == other.m_absoluteStickyBoxRect | |
| 168 && m_stickyOffsetAtLastLayout == other.m_stickyOffsetAtLastLayout | |
| 169 && m_layerPositionAtLastLayout == other.m_layerPositionAtLastLayout; | |
| 170 } | |
| 171 | |
| 172 bool operator!=(const StickyPositionViewportConstraints& other) const { retu
rn !(*this == other); } | |
| 173 | |
| 174 private: | |
| 175 virtual ConstraintType constraintType() const OVERRIDE { return StickyPositi
onConstraint; } | |
| 176 | |
| 177 float m_leftOffset; | |
| 178 float m_rightOffset; | |
| 179 float m_topOffset; | |
| 180 float m_bottomOffset; | |
| 181 FloatRect m_absoluteContainingBlockRect; | |
| 182 FloatRect m_absoluteStickyBoxRect; | |
| 183 FloatSize m_stickyOffsetAtLastLayout; | |
| 184 FloatPoint m_layerPositionAtLastLayout; | |
| 185 }; | |
| 186 | |
| 187 } // namespace WebCore | 113 } // namespace WebCore |
| 188 | 114 |
| 189 #endif // ScrollingConstraints_h | 115 #endif // ScrollingConstraints_h |
| OLD | NEW |