OLD | NEW |
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/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
9 #include "core/html/HTMLFrameOwnerElement.h" | 9 #include "core/html/HTMLFrameOwnerElement.h" |
10 #include "core/layout/LayoutBox.h" | 10 #include "core/layout/LayoutBox.h" |
11 #include "core/layout/LayoutScrollbar.h" | 11 #include "core/layout/LayoutScrollbar.h" |
12 #include "core/layout/LayoutScrollbarPart.h" | 12 #include "core/layout/LayoutScrollbarPart.h" |
13 #include "core/layout/PaintInvalidationState.h" | 13 #include "core/layout/PaintInvalidationState.h" |
14 #include "core/paint/FindPaintOffsetAndVisualRectNeedingUpdate.h" | |
15 #include "core/paint/ObjectPaintInvalidator.h" | 14 #include "core/paint/ObjectPaintInvalidator.h" |
16 #include "core/paint/PaintInvalidator.h" | 15 #include "core/paint/PaintInvalidator.h" |
17 #include "core/paint/PaintLayer.h" | 16 #include "core/paint/PaintLayer.h" |
18 #include "platform/graphics/GraphicsLayer.h" | 17 #include "platform/graphics/GraphicsLayer.h" |
19 | 18 |
20 namespace blink { | 19 namespace blink { |
21 | 20 |
22 void PaintInvalidationCapableScrollableArea::willRemoveScrollbar( | 21 void PaintInvalidationCapableScrollableArea::willRemoveScrollbar( |
23 Scrollbar& scrollbar, | 22 Scrollbar& scrollbar, |
24 ScrollbarOrientation orientation) { | 23 ScrollbarOrientation orientation) { |
25 if (!scrollbar.isCustomScrollbar() && | 24 if (!scrollbar.isCustomScrollbar() && |
26 !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar() | 25 !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar() |
27 : layerForVerticalScrollbar())) | 26 : layerForVerticalScrollbar())) |
28 ObjectPaintInvalidator(*layoutBox()) | 27 ObjectPaintInvalidator(*layoutBox()) |
29 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 28 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
30 scrollbar, PaintInvalidationScroll); | 29 scrollbar, PaintInvalidationScroll); |
31 | 30 |
32 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 31 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); |
33 } | 32 } |
34 | 33 |
35 static LayoutRect scrollControlVisualRect( | 34 static LayoutRect scrollControlVisualRect( |
36 const IntRect& scrollControlRect, | 35 const IntRect& scrollControlRect, |
37 const LayoutBox& box, | 36 const LayoutBox& box, |
38 const PaintInvalidatorContext& context, | 37 const PaintInvalidatorContext& context) { |
39 const LayoutRect& previousVisualRect) { | |
40 LayoutRect visualRect(scrollControlRect); | 38 LayoutRect visualRect(scrollControlRect); |
41 #if DCHECK_IS_ON() | |
42 FindVisualRectNeedingUpdateScope finder(box, context, previousVisualRect, | |
43 visualRect); | |
44 #endif | |
45 if (!context.needsVisualRectUpdate(box)) | |
46 return previousVisualRect; | |
47 | |
48 // No need to apply any paint offset. Scroll controls paint in a different | 39 // No need to apply any paint offset. Scroll controls paint in a different |
49 // transform space than their contained box (the scrollbarPaintOffset | 40 // transform space than their contained box (the scrollbarPaintOffset |
50 // transform node). | 41 // transform node). |
51 if (!visualRect.isEmpty() && | 42 if (!visualRect.isEmpty() && |
52 !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 43 !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
53 // PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking() treats | 44 // PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking() treats |
54 // the rect as in flipped block direction, but scrollbar controls don't | 45 // the rect as in flipped block direction, but scrollbar controls don't |
55 // flip for block direction, so flip here to undo the flip in the function. | 46 // flip for block direction, so flip here to undo the flip in the function. |
56 box.flipForWritingMode(visualRect); | 47 box.flipForWritingMode(visualRect); |
57 context.mapLocalRectToVisualRectInBacking(box, visualRect); | 48 context.mapLocalRectToVisualRectInBacking(box, visualRect); |
(...skipping 26 matching lines...) Expand all Loading... |
84 static LayoutRect invalidatePaintOfScrollbarIfNeeded( | 75 static LayoutRect invalidatePaintOfScrollbarIfNeeded( |
85 Scrollbar* scrollbar, | 76 Scrollbar* scrollbar, |
86 GraphicsLayer* graphicsLayer, | 77 GraphicsLayer* graphicsLayer, |
87 bool& previouslyWasOverlay, | 78 bool& previouslyWasOverlay, |
88 const LayoutRect& previousVisualRect, | 79 const LayoutRect& previousVisualRect, |
89 bool needsPaintInvalidationArg, | 80 bool needsPaintInvalidationArg, |
90 LayoutBox& box, | 81 LayoutBox& box, |
91 const PaintInvalidatorContext& context) { | 82 const PaintInvalidatorContext& context) { |
92 bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar(); | 83 bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar(); |
93 | 84 |
94 LayoutRect newVisualRect; | |
95 // Calculate visual rect of the scrollbar, except overlay composited | 85 // Calculate visual rect of the scrollbar, except overlay composited |
96 // scrollbars because we invalidate the graphics layer only. | 86 // scrollbars because we invalidate the graphics layer only. |
| 87 LayoutRect newVisualRect; |
97 if (scrollbar && !(graphicsLayer && isOverlay)) { | 88 if (scrollbar && !(graphicsLayer && isOverlay)) { |
98 newVisualRect = scrollControlVisualRect(scrollbar->frameRect(), box, | 89 newVisualRect = |
99 context, previousVisualRect); | 90 scrollControlVisualRect(scrollbar->frameRect(), box, context); |
100 } | 91 } |
101 | 92 |
102 bool needsPaintInvalidation = needsPaintInvalidationArg; | 93 bool needsPaintInvalidation = needsPaintInvalidationArg; |
103 if (needsPaintInvalidation && graphicsLayer) { | 94 if (needsPaintInvalidation && graphicsLayer) { |
104 // If the scrollbar needs paint invalidation but didn't change location/size | 95 // If the scrollbar needs paint invalidation but didn't change location/size |
105 // or the scrollbar is an overlay scrollbar (visual rect is empty), | 96 // or the scrollbar is an overlay scrollbar (visual rect is empty), |
106 // invalidating the graphics layer is enough (which has been done in | 97 // invalidating the graphics layer is enough (which has been done in |
107 // ScrollableArea::setScrollbarNeedsPaintInvalidation()). | 98 // ScrollableArea::setScrollbarNeedsPaintInvalidation()). |
108 // Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate | 99 // Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate |
109 // the old and new location of the scrollbar on the box's paint invalidation | 100 // the old and new location of the scrollbar on the box's paint invalidation |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 horizontalScrollbar(), layerForHorizontalScrollbar(), | 153 horizontalScrollbar(), layerForHorizontalScrollbar(), |
163 m_horizontalScrollbarPreviouslyWasOverlay, | 154 m_horizontalScrollbarPreviouslyWasOverlay, |
164 m_horizontalScrollbarVisualRect, | 155 m_horizontalScrollbarVisualRect, |
165 horizontalScrollbarNeedsPaintInvalidation(), box, context)); | 156 horizontalScrollbarNeedsPaintInvalidation(), box, context)); |
166 setVerticalScrollbarVisualRect(invalidatePaintOfScrollbarIfNeeded( | 157 setVerticalScrollbarVisualRect(invalidatePaintOfScrollbarIfNeeded( |
167 verticalScrollbar(), layerForVerticalScrollbar(), | 158 verticalScrollbar(), layerForVerticalScrollbar(), |
168 m_verticalScrollbarPreviouslyWasOverlay, m_verticalScrollbarVisualRect, | 159 m_verticalScrollbarPreviouslyWasOverlay, m_verticalScrollbarVisualRect, |
169 verticalScrollbarNeedsPaintInvalidation(), box, context)); | 160 verticalScrollbarNeedsPaintInvalidation(), box, context)); |
170 | 161 |
171 LayoutRect scrollCornerAndResizerVisualRect = | 162 LayoutRect scrollCornerAndResizerVisualRect = |
172 scrollControlVisualRect(scrollCornerAndResizerRect(), box, context, | 163 scrollControlVisualRect(scrollCornerAndResizerRect(), box, context); |
173 m_scrollCornerAndResizerVisualRect); | |
174 const LayoutBoxModelObject& paintInvalidationContainer = | 164 const LayoutBoxModelObject& paintInvalidationContainer = |
175 *context.paintInvalidationContainer; | 165 *context.paintInvalidationContainer; |
176 if (invalidatePaintOfScrollControlIfNeeded( | 166 if (invalidatePaintOfScrollControlIfNeeded( |
177 scrollCornerAndResizerVisualRect, m_scrollCornerAndResizerVisualRect, | 167 scrollCornerAndResizerVisualRect, m_scrollCornerAndResizerVisualRect, |
178 scrollCornerNeedsPaintInvalidation(), box, | 168 scrollCornerNeedsPaintInvalidation(), box, |
179 paintInvalidationContainer)) { | 169 paintInvalidationContainer)) { |
180 setScrollCornerAndResizerVisualRect(scrollCornerAndResizerVisualRect); | 170 setScrollCornerAndResizerVisualRect(scrollCornerAndResizerVisualRect); |
181 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) { | 171 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) { |
182 ObjectPaintInvalidator(*scrollCorner) | 172 ObjectPaintInvalidator(*scrollCorner) |
183 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( | 173 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 : UseCounter::ScrollbarUseHorizontalScrollbarTrack); | 252 : UseCounter::ScrollbarUseHorizontalScrollbarTrack); |
263 break; | 253 break; |
264 default: | 254 default: |
265 return; | 255 return; |
266 } | 256 } |
267 | 257 |
268 UseCounter::count(layoutBox()->document(), scrollbarUseUMA); | 258 UseCounter::count(layoutBox()->document(), scrollbarUseUMA); |
269 } | 259 } |
270 | 260 |
271 } // namespace blink | 261 } // namespace blink |
OLD | NEW |