| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // because some properties inherit from the containing block chain instead of | 117 // because some properties inherit from the containing block chain instead of |
| 118 // the painting parent and cannot be derived in O(1) during the paint walk. | 118 // the painting parent and cannot be derived in O(1) during the paint walk. |
| 119 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/> | 119 // For example, <div style='opacity: 0.3; position: relative; margin: 11px;'/> |
| 120 // would have a paint offset of (11px, 11px) and propertyTreeState.effect() | 120 // would have a paint offset of (11px, 11px) and propertyTreeState.effect() |
| 121 // would be an effect node with opacity of 0.3 which was created by the div | 121 // would be an effect node with opacity of 0.3 which was created by the div |
| 122 // itself. Note that propertyTreeState.transform() would not be null but would | 122 // itself. Note that propertyTreeState.transform() would not be null but would |
| 123 // instead point to the transform space setup by div's ancestors. | 123 // instead point to the transform space setup by div's ancestors. |
| 124 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { | 124 const PropertyTreeStateWithOffset* localBorderBoxProperties() const { |
| 125 return m_localBorderBoxProperties.get(); | 125 return m_localBorderBoxProperties.get(); |
| 126 } | 126 } |
| 127 void updateLocalBorderBoxProperties( | 127 // True if local border box changes, false otherwise. |
| 128 bool updateLocalBorderBoxProperties( |
| 128 LayoutPoint& paintOffset, | 129 LayoutPoint& paintOffset, |
| 129 const TransformPaintPropertyNode* transform, | 130 const TransformPaintPropertyNode* transform, |
| 130 const ClipPaintPropertyNode* clip, | 131 const ClipPaintPropertyNode* clip, |
| 131 const EffectPaintPropertyNode* effect, | 132 const EffectPaintPropertyNode* effect, |
| 132 const ScrollPaintPropertyNode* scroll) { | 133 const ScrollPaintPropertyNode* scroll) { |
| 133 if (m_localBorderBoxProperties) { | 134 if (!m_localBorderBoxProperties) { |
| 134 m_localBorderBoxProperties->paintOffset = paintOffset; | |
| 135 m_localBorderBoxProperties->propertyTreeState.setTransform(transform); | |
| 136 m_localBorderBoxProperties->propertyTreeState.setClip(clip); | |
| 137 m_localBorderBoxProperties->propertyTreeState.setEffect(effect); | |
| 138 m_localBorderBoxProperties->propertyTreeState.setScroll(scroll); | |
| 139 } else { | |
| 140 m_localBorderBoxProperties = WTF::wrapUnique( | 135 m_localBorderBoxProperties = WTF::wrapUnique( |
| 141 new ObjectPaintProperties::PropertyTreeStateWithOffset( | 136 new ObjectPaintProperties::PropertyTreeStateWithOffset( |
| 142 paintOffset, PropertyTreeState(transform, clip, effect, scroll))); | 137 paintOffset, PropertyTreeState(transform, clip, effect, scroll))); |
| 138 return true; |
| 143 } | 139 } |
| 140 bool changed = false; |
| 141 if (m_localBorderBoxProperties->paintOffset != paintOffset) { |
| 142 m_localBorderBoxProperties->paintOffset = paintOffset; |
| 143 changed = true; |
| 144 } |
| 145 const auto& borderBoxState = m_localBorderBoxProperties->propertyTreeState; |
| 146 if (borderBoxState.transform() != transform) { |
| 147 m_localBorderBoxProperties->propertyTreeState.setTransform(transform); |
| 148 changed = true; |
| 149 } |
| 150 if (borderBoxState.clip() != clip) { |
| 151 m_localBorderBoxProperties->propertyTreeState.setClip(clip); |
| 152 changed = true; |
| 153 } |
| 154 if (borderBoxState.effect() != effect) { |
| 155 m_localBorderBoxProperties->propertyTreeState.setEffect(effect); |
| 156 changed = true; |
| 157 } |
| 158 if (borderBoxState.scroll() != scroll) { |
| 159 m_localBorderBoxProperties->propertyTreeState.setScroll(scroll); |
| 160 changed = true; |
| 161 } |
| 162 return changed; |
| 144 } | 163 } |
| 145 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } | 164 // True if an existing property was deleted, false otherwise. |
| 165 bool clearLocalBorderBoxProperties() { |
| 166 if (m_localBorderBoxProperties) { |
| 167 m_localBorderBoxProperties = nullptr; |
| 168 return true; |
| 169 } |
| 170 return false; |
| 171 } |
| 146 | 172 |
| 147 // This is the complete set of property nodes and paint offset that can be | 173 // This is the complete set of property nodes and paint offset that can be |
| 148 // used to paint the contents of this object. It is similar to | 174 // used to paint the contents of this object. It is similar to |
| 149 // localBorderBoxProperties but includes properties (e.g., overflow clip, | 175 // localBorderBoxProperties but includes properties (e.g., overflow clip, |
| 150 // scroll translation) that apply to contents. This is suitable for paint | 176 // scroll translation) that apply to contents. This is suitable for paint |
| 151 // invalidation. | 177 // invalidation. |
| 152 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; | 178 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; |
| 153 | 179 |
| 154 // True if an existing property was deleted, false otherwise. | 180 // True if an existing property was deleted, false otherwise. |
| 155 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } | 181 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 350 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 325 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 351 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 326 RefPtr<ScrollPaintPropertyNode> m_scroll; | 352 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 327 | 353 |
| 328 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; | 354 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; |
| 329 }; | 355 }; |
| 330 | 356 |
| 331 } // namespace blink | 357 } // namespace blink |
| 332 | 358 |
| 333 #endif // ObjectPaintProperties_h | 359 #endif // ObjectPaintProperties_h |
| OLD | NEW |