| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ObjectPaintProperties_h | 5 #ifndef ObjectPaintProperties_h |
| 6 #define ObjectPaintProperties_h | 6 #define ObjectPaintProperties_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/geometry/LayoutPoint.h" | 9 #include "platform/geometry/LayoutPoint.h" |
| 10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 10 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // invalidation. | 136 // invalidation. |
| 137 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; | 137 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; |
| 138 | 138 |
| 139 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } | 139 void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } |
| 140 void clearTransform() { m_transform = nullptr; } | 140 void clearTransform() { m_transform = nullptr; } |
| 141 void clearEffect() { m_effect = nullptr; } | 141 void clearEffect() { m_effect = nullptr; } |
| 142 void clearCssClip() { m_cssClip = nullptr; } | 142 void clearCssClip() { m_cssClip = nullptr; } |
| 143 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } | 143 void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } |
| 144 void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; } | 144 void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; } |
| 145 void clearOverflowClip() { m_overflowClip = nullptr; } | 145 void clearOverflowClip() { m_overflowClip = nullptr; } |
| 146 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } |
| 146 void clearPerspective() { m_perspective = nullptr; } | 147 void clearPerspective() { m_perspective = nullptr; } |
| 147 void clearSvgLocalToBorderBoxTransform() { | 148 void clearSvgLocalToBorderBoxTransform() { |
| 148 m_svgLocalToBorderBoxTransform = nullptr; | 149 m_svgLocalToBorderBoxTransform = nullptr; |
| 149 } | 150 } |
| 150 void clearScrollTranslation() { m_scrollTranslation = nullptr; } | 151 void clearScrollTranslation() { m_scrollTranslation = nullptr; } |
| 151 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } | 152 void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } |
| 152 void clearScroll() { m_scroll = nullptr; } | 153 void clearScroll() { m_scroll = nullptr; } |
| 153 | 154 |
| 154 template <typename... Args> | 155 template <typename... Args> |
| 155 TransformPaintPropertyNode* updatePaintOffsetTranslation(Args&&... args) { | 156 void updatePaintOffsetTranslation(Args&&... args) { |
| 156 return updateProperty(m_paintOffsetTranslation, | 157 updateProperty(m_paintOffsetTranslation, std::forward<Args>(args)...); |
| 157 std::forward<Args>(args)...); | |
| 158 } | 158 } |
| 159 template <typename... Args> | 159 template <typename... Args> |
| 160 TransformPaintPropertyNode* updateTransform(Args&&... args) { | 160 void updateTransform(Args&&... args) { |
| 161 return updateProperty(m_transform, std::forward<Args>(args)...); | 161 updateProperty(m_transform, std::forward<Args>(args)...); |
| 162 } | 162 } |
| 163 template <typename... Args> | 163 template <typename... Args> |
| 164 TransformPaintPropertyNode* updatePerspective(Args&&... args) { | 164 void updatePerspective(Args&&... args) { |
| 165 return updateProperty(m_perspective, std::forward<Args>(args)...); | 165 updateProperty(m_perspective, std::forward<Args>(args)...); |
| 166 } | 166 } |
| 167 template <typename... Args> | 167 template <typename... Args> |
| 168 TransformPaintPropertyNode* updateSvgLocalToBorderBoxTransform( | 168 void updateSvgLocalToBorderBoxTransform(Args&&... args) { |
| 169 Args&&... args) { | |
| 170 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " | 169 DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " |
| 171 "should never be both a scroll translation " | 170 "should never be both a scroll translation " |
| 172 "and an SVG local to border box transform."; | 171 "and an SVG local to border box transform."; |
| 173 return updateProperty(m_svgLocalToBorderBoxTransform, | 172 updateProperty(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); |
| 174 std::forward<Args>(args)...); | |
| 175 } | 173 } |
| 176 template <typename... Args> | 174 template <typename... Args> |
| 177 TransformPaintPropertyNode* updateScrollTranslation(Args&&... args) { | 175 void updateScrollTranslation(Args&&... args) { |
| 178 DCHECK(!svgLocalToBorderBoxTransform()) | 176 DCHECK(!svgLocalToBorderBoxTransform()) |
| 179 << "SVG elements cannot scroll so there should never be both a scroll " | 177 << "SVG elements cannot scroll so there should never be both a scroll " |
| 180 "translation and an SVG local to border box transform."; | 178 "translation and an SVG local to border box transform."; |
| 181 return updateProperty(m_scrollTranslation, std::forward<Args>(args)...); | 179 updateProperty(m_scrollTranslation, std::forward<Args>(args)...); |
| 182 } | 180 } |
| 183 template <typename... Args> | 181 template <typename... Args> |
| 184 TransformPaintPropertyNode* updateScrollbarPaintOffset(Args&&... args) { | 182 void updateScrollbarPaintOffset(Args&&... args) { |
| 185 return updateProperty(m_scrollbarPaintOffset, std::forward<Args>(args)...); | 183 updateProperty(m_scrollbarPaintOffset, std::forward<Args>(args)...); |
| 186 } | 184 } |
| 187 template <typename... Args> | 185 template <typename... Args> |
| 188 ScrollPaintPropertyNode* updateScroll(Args&&... args) { | 186 void updateScroll(Args&&... args) { |
| 189 return updateProperty(m_scroll, std::forward<Args>(args)...); | 187 updateProperty(m_scroll, std::forward<Args>(args)...); |
| 190 } | 188 } |
| 191 template <typename... Args> | 189 template <typename... Args> |
| 192 EffectPaintPropertyNode* updateEffect(Args&&... args) { | 190 void updateEffect(Args&&... args) { |
| 193 return updateProperty(m_effect, std::forward<Args>(args)...); | 191 updateProperty(m_effect, std::forward<Args>(args)...); |
| 194 } | 192 } |
| 195 template <typename... Args> | 193 template <typename... Args> |
| 196 ClipPaintPropertyNode* updateCssClip(Args&&... args) { | 194 void updateCssClip(Args&&... args) { |
| 197 return updateProperty(m_cssClip, std::forward<Args>(args)...); | 195 updateProperty(m_cssClip, std::forward<Args>(args)...); |
| 198 } | 196 } |
| 199 template <typename... Args> | 197 template <typename... Args> |
| 200 ClipPaintPropertyNode* updateCssClipFixedPosition(Args&&... args) { | 198 void updateCssClipFixedPosition(Args&&... args) { |
| 201 return updateProperty(m_cssClipFixedPosition, std::forward<Args>(args)...); | 199 updateProperty(m_cssClipFixedPosition, std::forward<Args>(args)...); |
| 202 } | 200 } |
| 203 template <typename... Args> | 201 template <typename... Args> |
| 204 ClipPaintPropertyNode* updateInnerBorderRadiusClip(Args&&... args) { | 202 void updateInnerBorderRadiusClip(Args&&... args) { |
| 205 return updateProperty(m_innerBorderRadiusClip, std::forward<Args>(args)...); | 203 updateProperty(m_innerBorderRadiusClip, std::forward<Args>(args)...); |
| 206 } | 204 } |
| 207 template <typename... Args> | 205 template <typename... Args> |
| 208 ClipPaintPropertyNode* updateOverflowClip(Args&&... args) { | 206 void updateOverflowClip(Args&&... args) { |
| 209 return updateProperty(m_overflowClip, std::forward<Args>(args)...); | 207 updateProperty(m_overflowClip, std::forward<Args>(args)...); |
| 210 } | 208 } |
| 211 | 209 |
| 210 #if DCHECK_IS_ON() |
| 211 // Used by FindPropertiesNeedingUpdate.h for recording the current properties. |
| 212 std::unique_ptr<ObjectPaintProperties> clone() const { |
| 213 std::unique_ptr<ObjectPaintProperties> cloned = create(); |
| 214 if (m_paintOffsetTranslation) |
| 215 cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); |
| 216 if (m_transform) |
| 217 cloned->m_transform = m_transform->clone(); |
| 218 if (m_effect) |
| 219 cloned->m_effect = m_effect->clone(); |
| 220 if (m_cssClip) |
| 221 cloned->m_cssClip = m_cssClip->clone(); |
| 222 if (m_cssClipFixedPosition) |
| 223 cloned->m_cssClipFixedPosition = m_cssClipFixedPosition->clone(); |
| 224 if (m_innerBorderRadiusClip) |
| 225 cloned->m_innerBorderRadiusClip = m_innerBorderRadiusClip->clone(); |
| 226 if (m_overflowClip) |
| 227 cloned->m_overflowClip = m_overflowClip->clone(); |
| 228 if (m_perspective) |
| 229 cloned->m_perspective = m_perspective->clone(); |
| 230 if (m_svgLocalToBorderBoxTransform) { |
| 231 cloned->m_svgLocalToBorderBoxTransform = |
| 232 m_svgLocalToBorderBoxTransform->clone(); |
| 233 } |
| 234 if (m_scrollTranslation) |
| 235 cloned->m_scrollTranslation = m_scrollTranslation->clone(); |
| 236 if (m_scrollbarPaintOffset) |
| 237 cloned->m_scrollbarPaintOffset = m_scrollbarPaintOffset->clone(); |
| 238 if (m_scroll) |
| 239 cloned->m_scroll = m_scroll->clone(); |
| 240 if (m_localBorderBoxProperties) { |
| 241 auto& state = m_localBorderBoxProperties->propertyTreeState; |
| 242 cloned->m_localBorderBoxProperties = |
| 243 wrapUnique(new PropertyTreeStateWithOffset( |
| 244 m_localBorderBoxProperties->paintOffset, |
| 245 PropertyTreeState(state.transform(), state.clip(), state.effect(), |
| 246 state.scroll()))); |
| 247 } |
| 248 return cloned; |
| 249 } |
| 250 #endif |
| 251 |
| 212 private: | 252 private: |
| 213 ObjectPaintProperties() {} | 253 ObjectPaintProperties() {} |
| 214 | 254 |
| 215 template <typename PaintPropertyNode, typename... Args> | 255 template <typename PaintPropertyNode, typename... Args> |
| 216 PaintPropertyNode* updateProperty(RefPtr<PaintPropertyNode>& field, | 256 void updateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args) { |
| 217 Args&&... args) { | |
| 218 if (field) | 257 if (field) |
| 219 field->update(std::forward<Args>(args)...); | 258 field->update(std::forward<Args>(args)...); |
| 220 else | 259 else |
| 221 field = PaintPropertyNode::create(std::forward<Args>(args)...); | 260 field = PaintPropertyNode::create(std::forward<Args>(args)...); |
| 222 return field.get(); | |
| 223 } | 261 } |
| 224 | 262 |
| 225 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; | 263 RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; |
| 226 RefPtr<TransformPaintPropertyNode> m_transform; | 264 RefPtr<TransformPaintPropertyNode> m_transform; |
| 227 RefPtr<EffectPaintPropertyNode> m_effect; | 265 RefPtr<EffectPaintPropertyNode> m_effect; |
| 228 RefPtr<ClipPaintPropertyNode> m_cssClip; | 266 RefPtr<ClipPaintPropertyNode> m_cssClip; |
| 229 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; | 267 RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; |
| 230 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; | 268 RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; |
| 231 RefPtr<ClipPaintPropertyNode> m_overflowClip; | 269 RefPtr<ClipPaintPropertyNode> m_overflowClip; |
| 232 RefPtr<TransformPaintPropertyNode> m_perspective; | 270 RefPtr<TransformPaintPropertyNode> m_perspective; |
| 233 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. | 271 // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. |
| 234 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; | 272 RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; |
| 235 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 273 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 236 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 274 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 237 RefPtr<ScrollPaintPropertyNode> m_scroll; | 275 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 238 | 276 |
| 239 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; | 277 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; |
| 240 }; | 278 }; |
| 241 | 279 |
| 242 } // namespace blink | 280 } // namespace blink |
| 243 | 281 |
| 244 #endif // ObjectPaintProperties_h | 282 #endif // ObjectPaintProperties_h |
| OLD | NEW |