Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 return rootScroll; | 45 return rootScroll; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 PaintPropertyTreeBuilderContext PaintPropertyTreeBuilder::setupInitialContext() | 49 PaintPropertyTreeBuilderContext PaintPropertyTreeBuilder::setupInitialContext() |
| 50 { | 50 { |
| 51 PaintPropertyTreeBuilderContext context; | 51 PaintPropertyTreeBuilderContext context; |
| 52 | 52 |
| 53 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootClipNode(); | 53 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootClipNode(); |
| 54 context.currentEffect = rootEffectNode(); | 54 context.currentEffect = rootEffectNode(); |
| 55 | |
| 56 // TODO(pdr): Update the root layer scrolling paths to use the static root n odes for transform and scroll. | |
| 57 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | |
| 58 return context; | |
| 59 | |
| 60 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootTransformNode(); | 55 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootTransformNode(); |
| 61 context.current.scroll = context.absolutePosition.scroll = context.fixedPosi tion.scroll = rootScrollNode(); | 56 context.current.scroll = context.absolutePosition.scroll = context.fixedPosi tion.scroll = rootScrollNode(); |
| 62 | 57 |
| 63 // Ensure scroll tree properties are reset. They will be rebuilt during the tree walk. | 58 // Ensure scroll tree properties are reset. They will be rebuilt during the tree walk. |
| 64 rootScrollNode()->clearMainThreadScrollingReasons(); | 59 rootScrollNode()->clearMainThreadScrollingReasons(); |
| 65 | 60 |
| 66 return context; | 61 return context; |
| 67 } | 62 } |
| 68 | 63 |
| 69 void createOrUpdateFrameViewPreTranslation(FrameView& frameView, | 64 void createOrUpdateFrameViewPreTranslation(FrameView& frameView, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 LayoutView* layoutView = frameView.layoutView(); | 117 LayoutView* layoutView = frameView.layoutView(); |
| 123 if (!layoutView) | 118 if (!layoutView) |
| 124 return; | 119 return; |
| 125 | 120 |
| 126 TransformationMatrix frameTranslate; | 121 TransformationMatrix frameTranslate; |
| 127 frameTranslate.translate( | 122 frameTranslate.translate( |
| 128 frameView.x() + layoutView->location().x() + context.current.paintOf fset.x(), | 123 frameView.x() + layoutView->location().x() + context.current.paintOf fset.x(), |
| 129 frameView.y() + layoutView->location().y() + context.current.paintOf fset.y()); | 124 frameView.y() + layoutView->location().y() + context.current.paintOf fset.y()); |
| 130 context.current.transform = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdatePaintOffsetTranslation( | 125 context.current.transform = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdatePaintOffsetTranslation( |
| 131 context.current.transform, frameTranslate, FloatPoint3D()); | 126 context.current.transform, frameTranslate, FloatPoint3D()); |
| 132 context.current.scroll = layoutView->getMutableForPainting().ensureObjec tPaintProperties().createOrUpdateScroll( | |
| 133 context.current.scroll, context.current.transform, IntSize(), IntSiz e(), false, false); | |
| 134 context.current.paintOffset = LayoutPoint(); | 127 context.current.paintOffset = LayoutPoint(); |
| 135 context.current.renderingContextID = 0; | 128 context.current.renderingContextID = 0; |
| 136 context.current.shouldFlattenInheritedTransform = true; | 129 context.current.shouldFlattenInheritedTransform = true; |
| 137 context.absolutePosition = context.current; | 130 context.absolutePosition = context.current; |
| 138 context.containerForAbsolutePosition = nullptr; // This will get set in updateOutOfFlowContext(). | 131 context.containerForAbsolutePosition = nullptr; // This will get set in updateOutOfFlowContext(). |
| 139 context.fixedPosition = context.current; | 132 context.fixedPosition = context.current; |
| 140 return; | 133 return; |
| 141 } | 134 } |
| 142 | 135 |
| 143 TransformationMatrix frameTranslate; | 136 TransformationMatrix frameTranslate; |
| 144 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), fr ameView.y() + context.current.paintOffset.y()); | 137 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), fr ameView.y() + context.current.paintOffset.y()); |
| 145 createOrUpdateFrameViewPreTranslation(frameView, context.current.transform, frameTranslate, FloatPoint3D()); | 138 createOrUpdateFrameViewPreTranslation(frameView, context.current.transform, frameTranslate, FloatPoint3D()); |
| 146 | 139 |
| 147 FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSiz e())); | 140 FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSiz e())); |
| 148 createOrUpdateFrameViewContentClip(frameView, context.current.clip, frameVie w.preTranslation(), contentClip); | 141 createOrUpdateFrameViewContentClip(frameView, context.current.clip, frameVie w.preTranslation(), contentClip); |
| 149 | 142 |
| 150 DoubleSize scrollOffset = frameView.scrollOffsetDouble(); | 143 DoubleSize scrollOffset = frameView.scrollOffsetDouble(); |
|
szager1
2016/09/26 19:57:54
DoubleSize scrollOffset = frameView.layoutViewport
pdr.
2016/09/26 20:30:56
Why change this? It matches the code before this c
| |
| 151 TransformationMatrix frameScroll; | 144 if (frameView.isScrollable() || !scrollOffset.isZero()) { |
| 152 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); | 145 TransformationMatrix frameScroll; |
| 153 // TODO(pdr): A scroll translation should not be needed when frameView.isScr ollable() is false. | 146 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); |
| 154 createOrUpdateFrameViewScrollTranslation(frameView, frameView.preTranslation (), frameScroll, FloatPoint3D()); | 147 createOrUpdateFrameViewScrollTranslation(frameView, frameView.preTransla tion(), frameScroll, FloatPoint3D()); |
| 155 | 148 |
| 156 if (frameView.isScrollable()) { | |
| 157 IntSize scrollClip = frameView.visibleContentSize(); | 149 IntSize scrollClip = frameView.visibleContentSize(); |
| 158 IntSize scrollBounds = frameView.contentsSize(); | 150 IntSize scrollBounds = frameView.contentsSize(); |
| 159 bool userScrollableHorizontal = frameView.userInputScrollable(Horizontal Scrollbar); | 151 bool userScrollableHorizontal = frameView.userInputScrollable(Horizontal Scrollbar); |
| 160 bool userScrollableVertical = frameView.userInputScrollable(VerticalScro llbar); | 152 bool userScrollableVertical = frameView.userInputScrollable(VerticalScro llbar); |
| 161 createOrUpdateFrameViewScroll(frameView, context.current.scroll, frameVi ew.scrollTranslation(), scrollClip, scrollBounds, userScrollableHorizontal, user ScrollableVertical); | 153 createOrUpdateFrameViewScroll(frameView, context.current.scroll, frameVi ew.scrollTranslation(), scrollClip, scrollBounds, userScrollableHorizontal, user ScrollableVertical); |
| 162 } else { | 154 } else { |
| 155 frameView.setScrollTranslation(nullptr); | |
| 163 frameView.setScroll(nullptr); | 156 frameView.setScroll(nullptr); |
| 164 } | 157 } |
| 165 | 158 |
| 166 // Initialize the context for current, absolute and fixed position cases. | 159 // Initialize the context for current, absolute and fixed position cases. |
| 167 // They are the same, except that scroll translation does not apply to | 160 // They are the same, except that scroll translation does not apply to |
| 168 // fixed position descendants. | 161 // fixed position descendants. |
| 169 ScrollPaintPropertyNode* initialScroll = context.current.scroll; | 162 ScrollPaintPropertyNode* initialScroll = context.current.scroll; |
| 170 context.current.transform = frameView.scrollTranslation(); | 163 context.current.transform = frameView.scrollTranslation() ? frameView.scroll Translation() : frameView.preTranslation(); |
| 171 context.current.paintOffset = LayoutPoint(); | 164 context.current.paintOffset = LayoutPoint(); |
| 172 context.current.clip = frameView.contentClip(); | 165 context.current.clip = frameView.contentClip(); |
| 173 context.current.scroll = frameView.scroll() ? frameView.scroll() : initialSc roll; | 166 context.current.scroll = frameView.scroll() ? frameView.scroll() : initialSc roll; |
| 174 context.current.renderingContextID = 0; | 167 context.current.renderingContextID = 0; |
| 175 context.current.shouldFlattenInheritedTransform = true; | 168 context.current.shouldFlattenInheritedTransform = true; |
| 176 context.absolutePosition = context.current; | 169 context.absolutePosition = context.current; |
| 177 context.containerForAbsolutePosition = nullptr; | 170 context.containerForAbsolutePosition = nullptr; |
| 178 context.fixedPosition = context.current; | 171 context.fixedPosition = context.current; |
| 179 context.fixedPosition.transform = frameView.preTranslation(); | 172 context.fixedPosition.transform = frameView.preTranslation(); |
| 180 context.fixedPosition.scroll = initialScroll; | 173 context.fixedPosition.scroll = initialScroll; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 if (box.hasControlClip()) { | 363 if (box.hasControlClip()) { |
| 371 clipRect = box.controlClipRect(context.current.paintOffset); | 364 clipRect = box.controlClipRect(context.current.paintOffset); |
| 372 } else if (box.hasOverflowClip() || (box.isSVGRoot() && toLayoutSVGRoot(box) .shouldApplyViewportClip())) { | 365 } else if (box.hasOverflowClip() || (box.isSVGRoot() && toLayoutSVGRoot(box) .shouldApplyViewportClip())) { |
| 373 clipRect = box.overflowClipRect(context.current.paintOffset); | 366 clipRect = box.overflowClipRect(context.current.paintOffset); |
| 374 } else { | 367 } else { |
| 375 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties()) | 368 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties()) |
| 376 properties->clearOverflowClip(); | 369 properties->clearOverflowClip(); |
| 377 return; | 370 return; |
| 378 } | 371 } |
| 379 | 372 |
| 373 // TODO(pdr): We should create an entry in ObjectPaintProperties for border radius to ensure | |
| 374 // the owership model of properties is simple for incremental updates. | |
| 380 // This need to be in top-level block to hold the reference until we finish creating the normal clip node. | 375 // This need to be in top-level block to hold the reference until we finish creating the normal clip node. |
| 381 RefPtr<ClipPaintPropertyNode> borderRadiusClip; | 376 RefPtr<ClipPaintPropertyNode> borderRadiusClip; |
| 382 if (box.styleRef().hasBorderRadius()) { | 377 if (box.styleRef().hasBorderRadius()) { |
| 383 auto innerBorder = box.styleRef().getRoundedInnerBorderFor( | 378 auto innerBorder = box.styleRef().getRoundedInnerBorderFor( |
| 384 LayoutRect(context.current.paintOffset, box.size())); | 379 LayoutRect(context.current.paintOffset, box.size())); |
| 385 borderRadiusClip = ClipPaintPropertyNode::create(context.current.clip, c ontext.current.transform, innerBorder); | 380 borderRadiusClip = ClipPaintPropertyNode::create(context.current.clip, c ontext.current.transform, innerBorder); |
| 386 context.current.clip = borderRadiusClip.get(); | 381 context.current.clip = borderRadiusClip.get(); |
| 387 } | 382 } |
| 388 | 383 |
| 389 context.current.clip = object.getMutableForPainting().ensureObjectPaintPrope rties().createOrUpdateOverflowClip( | 384 context.current.clip = object.getMutableForPainting().ensureObjectPaintPrope rties().createOrUpdateOverflowClip( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 context.current.shouldFlattenInheritedTransform = false; | 435 context.current.shouldFlattenInheritedTransform = false; |
| 441 context.current.renderingContextID = 0; | 436 context.current.renderingContextID = 0; |
| 442 } | 437 } |
| 443 | 438 |
| 444 void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(const LayoutObje ct& object, PaintPropertyTreeBuilderContext& context) | 439 void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(const LayoutObje ct& object, PaintPropertyTreeBuilderContext& context) |
| 445 { | 440 { |
| 446 if (object.isBoxModelObject() && object.hasOverflowClip()) { | 441 if (object.isBoxModelObject() && object.hasOverflowClip()) { |
| 447 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | 442 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
| 448 DCHECK(layer); | 443 DCHECK(layer); |
| 449 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); | 444 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); |
| 450 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl edFeatures::rootLayerScrollingEnabled(); | 445 if (!scrollOffset.isZero() || layer->scrollsOverflow()) { |
|
szager1
2016/09/26 19:57:54
I think you still need to create the transform for
pdr.
2016/09/26 20:30:56
Why? With this patch I've switched FrameView to no
| |
| 451 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro llsOverflow()) { | |
| 452 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); | 446 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); |
| 453 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( | 447 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( |
| 454 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); | 448 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); |
| 455 | 449 |
| 456 IntSize scrollClip = layer->getScrollableArea()->visibleContentRect( ).size(); | 450 IntSize scrollClip = layer->getScrollableArea()->visibleContentRect( ).size(); |
| 457 IntSize scrollBounds = layer->getScrollableArea()->contentsSize(); | 451 IntSize scrollBounds = layer->getScrollableArea()->contentsSize(); |
| 458 bool userScrollableHorizontal = layer->getScrollableArea()->userInpu tScrollable(HorizontalScrollbar); | 452 bool userScrollableHorizontal = layer->getScrollableArea()->userInpu tScrollable(HorizontalScrollbar); |
| 459 bool userScrollableVertical = layer->getScrollableArea()->userInputS crollable(VerticalScrollbar); | 453 bool userScrollableVertical = layer->getScrollableArea()->userInputS crollable(VerticalScrollbar); |
| 460 ScrollPaintPropertyNode* parentScrollNode = forceScrollingForLayoutV iew ? nullptr : context.current.scroll; | |
| 461 context.current.scroll = object.getMutableForPainting().ensureObject PaintProperties().createOrUpdateScroll( | 454 context.current.scroll = object.getMutableForPainting().ensureObject PaintProperties().createOrUpdateScroll( |
| 462 parentScrollNode, context.current.transform, scrollClip, scrollB ounds, userScrollableHorizontal, userScrollableVertical); | 455 context.current.scroll, context.current.transform, scrollClip, s crollBounds, userScrollableHorizontal, userScrollableVertical); |
| 463 | 456 |
| 464 context.current.shouldFlattenInheritedTransform = false; | 457 context.current.shouldFlattenInheritedTransform = false; |
| 465 return; | 458 return; |
| 466 } | 459 } |
| 467 } | 460 } |
| 468 | 461 |
| 469 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) { | 462 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) { |
| 470 properties->clearScrollTranslation(); | 463 properties->clearScrollTranslation(); |
| 471 properties->clearScroll(); | 464 properties->clearScroll(); |
| 472 } | 465 } |
| 473 } | 466 } |
| 474 | 467 |
| 475 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) | 468 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) |
| 476 { | 469 { |
| 477 if (object.canContainAbsolutePositionObjects()) { | 470 if (object.canContainAbsolutePositionObjects()) { |
| 478 context.absolutePosition = context.current; | 471 context.absolutePosition = context.current; |
| 479 context.containerForAbsolutePosition = &object; | 472 context.containerForAbsolutePosition = &object; |
| 480 } | 473 } |
| 481 | 474 |
| 482 if (object.isLayoutView()) { | 475 if (object.isLayoutView()) { |
| 483 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 476 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 477 const auto* initialFixedTransform = context.fixedPosition.transform; | |
| 478 auto* initialFixedScroll = context.fixedPosition.scroll; | |
| 479 | |
| 484 context.fixedPosition = context.current; | 480 context.fixedPosition = context.current; |
| 485 const TransformPaintPropertyNode* transform = object.objectPaintProp erties()->paintOffsetTranslation(); | 481 |
| 486 DCHECK(transform); | 482 // Fixed position transform and scroll nodes should not be affected. |
|
chrishtr
2016/09/26 18:02:29
Why? Isn't a LayoutView a container for fixed posi
pdr.
2016/09/26 19:42:50
It is, but only specific property tree nodes shoul
| |
| 487 context.fixedPosition.transform = transform; | 483 context.fixedPosition.transform = initialFixedTransform; |
| 484 context.fixedPosition.scroll = initialFixedScroll; | |
| 488 } | 485 } |
| 489 } else if (object.canContainFixedPositionObjects()) { | 486 } else if (object.canContainFixedPositionObjects()) { |
| 490 context.fixedPosition = context.current; | 487 context.fixedPosition = context.current; |
| 491 } else if (object.getMutableForPainting().objectPaintProperties() && object. objectPaintProperties()->cssClip()) { | 488 } else if (object.getMutableForPainting().objectPaintProperties() && object. objectPaintProperties()->cssClip()) { |
| 492 // CSS clip applies to all descendants, even if this object is not a con taining block | 489 // CSS clip applies to all descendants, even if this object is not a con taining block |
| 493 // ancestor of the descendant. It is okay for absolute-position descenda nts because | 490 // ancestor of the descendant. It is okay for absolute-position descenda nts because |
| 494 // having CSS clip implies being absolute position container. However fo r fixed-position | 491 // having CSS clip implies being absolute position container. However fo r fixed-position |
| 495 // descendants we need to insert the clip here if we are not a containin g block ancestor | 492 // descendants we need to insert the clip here if we are not a containin g block ancestor |
| 496 // of them. | 493 // of them. |
| 497 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); | 494 auto* cssClip = object.getMutableForPainting().objectPaintProperties()-> cssClip(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 return; | 579 return; |
| 583 | 580 |
| 584 updateOverflowClip(object, context); | 581 updateOverflowClip(object, context); |
| 585 updatePerspective(object, context); | 582 updatePerspective(object, context); |
| 586 updateSvgLocalToBorderBoxTransform(object, context); | 583 updateSvgLocalToBorderBoxTransform(object, context); |
| 587 updateScrollAndScrollTranslation(object, context); | 584 updateScrollAndScrollTranslation(object, context); |
| 588 updateOutOfFlowContext(object, context); | 585 updateOutOfFlowContext(object, context); |
| 589 } | 586 } |
| 590 | 587 |
| 591 } // namespace blink | 588 } // namespace blink |
| OLD | NEW |