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 TransformationMatrix frameTranslate; | |
51 frameTranslate.translate( | |
52 frameView.x() + layoutView->location().x() + context.current.paintOf fset.x(), | |
53 frameView.y() + layoutView->location().y() + context.current.paintOf fset.y()); | |
54 context.current.transform = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdatePaintOffsetTranslation( | |
55 context.current.transform, frameTranslate, FloatPoint3D()); | |
56 context.current.paintOffset = LayoutPoint(); | |
57 context.current.clip = nullptr; // This will get set in updateOverflowCl ip(). | |
58 context.current.renderingContextID = 0; | |
59 context.current.shouldFlattenInheritedTransform = true; | |
60 context.absolutePosition = context.current; | |
61 context.containerForAbsolutePosition = nullptr; // This will get set in updateOutOfFlowContext(). | |
62 context.fixedPosition = context.current; | |
63 return; | |
64 } | |
43 | 65 |
44 TransformationMatrix frameTranslate; | 66 TransformationMatrix frameTranslate; |
45 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), fr ameView.y() + context.current.paintOffset.y()); | 67 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), fr ameView.y() + context.current.paintOffset.y()); |
46 if (TransformPaintPropertyNode* existingPreTranslation = frameView.preTransl ation()) | 68 if (TransformPaintPropertyNode* existingPreTranslation = frameView.preTransl ation()) |
47 existingPreTranslation->update(context.current.transform, frameTranslate , FloatPoint3D()); | 69 existingPreTranslation->update(context.current.transform, frameTranslate , FloatPoint3D()); |
48 else | 70 else |
49 frameView.setPreTranslation(TransformPaintPropertyNode::create(context.c urrent.transform, frameTranslate, FloatPoint3D())); | 71 frameView.setPreTranslation(TransformPaintPropertyNode::create(context.c urrent.transform, frameTranslate, FloatPoint3D())); |
50 | 72 |
51 FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSiz e())); | 73 FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSiz e())); |
52 if (ClipPaintPropertyNode* existingContentClip = frameView.contentClip()) | 74 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); | 113 LayoutPoint fractionalPaintOffset = LayoutPoint(context.current.pain tOffset - roundedPaintOffset); |
92 | 114 |
93 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdatePaintOffsetTranslation( | 115 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdatePaintOffsetTranslation( |
94 context.current.transform, TransformationMatrix().translate(roun dedPaintOffset.x(), roundedPaintOffset.y()), FloatPoint3D(), | 116 context.current.transform, TransformationMatrix().translate(roun dedPaintOffset.x(), roundedPaintOffset.y()), FloatPoint3D(), |
95 context.current.shouldFlattenInheritedTransform, context.current .renderingContextID); | 117 context.current.shouldFlattenInheritedTransform, context.current .renderingContextID); |
96 context.current.paintOffset = fractionalPaintOffset; | 118 context.current.paintOffset = fractionalPaintOffset; |
97 return; | 119 return; |
98 } | 120 } |
99 } | 121 } |
100 | 122 |
123 if (object.isLayoutView()) | |
124 return; | |
125 | |
101 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) | 126 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) |
102 properties->clearPaintOffsetTranslation(); | 127 properties->clearPaintOffsetTranslation(); |
103 } | 128 } |
104 | 129 |
105 static FloatPoint3D transformOrigin(const LayoutBox& box) | 130 static FloatPoint3D transformOrigin(const LayoutBox& box) |
106 { | 131 { |
107 const ComputedStyle& style = box.styleRef(); | 132 const ComputedStyle& style = box.styleRef(); |
108 FloatSize borderBoxSize(box.size()); | 133 FloatSize borderBoxSize(box.size()); |
109 return FloatPoint3D( | 134 return FloatPoint3D( |
110 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), | 135 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 return; | 187 return; |
163 } | 188 } |
164 } | 189 } |
165 | 190 |
166 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) | 191 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) |
167 properties->clearTransform(); | 192 properties->clearTransform(); |
168 } | 193 } |
169 | 194 |
170 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) | 195 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) |
171 { | 196 { |
197 if (object.isLayoutView() && !context.currentEffect) { | |
198 const LayoutView& layoutView = toLayoutView(object); | |
199 DCHECK(layoutView.frameView()->frame().settings()->rootLayerScrolls()); | |
200 DCHECK(layoutView.frameView()->frame().isMainFrame()); | |
201 context.currentEffect = layoutView.getMutableForPainting().ensureObjectP aintProperties().createOrUpdateEffect(nullptr, 1.0); | |
202 return; | |
203 } | |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 context.current.shouldFlattenInheritedTransform = false; | 346 context.current.shouldFlattenInheritedTransform = false; |
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(); |
356 bool needsScrollTranslation = !scrollOffset.isZero() || layer->scrollsOv erflow(); | |
357 if (!needsScrollTranslation && object.isLayoutView()) { | |
358 Settings* settings = object.document().settings(); | |
359 needsScrollTranslation = (settings && settings->rootLayerScrolls()); | |
360 } | |
trchen
2016/08/17 21:30:55
This is difficult to read. How about this:
bool fo
szager1
2016/08/19 01:52:13
Done.
| |
323 | 361 |
324 if (!scrollOffset.isZero() || layer->scrollsOverflow()) { | 362 if (needsScrollTranslation) { |
325 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); | 363 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); |
326 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( | 364 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( |
327 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); | 365 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); |
328 context.current.shouldFlattenInheritedTransform = false; | 366 context.current.shouldFlattenInheritedTransform = false; |
329 return; | 367 return; |
330 } | 368 } |
331 } | 369 } |
332 | 370 |
333 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) | 371 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) |
334 properties->clearScrollTranslation(); | 372 properties->clearScrollTranslation(); |
335 } | 373 } |
336 | 374 |
337 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) | 375 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) |
338 { | 376 { |
339 if (object.canContainAbsolutePositionObjects()) { | 377 if (object.canContainAbsolutePositionObjects()) { |
340 context.absolutePosition = context.current; | 378 context.absolutePosition = context.current; |
341 context.containerForAbsolutePosition = &object; | 379 context.containerForAbsolutePosition = &object; |
342 } | 380 } |
343 | 381 |
344 // TODO(pdr): Remove the !object.isLayoutView() condition when removing Fram eView | 382 if (object.isLayoutView()) { |
345 // paint properties for rootLayerScrolls. | 383 Settings* settings = object.document().settings(); |
346 if (!object.isLayoutView() && object.canContainFixedPositionObjects()) { | 384 if (settings && settings->rootLayerScrolls()) { |
385 context.fixedPosition = context.current; | |
386 const TransformPaintPropertyNode* transform = object.objectPaintProp erties()->paintOffsetTranslation(); | |
387 DCHECK(transform); | |
388 context.fixedPosition.transform = transform; | |
389 } | |
390 } else if (object.canContainFixedPositionObjects()) { | |
347 context.fixedPosition = context.current; | 391 context.fixedPosition = context.current; |
348 } else if (object.getMutableForPainting().objectPaintProperties() && object. objectPaintProperties()->cssClip()) { | 392 } 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 | 393 // 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 | 394 // 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 | 395 // 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 | 396 // descendants we need to insert the clip here if we are not a containin g block ancestor |
353 // of them. | 397 // of them. |
354 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); | 398 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); |
355 | 399 |
356 // Before we actually create anything, check whether in-flow context and fixed-position | 400 // 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); | 475 updateLocalBorderBoxContext(object, context); |
432 updateScrollbarPaintOffset(object, context); | 476 updateScrollbarPaintOffset(object, context); |
433 updateOverflowClip(object, context); | 477 updateOverflowClip(object, context); |
434 updatePerspective(object, context); | 478 updatePerspective(object, context); |
435 updateSvgLocalToBorderBoxTransform(object, context); | 479 updateSvgLocalToBorderBoxTransform(object, context); |
436 updateScrollTranslation(object, context); | 480 updateScrollTranslation(object, context); |
437 updateOutOfFlowContext(object, context); | 481 updateOutOfFlowContext(object, context); |
438 } | 482 } |
439 | 483 |
440 } // namespace blink | 484 } // namespace blink |
OLD | NEW |