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

Side by Side Diff: Source/core/paint/BoxPainter.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/paint/BoxPainter.h" 6 #include "core/paint/BoxPainter.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; 305 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true;
306 306
307 bool hasRoundedBorder = obj.style()->hasBorderRadius() && (includeLeftEdge | | includeRightEdge); 307 bool hasRoundedBorder = obj.style()->hasBorderRadius() && (includeLeftEdge | | includeRightEdge);
308 bool clippedWithLocalScrolling = obj.hasOverflowClip() && bgLayer.attachment () == LocalBackgroundAttachment; 308 bool clippedWithLocalScrolling = obj.hasOverflowClip() && bgLayer.attachment () == LocalBackgroundAttachment;
309 bool isBorderFill = bgLayer.clip() == BorderFillBox; 309 bool isBorderFill = bgLayer.clip() == BorderFillBox;
310 bool isBottomLayer = !bgLayer.next(); 310 bool isBottomLayer = !bgLayer.next();
311 311
312 Color bgColor = color; 312 Color bgColor = color;
313 StyleImage* bgImage = bgLayer.image(); 313 StyleImage* bgImage = bgLayer.image();
314 314
315 bool forceBackgroundToWhite = false; 315 bool forceBackgroundToWhite = shouldForceWhiteBackgroundForPrintEconomy(obj. styleRef(), obj.document());
316 if (obj.document().printing()) {
317 if (obj.style()->printColorAdjust() == PrintColorAdjustEconomy)
318 forceBackgroundToWhite = true;
319 if (obj.document().settings() && obj.document().settings()->shouldPrintB ackgrounds())
320 forceBackgroundToWhite = false;
321 }
322 316
323 // When printing backgrounds is disabled or using economy mode, 317 // When printing backgrounds is disabled or using economy mode,
324 // change existing background colors and images to a solid white background. 318 // change existing background colors and images to a solid white background.
325 // If there's no bg color or image, leave it untouched to avoid affecting tr ansparency. 319 // If there's no bg color or image, leave it untouched to avoid affecting tr ansparency.
326 // We don't try to avoid loading the background images, because this style f lag is only set 320 // We don't try to avoid loading the background images, because this style f lag is only set
327 // when printing, and at that point we've already loaded the background imag es anyway. (To avoid 321 // when printing, and at that point we've already loaded the background imag es anyway. (To avoid
328 // loading the background images we'd have to do this check when applying st yles rather than 322 // loading the background images we'd have to do this check when applying st yles rather than
329 // while layout.) 323 // while layout.)
330 if (forceBackgroundToWhite) { 324 if (forceBackgroundToWhite) {
331 // Note that we can't reuse this variable below because the bgColor migh t be changed 325 // Note that we can't reuse this variable below because the bgColor migh t be changed
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 clippedEdges |= GraphicsContext::RightEdge; 1042 clippedEdges |= GraphicsContext::RightEdge;
1049 else 1043 else
1050 clippedEdges |= GraphicsContext::BottomEdge; 1044 clippedEdges |= GraphicsContext::BottomEdge;
1051 } 1045 }
1052 // TODO: support non-integer shadows - crbug.com/334828 1046 // TODO: support non-integer shadows - crbug.com/334828
1053 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges); 1047 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges);
1054 } 1048 }
1055 } 1049 }
1056 } 1050 }
1057 1051
1052 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document)
1053 {
1054 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc onomy
1055 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ());
1056 }
1057
1058 } // namespace blink 1058 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698