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

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

Issue 2849603004: Introduce PaintPropertyTreeBuilderFragmentContext and use it throughout. (Closed)
Patch Set: none Created 3 years, 7 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/PaintInvalidator.h" 5 #include "core/paint/PaintInvalidator.h"
6 6
7 #include "core/editing/FrameSelection.h" 7 #include "core/editing/FrameSelection.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } else if (object == context.paint_invalidation_container) { 100 } else if (object == context.paint_invalidation_container) {
101 result = LayoutRect(rect); 101 result = LayoutRect(rect);
102 } else { 102 } else {
103 // For non-root SVG, the input rect is in local SVG coordinates in which 103 // For non-root SVG, the input rect is in local SVG coordinates in which
104 // paint offset doesn't apply. 104 // paint offset doesn't apply.
105 if (!is_svg_child) 105 if (!is_svg_child)
106 rect.MoveBy(Point(object.PaintOffset())); 106 rect.MoveBy(Point(object.PaintOffset()));
107 107
108 auto container_contents_properties = 108 auto container_contents_properties =
109 context.paint_invalidation_container->ContentsProperties(); 109 context.paint_invalidation_container->ContentsProperties();
110 if (context.tree_builder_context_->current.transform == 110 if (context.tree_builder_context_->fragments[0].current.transform ==
chrishtr 2017/04/27 22:25:41 The next patch will update PaintInvalidator also.
111 container_contents_properties.Transform() && 111 container_contents_properties.Transform() &&
112 context.tree_builder_context_->current.clip == 112 context.tree_builder_context_->fragments[0].current.clip ==
113 container_contents_properties.Clip()) { 113 container_contents_properties.Clip()) {
114 result = LayoutRect(rect); 114 result = LayoutRect(rect);
115 } else { 115 } else {
116 // Use enclosingIntRect to ensure the final visual rect will cover the 116 // Use enclosingIntRect to ensure the final visual rect will cover the
117 // rect in source coordinates no matter if the painting will use pixel 117 // rect in source coordinates no matter if the painting will use pixel
118 // snapping, when transforms are applied. If there is no transform, 118 // snapping, when transforms are applied. If there is no transform,
119 // enclosingIntRect is applied in the last step of paint invalidation 119 // enclosingIntRect is applied in the last step of paint invalidation
120 // (see CompositedLayerMapping::setContentsNeedDisplayInRect()). 120 // (see CompositedLayerMapping::setContentsNeedDisplayInRect()).
121 if (!is_svg_child && context.tree_builder_context_->current.transform != 121 if (!is_svg_child &&
122 container_contents_properties.Transform()) 122 context.tree_builder_context_->fragments[0].current.transform !=
123 container_contents_properties.Transform())
123 rect = Rect(EnclosingIntRect(rect)); 124 rect = Rect(EnclosingIntRect(rect));
124 125
125 PropertyTreeState current_tree_state( 126 PropertyTreeState current_tree_state(
126 context.tree_builder_context_->current.transform, 127 context.tree_builder_context_->fragments[0].current.transform,
127 context.tree_builder_context_->current.clip, nullptr); 128 context.tree_builder_context_->fragments[0].current.clip, nullptr);
128 129
129 FloatClipRect float_rect((FloatRect(rect))); 130 FloatClipRect float_rect((FloatRect(rect)));
130 GeometryMapper::SourceToDestinationVisualRect( 131 GeometryMapper::SourceToDestinationVisualRect(
131 current_tree_state, container_contents_properties, float_rect); 132 current_tree_state, container_contents_properties, float_rect);
132 result = LayoutRect(float_rect.Rect()); 133 result = LayoutRect(float_rect.Rect());
133 } 134 }
134 135
135 // Convert the result to the container's contents space. 136 // Convert the result to the container's contents space.
136 result.MoveBy(-context.paint_invalidation_container->PaintOffset()); 137 result.MoveBy(-context.paint_invalidation_container->PaintOffset());
137 } 138 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // In SPv2, locationInBacking is in the space of their local transform node. 175 // In SPv2, locationInBacking is in the space of their local transform node.
175 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 176 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
176 return object.PaintOffset(); 177 return object.PaintOffset();
177 178
178 LayoutPoint point; 179 LayoutPoint point;
179 if (object != context.paint_invalidation_container) { 180 if (object != context.paint_invalidation_container) {
180 point.MoveBy(object.PaintOffset()); 181 point.MoveBy(object.PaintOffset());
181 182
182 const auto* container_transform = 183 const auto* container_transform =
183 context.paint_invalidation_container->ContentsProperties().Transform(); 184 context.paint_invalidation_container->ContentsProperties().Transform();
184 if (context.tree_builder_context_->current.transform != 185 if (context.tree_builder_context_->fragments[0].current.transform !=
185 container_transform) { 186 container_transform) {
186 FloatRect rect = FloatRect(FloatPoint(point), FloatSize()); 187 FloatRect rect = FloatRect(FloatPoint(point), FloatSize());
187 GeometryMapper::SourceToDestinationRect( 188 GeometryMapper::SourceToDestinationRect(
188 context.tree_builder_context_->current.transform, container_transform, 189 context.tree_builder_context_->fragments[0].current.transform,
189 rect); 190 container_transform, rect);
190 point = LayoutPoint(rect.Location()); 191 point = LayoutPoint(rect.Location());
191 } 192 }
192 193
193 // Convert the result to the container's contents space. 194 // Convert the result to the container's contents space.
194 point.MoveBy(-context.paint_invalidation_container->PaintOffset()); 195 point.MoveBy(-context.paint_invalidation_container->PaintOffset());
195 } 196 }
196 197
197 if (context.paint_invalidation_container->Layer()->GroupedMapping()) { 198 if (context.paint_invalidation_container->Layer()->GroupedMapping()) {
198 FloatPoint float_point(point); 199 FloatPoint float_point(point);
199 PaintLayer::MapPointInPaintInvalidationContainerToBacking( 200 PaintLayer::MapPointInPaintInvalidationContainerToBacking(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // It undoes FrameView's content clip and scroll for paint invalidation of frame 259 // It undoes FrameView's content clip and scroll for paint invalidation of frame
259 // scroll controls and the LayoutView to which the content clip and scroll don't 260 // scroll controls and the LayoutView to which the content clip and scroll don't
260 // apply. 261 // apply.
261 class ScopedUndoFrameViewContentClipAndScroll { 262 class ScopedUndoFrameViewContentClipAndScroll {
262 public: 263 public:
263 ScopedUndoFrameViewContentClipAndScroll( 264 ScopedUndoFrameViewContentClipAndScroll(
264 const FrameView& frame_view, 265 const FrameView& frame_view,
265 const PaintPropertyTreeBuilderContext& tree_builder_context) 266 const PaintPropertyTreeBuilderContext& tree_builder_context)
266 : tree_builder_context_( 267 : tree_builder_context_(
267 const_cast<PaintPropertyTreeBuilderContext&>(tree_builder_context)), 268 const_cast<PaintPropertyTreeBuilderContext&>(tree_builder_context)),
268 saved_context_(tree_builder_context_.current) { 269 saved_context_(tree_builder_context_.fragments[0].current) {
269 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); 270 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled());
270 271
271 if (frame_view.ContentClip() == saved_context_.clip) 272 if (frame_view.ContentClip() == saved_context_.clip) {
272 tree_builder_context_.current.clip = saved_context_.clip->Parent(); 273 tree_builder_context_.fragments[0].current.clip =
274 saved_context_.clip->Parent();
275 }
273 if (const auto* scroll_translation = frame_view.ScrollTranslation()) { 276 if (const auto* scroll_translation = frame_view.ScrollTranslation()) {
274 if (scroll_translation->ScrollNode() == saved_context_.scroll) 277 if (scroll_translation->ScrollNode() == saved_context_.scroll) {
275 tree_builder_context_.current.scroll = saved_context_.scroll->Parent(); 278 tree_builder_context_.fragments[0].current.scroll =
279 saved_context_.scroll->Parent();
280 }
276 if (scroll_translation == saved_context_.transform) { 281 if (scroll_translation == saved_context_.transform) {
277 tree_builder_context_.current.transform = 282 tree_builder_context_.fragments[0].current.transform =
278 saved_context_.transform->Parent(); 283 saved_context_.transform->Parent();
279 } 284 }
280 } 285 }
281 } 286 }
282 287
283 ~ScopedUndoFrameViewContentClipAndScroll() { 288 ~ScopedUndoFrameViewContentClipAndScroll() {
284 tree_builder_context_.current = saved_context_; 289 tree_builder_context_.fragments[0].current = saved_context_;
285 } 290 }
286 291
287 private: 292 private:
288 PaintPropertyTreeBuilderContext& tree_builder_context_; 293 PaintPropertyTreeBuilderContext& tree_builder_context_;
289 PaintPropertyTreeBuilderContext::ContainingBlockContext saved_context_; 294 PaintPropertyTreeBuilderFragmentContext::ContainingBlockContext
295 saved_context_;
290 }; 296 };
291 297
292 } // namespace 298 } // namespace
293 299
294 void PaintInvalidator::UpdatePaintInvalidationContainer( 300 void PaintInvalidator::UpdatePaintInvalidationContainer(
295 const LayoutObject& object, 301 const LayoutObject& object,
296 PaintInvalidatorContext& context) { 302 PaintInvalidatorContext& context) {
297 if (object.IsPaintInvalidationContainer()) { 303 if (object.IsPaintInvalidationContainer()) {
298 context.paint_invalidation_container = ToLayoutBoxModelObject(&object); 304 context.paint_invalidation_container = ToLayoutBoxModelObject(&object);
299 if (object.StyleRef().IsStackingContext()) 305 if (object.StyleRef().IsStackingContext())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 376 }
371 377
372 UpdateVisualRect(object, context); 378 UpdateVisualRect(object, context);
373 } 379 }
374 380
375 void PaintInvalidator::UpdateVisualRect(const LayoutObject& object, 381 void PaintInvalidator::UpdateVisualRect(const LayoutObject& object,
376 PaintInvalidatorContext& context) { 382 PaintInvalidatorContext& context) {
377 // The paint offset should already be updated through 383 // The paint offset should already be updated through
378 // PaintPropertyTreeBuilder::updatePropertiesForSelf. 384 // PaintPropertyTreeBuilder::updatePropertiesForSelf.
379 DCHECK(context.tree_builder_context_); 385 DCHECK(context.tree_builder_context_);
380 DCHECK(context.tree_builder_context_->current.paint_offset == 386 DCHECK(context.tree_builder_context_->fragments[0].current.paint_offset ==
381 object.PaintOffset()); 387 object.PaintOffset());
382 388
383 Optional<ScopedUndoFrameViewContentClipAndScroll> 389 Optional<ScopedUndoFrameViewContentClipAndScroll>
384 undo_frame_view_content_clip_and_scroll; 390 undo_frame_view_content_clip_and_scroll;
385 391
386 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() && 392 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
387 object.IsLayoutView() && !object.IsPaintInvalidationContainer()) { 393 object.IsLayoutView() && !object.IsPaintInvalidationContainer()) {
388 undo_frame_view_content_clip_and_scroll.emplace( 394 undo_frame_view_content_clip_and_scroll.emplace(
389 *ToLayoutView(object).GetFrameView(), *context.tree_builder_context_); 395 *ToLayoutView(object).GetFrameView(), *context.tree_builder_context_);
390 } 396 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 511 }
506 512
507 void PaintInvalidator::ProcessPendingDelayedPaintInvalidations() { 513 void PaintInvalidator::ProcessPendingDelayedPaintInvalidations() {
508 for (auto target : pending_delayed_paint_invalidations_) { 514 for (auto target : pending_delayed_paint_invalidations_) {
509 target->GetMutableForPainting().SetShouldDoFullPaintInvalidation( 515 target->GetMutableForPainting().SetShouldDoFullPaintInvalidation(
510 kPaintInvalidationDelayedFull); 516 kPaintInvalidationDelayedFull);
511 } 517 }
512 } 518 }
513 519
514 } // namespace blink 520 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698