Chromium Code Reviews| 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 LayoutPoint& paintOffset, | 128 bool updateLocalBorderBoxProperties(LayoutPoint& paintOffset, |
| 129 const TransformPaintPropertyNode* transform, | 129 const TransformPaintPropertyNode* xform, |
| 130 const ClipPaintPropertyNode* clip, | 130 const ClipPaintPropertyNode* clip, |
| 131 const EffectPaintPropertyNode* effect, | 131 const EffectPaintPropertyNode* effect, |
| 132 const ScrollPaintPropertyNode* scroll) { | 132 const ScrollPaintPropertyNode* scroll) { |
| 133 if (m_localBorderBoxProperties) { | 133 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( | 134 m_localBorderBoxProperties = WTF::wrapUnique( |
| 141 new ObjectPaintProperties::PropertyTreeStateWithOffset( | 135 new ObjectPaintProperties::PropertyTreeStateWithOffset( |
| 142 paintOffset, PropertyTreeState(transform, clip, effect, scroll))); | 136 paintOffset, PropertyTreeState(xform, clip, effect, scroll))); |
| 137 return true; | |
| 143 } | 138 } |
| 139 bool changed = false; | |
| 140 if (m_localBorderBoxProperties->paintOffset != paintOffset) { | |
| 141 m_localBorderBoxProperties->paintOffset = paintOffset; | |
|
Xianzhu
2016/12/15 19:46:28
What's the relationship between this check of pain
| |
| 142 changed = true; | |
| 143 } | |
| 144 if (m_localBorderBoxProperties->propertyTreeState.transform() != xform) { | |
| 145 m_localBorderBoxProperties->propertyTreeState.setTransform(xform); | |
| 146 changed = true; | |
| 147 } | |
| 148 if (m_localBorderBoxProperties->propertyTreeState.clip() != clip) { | |
| 149 m_localBorderBoxProperties->propertyTreeState.setClip(clip); | |
| 150 changed = true; | |
| 151 } | |
| 152 if (m_localBorderBoxProperties->propertyTreeState.effect() != effect) { | |
| 153 m_localBorderBoxProperties->propertyTreeState.setEffect(effect); | |
| 154 changed = true; | |
| 155 } | |
| 156 if (m_localBorderBoxProperties->propertyTreeState.scroll() != scroll) { | |
| 157 m_localBorderBoxProperties->propertyTreeState.setScroll(scroll); | |
| 158 changed = true; | |
| 159 } | |
| 160 return changed; | |
| 144 } | 161 } |
| 145 void clearLocalBorderBoxProperties() { m_localBorderBoxProperties = nullptr; } | 162 // True if an existing property was deleted, false otherwise. |
| 163 bool clearLocalBorderBoxProperties() { | |
| 164 if (m_localBorderBoxProperties) { | |
| 165 m_localBorderBoxProperties = nullptr; | |
| 166 return true; | |
| 167 } | |
| 168 return false; | |
| 169 } | |
| 146 | 170 |
| 147 // This is the complete set of property nodes and paint offset that can be | 171 // 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 | 172 // used to paint the contents of this object. It is similar to |
| 149 // localBorderBoxProperties but includes properties (e.g., overflow clip, | 173 // localBorderBoxProperties but includes properties (e.g., overflow clip, |
| 150 // scroll translation) that apply to contents. This is suitable for paint | 174 // scroll translation) that apply to contents. This is suitable for paint |
| 151 // invalidation. | 175 // invalidation. |
| 152 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; | 176 ObjectPaintProperties::PropertyTreeStateWithOffset contentsProperties() const; |
| 153 | 177 |
| 154 // True if an existing property was deleted, false otherwise. | 178 // True if an existing property was deleted, false otherwise. |
| 155 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } | 179 bool clearPaintOffsetTranslation() { return clear(m_paintOffsetTranslation); } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 348 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
| 325 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; | 349 RefPtr<TransformPaintPropertyNode> m_scrollbarPaintOffset; |
| 326 RefPtr<ScrollPaintPropertyNode> m_scroll; | 350 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 327 | 351 |
| 328 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; | 352 std::unique_ptr<PropertyTreeStateWithOffset> m_localBorderBoxProperties; |
| 329 }; | 353 }; |
| 330 | 354 |
| 331 } // namespace blink | 355 } // namespace blink |
| 332 | 356 |
| 333 #endif // ObjectPaintProperties_h | 357 #endif // ObjectPaintProperties_h |
| OLD | NEW |