| 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(); | 24 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 25 if (settings && settings->rootLayerScrolls()) | |
| 26 return; | 25 return; |
| 27 | 26 |
| 28 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { | 27 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { |
| 29 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T
ransformationMatrix(), FloatPoint3D())); | 28 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T
ransformationMatrix(), FloatPoint3D())); |
| 30 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r
ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); | 29 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r
ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); |
| 31 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); | 30 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); |
| 32 } else { | 31 } else { |
| 33 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); | 32 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); |
| 34 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); | 33 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); |
| 35 } | 34 } |
| 36 | 35 |
| 37 context.current.transform = context.absolutePosition.transform = context.fix
edPosition.transform = rootFrame.rootTransform(); | 36 context.current.transform = context.absolutePosition.transform = context.fix
edPosition.transform = rootFrame.rootTransform(); |
| 38 context.current.clip = context.absolutePosition.clip = context.fixedPosition
.clip = rootFrame.rootClip(); | 37 context.current.clip = context.absolutePosition.clip = context.fixedPosition
.clip = rootFrame.rootClip(); |
| 39 context.currentEffect = rootFrame.rootEffect(); | 38 context.currentEffect = rootFrame.rootEffect(); |
| 40 } | 39 } |
| 41 | 40 |
| 42 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert
yTreeBuilderContext& context) | 41 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert
yTreeBuilderContext& context) |
| 43 { | 42 { |
| 44 Settings* settings = frameView.frame().settings(); | 43 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 45 if (settings && settings->rootLayerScrolls()) { | |
| 46 LayoutView* layoutView = frameView.layoutView(); | 44 LayoutView* layoutView = frameView.layoutView(); |
| 47 if (!layoutView) | 45 if (!layoutView) |
| 48 return; | 46 return; |
| 49 | 47 |
| 50 TransformationMatrix frameTranslate; | 48 TransformationMatrix frameTranslate; |
| 51 frameTranslate.translate( | 49 frameTranslate.translate( |
| 52 frameView.x() + layoutView->location().x() + context.current.paintOf
fset.x(), | 50 frameView.x() + layoutView->location().x() + context.current.paintOf
fset.x(), |
| 53 frameView.y() + layoutView->location().y() + context.current.paintOf
fset.y()); | 51 frameView.y() + layoutView->location().y() + context.current.paintOf
fset.y()); |
| 54 context.current.transform = layoutView->getMutableForPainting().ensureOb
jectPaintProperties().createOrUpdatePaintOffsetTranslation( | 52 context.current.transform = layoutView->getMutableForPainting().ensureOb
jectPaintProperties().createOrUpdatePaintOffsetTranslation( |
| 55 context.current.transform, frameTranslate, FloatPoint3D()); | 53 context.current.transform, frameTranslate, FloatPoint3D()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 186 } |
| 189 | 187 |
| 190 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) | 188 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) |
| 191 properties->clearTransform(); | 189 properties->clearTransform(); |
| 192 } | 190 } |
| 193 | 191 |
| 194 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro
pertyTreeBuilderContext& context) | 192 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro
pertyTreeBuilderContext& context) |
| 195 { | 193 { |
| 196 if (object.isLayoutView() && !context.currentEffect) { | 194 if (object.isLayoutView() && !context.currentEffect) { |
| 197 const LayoutView& layoutView = toLayoutView(object); | 195 const LayoutView& layoutView = toLayoutView(object); |
| 198 DCHECK(layoutView.frameView()->frame().settings()->rootLayerScrolls()); | 196 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 199 DCHECK(layoutView.frameView()->frame().isMainFrame()); | 197 DCHECK(layoutView.frameView()->frame().isMainFrame()); |
| 200 context.currentEffect = layoutView.getMutableForPainting().ensureObjectP
aintProperties().createOrUpdateEffect(nullptr, 1.0); | 198 context.currentEffect = layoutView.getMutableForPainting().ensureObjectP
aintProperties().createOrUpdateEffect(nullptr, 1.0); |
| 201 return; | 199 return; |
| 202 } | 200 } |
| 203 | 201 |
| 204 if (!object.styleRef().hasOpacity()) { | 202 if (!object.styleRef().hasOpacity()) { |
| 205 if (ObjectPaintProperties* properties = object.getMutableForPainting().o
bjectPaintProperties()) | 203 if (ObjectPaintProperties* properties = object.getMutableForPainting().o
bjectPaintProperties()) |
| 206 properties->clearEffect(); | 204 properties->clearEffect(); |
| 207 return; | 205 return; |
| 208 } | 206 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 236 return; | 234 return; |
| 237 | 235 |
| 238 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo
ntext = | 236 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo
ntext = |
| 239 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); | 237 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); |
| 240 borderBoxContext->paintOffset = context.current.paintOffset; | 238 borderBoxContext->paintOffset = context.current.paintOffset; |
| 241 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran
sform, context.current.clip, context.currentEffect); | 239 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran
sform, context.current.clip, context.currentEffect); |
| 242 | 240 |
| 243 if (!context.current.clip) { | 241 if (!context.current.clip) { |
| 244 DCHECK(object.isLayoutView()); | 242 DCHECK(object.isLayoutView()); |
| 245 DCHECK(toLayoutView(object).frameView()->frame().isMainFrame()); | 243 DCHECK(toLayoutView(object).frameView()->frame().isMainFrame()); |
| 246 DCHECK(toLayoutView(object).frameView()->frame().settings()->rootLayerSc
rolls()); | 244 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 247 borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create
(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRec
t())); | 245 borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create
(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRec
t())); |
| 248 context.current.clip = borderBoxContext->propertyTreeState.clip.get(); | 246 context.current.clip = borderBoxContext->propertyTreeState.clip.get(); |
| 249 } | 247 } |
| 250 | 248 |
| 251 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB
oxProperties(std::move(borderBoxContext)); | 249 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB
oxProperties(std::move(borderBoxContext)); |
| 252 | 250 |
| 253 } | 251 } |
| 254 | 252 |
| 255 // TODO(trchen): Remove this once we bake the paint offset into frameRect. | 253 // TODO(trchen): Remove this once we bake the paint offset into frameRect. |
| 256 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(const LayoutObject& ob
ject, const PaintPropertyTreeBuilderContext& context) | 254 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(const LayoutObject& ob
ject, const PaintPropertyTreeBuilderContext& context) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 context.current.shouldFlattenInheritedTransform = false; | 353 context.current.shouldFlattenInheritedTransform = false; |
| 356 context.current.renderingContextID = 0; | 354 context.current.renderingContextID = 0; |
| 357 } | 355 } |
| 358 | 356 |
| 359 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec
t, PaintPropertyTreeBuilderContext& context) | 357 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec
t, PaintPropertyTreeBuilderContext& context) |
| 360 { | 358 { |
| 361 if (object.isBoxModelObject() && object.hasOverflowClip()) { | 359 if (object.isBoxModelObject() && object.hasOverflowClip()) { |
| 362 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | 360 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
| 363 DCHECK(layer); | 361 DCHECK(layer); |
| 364 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); | 362 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); |
| 365 bool forceScrollingForLayoutView = false; | 363 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl
edFeatures::rootLayerScrollingEnabled(); |
| 366 if (object.isLayoutView()) { | |
| 367 Settings* settings = object.document().settings(); | |
| 368 forceScrollingForLayoutView = (settings && settings->rootLayerScroll
s()); | |
| 369 } | |
| 370 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro
llsOverflow()) { | 364 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro
llsOverflow()) { |
| 371 TransformationMatrix matrix = TransformationMatrix().translate(-scro
llOffset.width(), -scrollOffset.height()); | 365 TransformationMatrix matrix = TransformationMatrix().translate(-scro
llOffset.width(), -scrollOffset.height()); |
| 372 context.current.transform = object.getMutableForPainting().ensureObj
ectPaintProperties().createOrUpdateScrollTranslation( | 366 context.current.transform = object.getMutableForPainting().ensureObj
ectPaintProperties().createOrUpdateScrollTranslation( |
| 373 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); |
| 374 context.current.shouldFlattenInheritedTransform = false; | 368 context.current.shouldFlattenInheritedTransform = false; |
| 375 return; | 369 return; |
| 376 } | 370 } |
| 377 } | 371 } |
| 378 | 372 |
| 379 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) | 373 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) |
| 380 properties->clearScrollTranslation(); | 374 properties->clearScrollTranslation(); |
| 381 } | 375 } |
| 382 | 376 |
| 383 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object
, PaintPropertyTreeBuilderContext& context) | 377 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object
, PaintPropertyTreeBuilderContext& context) |
| 384 { | 378 { |
| 385 if (object.canContainAbsolutePositionObjects()) { | 379 if (object.canContainAbsolutePositionObjects()) { |
| 386 context.absolutePosition = context.current; | 380 context.absolutePosition = context.current; |
| 387 context.containerForAbsolutePosition = &object; | 381 context.containerForAbsolutePosition = &object; |
| 388 } | 382 } |
| 389 | 383 |
| 390 if (object.isLayoutView()) { | 384 if (object.isLayoutView()) { |
| 391 Settings* settings = object.document().settings(); | 385 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 392 if (settings && settings->rootLayerScrolls()) { | |
| 393 context.fixedPosition = context.current; | 386 context.fixedPosition = context.current; |
| 394 const TransformPaintPropertyNode* transform = object.objectPaintProp
erties()->paintOffsetTranslation(); | 387 const TransformPaintPropertyNode* transform = object.objectPaintProp
erties()->paintOffsetTranslation(); |
| 395 DCHECK(transform); | 388 DCHECK(transform); |
| 396 context.fixedPosition.transform = transform; | 389 context.fixedPosition.transform = transform; |
| 397 } | 390 } |
| 398 } else if (object.canContainFixedPositionObjects()) { | 391 } else if (object.canContainFixedPositionObjects()) { |
| 399 context.fixedPosition = context.current; | 392 context.fixedPosition = context.current; |
| 400 } else if (object.getMutableForPainting().objectPaintProperties() && object.
objectPaintProperties()->cssClip()) { | 393 } else if (object.getMutableForPainting().objectPaintProperties() && object.
objectPaintProperties()->cssClip()) { |
| 401 // CSS clip applies to all descendants, even if this object is not a con
taining block | 394 // CSS clip applies to all descendants, even if this object is not a con
taining block |
| 402 // ancestor of the descendant. It is okay for absolute-position descenda
nts because | 395 // ancestor of the descendant. It is okay for absolute-position descenda
nts because |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 return; | 483 return; |
| 491 | 484 |
| 492 updateOverflowClip(object, context); | 485 updateOverflowClip(object, context); |
| 493 updatePerspective(object, context); | 486 updatePerspective(object, context); |
| 494 updateSvgLocalToBorderBoxTransform(object, context); | 487 updateSvgLocalToBorderBoxTransform(object, context); |
| 495 updateScrollTranslation(object, context); | 488 updateScrollTranslation(object, context); |
| 496 updateOutOfFlowContext(object, context); | 489 updateOutOfFlowContext(object, context); |
| 497 } | 490 } |
| 498 | 491 |
| 499 } // namespace blink | 492 } // namespace blink |
| OLD | NEW |