Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2464823003: Refactor LayoutView paint offset updates out of FrameView update code (Closed)
Patch Set: Incorporate Tien-Ren's review ideas Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 existingScroll->update(std::move(parent), std::move(scrollOffset), clip, 95 existingScroll->update(std::move(parent), std::move(scrollOffset), clip,
96 bounds, userScrollableHorizontal, 96 bounds, userScrollableHorizontal,
97 userScrollableVertical); 97 userScrollableVertical);
98 } else { 98 } else {
99 frameView.setScroll(ScrollPaintPropertyNode::create( 99 frameView.setScroll(ScrollPaintPropertyNode::create(
100 std::move(parent), std::move(scrollOffset), clip, bounds, 100 std::move(parent), std::move(scrollOffset), clip, bounds,
101 userScrollableHorizontal, userScrollableVertical)); 101 userScrollableHorizontal, userScrollableVertical));
102 } 102 }
103 } 103 }
104 104
105 void PaintPropertyTreeBuilder::updatePropertiesAndContext( 105 void PaintPropertyTreeBuilder::updateFramePropertiesAndContext(
106 FrameView& frameView, 106 FrameView& frameView,
107 PaintPropertyTreeBuilderContext& context) { 107 PaintPropertyTreeBuilderContext& context) {
108 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 108 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
109 LayoutView* layoutView = frameView.layoutView(); 109 // With RootLayerScrolling, the LayoutView (a LayoutObject) properties are
110 if (!layoutView) 110 // updated like other objects (see updatePropertiesAndContextForSelf and
111 return; 111 // updatePropertiesAndContextForChildren) instead of having LayoutView-
112 112 // specific property updates here.
113 TransformationMatrix frameTranslate; 113 context.current.paintOffset.moveBy(frameView.location());
114 frameTranslate.translate(frameView.x() + layoutView->location().x() +
115 context.current.paintOffset.x(),
116 frameView.y() + layoutView->location().y() +
117 context.current.paintOffset.y());
118 layoutView->getMutableForPainting()
119 .ensurePaintProperties()
120 .updatePaintOffsetTranslation(context.current.transform, frameTranslate,
121 FloatPoint3D());
122
123 const auto* properties = layoutView->paintProperties();
124 DCHECK(properties && properties->paintOffsetTranslation());
125 context.current.transform = properties->paintOffsetTranslation();
126 context.current.paintOffset = LayoutPoint();
127 context.current.renderingContextID = 0; 114 context.current.renderingContextID = 0;
128 context.current.shouldFlattenInheritedTransform = true; 115 context.current.shouldFlattenInheritedTransform = true;
129 context.absolutePosition = context.current; 116 context.absolutePosition = context.current;
130 context.containerForAbsolutePosition = 117 context.containerForAbsolutePosition = nullptr;
131 nullptr; // This will get set in updateOutOfFlowContext().
132 context.fixedPosition = context.current; 118 context.fixedPosition = context.current;
133 return; 119 return;
134 } 120 }
135 121
136 TransformationMatrix frameTranslate; 122 TransformationMatrix frameTranslate;
137 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), 123 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(),
138 frameView.y() + context.current.paintOffset.y()); 124 frameView.y() + context.current.paintOffset.y());
139 updateFrameViewPreTranslation(frameView, context.current.transform, 125 updateFrameViewPreTranslation(frameView, context.current.transform,
140 frameTranslate, FloatPoint3D()); 126 frameTranslate, FloatPoint3D());
141 127
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 context.fixedPosition = context.current; 176 context.fixedPosition = context.current;
191 context.fixedPosition.transform = fixedTransformNode; 177 context.fixedPosition.transform = fixedTransformNode;
192 context.fixedPosition.scroll = fixedScrollNode; 178 context.fixedPosition.scroll = fixedScrollNode;
193 179
194 std::unique_ptr<PropertyTreeState> contentsState( 180 std::unique_ptr<PropertyTreeState> contentsState(
195 new PropertyTreeState(context.current.transform, context.current.clip, 181 new PropertyTreeState(context.current.transform, context.current.clip,
196 context.currentEffect, context.current.scroll)); 182 context.currentEffect, context.current.scroll));
197 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); 183 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState));
198 } 184 }
199 185
186 void PaintPropertyTreeBuilder::updateLayoutViewPaintOffsetTranslation(
187 const LayoutView& view,
188 PaintPropertyTreeBuilderContext& context) {
189 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled());
190 TransformationMatrix translate;
191 translate.translate(context.current.paintOffset.x(),
192 context.current.paintOffset.y());
193 view.getMutableForPainting()
194 .ensurePaintProperties()
195 .updatePaintOffsetTranslation(context.current.transform, translate,
196 FloatPoint3D());
197
198 const auto* properties = view.paintProperties();
199 DCHECK(properties && properties->paintOffsetTranslation());
200 context.current.transform = context.absolutePosition.transform =
201 context.fixedPosition.transform = properties->paintOffsetTranslation();
202 context.current.paintOffset = context.absolutePosition.paintOffset =
203 context.fixedPosition.paintOffset = LayoutPoint();
204 }
205
200 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( 206 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
201 const LayoutObject& object, 207 const LayoutObject& object,
202 PaintPropertyTreeBuilderContext& context) { 208 PaintPropertyTreeBuilderContext& context) {
203 // LayoutView's paint offset is updated in the FrameView property update. 209 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
204 if (object.isLayoutView()) { 210 object.isLayoutView()) {
trchen 2016/11/01 23:36:25 Is the special case still needed? It looks like t
205 DCHECK(context.current.paintOffset == LayoutPoint()); 211 updateLayoutViewPaintOffsetTranslation(toLayoutView(object), context);
206 return; 212 return;
207 } 213 }
208 214
209 bool usesPaintOffsetTranslation = false; 215 bool usesPaintOffsetTranslation = false;
210 if (object.isBoxModelObject() && 216 if (object.isBoxModelObject() &&
211 context.current.paintOffset != LayoutPoint()) { 217 context.current.paintOffset != LayoutPoint()) {
212 // TODO(trchen): Eliminate PaintLayer dependency. 218 // TODO(trchen): Eliminate PaintLayer dependency.
213 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); 219 PaintLayer* layer = toLayoutBoxModelObject(object).layer();
214 if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase)) 220 if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase))
215 usesPaintOffsetTranslation = true; 221 usesPaintOffsetTranslation = true;
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return; 874 return;
869 875
870 updateOverflowClip(object, context); 876 updateOverflowClip(object, context);
871 updatePerspective(object, context); 877 updatePerspective(object, context);
872 updateSvgLocalToBorderBoxTransform(object, context); 878 updateSvgLocalToBorderBoxTransform(object, context);
873 updateScrollAndScrollTranslation(object, context); 879 updateScrollAndScrollTranslation(object, context);
874 updateOutOfFlowContext(object, context); 880 updateOutOfFlowContext(object, context);
875 } 881 }
876 882
877 } // namespace blink 883 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698