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/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 16 matching lines...) Expand all Loading... |
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 scrollControlPaintInvalidationRect( |
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 paintInvalidationRect(scrollControlRect); |
37 // No need to apply any paint offset. Scroll controls paint in a different tra
nsform space than their contained box | 37 // No need to apply any paint offset. Scroll controls paint in a different |
38 // (the scrollbarPaintOffset transform node). | 38 // transform space than their contained box (the scrollbarPaintOffset |
| 39 // transform node). |
39 if (!paintInvalidationRect.isEmpty() && | 40 if (!paintInvalidationRect.isEmpty() && |
40 !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 41 !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
41 context.mapLocalRectToPaintInvalidationBacking(box, paintInvalidationRect); | 42 context.mapLocalRectToPaintInvalidationBacking(box, paintInvalidationRect); |
42 return paintInvalidationRect; | 43 return paintInvalidationRect; |
43 } | 44 } |
44 | 45 |
45 // Returns true if the scroll control is invalidated. | 46 // Returns true if the scroll control is invalidated. |
46 static bool invalidatePaintOfScrollControlIfNeeded( | 47 static bool invalidatePaintOfScrollControlIfNeeded( |
47 const LayoutRect& newPaintInvalidationRect, | 48 const LayoutRect& newPaintInvalidationRect, |
48 const LayoutRect& previousPaintInvalidationRect, | 49 const LayoutRect& previousPaintInvalidationRect, |
(...skipping 19 matching lines...) Expand all Loading... |
68 static void invalidatePaintOfScrollbarIfNeeded( | 69 static void invalidatePaintOfScrollbarIfNeeded( |
69 Scrollbar* scrollbar, | 70 Scrollbar* scrollbar, |
70 GraphicsLayer* graphicsLayer, | 71 GraphicsLayer* graphicsLayer, |
71 bool& previouslyWasOverlay, | 72 bool& previouslyWasOverlay, |
72 LayoutRect& previousPaintInvalidationRect, | 73 LayoutRect& previousPaintInvalidationRect, |
73 bool needsPaintInvalidationArg, | 74 bool needsPaintInvalidationArg, |
74 LayoutBox& box, | 75 LayoutBox& box, |
75 const PaintInvalidatorContext& context) { | 76 const PaintInvalidatorContext& context) { |
76 bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar(); | 77 bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar(); |
77 | 78 |
78 // Calculate paint invalidation rect of the scrollbar, except overlay composit
ed scrollbars because we invalidate the graphics layer only. | 79 // Calculate paint invalidation rect of the scrollbar, except overlay |
| 80 // composited scrollbars because we invalidate the graphics layer only. |
79 LayoutRect newPaintInvalidationRect; | 81 LayoutRect newPaintInvalidationRect; |
80 if (scrollbar && !(graphicsLayer && isOverlay)) | 82 if (scrollbar && !(graphicsLayer && isOverlay)) |
81 newPaintInvalidationRect = scrollControlPaintInvalidationRect( | 83 newPaintInvalidationRect = scrollControlPaintInvalidationRect( |
82 scrollbar->frameRect(), box, context); | 84 scrollbar->frameRect(), box, context); |
83 | 85 |
84 bool needsPaintInvalidation = needsPaintInvalidationArg; | 86 bool needsPaintInvalidation = needsPaintInvalidationArg; |
85 if (needsPaintInvalidation && graphicsLayer) { | 87 if (needsPaintInvalidation && graphicsLayer) { |
86 // If the scrollbar needs paint invalidation but didn't change location/size
or the scrollbar is an | 88 // If the scrollbar needs paint invalidation but didn't change location/size |
87 // overlay scrollbar (paint invalidation rect is empty), invalidating the gr
aphics layer is enough | 89 // or the scrollbar is an overlay scrollbar (paint invalidation rect is |
88 // (which has been done in ScrollableArea::setScrollbarNeedsPaintInvalidatio
n()). | 90 // empty), invalidating the graphics layer is enough (which has been done in |
89 // Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate
the old and new location | 91 // ScrollableArea::setScrollbarNeedsPaintInvalidation()). |
90 // of the scrollbar on the box's paint invalidation container to ensure newl
y expanded/shrunk areas | 92 // Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate |
91 // of the box to be invalidated. | 93 // the old and new location of the scrollbar on the box's paint invalidation |
| 94 // container to ensure newly expanded/shrunk areas of the box to be |
| 95 // invalidated. |
92 needsPaintInvalidation = false; | 96 needsPaintInvalidation = false; |
93 DCHECK(!graphicsLayer->drawsContent() || | 97 DCHECK(!graphicsLayer->drawsContent() || |
94 graphicsLayer->getPaintController().cacheIsEmpty()); | 98 graphicsLayer->getPaintController().cacheIsEmpty()); |
95 } | 99 } |
96 | 100 |
97 // Invalidate the box's display item client if the box's padding box size is a
ffected by change of the | 101 // Invalidate the box's display item client if the box's padding box size is |
98 // non-overlay scrollbar width. We detect change of paint invalidation rect si
ze instead of change of | 102 // affected by change of the non-overlay scrollbar width. We detect change of |
99 // scrollbar width change, which may have some false-positives (e.g. the scrol
lbar changed length but | 103 // paint invalidation rect size instead of change of scrollbar width change, |
100 // not width) but won't invalidate more than expected because in the false-pos
itive case the box must | 104 // which may have some false-positives (e.g. the scrollbar changed length but |
101 // have changed size and have been invalidated. | 105 // not width) but won't invalidate more than expected because in the |
| 106 // false-positive case the box must have changed size and have been |
| 107 // invalidated. |
102 const LayoutBoxModelObject& paintInvalidationContainer = | 108 const LayoutBoxModelObject& paintInvalidationContainer = |
103 *context.paintInvalidationContainer; | 109 *context.paintInvalidationContainer; |
104 LayoutSize newScrollbarUsedSpaceInBox; | 110 LayoutSize newScrollbarUsedSpaceInBox; |
105 if (!isOverlay) | 111 if (!isOverlay) |
106 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); | 112 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); |
107 LayoutSize previousScrollbarUsedSpaceInBox; | 113 LayoutSize previousScrollbarUsedSpaceInBox; |
108 if (!previouslyWasOverlay) | 114 if (!previouslyWasOverlay) |
109 previousScrollbarUsedSpaceInBox = previousPaintInvalidationRect.size(); | 115 previousScrollbarUsedSpaceInBox = previousPaintInvalidationRect.size(); |
110 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) { | 116 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) { |
111 context.paintingLayer->setNeedsRepaint(); | 117 context.paintingLayer->setNeedsRepaint(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 fullBounds.unite(m_scrollCornerAndResizerPreviousPaintInvalidationRect); | 198 fullBounds.unite(m_scrollCornerAndResizerPreviousPaintInvalidationRect); |
193 return fullBounds; | 199 return fullBounds; |
194 } | 200 } |
195 | 201 |
196 void PaintInvalidationCapableScrollableArea:: | 202 void PaintInvalidationCapableScrollableArea:: |
197 scrollControlWasSetNeedsPaintInvalidation() { | 203 scrollControlWasSetNeedsPaintInvalidation() { |
198 layoutBox()->setMayNeedPaintInvalidation(); | 204 layoutBox()->setMayNeedPaintInvalidation(); |
199 } | 205 } |
200 | 206 |
201 } // namespace blink | 207 } // namespace blink |
OLD | NEW |