OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/paint/ViewPaintInvalidator.h" |
| 6 |
| 7 #include "core/layout/LayoutView.h" |
| 8 #include "core/paint/BoxPaintInvalidator.h" |
| 9 #include "platform/geometry/LayoutSize.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 PaintInvalidationReason ViewPaintInvalidator::invalidatePaintIfNeeded() { |
| 14 invalidateBackgroundIfNeeded(); |
| 15 return BoxPaintInvalidator(m_view, m_context).invalidatePaintIfNeeded(); |
| 16 } |
| 17 |
| 18 void ViewPaintInvalidator::invalidateBackgroundIfNeeded() { |
| 19 // Fixed attachment background is handled in LayoutView::layout(). |
| 20 // TODO(wangxianzhu): Combine code for fixed-attachment background when we |
| 21 // enable rootLayerScrolling permanently. |
| 22 if (m_view.styleRef().hasEntirelyFixedBackground()) |
| 23 return; |
| 24 |
| 25 // LayoutView's non-fixed-attachment background is positioned in the |
| 26 // document element. |
| 27 // See https://drafts.csswg.org/css-backgrounds-3/#root-background. |
| 28 Element* documentElement = m_view.document().documentElement(); |
| 29 if (!documentElement) |
| 30 return; |
| 31 const LayoutObject* backgroundObject = documentElement->layoutObject(); |
| 32 if (!backgroundObject || !backgroundObject->isBox()) |
| 33 return; |
| 34 |
| 35 const LayoutBox& backgroundBox = toLayoutBox(*backgroundObject); |
| 36 LayoutSize oldSize = BoxPaintInvalidator::previousBorderBoxSize( |
| 37 backgroundBox, backgroundBox.visualRect().size()); |
| 38 LayoutSize newSize = backgroundBox.size(); |
| 39 const auto& backgroundLayers = m_view.styleRef().backgroundLayers(); |
| 40 if ((oldSize.width() != newSize.width() && |
| 41 LayoutBox::mustInvalidateFillLayersPaintOnWidthChange( |
| 42 backgroundLayers)) || |
| 43 (oldSize.height() != newSize.height() && |
| 44 LayoutBox::mustInvalidateFillLayersPaintOnHeightChange( |
| 45 backgroundLayers))) { |
| 46 m_view.getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 47 PaintInvalidationViewBackground); |
| 48 } |
| 49 } |
| 50 |
| 51 } // namespace blink |
OLD | NEW |