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