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 #include "core/paint/PrePaintTreeWalk.h" | 5 #include "core/paint/PrePaintTreeWalk.h" |
6 | 6 |
7 #include "core/dom/DocumentLifecycle.h" | 7 #include "core/dom/DocumentLifecycle.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
11 #include "core/layout/LayoutPart.h" | 11 #include "core/layout/LayoutPart.h" |
12 #include "core/layout/LayoutView.h" | 12 #include "core/layout/LayoutView.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 struct PrePaintTreeWalkContext { | 16 struct PrePaintTreeWalkContext { |
17 PrePaintTreeWalkContext() { } | 17 PrePaintTreeWalkContext() : paintInvalidatorContext(treeBuilderContext) { } |
18 PrePaintTreeWalkContext(const PaintPropertyTreeBuilderContext& parentTreeBui
lderContext) | 18 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext) |
19 : treeBuilderContext(parentTreeBuilderContext) { } | 19 : treeBuilderContext(parentContext.treeBuilderContext) |
| 20 , paintInvalidatorContext(treeBuilderContext, parentContext.paintInvalid
atorContext) |
| 21 { } |
20 | 22 |
21 PaintPropertyTreeBuilderContext treeBuilderContext; | 23 PaintPropertyTreeBuilderContext treeBuilderContext; |
22 // This will be initialized by PaintInvalidator::invalidatePaintIfNeeded(). | 24 PaintInvalidatorContext paintInvalidatorContext; |
23 // TODO(wangxianzhu): Change to copy-and-update pattern like PaintPropertyTr
eeBuilderContext. | |
24 Optional<PaintInvalidatorContext> paintInvalidatorContext; | |
25 }; | 25 }; |
26 | 26 |
27 void PrePaintTreeWalk::walk(FrameView& rootFrame) | 27 void PrePaintTreeWalk::walk(FrameView& rootFrame) |
28 { | 28 { |
29 DCHECK(rootFrame.frame().document()->lifecycle().state() == DocumentLifecycl
e::InPrePaint); | 29 DCHECK(rootFrame.frame().document()->lifecycle().state() == DocumentLifecycl
e::InPrePaint); |
30 | 30 |
31 PrePaintTreeWalkContext rootContext; | 31 PrePaintTreeWalkContext rootContext; |
32 m_propertyTreeBuilder.buildTreeRootNodes(rootFrame, rootContext.treeBuilderC
ontext); | 32 m_propertyTreeBuilder.buildTreeRootNodes(rootFrame, rootContext.treeBuilderC
ontext); |
33 walk(rootFrame, rootContext); | 33 walk(rootFrame, rootContext); |
34 m_paintInvalidator.processPendingDelayedPaintInvalidations(); | 34 m_paintInvalidator.processPendingDelayedPaintInvalidations(); |
35 } | 35 } |
36 | 36 |
37 void PrePaintTreeWalk::walk(FrameView& frameView, const PrePaintTreeWalkContext&
context) | 37 void PrePaintTreeWalk::walk(FrameView& frameView, const PrePaintTreeWalkContext&
context) |
38 { | 38 { |
39 PrePaintTreeWalkContext localContext(context.treeBuilderContext); | 39 PrePaintTreeWalkContext localContext(context); |
40 m_propertyTreeBuilder.buildTreeNodes(frameView, localContext.treeBuilderCont
ext); | 40 m_propertyTreeBuilder.buildTreeNodes(frameView, localContext.treeBuilderCont
ext); |
41 | 41 |
42 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | 42 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
43 m_paintInvalidator.invalidatePaintIfNeeded(frameView, localContext.treeB
uilderContext, localContext.paintInvalidatorContext); | 43 m_paintInvalidator.invalidatePaintIfNeeded(frameView, localContext.paint
InvalidatorContext); |
44 | 44 |
45 if (LayoutView* layoutView = frameView.layoutView()) | 45 if (LayoutView* layoutView = frameView.layoutView()) |
46 walk(*layoutView, localContext); | 46 walk(*layoutView, localContext); |
47 } | 47 } |
48 | 48 |
49 void PrePaintTreeWalk::walk(const LayoutObject& object, const PrePaintTreeWalkCo
ntext& context) | 49 void PrePaintTreeWalk::walk(const LayoutObject& object, const PrePaintTreeWalkCo
ntext& context) |
50 { | 50 { |
51 PrePaintTreeWalkContext localContext(context.treeBuilderContext); | 51 PrePaintTreeWalkContext localContext(context); |
52 m_propertyTreeBuilder.buildTreeNodes(object, localContext.treeBuilderContext
); | 52 m_propertyTreeBuilder.buildTreeNodes(object, localContext.treeBuilderContext
); |
53 | 53 |
54 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && context.pa
intInvalidatorContext) | 54 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
55 m_paintInvalidator.invalidatePaintIfNeeded(object, localContext.treeBuil
derContext, *context.paintInvalidatorContext, localContext.paintInvalidatorConte
xt); | 55 m_paintInvalidator.invalidatePaintIfNeeded(object, localContext.paintInv
alidatorContext); |
56 | 56 |
57 for (const LayoutObject* child = object.slowFirstChild(); child; child = chi
ld->nextSibling()) { | 57 for (const LayoutObject* child = object.slowFirstChild(); child; child = chi
ld->nextSibling()) { |
58 // Column spanners are walked through their placeholders. See below. | 58 // Column spanners are walked through their placeholders. See below. |
59 if (child->isColumnSpanAll()) | 59 if (child->isColumnSpanAll()) |
60 continue; | 60 continue; |
61 walk(*child, localContext); | 61 walk(*child, localContext); |
62 } | 62 } |
63 | 63 |
64 if (object.isLayoutMultiColumnSpannerPlaceholder()) | 64 if (object.isLayoutMultiColumnSpannerPlaceholder()) |
65 walk(*toLayoutMultiColumnSpannerPlaceholder(object).layoutObjectInFlowTh
read(), localContext); | 65 walk(*toLayoutMultiColumnSpannerPlaceholder(object).layoutObjectInFlowTh
read(), localContext); |
66 | 66 |
67 if (object.isLayoutPart()) { | 67 if (object.isLayoutPart()) { |
68 const LayoutPart& layoutPart = toLayoutPart(object); | 68 const LayoutPart& layoutPart = toLayoutPart(object); |
69 Widget* widget = layoutPart.widget(); | 69 Widget* widget = layoutPart.widget(); |
70 if (widget && widget->isFrameView()) { | 70 if (widget && widget->isFrameView()) { |
71 localContext.treeBuilderContext.current.paintOffset += layoutPart.re
placedContentRect().location() - widget->frameRect().location(); | 71 localContext.treeBuilderContext.current.paintOffset += layoutPart.re
placedContentRect().location() - widget->frameRect().location(); |
72 localContext.treeBuilderContext.current.paintOffset = roundedIntPoin
t(localContext.treeBuilderContext.current.paintOffset); | 72 localContext.treeBuilderContext.current.paintOffset = roundedIntPoin
t(localContext.treeBuilderContext.current.paintOffset); |
73 walk(*toFrameView(widget), localContext); | 73 walk(*toFrameView(widget), localContext); |
74 } | 74 } |
75 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 75 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 } // namespace blink | 79 } // namespace blink |
OLD | NEW |