| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 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 FindPropertiesNeedingUpdate_h |    5 #ifndef FindPropertiesNeedingUpdate_h | 
|    6 #define FindPropertiesNeedingUpdate_h |    6 #define FindPropertiesNeedingUpdate_h | 
|    7  |    7  | 
|    8 #if DCHECK_IS_ON() |    8 #if DCHECK_IS_ON() | 
|    9 namespace blink { |    9 namespace blink { | 
|   10  |   10  | 
|   11 #define DCHECK_PTR_VAL_EQ(ptrA, ptrB) \ |   11 #define DCHECK_PTR_VAL_EQ(ptrA, ptrB) \ | 
|   12   DCHECK((!!ptrA == !!ptrB) && ((!ptrA && !ptrB) || (*ptrA == *ptrB))); |   12   DCHECK((!!ptrA == !!ptrB) && ((!ptrA && !ptrB) || (*ptrA == *ptrB))); | 
|   13  |   13  | 
|   14 // This file contains two scope classes for catching cases where paint |   14 // This file contains two scope classes for catching cases where paint | 
|   15 // properties need an update but where not marked as such. If paint properties |   15 // properties need an update but where not marked as such. If paint properties | 
|   16 // will change, the object must be marked as needing a paint property update |   16 // will change, the object must be marked as needing a paint property update | 
|   17 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate(). |   17 // using {FrameView, LayoutObject}::setNeedsPaintPropertyUpdate(). | 
|   18 // |   18 // | 
|   19 // Both scope classes work by recording the paint property state of an object |   19 // Both scope classes work by recording the paint property state of an object | 
|   20 // before rebuilding properties, forcing the properties to get updated, then |   20 // before rebuilding properties, forcing the properties to get updated, then | 
|   21 // checking that the updated properties match the original properties. |   21 // checking that the updated properties match the original properties. | 
|   22  |   22  | 
|   23 class FindFrameViewPropertiesNeedingUpdateScope { |   23 class FindFrameViewPropertiesNeedingUpdateScope { | 
|   24  public: |   24  public: | 
|   25   FindFrameViewPropertiesNeedingUpdateScope(FrameView* frameView) |   25   FindFrameViewPropertiesNeedingUpdateScope( | 
 |   26       FrameView* frameView, | 
 |   27       PaintPropertyTreeBuilderContext& context) | 
|   26       : m_frameView(frameView), |   28       : m_frameView(frameView), | 
|   27         m_neededPaintPropertyUpdate(frameView->needsPaintPropertyUpdate()) { |   29         m_neededPaintPropertyUpdate(frameView->needsPaintPropertyUpdate()), | 
|   28     // No need to check when already marked as needing an update. |   30         m_neededForcedSubtreeUpdate(context.forceSubtreeUpdate) { | 
|   29     if (m_neededPaintPropertyUpdate) |   31     // No need to check if an update was already needed. | 
 |   32     if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) | 
|   30       return; |   33       return; | 
|   31  |   34  | 
|   32     // Mark the properties as needing an update to ensure they are rebuilt. |   35     // Mark the properties as needing an update to ensure they are rebuilt. | 
|   33     m_frameView->setNeedsPaintPropertyUpdate(); |   36     m_frameView->setOnlyThisNeedsPaintPropertyUpdateForTesting(); | 
 |   37  | 
|   34     if (auto* preTranslation = m_frameView->preTranslation()) |   38     if (auto* preTranslation = m_frameView->preTranslation()) | 
|   35       m_preTranslation = preTranslation->clone(); |   39       m_preTranslation = preTranslation->clone(); | 
|   36     if (auto* contentClip = m_frameView->contentClip()) |   40     if (auto* contentClip = m_frameView->contentClip()) | 
|   37       m_contentClip = contentClip->clone(); |   41       m_contentClip = contentClip->clone(); | 
|   38     if (auto* scrollTranslation = m_frameView->scrollTranslation()) |   42     if (auto* scrollTranslation = m_frameView->scrollTranslation()) | 
|   39       m_scrollTranslation = scrollTranslation->clone(); |   43       m_scrollTranslation = scrollTranslation->clone(); | 
|   40     if (auto* scroll = m_frameView->scroll()) |   44     if (auto* scroll = m_frameView->scroll()) | 
|   41       m_scroll = scroll->clone(); |   45       m_scroll = scroll->clone(); | 
|   42   } |   46   } | 
|   43  |   47  | 
|   44   ~FindFrameViewPropertiesNeedingUpdateScope() { |   48   ~FindFrameViewPropertiesNeedingUpdateScope() { | 
|   45     // No need to check when already marked as needing an update. |   49     // No need to check if an update was already needed. | 
|   46     if (m_neededPaintPropertyUpdate) |   50     if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) | 
|   47       return; |   51       return; | 
|   48  |   52  | 
|   49     // If paint properties are not marked as needing an update but still change, |   53     // If paint properties are not marked as needing an update but still change, | 
|   50     // we are missing a call to FrameView::setNeedsPaintPropertyUpdate(). |   54     // we are missing a call to FrameView::setNeedsPaintPropertyUpdate(). | 
|   51     DCHECK_PTR_VAL_EQ(m_preTranslation, m_frameView->preTranslation()); |   55     DCHECK_PTR_VAL_EQ(m_preTranslation, m_frameView->preTranslation()); | 
|   52     DCHECK_PTR_VAL_EQ(m_contentClip, m_frameView->contentClip()); |   56     DCHECK_PTR_VAL_EQ(m_contentClip, m_frameView->contentClip()); | 
|   53     DCHECK_PTR_VAL_EQ(m_scrollTranslation, m_frameView->scrollTranslation()); |   57     DCHECK_PTR_VAL_EQ(m_scrollTranslation, m_frameView->scrollTranslation()); | 
|   54     DCHECK_PTR_VAL_EQ(m_scroll, m_frameView->scroll()); |   58     DCHECK_PTR_VAL_EQ(m_scroll, m_frameView->scroll()); | 
 |   59  | 
|   55     // Restore original clean bit. |   60     // Restore original clean bit. | 
|   56     m_frameView->clearNeedsPaintPropertyUpdate(); |   61     m_frameView->clearNeedsPaintPropertyUpdate(); | 
|   57   } |   62   } | 
|   58  |   63  | 
|   59  private: |   64  private: | 
|   60   Persistent<FrameView> m_frameView; |   65   Persistent<FrameView> m_frameView; | 
|   61   bool m_neededPaintPropertyUpdate; |   66   bool m_neededPaintPropertyUpdate; | 
 |   67   bool m_neededForcedSubtreeUpdate; | 
|   62   RefPtr<TransformPaintPropertyNode> m_preTranslation; |   68   RefPtr<TransformPaintPropertyNode> m_preTranslation; | 
|   63   RefPtr<ClipPaintPropertyNode> m_contentClip; |   69   RefPtr<ClipPaintPropertyNode> m_contentClip; | 
|   64   RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |   70   RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 
|   65   RefPtr<ScrollPaintPropertyNode> m_scroll; |   71   RefPtr<ScrollPaintPropertyNode> m_scroll; | 
|   66 }; |   72 }; | 
|   67  |   73  | 
|   68 class FindObjectPropertiesNeedingUpdateScope { |   74 class FindObjectPropertiesNeedingUpdateScope { | 
|   69  public: |   75  public: | 
|   70   FindObjectPropertiesNeedingUpdateScope(const LayoutObject& object) |   76   FindObjectPropertiesNeedingUpdateScope( | 
 |   77       const LayoutObject& object, | 
 |   78       PaintPropertyTreeBuilderContext& context) | 
|   71       : m_object(object), |   79       : m_object(object), | 
|   72         m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()) { |   80         m_neededPaintPropertyUpdate(object.needsPaintPropertyUpdate()), | 
|   73     // No need to check when already marked as needing an update. |   81         m_neededForcedSubtreeUpdate(context.forceSubtreeUpdate) { | 
|   74     if (m_neededPaintPropertyUpdate) |   82     // No need to check if an update was already needed. | 
 |   83     if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) | 
|   75       return; |   84       return; | 
|   76  |   85  | 
|   77     // Mark the properties as needing an update to ensure they are rebuilt. |   86     // Mark the properties as needing an update to ensure they are rebuilt. | 
|   78     const_cast<LayoutObject&>(m_object).setNeedsPaintPropertyUpdate(); |   87     const_cast<LayoutObject&>(m_object) | 
 |   88         .setOnlyThisNeedsPaintPropertyUpdateForTesting(); | 
 |   89  | 
|   79     if (const auto* properties = m_object.paintProperties()) |   90     if (const auto* properties = m_object.paintProperties()) | 
|   80       m_properties = properties->clone(); |   91       m_properties = properties->clone(); | 
|   81   } |   92   } | 
|   82  |   93  | 
|   83   ~FindObjectPropertiesNeedingUpdateScope() { |   94   ~FindObjectPropertiesNeedingUpdateScope() { | 
|   84     // No need to check when already marked as needing an update. |   95     // No need to check if an update was already needed. | 
|   85     if (m_neededPaintPropertyUpdate) |   96     if (m_neededPaintPropertyUpdate || m_neededForcedSubtreeUpdate) | 
|   86       return; |   97       return; | 
|   87  |   98  | 
|   88     // If paint properties are not marked as needing an update but still change, |   99     // If paint properties are not marked as needing an update but still change, | 
|   89     // we are missing a call to LayoutObject::setNeedsPaintPropertyUpdate(). |  100     // we are missing a call to LayoutObject::setNeedsPaintPropertyUpdate(). | 
|   90     const auto* objectProperties = m_object.paintProperties(); |  101     const auto* objectProperties = m_object.paintProperties(); | 
|   91     if (m_properties && objectProperties) { |  102     if (m_properties && objectProperties) { | 
|   92       DCHECK_PTR_VAL_EQ(m_properties->paintOffsetTranslation(), |  103       DCHECK_PTR_VAL_EQ(m_properties->paintOffsetTranslation(), | 
|   93                         objectProperties->paintOffsetTranslation()); |  104                         objectProperties->paintOffsetTranslation()); | 
|   94       DCHECK_PTR_VAL_EQ(m_properties->transform(), |  105       DCHECK_PTR_VAL_EQ(m_properties->transform(), | 
|   95                         objectProperties->transform()); |  106                         objectProperties->transform()); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  128     } else { |  139     } else { | 
|  129       DCHECK_EQ(!!m_properties, !!objectProperties); |  140       DCHECK_EQ(!!m_properties, !!objectProperties); | 
|  130     } |  141     } | 
|  131     // Restore original clean bit. |  142     // Restore original clean bit. | 
|  132     const_cast<LayoutObject&>(m_object).clearNeedsPaintPropertyUpdate(); |  143     const_cast<LayoutObject&>(m_object).clearNeedsPaintPropertyUpdate(); | 
|  133   } |  144   } | 
|  134  |  145  | 
|  135  private: |  146  private: | 
|  136   const LayoutObject& m_object; |  147   const LayoutObject& m_object; | 
|  137   bool m_neededPaintPropertyUpdate; |  148   bool m_neededPaintPropertyUpdate; | 
 |  149   bool m_neededForcedSubtreeUpdate; | 
|  138   std::unique_ptr<const ObjectPaintProperties> m_properties; |  150   std::unique_ptr<const ObjectPaintProperties> m_properties; | 
|  139 }; |  151 }; | 
|  140  |  152  | 
|  141 }  // namespace blink |  153 }  // namespace blink | 
|  142 #endif  // DCHECK_IS_ON() |  154 #endif  // DCHECK_IS_ON() | 
|  143  |  155  | 
|  144 #endif  // FindPropertiesNeedingUpdate_h |  156 #endif  // FindPropertiesNeedingUpdate_h | 
| OLD | NEW |