| 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() { } |
| 18 PrePaintTreeWalkContext(const PaintPropertyTreeBuilderContext& parentTreeBui
lderContext) |
| 19 : treeBuilderContext(parentTreeBuilderContext) { } |
| 20 |
| 17 PaintPropertyTreeBuilderContext treeBuilderContext; | 21 PaintPropertyTreeBuilderContext treeBuilderContext; |
| 22 // This will be initialized by PaintInvalidator::invalidatePaintIfNeeded(). |
| 23 // TODO(wangxianzhu): Change to copy-and-update pattern like PaintPropertyTr
eeBuilderContext. |
| 24 Optional<PaintInvalidatorContext> paintInvalidatorContext; |
| 18 }; | 25 }; |
| 19 | 26 |
| 20 void PrePaintTreeWalk::walk(FrameView& rootFrame) | 27 void PrePaintTreeWalk::walk(FrameView& rootFrame) |
| 21 { | 28 { |
| 22 DCHECK(rootFrame.frame().document()->lifecycle().state() == DocumentLifecycl
e::InPrePaint); | 29 DCHECK(rootFrame.frame().document()->lifecycle().state() == DocumentLifecycl
e::InPrePaint); |
| 23 | 30 |
| 24 PaintPropertyTreeBuilderRootContext treeBuilderRootContext; | 31 PrePaintTreeWalkContext rootContext; |
| 25 m_propertyTreeBuilder.buildTreeRootNodes(rootFrame, treeBuilderRootContext); | 32 m_propertyTreeBuilder.buildTreeRootNodes(rootFrame, rootContext.treeBuilderC
ontext); |
| 26 PrePaintTreeWalkContext rootContext = { treeBuilderRootContext }; | |
| 27 walk(rootFrame, rootContext); | 33 walk(rootFrame, rootContext); |
| 34 m_paintInvalidator.processPendingDelayedPaintInvalidations(); |
| 28 } | 35 } |
| 29 | 36 |
| 30 void PrePaintTreeWalk::walk(FrameView& frameView, const PrePaintTreeWalkContext&
context) | 37 void PrePaintTreeWalk::walk(FrameView& frameView, const PrePaintTreeWalkContext&
context) |
| 31 { | 38 { |
| 32 PrePaintTreeWalkContext localContext(context); | 39 PrePaintTreeWalkContext localContext(context.treeBuilderContext); |
| 33 m_propertyTreeBuilder.buildTreeNodes(frameView, localContext.treeBuilderCont
ext); | 40 m_propertyTreeBuilder.buildTreeNodes(frameView, localContext.treeBuilderCont
ext); |
| 41 |
| 42 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 43 m_paintInvalidator.invalidatePaintIfNeeded(frameView, localContext.treeB
uilderContext, localContext.paintInvalidatorContext); |
| 44 |
| 34 if (LayoutView* layoutView = frameView.layoutView()) | 45 if (LayoutView* layoutView = frameView.layoutView()) |
| 35 walk(*layoutView, localContext); | 46 walk(*layoutView, localContext); |
| 36 } | 47 } |
| 37 | 48 |
| 38 void PrePaintTreeWalk::walk(const LayoutObject& object, const PrePaintTreeWalkCo
ntext& context) | 49 void PrePaintTreeWalk::walk(const LayoutObject& object, const PrePaintTreeWalkCo
ntext& context) |
| 39 { | 50 { |
| 40 PrePaintTreeWalkContext localContext(context); | 51 PrePaintTreeWalkContext localContext(context.treeBuilderContext); |
| 41 m_propertyTreeBuilder.buildTreeNodes(object, localContext.treeBuilderContext
); | 52 m_propertyTreeBuilder.buildTreeNodes(object, localContext.treeBuilderContext
); |
| 42 | 53 |
| 54 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && context.pa
intInvalidatorContext) |
| 55 m_paintInvalidator.invalidatePaintIfNeeded(object, localContext.treeBuil
derContext, *context.paintInvalidatorContext, localContext.paintInvalidatorConte
xt); |
| 56 |
| 43 for (const LayoutObject* child = object.slowFirstChild(); child; child = chi
ld->nextSibling()) { | 57 for (const LayoutObject* child = object.slowFirstChild(); child; child = chi
ld->nextSibling()) { |
| 44 if (!child->isBoxModelObject() && !child->isSVG()) | |
| 45 continue; | |
| 46 // Column spanners are walked through their placeholders. See below. | 58 // Column spanners are walked through their placeholders. See below. |
| 47 if (child->isColumnSpanAll()) | 59 if (child->isColumnSpanAll()) |
| 48 continue; | 60 continue; |
| 49 walk(*child, localContext); | 61 walk(*child, localContext); |
| 50 } | 62 } |
| 51 | 63 |
| 52 if (object.isLayoutMultiColumnSpannerPlaceholder()) | 64 if (object.isLayoutMultiColumnSpannerPlaceholder()) |
| 53 walk(*toLayoutMultiColumnSpannerPlaceholder(object).layoutObjectInFlowTh
read(), localContext); | 65 walk(*toLayoutMultiColumnSpannerPlaceholder(object).layoutObjectInFlowTh
read(), localContext); |
| 54 | 66 |
| 55 if (object.isLayoutPart()) { | 67 if (object.isLayoutPart()) { |
| 56 Widget* widget = toLayoutPart(object).widget(); | 68 Widget* widget = toLayoutPart(object).widget(); |
| 57 if (widget && widget->isFrameView()) | 69 if (widget && widget->isFrameView()) |
| 58 walk(*toFrameView(widget), localContext); | 70 walk(*toFrameView(widget), localContext); |
| 59 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 71 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
| 60 } | 72 } |
| 61 } | 73 } |
| 62 | 74 |
| 63 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |