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/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 } | |
trchen
2016/08/17 05:57:47
I think we should not create effect nodes for Layo
szager1
2016/08/17 19:21:34
Done.
| |
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()); | |
trchen
2016/08/17 05:57:47
It feels weird. We should not include LayoutView l
szager1
2016/08/17 19:21:34
Once root layer scrolling is enabled, FrameView sh
trchen
2016/08/17 21:30:55
That'd be great! I tried to do that 2 weeks ago bu
szager1
2016/08/19 01:52:13
This entire patch is intended match old-world beha
| |
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 Loading... | |
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()) | |
pdr.
2016/08/17 04:30:41
Can you add a comment here about why we don't clea
trchen
2016/08/17 05:57:47
I'd rather add CHECK(!object.isLayoutView()) on li
szager1
2016/08/17 19:21:34
With root layer scrolling, every LayoutView must h
trchen
2016/08/17 21:30:55
Does that match the behavior of old-world composit
szager1
2016/08/19 01:52:13
I'm not sure what "long term" is here. Chromium i
| |
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 Loading... | |
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 context.current.renderingContextID = 0; | 347 context.current.renderingContextID = 0; |
315 } | 348 } |
316 | 349 |
317 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec t, PaintPropertyTreeBuilderContext& context) | 350 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec t, PaintPropertyTreeBuilderContext& context) |
318 { | 351 { |
319 if (object.isBoxModelObject() && object.hasOverflowClip()) { | 352 if (object.isBoxModelObject() && object.hasOverflowClip()) { |
320 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | 353 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
321 DCHECK(layer); | 354 DCHECK(layer); |
322 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); | 355 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); |
323 | 356 |
324 if (!scrollOffset.isZero() || layer->scrollsOverflow()) { | 357 if (object.isLayoutView()) { |
skobes
2016/08/17 01:38:24
Why does the LayoutView have a separate path here?
trchen
2016/08/17 05:57:47
Yea... I can't spot any difference either.
szager1
2016/08/17 19:21:34
The difference is that LayoutView will get a scrol
| |
358 Settings* settings = object.document().settings(); | |
359 if (settings && settings->rootLayerScrolls()) { | |
360 context.current.transform = object.getMutableForPainting().ensur eObjectPaintProperties().createOrUpdateScrollTranslation(context.current.transfo rm, TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height ()), FloatPoint3D()); | |
361 context.current.shouldFlattenInheritedTransform = false; | |
362 return; | |
363 } | |
364 } else if (!scrollOffset.isZero() || layer->scrollsOverflow()) { | |
325 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); | 365 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); |
326 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( | 366 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( |
327 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); | 367 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); |
328 context.current.shouldFlattenInheritedTransform = false; | 368 context.current.shouldFlattenInheritedTransform = false; |
329 return; | 369 return; |
330 } | 370 } |
331 } | 371 } |
332 | 372 |
333 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) | 373 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) |
334 properties->clearScrollTranslation(); | 374 properties->clearScrollTranslation(); |
335 } | 375 } |
336 | 376 |
337 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) | 377 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) |
338 { | 378 { |
339 if (object.canContainAbsolutePositionObjects()) { | 379 if (object.canContainAbsolutePositionObjects()) { |
340 context.absolutePosition = context.current; | 380 context.absolutePosition = context.current; |
341 context.containerForAbsolutePosition = &object; | 381 context.containerForAbsolutePosition = &object; |
342 } | 382 } |
343 | 383 |
344 // TODO(pdr): Remove the !object.isLayoutView() condition when removing Fram eView | 384 if (object.isLayoutView()) { |
trchen
2016/08/17 05:57:47
It is unfortunate that canContainFixedPositionObje
szager1
2016/08/17 19:21:34
Be that as it may, I think that changing the retur
trchen
2016/08/17 21:30:55
I think it should return nullptr and the element w
szager1
2016/08/19 01:52:12
This is exactly the code that special-cases Layout
| |
345 // paint properties for rootLayerScrolls. | 385 Settings* settings = object.document().settings(); |
346 if (!object.isLayoutView() && object.canContainFixedPositionObjects()) { | 386 if (settings && settings->rootLayerScrolls()) { |
387 context.fixedPosition = context.current; | |
388 const TransformPaintPropertyNode* transform = object.objectPaintProp erties()->paintOffsetTranslation(); | |
389 DCHECK(transform); | |
390 context.fixedPosition.transform = transform; | |
391 } | |
392 } else if (object.canContainFixedPositionObjects()) { | |
347 context.fixedPosition = context.current; | 393 context.fixedPosition = context.current; |
348 } else if (object.getMutableForPainting().objectPaintProperties() && object. objectPaintProperties()->cssClip()) { | 394 } 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 | 395 // 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 | 396 // 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 | 397 // 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 | 398 // descendants we need to insert the clip here if we are not a containin g block ancestor |
353 // of them. | 399 // of them. |
354 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); | 400 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); |
355 | 401 |
356 // Before we actually create anything, check whether in-flow context and fixed-position | 402 // 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 Loading... | |
431 updateLocalBorderBoxContext(object, context); | 477 updateLocalBorderBoxContext(object, context); |
432 updateScrollbarPaintOffset(object, context); | 478 updateScrollbarPaintOffset(object, context); |
433 updateOverflowClip(object, context); | 479 updateOverflowClip(object, context); |
434 updatePerspective(object, context); | 480 updatePerspective(object, context); |
435 updateSvgLocalToBorderBoxTransform(object, context); | 481 updateSvgLocalToBorderBoxTransform(object, context); |
436 updateScrollTranslation(object, context); | 482 updateScrollTranslation(object, context); |
437 updateOutOfFlowContext(object, context); | 483 updateOutOfFlowContext(object, context); |
438 } | 484 } |
439 | 485 |
440 } // namespace blink | 486 } // namespace blink |
OLD | NEW |