| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro
pertyTreeBuilderContext& context) | 22 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro
pertyTreeBuilderContext& context) |
| 23 { | 23 { |
| 24 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 24 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 25 return; | 25 return; |
| 26 | 26 |
| 27 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { | 27 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { |
| 28 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T
ransformationMatrix(), FloatPoint3D())); | 28 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T
ransformationMatrix(), FloatPoint3D())); |
| 29 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r
ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); | 29 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r
ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); |
| 30 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); | 30 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); |
| 31 rootFrame.setRootScroll(ScrollPaintPropertyNode::create(nullptr, rootFra
me.rootTransform(), FloatSize(), FloatSize(), false, false)); |
| 31 } else { | 32 } else { |
| 32 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); | 33 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); |
| 33 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); | 34 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); |
| 34 } | 35 } |
| 35 | 36 |
| 36 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(); |
| 38 context.current.scroll = rootFrame.rootScroll(); |
| 37 context.current.clip = context.absolutePosition.clip = context.fixedPosition
.clip = rootFrame.rootClip(); | 39 context.current.clip = context.absolutePosition.clip = context.fixedPosition
.clip = rootFrame.rootClip(); |
| 38 context.currentEffect = rootFrame.rootEffect(); | 40 context.currentEffect = rootFrame.rootEffect(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert
yTreeBuilderContext& context) | 43 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert
yTreeBuilderContext& context) |
| 42 { | 44 { |
| 43 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 45 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 44 LayoutView* layoutView = frameView.layoutView(); | 46 LayoutView* layoutView = frameView.layoutView(); |
| 45 if (!layoutView) | 47 if (!layoutView) |
| 46 return; | 48 return; |
| 47 | 49 |
| 48 TransformationMatrix frameTranslate; | 50 TransformationMatrix frameTranslate; |
| 49 frameTranslate.translate( | 51 frameTranslate.translate( |
| 50 frameView.x() + layoutView->location().x() + context.current.paintOf
fset.x(), | 52 frameView.x() + layoutView->location().x() + context.current.paintOf
fset.x(), |
| 51 frameView.y() + layoutView->location().y() + context.current.paintOf
fset.y()); | 53 frameView.y() + layoutView->location().y() + context.current.paintOf
fset.y()); |
| 52 context.current.transform = layoutView->getMutableForPainting().ensureOb
jectPaintProperties().createOrUpdatePaintOffsetTranslation( | 54 context.current.transform = layoutView->getMutableForPainting().ensureOb
jectPaintProperties().createOrUpdatePaintOffsetTranslation( |
| 53 context.current.transform, frameTranslate, FloatPoint3D()); | 55 context.current.transform, frameTranslate, FloatPoint3D()); |
| 56 context.current.scroll = layoutView->getMutableForPainting().ensureObjec
tPaintProperties().createOrUpdateScroll( |
| 57 context.current.scroll, context.current.transform, FloatSize(), Floa
tSize(), false, false); |
| 54 context.current.paintOffset = LayoutPoint(); | 58 context.current.paintOffset = LayoutPoint(); |
| 55 context.current.renderingContextID = 0; | 59 context.current.renderingContextID = 0; |
| 56 context.current.shouldFlattenInheritedTransform = true; | 60 context.current.shouldFlattenInheritedTransform = true; |
| 57 context.absolutePosition = context.current; | 61 context.absolutePosition = context.current; |
| 58 context.containerForAbsolutePosition = nullptr; // This will get set in
updateOutOfFlowContext(). | 62 context.containerForAbsolutePosition = nullptr; // This will get set in
updateOutOfFlowContext(). |
| 59 context.fixedPosition = context.current; | 63 context.fixedPosition = context.current; |
| 60 return; | 64 return; |
| 61 } | 65 } |
| 62 | 66 |
| 63 TransformationMatrix frameTranslate; | 67 TransformationMatrix frameTranslate; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 74 frameView.setContentClip(ClipPaintPropertyNode::create(context.current.c
lip, frameView.preTranslation(), contentClip)); | 78 frameView.setContentClip(ClipPaintPropertyNode::create(context.current.c
lip, frameView.preTranslation(), contentClip)); |
| 75 | 79 |
| 76 DoubleSize scrollOffset = frameView.scrollOffsetDouble(); | 80 DoubleSize scrollOffset = frameView.scrollOffsetDouble(); |
| 77 TransformationMatrix frameScroll; | 81 TransformationMatrix frameScroll; |
| 78 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); | 82 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); |
| 79 if (TransformPaintPropertyNode* existingScrollTranslation = frameView.scroll
Translation()) | 83 if (TransformPaintPropertyNode* existingScrollTranslation = frameView.scroll
Translation()) |
| 80 existingScrollTranslation->update(frameView.preTranslation(), frameScrol
l, FloatPoint3D()); | 84 existingScrollTranslation->update(frameView.preTranslation(), frameScrol
l, FloatPoint3D()); |
| 81 else | 85 else |
| 82 frameView.setScrollTranslation(TransformPaintPropertyNode::create(frameV
iew.preTranslation(), frameScroll, FloatPoint3D())); | 86 frameView.setScrollTranslation(TransformPaintPropertyNode::create(frameV
iew.preTranslation(), frameScroll, FloatPoint3D())); |
| 83 | 87 |
| 88 // TODO(pdr): Set these values properly. |
| 89 FloatSize scrollClip; |
| 90 FloatSize scrollBounds; |
| 91 bool userScrollableHorizontal = false; |
| 92 bool userScrollableVertical = false; |
| 93 if (ScrollPaintPropertyNode* existingScroll = frameView.scroll()) |
| 94 existingScroll->update(context.current.scroll, frameView.scrollTranslati
on(), scrollClip, scrollBounds, userScrollableHorizontal, userScrollableVertical
); |
| 95 else |
| 96 frameView.setScroll(ScrollPaintPropertyNode::create(context.current.scro
ll, frameView.scrollTranslation(), scrollClip, scrollBounds, userScrollableHoriz
ontal, userScrollableVertical)); |
| 97 |
| 84 // Initialize the context for current, absolute and fixed position cases. | 98 // Initialize the context for current, absolute and fixed position cases. |
| 85 // They are the same, except that scroll translation does not apply to | 99 // They are the same, except that scroll translation does not apply to |
| 86 // fixed position descendants. | 100 // fixed position descendants. |
| 87 context.current.transform = frameView.scrollTranslation(); | 101 context.current.transform = frameView.scrollTranslation(); |
| 88 context.current.paintOffset = LayoutPoint(); | 102 context.current.paintOffset = LayoutPoint(); |
| 89 context.current.clip = frameView.contentClip(); | 103 context.current.clip = frameView.contentClip(); |
| 104 context.current.scroll = frameView.scroll(); |
| 90 context.current.renderingContextID = 0; | 105 context.current.renderingContextID = 0; |
| 91 context.current.shouldFlattenInheritedTransform = true; | 106 context.current.shouldFlattenInheritedTransform = true; |
| 92 context.absolutePosition = context.current; | 107 context.absolutePosition = context.current; |
| 93 context.containerForAbsolutePosition = nullptr; | 108 context.containerForAbsolutePosition = nullptr; |
| 94 context.fixedPosition = context.current; | 109 context.fixedPosition = context.current; |
| 95 context.fixedPosition.transform = frameView.preTranslation(); | 110 context.fixedPosition.transform = frameView.preTranslation(); |
| 96 } | 111 } |
| 97 | 112 |
| 98 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject&
object, PaintPropertyTreeBuilderContext& context) | 113 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject&
object, PaintPropertyTreeBuilderContext& context) |
| 99 { | 114 { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o
bject, PaintPropertyTreeBuilderContext& context) | 245 void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o
bject, PaintPropertyTreeBuilderContext& context) |
| 231 { | 246 { |
| 232 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since
we don't need them at the moment. | 247 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since
we don't need them at the moment. |
| 233 if (!object.isBox() && !object.hasLayer()) | 248 if (!object.isBox() && !object.hasLayer()) |
| 234 return; | 249 return; |
| 235 | 250 |
| 236 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo
ntext = | 251 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo
ntext = |
| 237 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); | 252 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); |
| 238 borderBoxContext->paintOffset = context.current.paintOffset; | 253 borderBoxContext->paintOffset = context.current.paintOffset; |
| 239 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran
sform, context.current.clip, context.currentEffect); | 254 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran
sform, context.current.clip, context.currentEffect); |
| 255 borderBoxContext->scroll = context.current.scroll; |
| 240 | 256 |
| 241 if (!context.current.clip) { | 257 if (!context.current.clip) { |
| 242 DCHECK(object.isLayoutView()); | 258 DCHECK(object.isLayoutView()); |
| 243 DCHECK(toLayoutView(object).frameView()->frame().isMainFrame()); | 259 DCHECK(toLayoutView(object).frameView()->frame().isMainFrame()); |
| 244 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 260 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 245 borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create
(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRec
t())); | 261 borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create
(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRec
t())); |
| 246 context.current.clip = borderBoxContext->propertyTreeState.clip.get(); | 262 context.current.clip = borderBoxContext->propertyTreeState.clip.get(); |
| 247 } | 263 } |
| 248 | 264 |
| 249 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB
oxProperties(std::move(borderBoxContext)); | 265 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB
oxProperties(std::move(borderBoxContext)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 properties->clearSvgLocalToBorderBoxTransform(); | 363 properties->clearSvgLocalToBorderBoxTransform(); |
| 348 return; | 364 return; |
| 349 } | 365 } |
| 350 | 366 |
| 351 context.current.transform = object.getMutableForPainting().ensureObjectPaint
Properties().createOrUpdateSvgLocalToBorderBoxTransform( | 367 context.current.transform = object.getMutableForPainting().ensureObjectPaint
Properties().createOrUpdateSvgLocalToBorderBoxTransform( |
| 352 context.current.transform, transformToBorderBox, FloatPoint3D()); | 368 context.current.transform, transformToBorderBox, FloatPoint3D()); |
| 353 context.current.shouldFlattenInheritedTransform = false; | 369 context.current.shouldFlattenInheritedTransform = false; |
| 354 context.current.renderingContextID = 0; | 370 context.current.renderingContextID = 0; |
| 355 } | 371 } |
| 356 | 372 |
| 357 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec
t, PaintPropertyTreeBuilderContext& context) | 373 void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(const LayoutObje
ct& object, PaintPropertyTreeBuilderContext& context) |
| 358 { | 374 { |
| 359 if (object.isBoxModelObject() && object.hasOverflowClip()) { | 375 if (object.isBoxModelObject() && object.hasOverflowClip()) { |
| 360 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | 376 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
| 361 DCHECK(layer); | 377 DCHECK(layer); |
| 362 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); | 378 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); |
| 363 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl
edFeatures::rootLayerScrollingEnabled(); | 379 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl
edFeatures::rootLayerScrollingEnabled(); |
| 364 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro
llsOverflow()) { | 380 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro
llsOverflow()) { |
| 365 TransformationMatrix matrix = TransformationMatrix().translate(-scro
llOffset.width(), -scrollOffset.height()); | 381 TransformationMatrix matrix = TransformationMatrix().translate(-scro
llOffset.width(), -scrollOffset.height()); |
| 366 context.current.transform = object.getMutableForPainting().ensureObj
ectPaintProperties().createOrUpdateScrollTranslation( | 382 context.current.transform = object.getMutableForPainting().ensureObj
ectPaintProperties().createOrUpdateScrollTranslation( |
| 367 context.current.transform, matrix, FloatPoint3D(), context.curre
nt.shouldFlattenInheritedTransform, context.current.renderingContextID); | 383 context.current.transform, matrix, FloatPoint3D(), context.curre
nt.shouldFlattenInheritedTransform, context.current.renderingContextID); |
| 384 |
| 385 // TODO(pdr): Set these values properly. |
| 386 FloatSize scrollClip; |
| 387 FloatSize scrollBounds; |
| 388 bool userScrollableHorizontal = false; |
| 389 bool userScrollableVertical = false; |
| 390 context.current.scroll = object.getMutableForPainting().ensureObject
PaintProperties().createOrUpdateScroll( |
| 391 context.current.scroll, context.current.transform, scrollClip, s
crollBounds, userScrollableHorizontal, userScrollableVertical); |
| 392 |
| 368 context.current.shouldFlattenInheritedTransform = false; | 393 context.current.shouldFlattenInheritedTransform = false; |
| 369 return; | 394 return; |
| 370 } | 395 } |
| 371 } | 396 } |
| 372 | 397 |
| 373 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) | 398 // TODO(pdr): Ensure non-scrollable objects get a scroll node that doesn't s
croll. |
| 399 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) { |
| 374 properties->clearScrollTranslation(); | 400 properties->clearScrollTranslation(); |
| 401 properties->clearScroll(); |
| 402 } |
| 375 } | 403 } |
| 376 | 404 |
| 377 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object
, PaintPropertyTreeBuilderContext& context) | 405 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object
, PaintPropertyTreeBuilderContext& context) |
| 378 { | 406 { |
| 379 if (object.canContainAbsolutePositionObjects()) { | 407 if (object.canContainAbsolutePositionObjects()) { |
| 380 context.absolutePosition = context.current; | 408 context.absolutePosition = context.current; |
| 381 context.containerForAbsolutePosition = &object; | 409 context.containerForAbsolutePosition = &object; |
| 382 } | 410 } |
| 383 | 411 |
| 384 if (object.isLayoutView()) { | 412 if (object.isLayoutView()) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 506 } |
| 479 | 507 |
| 480 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj
ect, PaintPropertyTreeBuilderContext& context) | 508 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj
ect, PaintPropertyTreeBuilderContext& context) |
| 481 { | 509 { |
| 482 if (!object.isBoxModelObject() && !object.isSVG()) | 510 if (!object.isBoxModelObject() && !object.isSVG()) |
| 483 return; | 511 return; |
| 484 | 512 |
| 485 updateOverflowClip(object, context); | 513 updateOverflowClip(object, context); |
| 486 updatePerspective(object, context); | 514 updatePerspective(object, context); |
| 487 updateSvgLocalToBorderBoxTransform(object, context); | 515 updateSvgLocalToBorderBoxTransform(object, context); |
| 488 updateScrollTranslation(object, context); | 516 updateScrollAndScrollTranslation(object, context); |
| 489 updateOutOfFlowContext(object, context); | 517 updateOutOfFlowContext(object, context); |
| 490 } | 518 } |
| 491 | 519 |
| 492 } // namespace blink | 520 } // namespace blink |
| OLD | NEW |