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

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

Issue 2410153007: Revert of Use enclosingLayoutRect instead of enclosingIntRect in SVGLayoutSupport::transformPaintInvalidation… (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "core/layout/LayoutBlockFlow.h" 11 #include "core/layout/LayoutBlockFlow.h"
12 #include "core/layout/LayoutObject.h" 12 #include "core/layout/LayoutObject.h"
13 #include "core/layout/LayoutTable.h" 13 #include "core/layout/LayoutTable.h"
14 #include "core/layout/LayoutView.h" 14 #include "core/layout/LayoutView.h"
15 #include "core/layout/svg/SVGLayoutSupport.h" 15 #include "core/layout/svg/SVGLayoutSupport.h"
16 #include "core/paint/ObjectPaintProperties.h" 16 #include "core/paint/ObjectPaintProperties.h"
17 #include "core/paint/PaintLayer.h" 17 #include "core/paint/PaintLayer.h"
18 #include "core/paint/PaintLayerScrollableArea.h" 18 #include "core/paint/PaintLayerScrollableArea.h"
19 #include "core/paint/PaintPropertyTreeBuilder.h" 19 #include "core/paint/PaintPropertyTreeBuilder.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 // TODO(wangxianzhu): Avoid using function when possible. For example, we can
24 // avoid it by avoiding unnecessary conversions between LayoutRects and
25 // FloatRects.
26 static LayoutRect enclosingLayoutRectIfNotEmpty(const FloatRect& floatRect) {
27 return floatRect.isEmpty() ? LayoutRect(floatRect)
28 : enclosingLayoutRect(floatRect);
29 }
30
31 static LayoutRect slowMapToVisualRectInAncestorSpace( 23 static LayoutRect slowMapToVisualRectInAncestorSpace(
32 const LayoutObject& object, 24 const LayoutObject& object,
33 const LayoutBoxModelObject& ancestor, 25 const LayoutBoxModelObject& ancestor,
34 const FloatRect& rect) { 26 const FloatRect& rect) {
35 if (object.isSVG() && !object.isSVGRoot()) { 27 if (object.isSVG() && !object.isSVGRoot()) {
36 LayoutRect result; 28 LayoutRect result;
37 SVGLayoutSupport::mapToVisualRectInAncestorSpace(object, &ancestor, rect, 29 SVGLayoutSupport::mapToVisualRectInAncestorSpace(object, &ancestor, rect,
38 result); 30 result);
39 return result; 31 return result;
40 } 32 }
41 33
42 LayoutRect result = enclosingLayoutRectIfNotEmpty(rect); 34 LayoutRect result(rect);
43 if (object.isLayoutView()) 35 if (object.isLayoutView())
44 toLayoutView(object).mapToVisualRectInAncestorSpace( 36 toLayoutView(object).mapToVisualRectInAncestorSpace(
45 &ancestor, result, InputIsInFrameCoordinates, DefaultVisualRectFlags); 37 &ancestor, result, InputIsInFrameCoordinates, DefaultVisualRectFlags);
46 else 38 else
47 object.mapToVisualRectInAncestorSpace(&ancestor, result); 39 object.mapToVisualRectInAncestorSpace(&ancestor, result);
48 return result; 40 return result;
49 } 41 }
50 42
51 // TODO(wangxianzhu): Combine this into 43 // TODO(wangxianzhu): Combine this into PaintInvalidator::mapLocalRectToPaintInv alidationBacking() when removing PaintInvalidationState.
52 // PaintInvalidator::mapLocalRectToPaintInvalidationBacking() when removing
53 // PaintInvalidationState.
54 static LayoutRect mapLocalRectToPaintInvalidationBacking( 44 static LayoutRect mapLocalRectToPaintInvalidationBacking(
55 GeometryMapper& geometryMapper, 45 GeometryMapper& geometryMapper,
56 const LayoutObject& object, 46 const LayoutObject& object,
57 const FloatRect& localRect, 47 const FloatRect& localRect,
58 const PaintInvalidatorContext& context) { 48 const PaintInvalidatorContext& context) {
59 // TODO(wkorman): The flip below is required because visual rects are 49 // TODO(wkorman): The flip below is required because visual rects are
60 // currently in "physical coordinates with flipped block-flow direction" 50 // currently in "physical coordinates with flipped block-flow direction"
61 // (see LayoutBoxModelObject.h) but we need them to be in physical 51 // (see LayoutBoxModelObject.h) but we need them to be in physical
62 // coordinates. 52 // coordinates.
63 FloatRect rect = localRect; 53 FloatRect rect = localRect;
64 // Writing-mode flipping doesn't apply to non-root SVG. 54 // Writing-mode flipping doesn't apply to non-root SVG.
65 if (!object.isSVG() || object.isSVGRoot()) { 55 if (!object.isSVG() || object.isSVGRoot()) {
66 if (object.isBox()) { 56 if (object.isBox()) {
67 toLayoutBox(object).flipForWritingMode(rect); 57 toLayoutBox(object).flipForWritingMode(rect);
68 } else if (!(context.forcedSubtreeInvalidationFlags & 58 } else if (!(context.forcedSubtreeInvalidationFlags &
69 PaintInvalidatorContext::ForcedSubtreeSlowPathRect)) { 59 PaintInvalidatorContext::ForcedSubtreeSlowPathRect)) {
70 // For SPv2 and the GeometryMapper path, we also need to convert the rect 60 // For SPv2 and the GeometryMapper path, we also need to convert the rect
71 // for non-boxes into physical coordinates before applying paint offset. 61 // for non-boxes into physical coordinates before applying paint offset.
72 // (Otherwise we'll call mapToVisualrectInAncestorSpace() which requires 62 // (Otherwise we'll call mapToVisualrectInAncestorSpace() which requires
73 // physical coordinates for boxes, but "physical coordinates with flipped 63 // physical coordinates for boxes, but "physical coordinates with flipped
74 // block-flow direction" for non-boxes for which we don't need to flip.) 64 // block-flow direction" for non-boxes for which we don't need to flip.)
75 // TODO(wangxianzhu): Avoid containingBlock(). 65 // TODO(wangxianzhu): Avoid containingBlock().
76 object.containingBlock()->flipForWritingMode(rect); 66 object.containingBlock()->flipForWritingMode(rect);
77 } 67 }
78 } 68 }
79 69
80 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 70 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
81 // In SPv2, visual rects are in the space of their local transform node. 71 // In SPv2, visual rects are in the space of their local transform node.
82 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); 72 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
83 return enclosingLayoutRectIfNotEmpty(rect); 73 return LayoutRect(rect);
84 } 74 }
85 75
86 LayoutRect result; 76 LayoutRect result;
87 if (context.forcedSubtreeInvalidationFlags & 77 if (context.forcedSubtreeInvalidationFlags &
88 PaintInvalidatorContext::ForcedSubtreeSlowPathRect) { 78 PaintInvalidatorContext::ForcedSubtreeSlowPathRect) {
89 result = slowMapToVisualRectInAncestorSpace( 79 result = slowMapToVisualRectInAncestorSpace(
90 object, *context.paintInvalidationContainer, rect); 80 object, *context.paintInvalidationContainer, rect);
91 } else if (object == context.paintInvalidationContainer) { 81 } else if (object == context.paintInvalidationContainer) {
92 result = enclosingLayoutRectIfNotEmpty(rect); 82 result = LayoutRect(rect);
93 } else { 83 } else {
94 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); 84 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
95 85
96 PropertyTreeState currentTreeState( 86 PropertyTreeState currentTreeState(
97 context.treeBuilderContext.current.transform, 87 context.treeBuilderContext.current.transform,
98 context.treeBuilderContext.current.clip, 88 context.treeBuilderContext.current.clip,
99 context.treeBuilderContext.currentEffect, 89 context.treeBuilderContext.currentEffect,
100 context.treeBuilderContext.current.scroll); 90 context.treeBuilderContext.current.scroll);
101 const ObjectPaintProperties* containerPaintProperties = 91 const ObjectPaintProperties* containerPaintProperties =
102 context.paintInvalidationContainer->objectPaintProperties(); 92 context.paintInvalidationContainer->objectPaintProperties();
103 auto containerContentsProperties = 93 auto containerContentsProperties =
104 containerPaintProperties->contentsProperties(); 94 containerPaintProperties->contentsProperties();
105 95
106 bool success = false; 96 bool success = false;
107 result = enclosingLayoutRectIfNotEmpty( 97 result = LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace(
108 geometryMapper.mapToVisualRectInDestinationSpace( 98 rect, currentTreeState, containerContentsProperties.propertyTreeState,
109 rect, currentTreeState, 99 success));
110 containerContentsProperties.propertyTreeState, success));
111 DCHECK(success); 100 DCHECK(success);
112 101
113 // Convert the result to the container's contents space. 102 // Convert the result to the container's contents space.
114 result.moveBy(-containerContentsProperties.paintOffset); 103 result.moveBy(-containerContentsProperties.paintOffset);
115 } 104 }
116 105
117 if (context.paintInvalidationContainer->layer()->groupedMapping()) 106 if (context.paintInvalidationContainer->layer()->groupedMapping())
118 PaintLayer::mapRectInPaintInvalidationContainerToBacking( 107 PaintLayer::mapRectInPaintInvalidationContainerToBacking(
119 *context.paintInvalidationContainer, result); 108 *context.paintInvalidationContainer, result);
120 return result; 109 return result;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 object.getMutableForPainting().clearPaintInvalidationFlags(); 428 object.getMutableForPainting().clearPaintInvalidationFlags();
440 } 429 }
441 430
442 void PaintInvalidator::processPendingDelayedPaintInvalidations() { 431 void PaintInvalidator::processPendingDelayedPaintInvalidations() {
443 for (auto target : m_pendingDelayedPaintInvalidations) 432 for (auto target : m_pendingDelayedPaintInvalidations)
444 target->getMutableForPainting().setShouldDoFullPaintInvalidation( 433 target->getMutableForPainting().setShouldDoFullPaintInvalidation(
445 PaintInvalidationDelayedFull); 434 PaintInvalidationDelayedFull);
446 } 435 }
447 436
448 } // namespace blink 437 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698