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

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: Remove unnecessary forward decl 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 root layer scrolling, the LayoutView (a LayoutObject) properties are
110 if (!layoutView) 110 // updated like other objects (see updatePropertiesAndContextForSelf and
111 return; 111 // updatePropertiesAndContextForChildren) instead of needing 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
200 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( 186 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
201 const LayoutObject& object, 187 const LayoutObject& object,
202 PaintPropertyTreeBuilderContext& context) { 188 PaintPropertyTreeBuilderContext& context) {
203 // LayoutView's paint offset is updated in the FrameView property update.
204 if (object.isLayoutView()) {
205 DCHECK(context.current.paintOffset == LayoutPoint());
206 return;
207 }
208
209 bool usesPaintOffsetTranslation = false; 189 bool usesPaintOffsetTranslation = false;
210 if (object.isBoxModelObject() && 190 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
211 context.current.paintOffset != LayoutPoint()) { 191 object.isLayoutView()) {
192 // Root layer scrolling always creates a translation node for LayoutView to
193 // ensure fixed and absolute contexts use the correct transform space.
194 usesPaintOffsetTranslation = true;
195 } else if (object.isBoxModelObject() &&
196 context.current.paintOffset != LayoutPoint()) {
212 // TODO(trchen): Eliminate PaintLayer dependency. 197 // TODO(trchen): Eliminate PaintLayer dependency.
213 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); 198 PaintLayer* layer = toLayoutBoxModelObject(object).layer();
214 if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase)) 199 if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase))
215 usesPaintOffsetTranslation = true; 200 usesPaintOffsetTranslation = true;
216 } 201 }
217 202
218 // We should use the same subpixel paint offset values for snapping 203 // We should use the same subpixel paint offset values for snapping
219 // regardless of whether a transform is present. If there is a transform 204 // regardless of whether a transform is present. If there is a transform
220 // we round the paint offset but keep around the residual fractional 205 // we round the paint offset but keep around the residual fractional
221 // component for the transformed content to paint with. In spv1 this was 206 // component for the transformed content to paint with. In spv1 this was
(...skipping 15 matching lines...) Expand all
237 context.current.renderingContextID); 222 context.current.renderingContextID);
238 } else { 223 } else {
239 if (auto* properties = object.getMutableForPainting().paintProperties()) 224 if (auto* properties = object.getMutableForPainting().paintProperties())
240 properties->clearPaintOffsetTranslation(); 225 properties->clearPaintOffsetTranslation();
241 } 226 }
242 227
243 const auto* properties = object.paintProperties(); 228 const auto* properties = object.paintProperties();
244 if (properties && properties->paintOffsetTranslation()) { 229 if (properties && properties->paintOffsetTranslation()) {
245 context.current.transform = properties->paintOffsetTranslation(); 230 context.current.transform = properties->paintOffsetTranslation();
246 context.current.paintOffset = fractionalPaintOffset; 231 context.current.paintOffset = fractionalPaintOffset;
232 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
233 object.isLayoutView()) {
234 context.absolutePosition.transform = properties->paintOffsetTranslation();
235 context.fixedPosition.transform = properties->paintOffsetTranslation();
236 context.absolutePosition.paintOffset = LayoutPoint();
237 context.fixedPosition.paintOffset = LayoutPoint();
238 }
247 } 239 }
248 } 240 }
249 241
250 static FloatPoint3D transformOrigin(const LayoutBox& box) { 242 static FloatPoint3D transformOrigin(const LayoutBox& box) {
251 const ComputedStyle& style = box.styleRef(); 243 const ComputedStyle& style = box.styleRef();
252 FloatSize borderBoxSize(box.size()); 244 FloatSize borderBoxSize(box.size());
253 return FloatPoint3D( 245 return FloatPoint3D(
254 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), 246 floatValueForLength(style.transformOriginX(), borderBoxSize.width()),
255 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), 247 floatValueForLength(style.transformOriginY(), borderBoxSize.height()),
256 style.transformOriginZ()); 248 style.transformOriginZ());
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return; 860 return;
869 861
870 updateOverflowClip(object, context); 862 updateOverflowClip(object, context);
871 updatePerspective(object, context); 863 updatePerspective(object, context);
872 updateSvgLocalToBorderBoxTransform(object, context); 864 updateSvgLocalToBorderBoxTransform(object, context);
873 updateScrollAndScrollTranslation(object, context); 865 updateScrollAndScrollTranslation(object, context);
874 updateOutOfFlowContext(object, context); 866 updateOutOfFlowContext(object, context);
875 } 867 }
876 868
877 } // namespace blink 869 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698