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" |
11 #include "core/layout/LayoutScrollbarPart.h" | 11 #include "core/layout/LayoutScrollbarPart.h" |
12 #include "core/layout/PaintInvalidationState.h" | 12 #include "core/layout/PaintInvalidationState.h" |
13 #include "core/paint/PaintLayer.h" | 13 #include "core/paint/PaintLayer.h" |
14 #include "platform/graphics/GraphicsLayer.h" | 14 #include "platform/graphics/GraphicsLayer.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 void PaintInvalidationCapableScrollableArea::willRemoveScrollbar(Scrollbar& scro
llbar, ScrollbarOrientation orientation) | 18 void PaintInvalidationCapableScrollableArea::willRemoveScrollbar(Scrollbar& scro
llbar, ScrollbarOrientation orientation) |
19 { | 19 { |
20 if (!scrollbar.isCustomScrollbar() | 20 if (!scrollbar.isCustomScrollbar() |
21 && !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar()
: layerForVerticalScrollbar())) | 21 && !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar()
: layerForVerticalScrollbar())) |
22 boxForScrollControlPaintInvalidation().invalidateDisplayItemClient(scrol
lbar); | 22 boxForScrollControlPaintInvalidation().slowSetPaintingLayerNeedsRepaintA
ndInvalidateDisplayItemClient(scrollbar, PaintInvalidationScroll); |
23 | 23 |
24 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 24 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); |
25 } | 25 } |
26 | 26 |
27 static LayoutRect scrollControlPaintInvalidationRect(const IntRect& scrollContro
lRect, const LayoutBox& box, const PaintInvalidationState& paintInvalidationStat
e) | 27 static LayoutRect scrollControlPaintInvalidationRect(const IntRect& scrollContro
lRect, const LayoutBox& box, const PaintInvalidationState& paintInvalidationStat
e) |
28 { | 28 { |
29 LayoutRect paintInvalidationRect(scrollControlRect); | 29 LayoutRect paintInvalidationRect(scrollControlRect); |
30 if (!paintInvalidationRect.isEmpty()) | 30 if (!paintInvalidationRect.isEmpty()) |
31 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(paintInval
idationRect); | 31 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(paintInval
idationRect); |
32 return paintInvalidationRect; | 32 return paintInvalidationRect; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // not width) but won't invalidate more than expected because in the false-p
ositive case the box must | 75 // not width) but won't invalidate more than expected because in the false-p
ositive case the box must |
76 // have changed size and have been invalidated. | 76 // have changed size and have been invalidated. |
77 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt
ate.paintInvalidationContainer(); | 77 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt
ate.paintInvalidationContainer(); |
78 LayoutSize newScrollbarUsedSpaceInBox; | 78 LayoutSize newScrollbarUsedSpaceInBox; |
79 if (!isOverlay) | 79 if (!isOverlay) |
80 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); | 80 newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size(); |
81 LayoutSize previousScrollbarUsedSpaceInBox; | 81 LayoutSize previousScrollbarUsedSpaceInBox; |
82 if (!previouslyWasOverlay) | 82 if (!previouslyWasOverlay) |
83 previousScrollbarUsedSpaceInBox= previousPaintInvalidationRect.size(); | 83 previousScrollbarUsedSpaceInBox= previousPaintInvalidationRect.size(); |
84 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) | 84 if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox) |
85 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(box, Pai
ntInvalidationScroll, &box); | 85 box.setPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(paintInva
lidationState, box, PaintInvalidationScroll); |
86 | 86 |
87 bool invalidated = invalidatePaintOfScrollControlIfNeeded(newPaintInvalidati
onRect, previousPaintInvalidationRect, needsPaintInvalidation, box, paintInvalid
ationContainer); | 87 bool invalidated = invalidatePaintOfScrollControlIfNeeded(newPaintInvalidati
onRect, previousPaintInvalidationRect, needsPaintInvalidation, box, paintInvalid
ationContainer); |
88 | 88 |
89 previousPaintInvalidationRect = newPaintInvalidationRect; | 89 previousPaintInvalidationRect = newPaintInvalidationRect; |
90 previouslyWasOverlay = isOverlay; | 90 previouslyWasOverlay = isOverlay; |
91 | 91 |
92 if (!invalidated || !scrollbar || graphicsLayer) | 92 if (!invalidated || !scrollbar || graphicsLayer) |
93 return; | 93 return; |
94 | 94 |
95 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*scrollbar,
PaintInvalidationScroll); | 95 box.setPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(paintInvalida
tionState, *scrollbar, PaintInvalidationScroll); |
96 if (scrollbar->isCustomScrollbar()) | 96 if (scrollbar->isCustomScrollbar()) |
97 toLayoutScrollbar(scrollbar)->invalidateDisplayItemClientsOfScrollbarPar
ts(paintInvalidationContainer); | 97 toLayoutScrollbar(scrollbar)->invalidateDisplayItemClientsOfScrollbarPar
ts(); |
98 } | 98 } |
99 | 99 |
100 void PaintInvalidationCapableScrollableArea::invalidatePaintOfScrollControlsIfNe
eded(const PaintInvalidationState& paintInvalidationState) | 100 void PaintInvalidationCapableScrollableArea::invalidatePaintOfScrollControlsIfNe
eded(const PaintInvalidationState& paintInvalidationState) |
101 { | 101 { |
102 LayoutBox& box = boxForScrollControlPaintInvalidation(); | 102 LayoutBox& box = boxForScrollControlPaintInvalidation(); |
103 invalidatePaintOfScrollbarIfNeeded(horizontalScrollbar(), layerForHorizontal
Scrollbar(), m_horizontalScrollbarPreviouslyWasOverlay, m_horizontalScrollbarPre
viousPaintInvalidationRect, horizontalScrollbarNeedsPaintInvalidation(), box, pa
intInvalidationState); | 103 invalidatePaintOfScrollbarIfNeeded(horizontalScrollbar(), layerForHorizontal
Scrollbar(), m_horizontalScrollbarPreviouslyWasOverlay, m_horizontalScrollbarPre
viousPaintInvalidationRect, horizontalScrollbarNeedsPaintInvalidation(), box, pa
intInvalidationState); |
104 invalidatePaintOfScrollbarIfNeeded(verticalScrollbar(), layerForVerticalScro
llbar(), m_verticalScrollbarPreviouslyWasOverlay, m_verticalScrollbarPreviousPai
ntInvalidationRect, verticalScrollbarNeedsPaintInvalidation(), box, paintInvalid
ationState); | 104 invalidatePaintOfScrollbarIfNeeded(verticalScrollbar(), layerForVerticalScro
llbar(), m_verticalScrollbarPreviouslyWasOverlay, m_verticalScrollbarPreviousPai
ntInvalidationRect, verticalScrollbarNeedsPaintInvalidation(), box, paintInvalid
ationState); |
105 | 105 |
106 LayoutRect scrollCornerPaintInvalidationRect = scrollControlPaintInvalidatio
nRect(scrollCornerAndResizerRect(), box, paintInvalidationState); | 106 LayoutRect scrollCornerPaintInvalidationRect = scrollControlPaintInvalidatio
nRect(scrollCornerAndResizerRect(), box, paintInvalidationState); |
107 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt
ate.paintInvalidationContainer(); | 107 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt
ate.paintInvalidationContainer(); |
108 if (invalidatePaintOfScrollControlIfNeeded(scrollCornerPaintInvalidationRect
, m_scrollCornerAndResizerPreviousPaintInvalidationRect, scrollCornerNeedsPaintI
nvalidation(), box, paintInvalidationContainer)) { | 108 if (invalidatePaintOfScrollControlIfNeeded(scrollCornerPaintInvalidationRect
, m_scrollCornerAndResizerPreviousPaintInvalidationRect, scrollCornerNeedsPaintI
nvalidation(), box, paintInvalidationContainer)) { |
109 m_scrollCornerAndResizerPreviousPaintInvalidationRect = scrollCornerPain
tInvalidationRect; | 109 m_scrollCornerAndResizerPreviousPaintInvalidationRect = scrollCornerPain
tInvalidationRect; |
110 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) | 110 if (LayoutScrollbarPart* scrollCorner = this->scrollCorner()) |
111 scrollCorner->invalidateDisplayItemClientsIncludingNonCompositingDes
cendants(&paintInvalidationContainer, PaintInvalidationScroll); | 111 scrollCorner->invalidateDisplayItemClientsIncludingNonCompositingDes
cendants(PaintInvalidationScroll); |
112 if (LayoutScrollbarPart* resizer = this->resizer()) | 112 if (LayoutScrollbarPart* resizer = this->resizer()) |
113 resizer->invalidateDisplayItemClientsIncludingNonCompositingDescenda
nts(&paintInvalidationContainer, PaintInvalidationScroll); | 113 resizer->invalidateDisplayItemClientsIncludingNonCompositingDescenda
nts(PaintInvalidationScroll); |
114 } | 114 } |
115 | 115 |
116 clearNeedsPaintInvalidationForScrollControls(); | 116 clearNeedsPaintInvalidationForScrollControls(); |
117 } | 117 } |
118 | 118 |
119 void PaintInvalidationCapableScrollableArea::clearPreviousPaintInvalidationRects
() | 119 void PaintInvalidationCapableScrollableArea::clearPreviousPaintInvalidationRects
() |
120 { | 120 { |
121 m_horizontalScrollbarPreviousPaintInvalidationRect = LayoutRect(); | 121 m_horizontalScrollbarPreviousPaintInvalidationRect = LayoutRect(); |
122 m_verticalScrollbarPreviousPaintInvalidationRect = LayoutRect(); | 122 m_verticalScrollbarPreviousPaintInvalidationRect = LayoutRect(); |
123 m_scrollCornerAndResizerPreviousPaintInvalidationRect = LayoutRect(); | 123 m_scrollCornerAndResizerPreviousPaintInvalidationRect = LayoutRect(); |
124 } | 124 } |
125 | 125 |
126 LayoutRect PaintInvalidationCapableScrollableArea::visualRectForScrollbarParts()
const | 126 LayoutRect PaintInvalidationCapableScrollableArea::visualRectForScrollbarParts()
const |
127 { | 127 { |
128 LayoutRect fullBounds(m_horizontalScrollbarPreviousPaintInvalidationRect); | 128 LayoutRect fullBounds(m_horizontalScrollbarPreviousPaintInvalidationRect); |
129 fullBounds.unite(m_verticalScrollbarPreviousPaintInvalidationRect); | 129 fullBounds.unite(m_verticalScrollbarPreviousPaintInvalidationRect); |
130 fullBounds.unite(m_scrollCornerAndResizerPreviousPaintInvalidationRect); | 130 fullBounds.unite(m_scrollCornerAndResizerPreviousPaintInvalidationRect); |
131 return fullBounds; | 131 return fullBounds; |
132 } | 132 } |
133 | 133 |
134 } // namespace blink | 134 } // namespace blink |
OLD | NEW |