| 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 15 matching lines...) Expand all Loading... |
| 26 return; | 26 return; |
| 27 | 27 |
| 28 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { | 28 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { |
| 29 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T
ransformationMatrix(), FloatPoint3D())); | 29 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T
ransformationMatrix(), FloatPoint3D())); |
| 30 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r
ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); | 30 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r
ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); |
| 31 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); | 31 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); |
| 32 rootFrame.setRootScroll(ScrollPaintPropertyNode::create(nullptr, rootFra
me.rootTransform(), IntSize(), IntSize(), false, false)); | 32 rootFrame.setRootScroll(ScrollPaintPropertyNode::create(nullptr, rootFra
me.rootTransform(), IntSize(), IntSize(), false, false)); |
| 33 } else { | 33 } else { |
| 34 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); | 34 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); |
| 35 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); | 35 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); |
| 36 DCHECK(rootFrame.rootScroll() && !rootFrame.rootScroll()->parent()); |
| 37 // Ensure main thread scroll reasons are reset. |
| 38 rootFrame.rootScroll()->update(nullptr, rootFrame.rootTransform(), IntSi
ze(), IntSize(), false, false); |
| 36 } | 39 } |
| 37 | 40 |
| 38 context.current.transform = context.absolutePosition.transform = context.fix
edPosition.transform = rootFrame.rootTransform(); | 41 context.current.transform = context.absolutePosition.transform = context.fix
edPosition.transform = rootFrame.rootTransform(); |
| 39 context.current.scroll = rootFrame.rootScroll(); | 42 context.current.scroll = rootFrame.rootScroll(); |
| 40 context.current.clip = context.absolutePosition.clip = context.fixedPosition
.clip = rootFrame.rootClip(); | 43 context.current.clip = context.absolutePosition.clip = context.fixedPosition
.clip = rootFrame.rootClip(); |
| 41 context.currentEffect = rootFrame.rootEffect(); | 44 context.currentEffect = rootFrame.rootEffect(); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void createOrUpdateFrameViewPreTranslation(FrameView& frameView, | 47 void createOrUpdateFrameViewPreTranslation(FrameView& frameView, |
| 45 PassRefPtr<const TransformPaintPropertyNode> parent, | 48 PassRefPtr<const TransformPaintPropertyNode> parent, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 71 const FloatPoint3D& origin) | 74 const FloatPoint3D& origin) |
| 72 { | 75 { |
| 73 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 76 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 74 if (TransformPaintPropertyNode* existingScrollTranslation = frameView.scroll
Translation()) | 77 if (TransformPaintPropertyNode* existingScrollTranslation = frameView.scroll
Translation()) |
| 75 existingScrollTranslation->update(parent, matrix, origin); | 78 existingScrollTranslation->update(parent, matrix, origin); |
| 76 else | 79 else |
| 77 frameView.setScrollTranslation(TransformPaintPropertyNode::create(parent
, matrix, origin)); | 80 frameView.setScrollTranslation(TransformPaintPropertyNode::create(parent
, matrix, origin)); |
| 78 } | 81 } |
| 79 | 82 |
| 80 void createOrUpdateFrameViewScroll(FrameView& frameView, | 83 void createOrUpdateFrameViewScroll(FrameView& frameView, |
| 81 PassRefPtr<const ScrollPaintPropertyNode> parent, | 84 PassRefPtr<ScrollPaintPropertyNode> parent, |
| 82 PassRefPtr<const TransformPaintPropertyNode> scrollOffset, | 85 PassRefPtr<const TransformPaintPropertyNode> scrollOffset, |
| 83 const IntSize& clip, const IntSize& bounds, | 86 const IntSize& clip, const IntSize& bounds, |
| 84 bool userScrollableHorizontal, | 87 bool userScrollableHorizontal, |
| 85 bool userScrollableVertical) | 88 bool userScrollableVertical) |
| 86 { | 89 { |
| 87 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 90 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 88 if (ScrollPaintPropertyNode* existingScroll = frameView.scroll()) | 91 if (ScrollPaintPropertyNode* existingScroll = frameView.scroll()) |
| 89 existingScroll->update(parent, scrollOffset, clip, bounds, userScrollabl
eHorizontal, userScrollableVertical); | 92 existingScroll->update(parent, scrollOffset, clip, bounds, userScrollabl
eHorizontal, userScrollableVertical); |
| 90 else | 93 else |
| 91 frameView.setScroll(ScrollPaintPropertyNode::create(parent, scrollOffset
, clip, bounds, userScrollableHorizontal, userScrollableVertical)); | 94 frameView.setScroll(ScrollPaintPropertyNode::create(parent, scrollOffset
, clip, bounds, userScrollableHorizontal, userScrollableVertical)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 bool userScrollableHorizontal = frameView.userInputScrollable(Horizontal
Scrollbar); | 137 bool userScrollableHorizontal = frameView.userInputScrollable(Horizontal
Scrollbar); |
| 135 bool userScrollableVertical = frameView.userInputScrollable(VerticalScro
llbar); | 138 bool userScrollableVertical = frameView.userInputScrollable(VerticalScro
llbar); |
| 136 createOrUpdateFrameViewScroll(frameView, context.current.scroll, frameVi
ew.scrollTranslation(), scrollClip, scrollBounds, userScrollableHorizontal, user
ScrollableVertical); | 139 createOrUpdateFrameViewScroll(frameView, context.current.scroll, frameVi
ew.scrollTranslation(), scrollClip, scrollBounds, userScrollableHorizontal, user
ScrollableVertical); |
| 137 } else { | 140 } else { |
| 138 frameView.setScroll(nullptr); | 141 frameView.setScroll(nullptr); |
| 139 } | 142 } |
| 140 | 143 |
| 141 // Initialize the context for current, absolute and fixed position cases. | 144 // Initialize the context for current, absolute and fixed position cases. |
| 142 // They are the same, except that scroll translation does not apply to | 145 // They are the same, except that scroll translation does not apply to |
| 143 // fixed position descendants. | 146 // fixed position descendants. |
| 144 const ScrollPaintPropertyNode* initialScroll = context.current.scroll; | 147 ScrollPaintPropertyNode* initialScroll = context.current.scroll; |
| 145 context.current.transform = frameView.scrollTranslation(); | 148 context.current.transform = frameView.scrollTranslation(); |
| 146 context.current.paintOffset = LayoutPoint(); | 149 context.current.paintOffset = LayoutPoint(); |
| 147 context.current.clip = frameView.contentClip(); | 150 context.current.clip = frameView.contentClip(); |
| 148 context.current.scroll = frameView.scroll() ? frameView.scroll() : initialSc
roll; | 151 context.current.scroll = frameView.scroll() ? frameView.scroll() : initialSc
roll; |
| 149 context.current.renderingContextID = 0; | 152 context.current.renderingContextID = 0; |
| 150 context.current.shouldFlattenInheritedTransform = true; | 153 context.current.shouldFlattenInheritedTransform = true; |
| 151 context.absolutePosition = context.current; | 154 context.absolutePosition = context.current; |
| 152 context.containerForAbsolutePosition = nullptr; | 155 context.containerForAbsolutePosition = nullptr; |
| 153 context.fixedPosition = context.current; | 156 context.fixedPosition = context.current; |
| 154 context.fixedPosition.transform = frameView.preTranslation(); | 157 context.fixedPosition.transform = frameView.preTranslation(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 context.current.transform, paintOffset, FloatPoint3D()); | 326 context.current.transform, paintOffset, FloatPoint3D()); |
| 324 return; | 327 return; |
| 325 } | 328 } |
| 326 } | 329 } |
| 327 } | 330 } |
| 328 | 331 |
| 329 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) | 332 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) |
| 330 properties->clearScrollbarPaintOffset(); | 333 properties->clearScrollbarPaintOffset(); |
| 331 } | 334 } |
| 332 | 335 |
| 336 void PaintPropertyTreeBuilder::updateMainThreadScrollingReasons(const LayoutObje
ct& object, PaintPropertyTreeBuilderContext& context) |
| 337 { |
| 338 if (object.isBackgroundAttachmentFixedObject()) { |
| 339 auto* scrollNode = context.current.scroll; |
| 340 while (scrollNode && !scrollNode->hasBackgroundAttachmentFixedMainThread
ScrollingReason()) { |
| 341 scrollNode->setBackgroundAttachmentFixedMainThreadScrollingReason(); |
| 342 scrollNode = scrollNode->parent(); |
| 343 } |
| 344 } |
| 345 } |
| 346 |
| 333 void PaintPropertyTreeBuilder::updateOverflowClip(const LayoutObject& object, Pa
intPropertyTreeBuilderContext& context) | 347 void PaintPropertyTreeBuilder::updateOverflowClip(const LayoutObject& object, Pa
intPropertyTreeBuilderContext& context) |
| 334 { | 348 { |
| 335 if (!object.isBox()) | 349 if (!object.isBox()) |
| 336 return; | 350 return; |
| 337 const LayoutBox& box = toLayoutBox(object); | 351 const LayoutBox& box = toLayoutBox(object); |
| 338 | 352 |
| 339 // The <input> elements can't have contents thus CSS overflow property doesn
't apply. | 353 // The <input> elements can't have contents thus CSS overflow property doesn
't apply. |
| 340 // However for layout purposes we do generate child layout objects for them,
e.g. button label. | 354 // However for layout purposes we do generate child layout objects for them,
e.g. button label. |
| 341 // We should clip the overflow from those children. This is called control c
lip and we | 355 // We should clip the overflow from those children. This is called control c
lip and we |
| 342 // technically treat them like overflow clip. | 356 // technically treat them like overflow clip. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl
edFeatures::rootLayerScrollingEnabled(); | 438 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl
edFeatures::rootLayerScrollingEnabled(); |
| 425 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro
llsOverflow()) { | 439 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro
llsOverflow()) { |
| 426 TransformationMatrix matrix = TransformationMatrix().translate(-scro
llOffset.width(), -scrollOffset.height()); | 440 TransformationMatrix matrix = TransformationMatrix().translate(-scro
llOffset.width(), -scrollOffset.height()); |
| 427 context.current.transform = object.getMutableForPainting().ensureObj
ectPaintProperties().createOrUpdateScrollTranslation( | 441 context.current.transform = object.getMutableForPainting().ensureObj
ectPaintProperties().createOrUpdateScrollTranslation( |
| 428 context.current.transform, matrix, FloatPoint3D(), context.curre
nt.shouldFlattenInheritedTransform, context.current.renderingContextID); | 442 context.current.transform, matrix, FloatPoint3D(), context.curre
nt.shouldFlattenInheritedTransform, context.current.renderingContextID); |
| 429 | 443 |
| 430 IntSize scrollClip = layer->getScrollableArea()->visibleContentRect(
).size(); | 444 IntSize scrollClip = layer->getScrollableArea()->visibleContentRect(
).size(); |
| 431 IntSize scrollBounds = layer->getScrollableArea()->contentsSize(); | 445 IntSize scrollBounds = layer->getScrollableArea()->contentsSize(); |
| 432 bool userScrollableHorizontal = layer->getScrollableArea()->userInpu
tScrollable(HorizontalScrollbar); | 446 bool userScrollableHorizontal = layer->getScrollableArea()->userInpu
tScrollable(HorizontalScrollbar); |
| 433 bool userScrollableVertical = layer->getScrollableArea()->userInputS
crollable(VerticalScrollbar); | 447 bool userScrollableVertical = layer->getScrollableArea()->userInputS
crollable(VerticalScrollbar); |
| 434 const ScrollPaintPropertyNode* parentScrollNode = forceScrollingForL
ayoutView ? nullptr : context.current.scroll; | 448 ScrollPaintPropertyNode* parentScrollNode = forceScrollingForLayoutV
iew ? nullptr : context.current.scroll; |
| 435 context.current.scroll = object.getMutableForPainting().ensureObject
PaintProperties().createOrUpdateScroll( | 449 context.current.scroll = object.getMutableForPainting().ensureObject
PaintProperties().createOrUpdateScroll( |
| 436 parentScrollNode, context.current.transform, scrollClip, scrollB
ounds, userScrollableHorizontal, userScrollableVertical); | 450 parentScrollNode, context.current.transform, scrollClip, scrollB
ounds, userScrollableHorizontal, userScrollableVertical); |
| 437 | 451 |
| 438 context.current.shouldFlattenInheritedTransform = false; | 452 context.current.shouldFlattenInheritedTransform = false; |
| 439 return; | 453 return; |
| 440 } | 454 } |
| 441 } | 455 } |
| 442 | 456 |
| 443 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) { | 457 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec
tPaintProperties()) { |
| 444 properties->clearScrollTranslation(); | 458 properties->clearScrollTranslation(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 return; | 554 return; |
| 541 | 555 |
| 542 deriveBorderBoxFromContainerContext(object, context); | 556 deriveBorderBoxFromContainerContext(object, context); |
| 543 | 557 |
| 544 updatePaintOffsetTranslation(object, context); | 558 updatePaintOffsetTranslation(object, context); |
| 545 updateTransform(object, context); | 559 updateTransform(object, context); |
| 546 updateEffect(object, context); | 560 updateEffect(object, context); |
| 547 updateCssClip(object, context); | 561 updateCssClip(object, context); |
| 548 updateLocalBorderBoxContext(object, context); | 562 updateLocalBorderBoxContext(object, context); |
| 549 updateScrollbarPaintOffset(object, context); | 563 updateScrollbarPaintOffset(object, context); |
| 564 updateMainThreadScrollingReasons(object, context); |
| 550 } | 565 } |
| 551 | 566 |
| 552 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj
ect, PaintPropertyTreeBuilderContext& context) | 567 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj
ect, PaintPropertyTreeBuilderContext& context) |
| 553 { | 568 { |
| 554 if (!object.isBoxModelObject() && !object.isSVG()) | 569 if (!object.isBoxModelObject() && !object.isSVG()) |
| 555 return; | 570 return; |
| 556 | 571 |
| 557 updateOverflowClip(object, context); | 572 updateOverflowClip(object, context); |
| 558 updatePerspective(object, context); | 573 updatePerspective(object, context); |
| 559 updateSvgLocalToBorderBoxTransform(object, context); | 574 updateSvgLocalToBorderBoxTransform(object, context); |
| 560 updateScrollAndScrollTranslation(object, context); | 575 updateScrollAndScrollTranslation(object, context); |
| 561 updateOutOfFlowContext(object, context); | 576 updateOutOfFlowContext(object, context); |
| 562 } | 577 } |
| 563 | 578 |
| 564 } // namespace blink | 579 } // namespace blink |
| OLD | NEW |