Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef LayoutObjectSubtreeRecorder_h | |
| 6 #define LayoutObjectSubtreeRecorder_h | |
| 7 | |
| 8 #include "core/layout/LayoutObject.h" | |
| 9 #include "core/paint/PaintPhase.h" | |
| 10 #include "platform/graphics/paint/SubtreeRecorder.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 class GraphicsContext; | |
| 15 | |
| 16 // Convenience wrapper of SubtreeRecorder for LayoutObject painters. | |
|
pdr.
2015/08/20 22:45:06
Do we need subtree recorders for anything but layo
Xianzhu
2015/08/21 00:31:38
Done.
Previously I moved SubtreeRecorder from cor
| |
| 17 class LayoutObjectSubtreeRecorder final { | |
| 18 public: | |
| 19 LayoutObjectSubtreeRecorder(GraphicsContext& context, const LayoutObject& la youtObject, PaintPhase phase) | |
| 20 : m_canUseCache(false) | |
| 21 #if ENABLE(ASSERT) | |
| 22 #endif | |
| 23 { | |
| 24 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 25 return; | |
| 26 if (!needsSubtreeRecorder(layoutObject)) | |
| 27 return; | |
| 28 | |
| 29 m_canUseCache = !layoutObject.shouldCheckForRepaint() && SubtreeRecorder ::useCachedSubtreeIfPossible(context, layoutObject, phase); | |
| 30 if (!m_canUseCache) | |
| 31 m_subtreeRecorder.emplace(context, layoutObject, phase); | |
| 32 } | |
| 33 | |
| 34 bool canUseCache() const { return m_canUseCache; } | |
| 35 | |
| 36 private: | |
| 37 // We need to balance the benefit of subtree optimization and the cost of su btree display items. | |
| 38 // Only output subtree information if the block has multiple children or mul tiple line boxes. | |
| 39 static bool needsSubtreeRecorder(const LayoutObject& layoutObject) | |
| 40 { | |
| 41 return (layoutObject.slowFirstChild() && layoutObject.slowFirstChild()-> nextSibling()) | |
| 42 || (layoutObject.isLayoutBlockFlow() && toLayoutBlockFlow(layoutObje ct).firstLineBox() && toLayoutBlockFlow(layoutObject).firstLineBox()->nextLineBo x()); | |
| 43 } | |
| 44 | |
| 45 Optional<SubtreeRecorder> m_subtreeRecorder; | |
| 46 bool m_canUseCache; | |
|
pdr.
2015/08/20 22:45:06
I think we can reuse the pointer in m_subtreeRecor
Xianzhu
2015/08/21 00:31:38
Done.
| |
| 47 #if ENABLE(ASSERT) | |
|
pdr.
2015/08/20 22:45:06
Oops
Xianzhu
2015/08/21 00:31:38
Done.
| |
| 48 | |
| 49 #endif | |
| 50 }; | |
| 51 | |
| 52 } // namespace blink | |
| 53 | |
| 54 #endif // LayoutObjectSubtreeRecorder_h | |
| OLD | NEW |