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 if (!m_view.styleRef().hasEntirelyFixedBackground()) { |
| 15 // LayoutView's non-fixed-attachment background is positioned in the |
| 16 // document element. |
| 17 if (Element* documentElement = m_view.document().documentElement()) { |
| 18 const LayoutObject* backgroundObject = documentElement->layoutObject(); |
| 19 if (backgroundObject && backgroundObject->isBox()) { |
| 20 const LayoutBox& backgroundBox = toLayoutBox(*backgroundObject); |
| 21 LayoutSize oldSize = |
| 22 BoxPaintInvalidator::previousBorderBoxSize(backgroundBox); |
| 23 LayoutSize newSize = backgroundBox.size(); |
| 24 const auto& backgroundLayers = m_view.styleRef().backgroundLayers(); |
| 25 if ((oldSize.width() != newSize.width() && |
| 26 LayoutBox::mustInvalidateFillLayersPaintOnWidthChange( |
| 27 backgroundLayers)) || |
| 28 (oldSize.height() != newSize.height() && |
| 29 LayoutBox::mustInvalidateFillLayersPaintOnHeightChange( |
| 30 backgroundLayers))) { |
| 31 m_view.getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 32 PaintInvalidationViewBackground); |
| 33 } |
| 34 } |
| 35 } |
| 36 } |
| 37 |
| 38 return BoxPaintInvalidator(m_view, m_context).invalidatePaintIfNeeded(); |
| 39 } |
| 40 |
| 41 } // namespace blink |
OLD | NEW |