| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  135       m_localBorderBoxProperties->propertyTreeState.setTransform(transform); |  135       m_localBorderBoxProperties->propertyTreeState.setTransform(transform); | 
|  136       m_localBorderBoxProperties->propertyTreeState.setClip(clip); |  136       m_localBorderBoxProperties->propertyTreeState.setClip(clip); | 
|  137       m_localBorderBoxProperties->propertyTreeState.setEffect(effect); |  137       m_localBorderBoxProperties->propertyTreeState.setEffect(effect); | 
|  138       m_localBorderBoxProperties->propertyTreeState.setScroll(scroll); |  138       m_localBorderBoxProperties->propertyTreeState.setScroll(scroll); | 
|  139     } else { |  139     } else { | 
|  140       m_localBorderBoxProperties = |  140       m_localBorderBoxProperties = | 
|  141           wrapUnique(new ObjectPaintProperties::PropertyTreeStateWithOffset( |  141           wrapUnique(new ObjectPaintProperties::PropertyTreeStateWithOffset( | 
|  142               paintOffset, PropertyTreeState(transform, clip, effect, scroll))); |  142               paintOffset, PropertyTreeState(transform, clip, effect, scroll))); | 
|  143     } |  143     } | 
|  144   } |  144   } | 
 |  145   void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } | 
|  145  |  146  | 
|  146   // This is the complete set of property nodes and paint offset that can be |  147   // This is the complete set of property nodes and paint offset that can be | 
|  147   // used to paint the contents of this object. It is similar to |  148   // used to paint the contents of this object. It is similar to | 
|  148   // localBorderBoxProperties but includes properties (e.g., overflow clip, |  149   // localBorderBoxProperties but includes properties (e.g., overflow clip, | 
|  149   // scroll translation) that apply to contents. This is suitable for paint |  150   // scroll translation) that apply to contents. This is suitable for paint | 
|  150   // invalidation. |  151   // invalidation. | 
|  151   ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; |  152   ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; | 
|  152  |  153  | 
|  153   void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } |  154   // True if an existing property was deleted, false otherwise. | 
|  154   void clearTransform() { m_transform = nullptr; } |  155   bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } | 
|  155   void clearEffect() { m_effect = nullptr; } |  156   // True if an existing property was deleted, false otherwise. | 
|  156   void clearCssClip() { m_cssClip = nullptr; } |  157   bool clearTransform() { return clear(m_transform); } | 
|  157   void clearCssClipFixedPosition() { m_cssClipFixedPosition = nullptr; } |  158   // True if an existing property was deleted, false otherwise. | 
|  158   void clearInnerBorderRadiusClip() { m_innerBorderRadiusClip = nullptr; } |  159   bool clearEffect() { return clear(m_effect); } | 
|  159   void clearOverflowClip() { m_overflowClip = nullptr; } |  160   // True if an existing property was deleted, false otherwise. | 
|  160   void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } |  161   bool clearCssClip() { return clear(m_cssClip); } | 
|  161   void clearPerspective() { m_perspective = nullptr; } |  162   // True if an existing property was deleted, false otherwise. | 
|  162   void clearSvgLocalToBorderBoxTransform() { |  163   bool clearCssClipFixedPosition() { return clear(m_cssClipFixedPosition); } | 
|  163     m_svgLocalToBorderBoxTransform = nullptr; |  164   // True if an existing property was deleted, false otherwise. | 
 |  165   bool clearInnerBorderRadiusClip() { return clear(m_innerBorderRadiusClip); } | 
 |  166   // True if an existing property was deleted, false otherwise. | 
 |  167   bool clearOverflowClip() { return clear(m_overflowClip); } | 
 |  168   // True if an existing property was deleted, false otherwise. | 
 |  169   bool clearPerspective() { return clear(m_perspective); } | 
 |  170   // True if an existing property was deleted, false otherwise. | 
 |  171   bool clearSvgLocalToBorderBoxTransform() { | 
 |  172     return clear(m_svgLocalToBorderBoxTransform); | 
|  164   } |  173   } | 
|  165   void clearScrollTranslation() { m_scrollTranslation = nullptr; } |  174   // True if an existing property was deleted, false otherwise. | 
|  166   void clearScrollbarPaintOffset() { m_scrollbarPaintOffset = nullptr; } |  175   bool clearScrollTranslation() { return clear(m_scrollTranslation); } | 
|  167   void clearScroll() { m_scroll = nullptr; } |  176   // True if an existing property was deleted, false otherwise. | 
 |  177   bool clearScrollbarPaintOffset() { return clear(m_scrollbarPaintOffset); } | 
 |  178   // True if an existing property was deleted, false otherwise. | 
 |  179   bool clearScroll() { return clear(m_scroll); } | 
|  168  |  180  | 
 |  181   // True if a new property was created, false if an existing one was updated. | 
|  169   template <typename... Args> |  182   template <typename... Args> | 
|  170   void updatePaintOffsetTranslation(Args&&... args) { |  183   bool updatePaintOffsetTranslation(Args&&... args) { | 
|  171     updateProperty(m_paintOffsetTranslation, std::forward<Args>(args)...); |  184     return update(m_paintOffsetTranslation, std::forward<Args>(args)...); | 
|  172   } |  185   } | 
 |  186   // True if a new property was created, false if an existing one was updated. | 
|  173   template <typename... Args> |  187   template <typename... Args> | 
|  174   void updateTransform(Args&&... args) { |  188   bool updateTransform(Args&&... args) { | 
|  175     updateProperty(m_transform, std::forward<Args>(args)...); |  189     return update(m_transform, std::forward<Args>(args)...); | 
|  176   } |  190   } | 
 |  191   // True if a new property was created, false if an existing one was updated. | 
|  177   template <typename... Args> |  192   template <typename... Args> | 
|  178   void updatePerspective(Args&&... args) { |  193   bool updatePerspective(Args&&... args) { | 
|  179     updateProperty(m_perspective, std::forward<Args>(args)...); |  194     return update(m_perspective, std::forward<Args>(args)...); | 
|  180   } |  195   } | 
 |  196   // True if a new property was created, false if an existing one was updated. | 
|  181   template <typename... Args> |  197   template <typename... Args> | 
|  182   void updateSvgLocalToBorderBoxTransform(Args&&... args) { |  198   bool updateSvgLocalToBorderBoxTransform(Args&&... args) { | 
|  183     DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " |  199     DCHECK(!scrollTranslation()) << "SVG elements cannot scroll so there " | 
|  184                                     "should never be both a scroll translation " |  200                                     "should never be both a scroll translation " | 
|  185                                     "and an SVG local to border box transform."; |  201                                     "and an SVG local to border box transform."; | 
|  186     updateProperty(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); |  202     return update(m_svgLocalToBorderBoxTransform, std::forward<Args>(args)...); | 
|  187   } |  203   } | 
 |  204   // True if a new property was created, false if an existing one was updated. | 
|  188   template <typename... Args> |  205   template <typename... Args> | 
|  189   void updateScrollTranslation(Args&&... args) { |  206   bool updateScrollTranslation(Args&&... args) { | 
|  190     DCHECK(!svgLocalToBorderBoxTransform()) |  207     DCHECK(!svgLocalToBorderBoxTransform()) | 
|  191         << "SVG elements cannot scroll so there should never be both a scroll " |  208         << "SVG elements cannot scroll so there should never be both a scroll " | 
|  192            "translation and an SVG local to border box transform."; |  209            "translation and an SVG local to border box transform."; | 
|  193     updateProperty(m_scrollTranslation, std::forward<Args>(args)...); |  210     return update(m_scrollTranslation, std::forward<Args>(args)...); | 
|  194   } |  211   } | 
 |  212   // True if a new property was created, false if an existing one was updated. | 
|  195   template <typename... Args> |  213   template <typename... Args> | 
|  196   void updateScrollbarPaintOffset(Args&&... args) { |  214   bool updateScrollbarPaintOffset(Args&&... args) { | 
|  197     updateProperty(m_scrollbarPaintOffset, std::forward<Args>(args)...); |  215     return update(m_scrollbarPaintOffset, std::forward<Args>(args)...); | 
|  198   } |  216   } | 
 |  217   // True if a new property was created, false if an existing one was updated. | 
|  199   template <typename... Args> |  218   template <typename... Args> | 
|  200   void updateScroll(Args&&... args) { |  219   bool updateScroll(Args&&... args) { | 
|  201     updateProperty(m_scroll, std::forward<Args>(args)...); |  220     return update(m_scroll, std::forward<Args>(args)...); | 
|  202   } |  221   } | 
 |  222   // True if a new property was created, false if an existing one was updated. | 
|  203   template <typename... Args> |  223   template <typename... Args> | 
|  204   void updateEffect(Args&&... args) { |  224   bool updateEffect(Args&&... args) { | 
|  205     updateProperty(m_effect, std::forward<Args>(args)...); |  225     return update(m_effect, std::forward<Args>(args)...); | 
|  206   } |  226   } | 
 |  227   // True if a new property was created, false if an existing one was updated. | 
|  207   template <typename... Args> |  228   template <typename... Args> | 
|  208   void updateCssClip(Args&&... args) { |  229   bool updateCssClip(Args&&... args) { | 
|  209     updateProperty(m_cssClip, std::forward<Args>(args)...); |  230     return update(m_cssClip, std::forward<Args>(args)...); | 
|  210   } |  231   } | 
 |  232   // True if a new property was created, false if an existing one was updated. | 
|  211   template <typename... Args> |  233   template <typename... Args> | 
|  212   void updateCssClipFixedPosition(Args&&... args) { |  234   bool updateCssClipFixedPosition(Args&&... args) { | 
|  213     updateProperty(m_cssClipFixedPosition, std::forward<Args>(args)...); |  235     return update(m_cssClipFixedPosition, std::forward<Args>(args)...); | 
|  214   } |  236   } | 
 |  237   // True if a new property was created, false if an existing one was updated. | 
|  215   template <typename... Args> |  238   template <typename... Args> | 
|  216   void updateInnerBorderRadiusClip(Args&&... args) { |  239   bool updateInnerBorderRadiusClip(Args&&... args) { | 
|  217     updateProperty(m_innerBorderRadiusClip, std::forward<Args>(args)...); |  240     return update(m_innerBorderRadiusClip, std::forward<Args>(args)...); | 
|  218   } |  241   } | 
 |  242   // True if a new property was created, false if an existing one was updated. | 
|  219   template <typename... Args> |  243   template <typename... Args> | 
|  220   void updateOverflowClip(Args&&... args) { |  244   bool updateOverflowClip(Args&&... args) { | 
|  221     updateProperty(m_overflowClip, std::forward<Args>(args)...); |  245     return update(m_overflowClip, std::forward<Args>(args)...); | 
|  222   } |  246   } | 
|  223  |  247  | 
|  224 #if DCHECK_IS_ON() |  248 #if DCHECK_IS_ON() | 
|  225   // Used by FindPropertiesNeedingUpdate.h for recording the current properties. |  249   // Used by FindPropertiesNeedingUpdate.h for recording the current properties. | 
|  226   std::unique_ptr<ObjectPaintProperties> clone() const { |  250   std::unique_ptr<ObjectPaintProperties> clone() const { | 
|  227     std::unique_ptr<ObjectPaintProperties> cloned = create(); |  251     std::unique_ptr<ObjectPaintProperties> cloned = create(); | 
|  228     if (m_paintOffsetTranslation) |  252     if (m_paintOffsetTranslation) | 
|  229       cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); |  253       cloned->m_paintOffsetTranslation = m_paintOffsetTranslation->clone(); | 
|  230     if (m_transform) |  254     if (m_transform) | 
|  231       cloned->m_transform = m_transform->clone(); |  255       cloned->m_transform = m_transform->clone(); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|  259               PropertyTreeState(state.transform(), state.clip(), state.effect(), |  283               PropertyTreeState(state.transform(), state.clip(), state.effect(), | 
|  260                                 state.scroll()))); |  284                                 state.scroll()))); | 
|  261     } |  285     } | 
|  262     return cloned; |  286     return cloned; | 
|  263   } |  287   } | 
|  264 #endif |  288 #endif | 
|  265  |  289  | 
|  266  private: |  290  private: | 
|  267   ObjectPaintProperties() {} |  291   ObjectPaintProperties() {} | 
|  268  |  292  | 
 |  293   // True if an existing property was deleted, false otherwise. | 
 |  294   template <typename PaintPropertyNode> | 
 |  295   bool clear(RefPtr<PaintPropertyNode>& field) { | 
 |  296     if (field) { | 
 |  297       field = nullptr; | 
 |  298       return true; | 
 |  299     } | 
 |  300     return false; | 
 |  301   } | 
 |  302  | 
 |  303   // True if a new property was created, false if an existing one was updated. | 
|  269   template <typename PaintPropertyNode, typename... Args> |  304   template <typename PaintPropertyNode, typename... Args> | 
|  270   void updateProperty(RefPtr<PaintPropertyNode>& field, Args&&... args) { |  305   bool update(RefPtr<PaintPropertyNode>& field, Args&&... args) { | 
|  271     if (field) |  306     if (field) { | 
|  272       field->update(std::forward<Args>(args)...); |  307       field->update(std::forward<Args>(args)...); | 
|  273     else |  308       return false; | 
|  274       field = PaintPropertyNode::create(std::forward<Args>(args)...); |  309     } | 
 |  310     field = PaintPropertyNode::create(std::forward<Args>(args)...); | 
 |  311     return true; | 
|  275   } |  312   } | 
|  276  |  313  | 
|  277   RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; |  314   RefPtr<TransformPaintPropertyNode> m_paintOffsetTranslation; | 
|  278   RefPtr<TransformPaintPropertyNode> m_transform; |  315   RefPtr<TransformPaintPropertyNode> m_transform; | 
|  279   RefPtr<EffectPaintPropertyNode> m_effect; |  316   RefPtr<EffectPaintPropertyNode> m_effect; | 
|  280   RefPtr<ClipPaintPropertyNode> m_cssClip; |  317   RefPtr<ClipPaintPropertyNode> m_cssClip; | 
|  281   RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; |  318   RefPtr<ClipPaintPropertyNode> m_cssClipFixedPosition; | 
|  282   RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; |  319   RefPtr<ClipPaintPropertyNode> m_innerBorderRadiusClip; | 
|  283   RefPtr<ClipPaintPropertyNode> m_overflowClip; |  320   RefPtr<ClipPaintPropertyNode> m_overflowClip; | 
|  284   RefPtr<TransformPaintPropertyNode> m_perspective; |  321   RefPtr<TransformPaintPropertyNode> m_perspective; | 
|  285   // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. |  322   // TODO(pdr): Only LayoutSVGRoot needs this and it should be moved there. | 
|  286   RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; |  323   RefPtr<TransformPaintPropertyNode> m_svgLocalToBorderBoxTransform; | 
|  287   RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |  324   RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 
|  288   RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |  325   RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 
|  289   RefPtr<ScrollPaintPropertyNode> m_scroll; |  326   RefPtr<ScrollPaintPropertyNode> m_scroll; | 
|  290  |  327  | 
|  291   std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; |  328   std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; | 
|  292 }; |  329 }; | 
|  293  |  330  | 
|  294 }  // namespace blink |  331 }  // namespace blink | 
|  295  |  332  | 
|  296 #endif  // ObjectPaintProperties_h |  333 #endif  // ObjectPaintProperties_h | 
| OLD | NEW |