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" |
| 11 #include "core/layout/LayoutPart.h" | 11 #include "core/layout/LayoutPart.h" |
| 12 #include "core/layout/LayoutView.h" | 12 #include "core/layout/LayoutView.h" |
| 13 #include "core/layout/svg/LayoutSVGRoot.h" | 13 #include "core/layout/svg/LayoutSVGRoot.h" |
| 14 #include "core/paint/ObjectPaintProperties.h" | 14 #include "core/paint/ObjectPaintProperties.h" |
| 15 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
| 16 #include "core/paint/SVGRootPainter.h" | 16 #include "core/paint/SVGRootPainter.h" |
| 17 #include "platform/transforms/TransformationMatrix.h" | 17 #include "platform/transforms/TransformationMatrix.h" |
| 18 #include "wtf/PtrUtil.h" | 18 #include "wtf/PtrUtil.h" |
| 19 #include <memory> | 19 #include <memory> |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro pertyTreeBuilderContext& context) | 23 namespace { |
| 24 { | 24 TransformPaintPropertyNode* rootTransformNode() |
| 25 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 25 { |
| 26 return; | 26 DEFINE_STATIC_REF(TransformPaintPropertyNode, rootTransform, (TransformP aintPropertyNode::create(nullptr, TransformationMatrix(), FloatPoint3D()))); |
| 27 | 27 return rootTransform; |
| 28 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { | |
| 29 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T ransformationMatrix(), FloatPoint3D())); | |
| 30 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); | |
| 31 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); | |
| 32 rootFrame.setRootScroll(ScrollPaintPropertyNode::create(nullptr, rootFra me.rootTransform(), IntSize(), IntSize(), false, false)); | |
| 33 } else { | |
| 34 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->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); | |
| 39 } | 28 } |
| 40 | 29 |
| 41 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootFrame.rootTransform(); | 30 ClipPaintPropertyNode* rootClipNode() |
| 42 context.current.scroll = rootFrame.rootScroll(); | 31 { |
| 43 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootFrame.rootClip(); | 32 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip, (ClipPaintPropertyNod e::create(nullptr, rootTransformNode(), FloatRoundedRect(LayoutRect::infiniteInt Rect())))); |
| 44 context.currentEffect = rootFrame.rootEffect(); | 33 return rootClip; |
| 34 } | |
| 35 | |
| 36 EffectPaintPropertyNode* rootEffectNode() | |
| 37 { | |
| 38 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect, (EffectPaintPrope rtyNode::create(nullptr, 1.0))); | |
| 39 return rootEffect; | |
| 40 } | |
| 41 | |
| 42 ScrollPaintPropertyNode* rootScrollNode() | |
| 43 { | |
| 44 DEFINE_STATIC_REF(ScrollPaintPropertyNode, rootScroll, (ScrollPaintPrope rtyNode::create(nullptr, rootTransformNode(), IntSize(), IntSize(), false, false ))); | |
| 45 return rootScroll; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 PaintPropertyTreeBuilderContext PaintPropertyTreeBuilder::setupInitialContext() | |
| 50 { | |
| 51 PaintPropertyTreeBuilderContext context; | |
| 52 | |
| 53 // TODO(pdr): Update the root layer scrolling paths to use the static root n odes. | |
| 54 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | |
| 55 return context; | |
| 56 | |
| 57 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootTransformNode(); | |
| 58 context.current.scroll = context.absolutePosition.scroll = context.fixedPosi tion.scroll = rootScrollNode(); | |
| 59 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootClipNode(); | |
| 60 context.currentEffect = rootEffectNode(); | |
| 61 | |
| 62 // Ensure scroll tree properties are reset. They will be rebuilt during the tree walk. | |
| 63 rootScrollNode()->clearMainThreadScrollingReasons(); | |
|
jbroman
2016/09/22 14:20:52
This one confuses me a little. If there's a global
pdr.
2016/09/22 19:48:20
This patch was just matching the existing behavior
| |
| 64 | |
| 65 return context; | |
| 45 } | 66 } |
| 46 | 67 |
| 47 void createOrUpdateFrameViewPreTranslation(FrameView& frameView, | 68 void createOrUpdateFrameViewPreTranslation(FrameView& frameView, |
| 48 PassRefPtr<const TransformPaintPropertyNode> parent, | 69 PassRefPtr<const TransformPaintPropertyNode> parent, |
| 49 const TransformationMatrix& matrix, | 70 const TransformationMatrix& matrix, |
| 50 const FloatPoint3D& origin) | 71 const FloatPoint3D& origin) |
| 51 { | 72 { |
| 52 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 73 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 53 if (TransformPaintPropertyNode* existingPreTranslation = frameView.preTransl ation()) | 74 if (TransformPaintPropertyNode* existingPreTranslation = frameView.preTransl ation()) |
| 54 existingPreTranslation->update(std::move(parent), matrix, origin); | 75 existingPreTranslation->update(std::move(parent), matrix, origin); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 context.current.paintOffset = LayoutPoint(); | 170 context.current.paintOffset = LayoutPoint(); |
| 150 context.current.clip = frameView.contentClip(); | 171 context.current.clip = frameView.contentClip(); |
| 151 context.current.scroll = frameView.scroll() ? frameView.scroll() : initialSc roll; | 172 context.current.scroll = frameView.scroll() ? frameView.scroll() : initialSc roll; |
| 152 context.current.renderingContextID = 0; | 173 context.current.renderingContextID = 0; |
| 153 context.current.shouldFlattenInheritedTransform = true; | 174 context.current.shouldFlattenInheritedTransform = true; |
| 154 context.absolutePosition = context.current; | 175 context.absolutePosition = context.current; |
| 155 context.containerForAbsolutePosition = nullptr; | 176 context.containerForAbsolutePosition = nullptr; |
| 156 context.fixedPosition = context.current; | 177 context.fixedPosition = context.current; |
| 157 context.fixedPosition.transform = frameView.preTranslation(); | 178 context.fixedPosition.transform = frameView.preTranslation(); |
| 158 context.fixedPosition.scroll = initialScroll; | 179 context.fixedPosition.scroll = initialScroll; |
| 180 | |
| 181 std::unique_ptr<PropertyTreeState> contentsState(new PropertyTreeState(conte xt.current.transform, context.current.clip, context.currentEffect, context.curre nt.scroll)); | |
| 182 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); | |
| 159 } | 183 } |
| 160 | 184 |
| 161 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) | 185 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
| 162 { | 186 { |
| 163 if (object.isBoxModelObject() && context.current.paintOffset != LayoutPoint( )) { | 187 if (object.isBoxModelObject() && context.current.paintOffset != LayoutPoint( )) { |
| 164 // TODO(trchen): Eliminate PaintLayer dependency. | 188 // TODO(trchen): Eliminate PaintLayer dependency. |
| 165 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | 189 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
| 166 if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase)) { | 190 if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase)) { |
| 167 // We should use the same subpixel paint offset values for snapping regardless of whether a | 191 // We should use the same subpixel paint offset values for snapping regardless of whether a |
| 168 // transform is present. If there is a transform we round the paint offset but keep around | 192 // transform is present. If there is a transform we round the paint offset but keep around |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 return; | 597 return; |
| 574 | 598 |
| 575 updateOverflowClip(object, context); | 599 updateOverflowClip(object, context); |
| 576 updatePerspective(object, context); | 600 updatePerspective(object, context); |
| 577 updateSvgLocalToBorderBoxTransform(object, context); | 601 updateSvgLocalToBorderBoxTransform(object, context); |
| 578 updateScrollAndScrollTranslation(object, context); | 602 updateScrollAndScrollTranslation(object, context); |
| 579 updateOutOfFlowContext(object, context); | 603 updateOutOfFlowContext(object, context); |
| 580 } | 604 } |
| 581 | 605 |
| 582 } // namespace blink | 606 } // namespace blink |
| OLD | NEW |