| 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/FindPaintOffsetAndVisualRectNeedingUpdate.h" |
| 15 #include "core/paint/ObjectPaintInvalidator.h" | 15 #include "core/paint/ObjectPaintInvalidator.h" |
| 16 #include "core/paint/PaintInvalidator.h" | 16 #include "core/paint/PaintInvalidator.h" |
| 17 #include "core/paint/PaintLayer.h" | 17 #include "core/paint/PaintLayer.h" |
| 18 #include "platform/graphics/GraphicsLayer.h" | 18 #include "platform/graphics/GraphicsLayer.h" |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 void PaintInvalidationCapableScrollableArea::WillRemoveScrollbar( | 22 void PaintInvalidationCapableScrollableArea::WillRemoveScrollbar( |
| 23 Scrollbar& scrollbar, | 23 Scrollbar& scrollbar, |
| 24 ScrollbarOrientation orientation) { | 24 ScrollbarOrientation orientation) { |
| 25 if (!scrollbar.IsCustomScrollbar() && | 25 if (!scrollbar.IsCustomScrollbar() && |
| 26 !(orientation == kHorizontalScrollbar ? LayerForHorizontalScrollbar() | 26 !(orientation == kHorizontalScrollbar ? LayerForHorizontalScrollbar() |
| 27 : LayerForVerticalScrollbar())) | 27 : LayerForVerticalScrollbar())) { |
| 28 ObjectPaintInvalidator(*GetLayoutBox()) | 28 ObjectPaintInvalidator(*GetLayoutBox()) |
| 29 .SlowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 29 .SlowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| 30 scrollbar, kPaintInvalidationScroll); | 30 scrollbar, PaintInvalidationReason::kScrollControl); |
| 31 } |
| 31 | 32 |
| 32 ScrollableArea::WillRemoveScrollbar(scrollbar, orientation); | 33 ScrollableArea::WillRemoveScrollbar(scrollbar, orientation); |
| 33 } | 34 } |
| 34 | 35 |
| 35 static LayoutRect ScrollControlVisualRect( | 36 static LayoutRect ScrollControlVisualRect( |
| 36 const IntRect& scroll_control_rect, | 37 const IntRect& scroll_control_rect, |
| 37 const LayoutBox& box, | 38 const LayoutBox& box, |
| 38 const PaintInvalidatorContext& context, | 39 const PaintInvalidatorContext& context, |
| 39 const LayoutRect& previous_visual_rect) { | 40 const LayoutRect& previous_visual_rect) { |
| 40 LayoutRect visual_rect(scroll_control_rect); | 41 LayoutRect visual_rect(scroll_control_rect); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 63 static bool InvalidatePaintOfScrollControlIfNeeded( | 64 static bool InvalidatePaintOfScrollControlIfNeeded( |
| 64 const LayoutRect& new_visual_rect, | 65 const LayoutRect& new_visual_rect, |
| 65 const LayoutRect& previous_visual_rect, | 66 const LayoutRect& previous_visual_rect, |
| 66 bool needs_paint_invalidation, | 67 bool needs_paint_invalidation, |
| 67 LayoutBox& box, | 68 LayoutBox& box, |
| 68 const LayoutBoxModelObject& paint_invalidation_container) { | 69 const LayoutBoxModelObject& paint_invalidation_container) { |
| 69 bool should_invalidate_new_rect = needs_paint_invalidation; | 70 bool should_invalidate_new_rect = needs_paint_invalidation; |
| 70 if (new_visual_rect != previous_visual_rect) { | 71 if (new_visual_rect != previous_visual_rect) { |
| 71 ObjectPaintInvalidator(box).InvalidatePaintUsingContainer( | 72 ObjectPaintInvalidator(box).InvalidatePaintUsingContainer( |
| 72 paint_invalidation_container, previous_visual_rect, | 73 paint_invalidation_container, previous_visual_rect, |
| 73 kPaintInvalidationScroll); | 74 PaintInvalidationReason::kScrollControl); |
| 74 should_invalidate_new_rect = true; | 75 should_invalidate_new_rect = true; |
| 75 } | 76 } |
| 76 if (should_invalidate_new_rect) { | 77 if (should_invalidate_new_rect) { |
| 77 ObjectPaintInvalidator(box).InvalidatePaintUsingContainer( | 78 ObjectPaintInvalidator(box).InvalidatePaintUsingContainer( |
| 78 paint_invalidation_container, new_visual_rect, | 79 paint_invalidation_container, new_visual_rect, |
| 79 kPaintInvalidationScroll); | 80 PaintInvalidationReason::kScrollControl); |
| 80 return true; | 81 return true; |
| 81 } | 82 } |
| 82 return false; | 83 return false; |
| 83 } | 84 } |
| 84 | 85 |
| 85 static LayoutRect InvalidatePaintOfScrollbarIfNeeded( | 86 static LayoutRect InvalidatePaintOfScrollbarIfNeeded( |
| 86 Scrollbar* scrollbar, | 87 Scrollbar* scrollbar, |
| 87 GraphicsLayer* graphics_layer, | 88 GraphicsLayer* graphics_layer, |
| 88 bool& previously_was_overlay, | 89 bool& previously_was_overlay, |
| 89 const LayoutRect& previous_visual_rect, | 90 const LayoutRect& previous_visual_rect, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 *context.paint_invalidation_container; | 126 *context.paint_invalidation_container; |
| 126 LayoutSize new_scrollbar_used_space_in_box; | 127 LayoutSize new_scrollbar_used_space_in_box; |
| 127 if (!is_overlay) | 128 if (!is_overlay) |
| 128 new_scrollbar_used_space_in_box = new_visual_rect.Size(); | 129 new_scrollbar_used_space_in_box = new_visual_rect.Size(); |
| 129 LayoutSize previous_scrollbar_used_space_in_box; | 130 LayoutSize previous_scrollbar_used_space_in_box; |
| 130 if (!previously_was_overlay) | 131 if (!previously_was_overlay) |
| 131 previous_scrollbar_used_space_in_box = previous_visual_rect.Size(); | 132 previous_scrollbar_used_space_in_box = previous_visual_rect.Size(); |
| 132 if (new_scrollbar_used_space_in_box != previous_scrollbar_used_space_in_box) { | 133 if (new_scrollbar_used_space_in_box != previous_scrollbar_used_space_in_box) { |
| 133 context.painting_layer->SetNeedsRepaint(); | 134 context.painting_layer->SetNeedsRepaint(); |
| 134 ObjectPaintInvalidator(box).InvalidateDisplayItemClient( | 135 ObjectPaintInvalidator(box).InvalidateDisplayItemClient( |
| 135 box, kPaintInvalidationScroll); | 136 box, PaintInvalidationReason::kGeometry); |
| 136 } | 137 } |
| 137 | 138 |
| 138 bool invalidated = InvalidatePaintOfScrollControlIfNeeded( | 139 bool invalidated = InvalidatePaintOfScrollControlIfNeeded( |
| 139 new_visual_rect, previous_visual_rect, needs_paint_invalidation, box, | 140 new_visual_rect, previous_visual_rect, needs_paint_invalidation, box, |
| 140 paint_invalidation_container); | 141 paint_invalidation_container); |
| 141 | 142 |
| 142 previously_was_overlay = is_overlay; | 143 previously_was_overlay = is_overlay; |
| 143 | 144 |
| 144 if (!invalidated || !scrollbar || graphics_layer) | 145 if (!invalidated || !scrollbar || graphics_layer) |
| 145 return new_visual_rect; | 146 return new_visual_rect; |
| 146 | 147 |
| 147 context.painting_layer->SetNeedsRepaint(); | 148 context.painting_layer->SetNeedsRepaint(); |
| 148 ObjectPaintInvalidator(box).InvalidateDisplayItemClient( | 149 ObjectPaintInvalidator(box).InvalidateDisplayItemClient( |
| 149 *scrollbar, kPaintInvalidationScroll); | 150 *scrollbar, PaintInvalidationReason::kScrollControl); |
| 150 if (scrollbar->IsCustomScrollbar()) { | 151 if (scrollbar->IsCustomScrollbar()) { |
| 151 ToLayoutScrollbar(scrollbar) | 152 ToLayoutScrollbar(scrollbar) |
| 152 ->InvalidateDisplayItemClientsOfScrollbarParts(); | 153 ->InvalidateDisplayItemClientsOfScrollbarParts(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 return new_visual_rect; | 156 return new_visual_rect; |
| 156 } | 157 } |
| 157 | 158 |
| 158 void PaintInvalidationCapableScrollableArea:: | 159 void PaintInvalidationCapableScrollableArea:: |
| 159 InvalidatePaintOfScrollControlsIfNeeded( | 160 InvalidatePaintOfScrollControlsIfNeeded( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 177 *context.paint_invalidation_container; | 178 *context.paint_invalidation_container; |
| 178 if (InvalidatePaintOfScrollControlIfNeeded( | 179 if (InvalidatePaintOfScrollControlIfNeeded( |
| 179 scroll_corner_and_resizer_visual_rect, | 180 scroll_corner_and_resizer_visual_rect, |
| 180 scroll_corner_and_resizer_visual_rect_, | 181 scroll_corner_and_resizer_visual_rect_, |
| 181 ScrollCornerNeedsPaintInvalidation(), box, | 182 ScrollCornerNeedsPaintInvalidation(), box, |
| 182 paint_invalidation_container)) { | 183 paint_invalidation_container)) { |
| 183 SetScrollCornerAndResizerVisualRect(scroll_corner_and_resizer_visual_rect); | 184 SetScrollCornerAndResizerVisualRect(scroll_corner_and_resizer_visual_rect); |
| 184 if (LayoutScrollbarPart* scroll_corner = this->ScrollCorner()) { | 185 if (LayoutScrollbarPart* scroll_corner = this->ScrollCorner()) { |
| 185 ObjectPaintInvalidator(*scroll_corner) | 186 ObjectPaintInvalidator(*scroll_corner) |
| 186 .InvalidateDisplayItemClientsIncludingNonCompositingDescendants( | 187 .InvalidateDisplayItemClientsIncludingNonCompositingDescendants( |
| 187 kPaintInvalidationScroll); | 188 PaintInvalidationReason::kScrollControl); |
| 188 } | 189 } |
| 189 if (LayoutScrollbarPart* resizer = this->Resizer()) { | 190 if (LayoutScrollbarPart* resizer = this->Resizer()) { |
| 190 ObjectPaintInvalidator(*resizer) | 191 ObjectPaintInvalidator(*resizer) |
| 191 .InvalidateDisplayItemClientsIncludingNonCompositingDescendants( | 192 .InvalidateDisplayItemClientsIncludingNonCompositingDescendants( |
| 192 kPaintInvalidationScroll); | 193 PaintInvalidationReason::kScrollControl); |
| 193 } | 194 } |
| 194 } | 195 } |
| 195 | 196 |
| 196 ClearNeedsPaintInvalidationForScrollControls(); | 197 ClearNeedsPaintInvalidationForScrollControls(); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void PaintInvalidationCapableScrollableArea:: | 200 void PaintInvalidationCapableScrollableArea:: |
| 200 InvalidatePaintOfScrollControlsIfNeeded( | 201 InvalidatePaintOfScrollControlsIfNeeded( |
| 201 const PaintInvalidationState& paint_invalidation_state) { | 202 const PaintInvalidationState& paint_invalidation_state) { |
| 202 InvalidatePaintOfScrollControlsIfNeeded( | 203 InvalidatePaintOfScrollControlsIfNeeded( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 : UseCounter::kScrollbarUseHorizontalScrollbarTrack); | 266 : UseCounter::kScrollbarUseHorizontalScrollbarTrack); |
| 266 break; | 267 break; |
| 267 default: | 268 default: |
| 268 return; | 269 return; |
| 269 } | 270 } |
| 270 | 271 |
| 271 UseCounter::Count(GetLayoutBox()->GetDocument(), scrollbar_use_uma); | 272 UseCounter::Count(GetLayoutBox()->GetDocument(), scrollbar_use_uma); |
| 272 } | 273 } |
| 273 | 274 |
| 274 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |