Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Unified Diff: third_party/WebKit/Source/core/paint/ViewPaintInvalidator.cpp

Issue 2699463004: Fix gradient background invalidation when HTML size changes (Closed)
Patch Set: - Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/ViewPaintInvalidator.cpp
diff --git a/third_party/WebKit/Source/core/paint/ViewPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/ViewPaintInvalidator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1527c8d002efbf2456323a86a9ff4955677e30b3
--- /dev/null
+++ b/third_party/WebKit/Source/core/paint/ViewPaintInvalidator.cpp
@@ -0,0 +1,51 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/paint/ViewPaintInvalidator.h"
+
+#include "core/layout/LayoutView.h"
+#include "core/paint/BoxPaintInvalidator.h"
+#include "platform/geometry/LayoutSize.h"
+
+namespace blink {
+
+PaintInvalidationReason ViewPaintInvalidator::invalidatePaintIfNeeded() {
+ invalidateBackgroundIfNeeded();
+ return BoxPaintInvalidator(m_view, m_context).invalidatePaintIfNeeded();
+}
+
+void ViewPaintInvalidator::invalidateBackgroundIfNeeded() {
+ // Fixed attachment background is handled in LayoutView::layout().
+ // TODO(wangxianzhu): Combine code for fixed-attachment background when we
+ // enable rootLayerScrolling permanently.
+ if (m_view.styleRef().hasEntirelyFixedBackground())
+ return;
+
+ // LayoutView's non-fixed-attachment background is positioned in the
+ // document element.
+ // See https://drafts.csswg.org/css-backgrounds-3/#root-background.
+ Element* documentElement = m_view.document().documentElement();
+ if (!documentElement)
+ return;
+ const LayoutObject* backgroundObject = documentElement->layoutObject();
+ if (!backgroundObject || !backgroundObject->isBox())
+ return;
+
+ const LayoutBox& backgroundBox = toLayoutBox(*backgroundObject);
+ LayoutSize oldSize = BoxPaintInvalidator::previousBorderBoxSize(
+ backgroundBox, backgroundBox.visualRect().size());
+ LayoutSize newSize = backgroundBox.size();
+ const auto& backgroundLayers = m_view.styleRef().backgroundLayers();
+ if ((oldSize.width() != newSize.width() &&
+ LayoutBox::mustInvalidateFillLayersPaintOnWidthChange(
+ backgroundLayers)) ||
+ (oldSize.height() != newSize.height() &&
+ LayoutBox::mustInvalidateFillLayersPaintOnHeightChange(
+ backgroundLayers))) {
+ m_view.getMutableForPainting().setShouldDoFullPaintInvalidation(
+ PaintInvalidationViewBackground);
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698