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

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

Issue 2465983002: Rename "paint invalidation rect" etc. to "visual rect". (Closed)
Patch Set: - 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/PaintInvalidationCapableScrollableArea.h" 5 #include "core/paint/PaintInvalidationCapableScrollableArea.h"
6 6
7 #include "core/frame/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/html/HTMLFrameOwnerElement.h" 8 #include "core/html/HTMLFrameOwnerElement.h"
9 #include "core/layout/LayoutBox.h" 9 #include "core/layout/LayoutBox.h"
10 #include "core/layout/LayoutScrollbar.h" 10 #include "core/layout/LayoutScrollbar.h"
(...skipping 11 matching lines...) Expand all
22 if (!scrollbar.isCustomScrollbar() && 22 if (!scrollbar.isCustomScrollbar() &&
23 !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar() 23 !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar()
24 : layerForVerticalScrollbar())) 24 : layerForVerticalScrollbar()))
25 ObjectPaintInvalidator(*layoutBox()) 25 ObjectPaintInvalidator(*layoutBox())
26 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( 26 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
27 scrollbar, PaintInvalidationScroll); 27 scrollbar, PaintInvalidationScroll);
28 28
29 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 29 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
30 } 30 }
31 31
32 static LayoutRect scrollControlPaintInvalidationRect( 32 static LayoutRect scrollControlVisualRect(
33 const IntRect& scrollControlRect, 33 const IntRect& scrollControlRect,
34 const LayoutBox& box, 34 const LayoutBox& box,
35 const PaintInvalidatorContext& context) { 35 const PaintInvalidatorContext& context) {
36 LayoutRect paintInvalidationRect(scrollControlRect); 36 LayoutRect visualRect(scrollControlRect);
37 // No need to apply any paint offset. Scroll controls paint in a different 37 // No need to apply any paint offset. Scroll controls paint in a different
38 // transform space than their contained box (the scrollbarPaintOffset 38 // transform space than their contained box (the scrollbarPaintOffset
39 // transform node). 39 // transform node).
40 if (!paintInvalidationRect.isEmpty() && 40 if (!visualRect.isEmpty() &&
41 !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 41 !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
42 context.mapLocalRectToPaintInvalidationBacking(box, paintInvalidationRect); 42 context.mapLocalRectToPaintInvalidationBacking(box, visualRect);
43 43
44 IntSize adjustment = box.scrollAdjustmentForPaintInvalidation( 44 IntSize adjustment = box.scrollAdjustmentForPaintInvalidation(
45 *context.paintInvalidationContainer); 45 *context.paintInvalidationContainer);
46 paintInvalidationRect.move(adjustment); 46 visualRect.move(adjustment);
47 } 47 }
48 return paintInvalidationRect; 48 return visualRect;
49 } 49 }
50 50
51 // Returns true if the scroll control is invalidated. 51 // Returns true if the scroll control is invalidated.
52 static bool invalidatePaintOfScrollControlIfNeeded( 52 static bool invalidatePaintOfScrollControlIfNeeded(
53 const LayoutRect& newPaintInvalidationRect, 53 const LayoutRect& newVisualRect,
54 const LayoutRect& previousPaintInvalidationRect, 54 const LayoutRect& previousVisualRect,
55 bool needsPaintInvalidation, 55 bool needsPaintInvalidation,
56 LayoutBox& box, 56 LayoutBox& box,
57 const LayoutBoxModelObject& paintInvalidationContainer) { 57 const LayoutBoxModelObject& paintInvalidationContainer) {
58 bool shouldInvalidateNewRect = needsPaintInvalidation; 58 bool shouldInvalidateNewRect = needsPaintInvalidation;
59 if (newPaintInvalidationRect != previousPaintInvalidationRect) { 59 if (newVisualRect != previousVisualRect) {
60 ObjectPaintInvalidator(box).invalidatePaintUsingContainer( 60 ObjectPaintInvalidator(box).invalidatePaintUsingContainer(
61 paintInvalidationContainer, previousPaintInvalidationRect, 61 paintInvalidationContainer, previousVisualRect,
62 PaintInvalidationScroll); 62 PaintInvalidationScroll);
63 shouldInvalidateNewRect = true; 63 shouldInvalidateNewRect = true;
64 } 64 }
65 if (shouldInvalidateNewRect) { 65 if (shouldInvalidateNewRect) {
66 ObjectPaintInvalidator(box).invalidatePaintUsingContainer( 66 ObjectPaintInvalidator(box).invalidatePaintUsingContainer(
67 paintInvalidationContainer, newPaintInvalidationRect, 67 paintInvalidationContainer, newVisualRect, PaintInvalidationScroll);
68 PaintInvalidationScroll);
69 return true; 68 return true;
70 } 69 }
71 return false; 70 return false;
72 } 71 }
73 72
74 static void invalidatePaintOfScrollbarIfNeeded( 73 static void invalidatePaintOfScrollbarIfNeeded(
75 Scrollbar* scrollbar, 74 Scrollbar* scrollbar,
76 GraphicsLayer* graphicsLayer, 75 GraphicsLayer* graphicsLayer,
77 bool& previouslyWasOverlay, 76 bool& previouslyWasOverlay,
78 LayoutRect& previousPaintInvalidationRect, 77 LayoutRect& previousVisualRect,
79 bool needsPaintInvalidationArg, 78 bool needsPaintInvalidationArg,
80 LayoutBox& box, 79 LayoutBox& box,
81 const PaintInvalidatorContext& context) { 80 const PaintInvalidatorContext& context) {
82 bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar(); 81 bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar();
83 82
84 // Calculate paint invalidation rect of the scrollbar, except overlay 83 // Calculate visual rect of the scrollbar, except overlay composited
85 // composited scrollbars because we invalidate the graphics layer only. 84 // scrollbars because we invalidate the graphics layer only.
86 LayoutRect newPaintInvalidationRect; 85 LayoutRect newVisualRect;
87 if (scrollbar && !(graphicsLayer && isOverlay)) 86 if (scrollbar && !(graphicsLayer && isOverlay)) {
88 newPaintInvalidationRect = scrollControlPaintInvalidationRect( 87 newVisualRect =
89 scrollbar->frameRect(), box, context); 88 scrollControlVisualRect(scrollbar->frameRect(), box, context);
89 }
90 90
91 bool needsPaintInvalidation = needsPaintInvalidationArg; 91 bool needsPaintInvalidation = needsPaintInvalidationArg;
92 if (needsPaintInvalidation && graphicsLayer) { 92 if (needsPaintInvalidation && graphicsLayer) {
93 // If the scrollbar needs paint invalidation but didn't change location/size 93 // If the scrollbar needs paint invalidation but didn't change location/size
94 // or the scrollbar is an overlay scrollbar (paint invalidation rect is 94 // or the scrollbar is an overlay scrollbar (visual rect is empty),
95 // empty), invalidating the graphics layer is enough (which has been done in 95 // invalidating the graphics layer is enough (which has been done in
96 // ScrollableArea::setScrollbarNeedsPaintInvalidation()). 96 // ScrollableArea::setScrollbarNeedsPaintInvalidation()).
97 // Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate 97 // Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate
98 // the old and new location of the scrollbar on the box's paint invalidation 98 // the old and new location of the scrollbar on the box's paint invalidation
99 // container to ensure newly expanded/shrunk areas of the box to be 99 // container to ensure newly expanded/shrunk areas of the box to be
100 // invalidated. 100 // invalidated.
101 needsPaintInvalidation = false; 101 needsPaintInvalidation = false;
102 DCHECK(!graphicsLayer->drawsContent() || 102 DCHECK(!graphicsLayer->drawsContent() ||
103 graphicsLayer->getPaintController().cacheIsEmpty()); 103 graphicsLayer->getPaintController().cacheIsEmpty());
104 } 104 }
105 105
106 // Invalidate the box's display item client if the box's padding box size is 106 // Invalidate the box's display item client if the box's padding box size is
107 // affected by change of the non-overlay scrollbar width. We detect change of 107 // affected by change of the non-overlay scrollbar width. We detect change of
108 // paint invalidation rect size instead of change of scrollbar width change, 108 // visual rect size instead of change of scrollbar width change, which may
109 // which may have some false-positives (e.g. the scrollbar changed length but 109 // have some false-positives (e.g. the scrollbar changed length but not width)
110 // not width) but won't invalidate more than expected because in the 110 // but won't invalidate more than expected because in the false-positive case
111 // false-positive case the box must have changed size and have been 111 // the box must have changed size and have been invalidated.
112 // invalidated.
113 const LayoutBoxModelObject& paintInvalidationContainer = 112 const LayoutBoxModelObject& paintInvalidationContainer =
114 *context.paintInvalidationContainer; 113 *context.paintInvalidationContainer;
115 LayoutSize newScrollbarUsedSpaceInBox; 114 LayoutSize newScrollbarUsedSpaceInBox;
116 if (!isOverlay) 115 if (!isOverlay)
117 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); 116 newScrollbarUsedSpaceInBox = newVisualRect.size();
118 LayoutSize previousScrollbarUsedSpaceInBox; 117 LayoutSize previousScrollbarUsedSpaceInBox;
119 if (!previouslyWasOverlay) 118 if (!previouslyWasOverlay)
120 previousScrollbarUsedSpaceInBox = previousPaintInvalidationRect.size(); 119 previousScrollbarUsedSpaceInBox = previousVisualRect.size();
121 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) { 120 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) {
122 context.paintingLayer->setNeedsRepaint(); 121 context.paintingLayer->setNeedsRepaint();
123 ObjectPaintInvalidator(box).invalidateDisplayItemClient( 122 ObjectPaintInvalidator(box).invalidateDisplayItemClient(
124 box, PaintInvalidationScroll); 123 box, PaintInvalidationScroll);
125 } 124 }
126 125
127 bool invalidated = invalidatePaintOfScrollControlIfNeeded( 126 bool invalidated = invalidatePaintOfScrollControlIfNeeded(
128 newPaintInvalidationRect, previousPaintInvalidationRect, 127 newVisualRect, previousVisualRect, needsPaintInvalidation, box,
129 needsPaintInvalidation, box, paintInvalidationContainer); 128 paintInvalidationContainer);
130 129
131 previousPaintInvalidationRect = newPaintInvalidationRect; 130 previousVisualRect = newVisualRect;
132 previouslyWasOverlay = isOverlay; 131 previouslyWasOverlay = isOverlay;
133 132
134 if (!invalidated || !scrollbar || graphicsLayer) 133 if (!invalidated || !scrollbar || graphicsLayer)
135 return; 134 return;
136 135
137 context.paintingLayer->setNeedsRepaint(); 136 context.paintingLayer->setNeedsRepaint();
138 ObjectPaintInvalidator(box).invalidateDisplayItemClient( 137 ObjectPaintInvalidator(box).invalidateDisplayItemClient(
139 *scrollbar, PaintInvalidationScroll); 138 *scrollbar, PaintInvalidationScroll);
140 if (scrollbar->isCustomScrollbar()) 139 if (scrollbar->isCustomScrollbar())
141 toLayoutScrollbar(scrollbar) 140 toLayoutScrollbar(scrollbar)
142 ->invalidateDisplayItemClientsOfScrollbarParts(); 141 ->invalidateDisplayItemClientsOfScrollbarParts();
143 } 142 }
144 143
145 void PaintInvalidationCapableScrollableArea:: 144 void PaintInvalidationCapableScrollableArea::
146 invalidatePaintOfScrollControlsIfNeeded( 145 invalidatePaintOfScrollControlsIfNeeded(
147 const PaintInvalidatorContext& context) { 146 const PaintInvalidatorContext& context) {
148 LayoutBox& box = *layoutBox(); 147 LayoutBox& box = *layoutBox();
149 invalidatePaintOfScrollbarIfNeeded( 148 invalidatePaintOfScrollbarIfNeeded(
150 horizontalScrollbar(), layerForHorizontalScrollbar(), 149 horizontalScrollbar(), layerForHorizontalScrollbar(),
151 m_horizontalScrollbarPreviouslyWasOverlay, 150 m_horizontalScrollbarPreviouslyWasOverlay,
152 m_horizontalScrollbarPreviousPaintInvalidationRect, 151 m_horizontalScrollbarPreviousVisualRect,
153 horizontalScrollbarNeedsPaintInvalidation(), box, context); 152 horizontalScrollbarNeedsPaintInvalidation(), box, context);
154 invalidatePaintOfScrollbarIfNeeded( 153 invalidatePaintOfScrollbarIfNeeded(
155 verticalScrollbar(), layerForVerticalScrollbar(), 154 verticalScrollbar(), layerForVerticalScrollbar(),
156 m_verticalScrollbarPreviouslyWasOverlay, 155 m_verticalScrollbarPreviouslyWasOverlay,
157 m_verticalScrollbarPreviousPaintInvalidationRect, 156 m_verticalScrollbarPreviousVisualRect,
158 verticalScrollbarNeedsPaintInvalidation(), box, context); 157 verticalScrollbarNeedsPaintInvalidation(), box, context);
159 158
160 LayoutRect scrollCornerPaintInvalidationRect = 159 LayoutRect scrollCornerVisualRect =
161 scrollControlPaintInvalidationRect(scrollCornerAndResizerRect(), box, 160 scrollControlVisualRect(scrollCornerAndResizerRect(), box, context);
162 context);
163 const LayoutBoxModelObject& paintInvalidationContainer = 161 const LayoutBoxModelObject& paintInvalidationContainer =
164 *context.paintInvalidationContainer; 162 *context.paintInvalidationContainer;
165 if (invalidatePaintOfScrollControlIfNeeded( 163 if (invalidatePaintOfScrollControlIfNeeded(
166 scrollCornerPaintInvalidationRect, 164 scrollCornerVisualRect, m_scrollCornerAndResizerPreviousVisualRect,
167 m_scrollCornerAndResizerPreviousPaintInvalidationRect,
168 scrollCornerNeedsPaintInvalidation(), box, 165 scrollCornerNeedsPaintInvalidation(), box,
169 paintInvalidationContainer)) { 166 paintInvalidationContainer)) {
170 m_scrollCornerAndResizerPreviousPaintInvalidationRect = 167 m_scrollCornerAndResizerPreviousVisualRect = scrollCornerVisualRect;
171 scrollCornerPaintInvalidationRect;
172 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) 168 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner())
173 ObjectPaintInvalidator(*scrollCorner) 169 ObjectPaintInvalidator(*scrollCorner)
174 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( 170 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
175 PaintInvalidationScroll); 171 PaintInvalidationScroll);
176 if (LayoutScrollbarPart* resizer = this->resizer()) 172 if (LayoutScrollbarPart* resizer = this->resizer())
177 ObjectPaintInvalidator(*resizer) 173 ObjectPaintInvalidator(*resizer)
178 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( 174 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
179 PaintInvalidationScroll); 175 PaintInvalidationScroll);
180 } 176 }
181 177
182 clearNeedsPaintInvalidationForScrollControls(); 178 clearNeedsPaintInvalidationForScrollControls();
183 } 179 }
184 180
185 void PaintInvalidationCapableScrollableArea:: 181 void PaintInvalidationCapableScrollableArea::
186 invalidatePaintOfScrollControlsIfNeeded( 182 invalidatePaintOfScrollControlsIfNeeded(
187 const PaintInvalidationState& paintInvalidationState) { 183 const PaintInvalidationState& paintInvalidationState) {
188 invalidatePaintOfScrollControlsIfNeeded( 184 invalidatePaintOfScrollControlsIfNeeded(
189 PaintInvalidatorContextAdapter(paintInvalidationState)); 185 PaintInvalidatorContextAdapter(paintInvalidationState));
190 } 186 }
191 187
192 void PaintInvalidationCapableScrollableArea:: 188 void PaintInvalidationCapableScrollableArea::clearPreviousVisualRects() {
193 clearPreviousPaintInvalidationRects() { 189 m_horizontalScrollbarPreviousVisualRect = LayoutRect();
194 m_horizontalScrollbarPreviousPaintInvalidationRect = LayoutRect(); 190 m_verticalScrollbarPreviousVisualRect = LayoutRect();
195 m_verticalScrollbarPreviousPaintInvalidationRect = LayoutRect(); 191 m_scrollCornerAndResizerPreviousVisualRect = LayoutRect();
196 m_scrollCornerAndResizerPreviousPaintInvalidationRect = LayoutRect();
197 } 192 }
198 193
199 LayoutRect PaintInvalidationCapableScrollableArea::visualRectForScrollbarParts() 194 LayoutRect PaintInvalidationCapableScrollableArea::visualRectForScrollbarParts()
200 const { 195 const {
201 LayoutRect fullBounds(m_horizontalScrollbarPreviousPaintInvalidationRect); 196 LayoutRect fullBounds(m_horizontalScrollbarPreviousVisualRect);
202 fullBounds.unite(m_verticalScrollbarPreviousPaintInvalidationRect); 197 fullBounds.unite(m_verticalScrollbarPreviousVisualRect);
203 fullBounds.unite(m_scrollCornerAndResizerPreviousPaintInvalidationRect); 198 fullBounds.unite(m_scrollCornerAndResizerPreviousVisualRect);
204 return fullBounds; 199 return fullBounds;
205 } 200 }
206 201
207 void PaintInvalidationCapableScrollableArea:: 202 void PaintInvalidationCapableScrollableArea::
208 scrollControlWasSetNeedsPaintInvalidation() { 203 scrollControlWasSetNeedsPaintInvalidation() {
209 layoutBox()->setMayNeedPaintInvalidation(); 204 layoutBox()->setMayNeedPaintInvalidation();
210 } 205 }
211 206
212 } // namespace blink 207 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698