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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // scrollbar width change, which may have some false-positives (e.g. the scr
ollbar changed length but | 73 // scrollbar width change, which may have some false-positives (e.g. the scr
ollbar changed length but |
74 // not width) but won't invalidate more than expected because in the false-p
ositive case the box must | 74 // not width) but won't invalidate more than expected because in the false-p
ositive case the box must |
75 // have changed size and have been invalidated. | 75 // have changed size and have been invalidated. |
76 LayoutSize newScrollbarUsedSpaceInBox; | 76 LayoutSize newScrollbarUsedSpaceInBox; |
77 if (!isOverlay) | 77 if (!isOverlay) |
78 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); | 78 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); |
79 LayoutSize previousScrollbarUsedSpaceInBox; | 79 LayoutSize previousScrollbarUsedSpaceInBox; |
80 if (!previouslyWasOverlay) | 80 if (!previouslyWasOverlay) |
81 previousScrollbarUsedSpaceInBox= previousPaintInvalidationRect.size(); | 81 previousScrollbarUsedSpaceInBox= previousPaintInvalidationRect.size(); |
82 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) | 82 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) |
83 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(box, Pai
ntInvalidationScroll, nullptr); | 83 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(box, Pai
ntInvalidationScroll); |
84 | 84 |
85 bool invalidated = invalidatePaintOfScrollControlIfNeeded(newPaintInvalidati
onRect, previousPaintInvalidationRect, needsPaintInvalidation, box, paintInvalid
ationContainer); | 85 bool invalidated = invalidatePaintOfScrollControlIfNeeded(newPaintInvalidati
onRect, previousPaintInvalidationRect, needsPaintInvalidation, box, paintInvalid
ationContainer); |
86 | 86 |
87 previousPaintInvalidationRect = newPaintInvalidationRect; | 87 previousPaintInvalidationRect = newPaintInvalidationRect; |
88 previouslyWasOverlay = isOverlay; | 88 previouslyWasOverlay = isOverlay; |
89 | 89 |
90 if (!invalidated || !scrollbar || graphicsLayer) | 90 if (!invalidated || !scrollbar || graphicsLayer) |
91 return; | 91 return; |
92 | 92 |
93 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*scrollbar,
PaintInvalidationScroll, &previousPaintInvalidationRect); | 93 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*scrollbar,
PaintInvalidationScroll); |
94 if (scrollbar->isCustomScrollbar()) | 94 if (scrollbar->isCustomScrollbar()) |
95 toLayoutScrollbar(scrollbar)->invalidateDisplayItemClientsOfScrollbarPar
ts(paintInvalidationContainer, previousPaintInvalidationRect); | 95 toLayoutScrollbar(scrollbar)->invalidateDisplayItemClientsOfScrollbarPar
ts(paintInvalidationContainer); |
96 } | 96 } |
97 | 97 |
98 void PaintInvalidationCapableScrollableArea::invalidatePaintOfScrollControlsIfNe
eded(const PaintInvalidationState& paintInvalidationState, const LayoutBoxModelO
bject& paintInvalidationContainer) | 98 void PaintInvalidationCapableScrollableArea::invalidatePaintOfScrollControlsIfNe
eded(const PaintInvalidationState& paintInvalidationState, const LayoutBoxModelO
bject& paintInvalidationContainer) |
99 { | 99 { |
100 LayoutBox& box = boxForScrollControlPaintInvalidation(); | 100 LayoutBox& box = boxForScrollControlPaintInvalidation(); |
101 invalidatePaintOfScrollbarIfNeeded(horizontalScrollbar(), layerForHorizontal
Scrollbar(), m_horizontalScrollbarPreviouslyWasOverlay, m_horizontalScrollbarPre
viousPaintInvalidationRect, horizontalScrollbarNeedsPaintInvalidation(), box, pa
intInvalidationState, paintInvalidationContainer); | 101 invalidatePaintOfScrollbarIfNeeded(horizontalScrollbar(), layerForHorizontal
Scrollbar(), m_horizontalScrollbarPreviouslyWasOverlay, m_horizontalScrollbarPre
viousPaintInvalidationRect, horizontalScrollbarNeedsPaintInvalidation(), box, pa
intInvalidationState, paintInvalidationContainer); |
102 invalidatePaintOfScrollbarIfNeeded(verticalScrollbar(), layerForVerticalScro
llbar(), m_verticalScrollbarPreviouslyWasOverlay, m_verticalScrollbarPreviousPai
ntInvalidationRect, verticalScrollbarNeedsPaintInvalidation(), box, paintInvalid
ationState, paintInvalidationContainer); | 102 invalidatePaintOfScrollbarIfNeeded(verticalScrollbar(), layerForVerticalScro
llbar(), m_verticalScrollbarPreviouslyWasOverlay, m_verticalScrollbarPreviousPai
ntInvalidationRect, verticalScrollbarNeedsPaintInvalidation(), box, paintInvalid
ationState, paintInvalidationContainer); |
103 | 103 |
104 LayoutRect scrollCornerPaintInvalidationRect = scrollControlPaintInvalidatio
nRect(scrollCornerRect(), box, paintInvalidationState, paintInvalidationContaine
r); | 104 LayoutRect scrollCornerPaintInvalidationRect = scrollControlPaintInvalidatio
nRect(scrollCornerRect(), box, paintInvalidationState, paintInvalidationContaine
r); |
105 if (invalidatePaintOfScrollControlIfNeeded(scrollCornerPaintInvalidationRect
, m_scrollCornerPreviousPaintInvalidationRect, scrollCornerNeedsPaintInvalidatio
n(), box, paintInvalidationContainer)) { | 105 if (invalidatePaintOfScrollControlIfNeeded(scrollCornerPaintInvalidationRect
, m_scrollCornerPreviousPaintInvalidationRect, scrollCornerNeedsPaintInvalidatio
n(), box, paintInvalidationContainer)) { |
106 m_scrollCornerPreviousPaintInvalidationRect = scrollCornerPaintInvalidat
ionRect; | 106 m_scrollCornerPreviousPaintInvalidationRect = scrollCornerPaintInvalidat
ionRect; |
107 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) | 107 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) |
108 scrollCorner->invalidateDisplayItemClientsIncludingNonCompositingDes
cendants(&paintInvalidationContainer, PaintInvalidationScroll, &m_scrollCornerPr
eviousPaintInvalidationRect); | 108 scrollCorner->invalidateDisplayItemClientsIncludingNonCompositingDes
cendants(&paintInvalidationContainer, PaintInvalidationScroll); |
109 if (LayoutScrollbarPart* resizer = this->resizer()) | 109 if (LayoutScrollbarPart* resizer = this->resizer()) |
110 resizer->invalidateDisplayItemClientsIncludingNonCompositingDescenda
nts(&paintInvalidationContainer, PaintInvalidationScroll, &m_scrollCornerPreviou
sPaintInvalidationRect); | 110 resizer->invalidateDisplayItemClientsIncludingNonCompositingDescenda
nts(&paintInvalidationContainer, PaintInvalidationScroll); |
111 } | 111 } |
112 | 112 |
113 clearNeedsPaintInvalidationForScrollControls(); | 113 clearNeedsPaintInvalidationForScrollControls(); |
114 } | 114 } |
115 | 115 |
116 void PaintInvalidationCapableScrollableArea::clearPreviousPaintInvalidationRects
() | 116 void PaintInvalidationCapableScrollableArea::clearPreviousPaintInvalidationRects
() |
117 { | 117 { |
118 m_horizontalScrollbarPreviousPaintInvalidationRect = LayoutRect(); | 118 m_horizontalScrollbarPreviousPaintInvalidationRect = LayoutRect(); |
119 m_verticalScrollbarPreviousPaintInvalidationRect = LayoutRect(); | 119 m_verticalScrollbarPreviousPaintInvalidationRect = LayoutRect(); |
120 m_scrollCornerPreviousPaintInvalidationRect = LayoutRect(); | 120 m_scrollCornerPreviousPaintInvalidationRect = LayoutRect(); |
121 } | 121 } |
122 | 122 |
123 } // namespace blink | 123 } // namespace blink |
OLD | NEW |