Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2244873002: Fix PaintPropertyTreeBuilder for root layer scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@rls-enable
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/PaintPropertyTreeBuilder.h" 5 #include "core/paint/PaintPropertyTreeBuilder.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutInline.h" 10 #include "core/layout/LayoutInline.h"
11 #include "core/layout/LayoutPart.h" 11 #include "core/layout/LayoutPart.h"
12 #include "core/layout/svg/LayoutSVGRoot.h" 12 #include "core/layout/svg/LayoutSVGRoot.h"
13 #include "core/paint/ObjectPaintProperties.h" 13 #include "core/paint/ObjectPaintProperties.h"
14 #include "core/paint/PaintLayer.h" 14 #include "core/paint/PaintLayer.h"
15 #include "core/paint/SVGRootPainter.h" 15 #include "core/paint/SVGRootPainter.h"
16 #include "platform/transforms/TransformationMatrix.h" 16 #include "platform/transforms/TransformationMatrix.h"
17 #include "wtf/PtrUtil.h" 17 #include "wtf/PtrUtil.h"
18 #include <memory> 18 #include <memory>
19 19
20 namespace blink { 20 namespace blink {
21 21
22 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro pertyTreeBuilderContext& context) 22 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro pertyTreeBuilderContext& context)
23 { 23 {
24 Settings* settings = rootFrame.frame().settings();
25 if (settings && settings->rootLayerScrolls())
26 return;
27
24 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { 28 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) {
25 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T ransformationMatrix(), FloatPoint3D())); 29 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T ransformationMatrix(), FloatPoint3D()));
26 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); 30 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect())));
27 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); 31 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0));
28 } else { 32 } else {
29 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); 33 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent());
30 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); 34 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent());
31 } 35 }
32 36
33 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootFrame.rootTransform(); 37 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootFrame.rootTransform();
34 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootFrame.rootClip(); 38 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootFrame.rootClip();
35 context.currentEffect = rootFrame.rootEffect(); 39 context.currentEffect = rootFrame.rootEffect();
36 } 40 }
37 41
38 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert yTreeBuilderContext& context) 42 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert yTreeBuilderContext& context)
39 { 43 {
40 // TODO(pdr): Creating paint properties for FrameView here will not be 44 Settings* settings = frameView.frame().settings();
41 // needed once settings()->rootLayerScrolls() is enabled. 45 if (settings && settings->rootLayerScrolls()) {
42 // TODO(pdr): Make this conditional on the rootLayerScrolls setting. 46 LayoutView* layoutView = frameView.layoutView();
47 if (!layoutView)
48 return;
49
50 if (!context.currentEffect) {
51 DCHECK(frameView.frame().isLocalRoot());
52 context.currentEffect = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdateEffect(nullptr, 1.0);
53 }
54
55 TransformationMatrix frameTranslate;
56 frameTranslate.translate(
57 frameView.x() + layoutView->location().x() + context.current.paintOf fset.x(),
58 frameView.y() + layoutView->location().y() + context.current.paintOf fset.y());
59 context.current.transform = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdatePaintOffsetTranslation(
60 context.current.transform, frameTranslate, FloatPoint3D());
61 context.current.paintOffset = LayoutPoint();
62 context.current.clip = nullptr; // This will get set in updateOverflowCl ip().
63 context.current.renderingContextID = 0;
64 context.current.shouldFlattenInheritedTransform = true;
65 context.absolutePosition = context.current;
66 context.containerForAbsolutePosition = nullptr; // This will get set in updateOutOfFlowContext().
67 context.fixedPosition = context.current;
68 return;
69 }
43 70
44 TransformationMatrix frameTranslate; 71 TransformationMatrix frameTranslate;
45 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), fr ameView.y() + context.current.paintOffset.y()); 72 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), fr ameView.y() + context.current.paintOffset.y());
46 if (TransformPaintPropertyNode* existingPreTranslation = frameView.preTransl ation()) 73 if (TransformPaintPropertyNode* existingPreTranslation = frameView.preTransl ation())
47 existingPreTranslation->update(context.current.transform, frameTranslate , FloatPoint3D()); 74 existingPreTranslation->update(context.current.transform, frameTranslate , FloatPoint3D());
48 else 75 else
49 frameView.setPreTranslation(TransformPaintPropertyNode::create(context.c urrent.transform, frameTranslate, FloatPoint3D())); 76 frameView.setPreTranslation(TransformPaintPropertyNode::create(context.c urrent.transform, frameTranslate, FloatPoint3D()));
50 77
51 FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSiz e())); 78 FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSiz e()));
52 if (ClipPaintPropertyNode* existingContentClip = frameView.contentClip()) 79 if (ClipPaintPropertyNode* existingContentClip = frameView.contentClip())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 LayoutPoint fractionalPaintOffset = LayoutPoint(context.current.pain tOffset - roundedPaintOffset); 118 LayoutPoint fractionalPaintOffset = LayoutPoint(context.current.pain tOffset - roundedPaintOffset);
92 119
93 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdatePaintOffsetTranslation( 120 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdatePaintOffsetTranslation(
94 context.current.transform, TransformationMatrix().translate(roun dedPaintOffset.x(), roundedPaintOffset.y()), FloatPoint3D(), 121 context.current.transform, TransformationMatrix().translate(roun dedPaintOffset.x(), roundedPaintOffset.y()), FloatPoint3D(),
95 context.current.shouldFlattenInheritedTransform, context.current .renderingContextID); 122 context.current.shouldFlattenInheritedTransform, context.current .renderingContextID);
96 context.current.paintOffset = fractionalPaintOffset; 123 context.current.paintOffset = fractionalPaintOffset;
97 return; 124 return;
98 } 125 }
99 } 126 }
100 127
128 if (object.isLayoutView())
129 return;
130
101 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) 131 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties())
102 properties->clearPaintOffsetTranslation(); 132 properties->clearPaintOffsetTranslation();
103 } 133 }
104 134
105 static FloatPoint3D transformOrigin(const LayoutBox& box) 135 static FloatPoint3D transformOrigin(const LayoutBox& box)
106 { 136 {
107 const ComputedStyle& style = box.styleRef(); 137 const ComputedStyle& style = box.styleRef();
108 FloatSize borderBoxSize(box.size()); 138 FloatSize borderBoxSize(box.size());
109 return FloatPoint3D( 139 return FloatPoint3D(
110 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), 140 floatValueForLength(style.transformOriginX(), borderBoxSize.width()),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return; 192 return;
163 } 193 }
164 } 194 }
165 195
166 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) 196 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties())
167 properties->clearTransform(); 197 properties->clearTransform();
168 } 198 }
169 199
170 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) 200 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context)
171 { 201 {
202 if (object.isLayoutView())
203 return;
204
172 if (!object.styleRef().hasOpacity()) { 205 if (!object.styleRef().hasOpacity()) {
173 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties()) 206 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties())
174 properties->clearEffect(); 207 properties->clearEffect();
175 return; 208 return;
176 } 209 }
177 210
178 context.currentEffect = object.getMutableForPainting().ensureObjectPaintProp erties().createOrUpdateEffect( 211 context.currentEffect = object.getMutableForPainting().ensureObjectPaintProp erties().createOrUpdateEffect(
179 context.currentEffect, object.styleRef().opacity()); 212 context.currentEffect, object.styleRef().opacity());
180 } 213 }
181 214
(...skipping 18 matching lines...) Expand all
200 void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o bject, const PaintPropertyTreeBuilderContext& context) 233 void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o bject, const PaintPropertyTreeBuilderContext& context)
201 { 234 {
202 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since we don't need them at the moment. 235 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since we don't need them at the moment.
203 if (!object.isBox() && !object.hasLayer()) 236 if (!object.isBox() && !object.hasLayer())
204 return; 237 return;
205 238
206 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo ntext = 239 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo ntext =
207 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); 240 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties);
208 borderBoxContext->paintOffset = context.current.paintOffset; 241 borderBoxContext->paintOffset = context.current.paintOffset;
209 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran sform, context.current.clip, context.currentEffect); 242 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran sform, context.current.clip, context.currentEffect);
243
210 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB oxProperties(std::move(borderBoxContext)); 244 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB oxProperties(std::move(borderBoxContext));
211 } 245 }
212 246
213 // TODO(trchen): Remove this once we bake the paint offset into frameRect. 247 // TODO(trchen): Remove this once we bake the paint offset into frameRect.
214 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(const LayoutObject& ob ject, const PaintPropertyTreeBuilderContext& context) 248 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(const LayoutObject& ob ject, const PaintPropertyTreeBuilderContext& context)
215 { 249 {
216 IntPoint roundedPaintOffset = roundedIntPoint(context.current.paintOffset); 250 IntPoint roundedPaintOffset = roundedIntPoint(context.current.paintOffset);
217 if (roundedPaintOffset != IntPoint() && object.isBoxModelObject()) { 251 if (roundedPaintOffset != IntPoint() && object.isBoxModelObject()) {
218 if (PaintLayerScrollableArea* scrollableArea = toLayoutBoxModelObject(ob ject).getScrollableArea()) { 252 if (PaintLayerScrollableArea* scrollableArea = toLayoutBoxModelObject(ob ject).getScrollableArea()) {
219 if (scrollableArea->horizontalScrollbar() || scrollableArea->vertica lScrollbar()) { 253 if (scrollableArea->horizontalScrollbar() || scrollableArea->vertica lScrollbar()) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 context.current.renderingContextID = 0; 348 context.current.renderingContextID = 0;
315 } 349 }
316 350
317 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec t, PaintPropertyTreeBuilderContext& context) 351 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec t, PaintPropertyTreeBuilderContext& context)
318 { 352 {
319 if (object.isBoxModelObject() && object.hasOverflowClip()) { 353 if (object.isBoxModelObject() && object.hasOverflowClip()) {
320 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); 354 PaintLayer* layer = toLayoutBoxModelObject(object).layer();
321 DCHECK(layer); 355 DCHECK(layer);
322 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); 356 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset();
323 357
324 if (!scrollOffset.isZero() || layer->scrollsOverflow()) { 358 if (object.isLayoutView()) {
359 Settings* settings = object.document().settings();
360 if (settings && settings->rootLayerScrolls()) {
361 context.current.transform = object.getMutableForPainting().ensur eObjectPaintProperties().createOrUpdateScrollTranslation(context.current.transfo rm, TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height ()), FloatPoint3D());
362 context.current.shouldFlattenInheritedTransform = false;
363 return;
364 }
365 } else if (!scrollOffset.isZero() || layer->scrollsOverflow()) {
325 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); 366 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height());
326 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( 367 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation(
327 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); 368 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID);
328 context.current.shouldFlattenInheritedTransform = false; 369 context.current.shouldFlattenInheritedTransform = false;
329 return; 370 return;
330 } 371 }
331 } 372 }
332 373
333 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) 374 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties())
334 properties->clearScrollTranslation(); 375 properties->clearScrollTranslation();
335 } 376 }
336 377
337 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) 378 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context)
338 { 379 {
339 if (object.canContainAbsolutePositionObjects()) { 380 if (object.canContainAbsolutePositionObjects()) {
340 context.absolutePosition = context.current; 381 context.absolutePosition = context.current;
341 context.containerForAbsolutePosition = &object; 382 context.containerForAbsolutePosition = &object;
342 } 383 }
343 384
344 // TODO(pdr): Remove the !object.isLayoutView() condition when removing Fram eView 385 if (object.isLayoutView()) {
345 // paint properties for rootLayerScrolls. 386 Settings* settings = object.document().settings();
346 if (!object.isLayoutView() && object.canContainFixedPositionObjects()) { 387 if (settings && settings->rootLayerScrolls()) {
388 context.fixedPosition = context.current;
389 const TransformPaintPropertyNode* transform = object.objectPaintProp erties()->paintOffsetTranslation();
390 DCHECK(transform);
391 context.fixedPosition.transform = transform;
392 }
393 } else if (object.canContainFixedPositionObjects()) {
347 context.fixedPosition = context.current; 394 context.fixedPosition = context.current;
348 } else if (object.getMutableForPainting().objectPaintProperties() && object. objectPaintProperties()->cssClip()) { 395 } else if (object.getMutableForPainting().objectPaintProperties() && object. objectPaintProperties()->cssClip()) {
349 // CSS clip applies to all descendants, even if this object is not a con taining block 396 // CSS clip applies to all descendants, even if this object is not a con taining block
350 // ancestor of the descendant. It is okay for absolute-position descenda nts because 397 // ancestor of the descendant. It is okay for absolute-position descenda nts because
351 // having CSS clip implies being absolute position container. However fo r fixed-position 398 // having CSS clip implies being absolute position container. However fo r fixed-position
352 // descendants we need to insert the clip here if we are not a containin g block ancestor 399 // descendants we need to insert the clip here if we are not a containin g block ancestor
353 // of them. 400 // of them.
354 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); 401 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip();
355 402
356 // Before we actually create anything, check whether in-flow context and fixed-position 403 // Before we actually create anything, check whether in-flow context and fixed-position
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 updateLocalBorderBoxContext(object, context); 478 updateLocalBorderBoxContext(object, context);
432 updateScrollbarPaintOffset(object, context); 479 updateScrollbarPaintOffset(object, context);
433 updateOverflowClip(object, context); 480 updateOverflowClip(object, context);
434 updatePerspective(object, context); 481 updatePerspective(object, context);
435 updateSvgLocalToBorderBoxTransform(object, context); 482 updateSvgLocalToBorderBoxTransform(object, context);
436 updateScrollTranslation(object, context); 483 updateScrollTranslation(object, context);
437 updateOutOfFlowContext(object, context); 484 updateOutOfFlowContext(object, context);
438 } 485 }
439 486
440 } // namespace blink 487 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698