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

Unified Diff: Source/core/paint/ViewPainter.cpp

Issue 1196223008: ViewPainter should skip background in print economy mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix unittests Created 5 years, 6 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
« Source/core/paint/BoxPainter.h ('K') | « Source/core/paint/TextPainterTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/ViewPainter.cpp
diff --git a/Source/core/paint/ViewPainter.cpp b/Source/core/paint/ViewPainter.cpp
index fd892d571a52e8ebc3a2a99f43c804adeaff4f20..386840cec65e8f2add2ccd7594c101b255c9cf17 100644
--- a/Source/core/paint/ViewPainter.cpp
+++ b/Source/core/paint/ViewPainter.cpp
@@ -56,12 +56,22 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
bool paintsBaseBackground = isMainFrame && !frameView.isTransparent();
bool shouldClearCanvas = paintsBaseBackground && (document.settings() && document.settings()->shouldClearDocumentBackground());
Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundColor() : Color();
+ Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSPropertyBackgroundColor);
const LayoutObject* rootObject = document.documentElement() ? document.documentElement()->layoutObject() : nullptr;
LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::BoxDecorationBackground, documentRect);
if (recorder.canUseCachedDrawing())
return;
+ // Special handling for print economy mode.
+ bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(m_layoutView.styleRef(), document);
+ if (forceBackgroundToWhite) {
+ // If for any reason the view background is not transparent, paint white instead, otherwise keep transparent as is.
+ if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView.style()->backgroundLayers().image())
+ context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode);
+ return;
+ }
+
// Compute the enclosing rect of the view, in root element space.
//
// For background colors we can simply paint the document rect in the default space.
@@ -100,7 +110,6 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
BoxPainter::FillLayerOcclusionOutputList reversedPaintList;
bool shouldDrawBackgroundInSeparateBuffer = BoxPainter(m_layoutView).calculateFillLayerOcclusionCulling(reversedPaintList, m_layoutView.style()->backgroundLayers());
ASSERT(reversedPaintList.size());
- Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSPropertyBackgroundColor);
// If the root background color is opaque, isolation group can be skipped because the canvas
// will be cleared by root background color.
« Source/core/paint/BoxPainter.h ('K') | « Source/core/paint/TextPainterTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698