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

Side by Side Diff: Source/core/paint/TextPainter.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/TextPainter.h" 6 #include "core/paint/TextPainter.h"
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutObject.h" 10 #include "core/layout/LayoutObject.h"
11 #include "core/layout/LayoutTextCombine.h" 11 #include "core/layout/LayoutTextCombine.h"
12 #include "core/layout/line/InlineTextBox.h" 12 #include "core/layout/line/InlineTextBox.h"
13 #include "core/paint/BoxPainter.h"
13 #include "core/style/ComputedStyle.h" 14 #include "core/style/ComputedStyle.h"
14 #include "core/style/ShadowList.h" 15 #include "core/style/ShadowList.h"
15 #include "platform/fonts/Font.h" 16 #include "platform/fonts/Font.h"
16 #include "platform/graphics/GraphicsContext.h" 17 #include "platform/graphics/GraphicsContext.h"
17 #include "platform/graphics/GraphicsContextStateSaver.h" 18 #include "platform/graphics/GraphicsContextStateSaver.h"
18 #include "platform/text/TextRun.h" 19 #include "platform/text/TextRun.h"
19 #include "wtf/Assertions.h" 20 #include "wtf/Assertions.h"
20 #include "wtf/unicode/CharacterNames.h" 21 #include "wtf/unicode/CharacterNames.h"
21 22
22 namespace blink { 23 namespace blink {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 textStyle.shadow = 0; 129 textStyle.shadow = 0;
129 } else { 130 } else {
130 textStyle.currentColor = style.visitedDependentColor(CSSPropertyColor); 131 textStyle.currentColor = style.visitedDependentColor(CSSPropertyColor);
131 textStyle.fillColor = layoutObject.resolveColor(style, CSSPropertyWebkit TextFillColor); 132 textStyle.fillColor = layoutObject.resolveColor(style, CSSPropertyWebkit TextFillColor);
132 textStyle.strokeColor = layoutObject.resolveColor(style, CSSPropertyWebk itTextStrokeColor); 133 textStyle.strokeColor = layoutObject.resolveColor(style, CSSPropertyWebk itTextStrokeColor);
133 textStyle.emphasisMarkColor = layoutObject.resolveColor(style, CSSProper tyWebkitTextEmphasisColor); 134 textStyle.emphasisMarkColor = layoutObject.resolveColor(style, CSSProper tyWebkitTextEmphasisColor);
134 textStyle.strokeWidth = style.textStrokeWidth(); 135 textStyle.strokeWidth = style.textStrokeWidth();
135 textStyle.shadow = style.textShadow(); 136 textStyle.shadow = style.textShadow();
136 137
137 // Adjust text color when printing with a white background. 138 // Adjust text color when printing with a white background.
138 bool forceBackgroundToWhite = false; 139 ASSERT(layoutObject.document().printing() == isPrinting);
139 if (isPrinting) { 140 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForP rintEconomy(style, layoutObject.document());
140 if (style.printColorAdjust() == PrintColorAdjustEconomy)
141 forceBackgroundToWhite = true;
142 if (layoutObject.document().settings() && layoutObject.document().se ttings()->shouldPrintBackgrounds())
143 forceBackgroundToWhite = false;
144 }
145 if (forceBackgroundToWhite) { 141 if (forceBackgroundToWhite) {
146 textStyle.fillColor = textColorForWhiteBackground(textStyle.fillColo r); 142 textStyle.fillColor = textColorForWhiteBackground(textStyle.fillColo r);
147 textStyle.strokeColor = textColorForWhiteBackground(textStyle.stroke Color); 143 textStyle.strokeColor = textColorForWhiteBackground(textStyle.stroke Color);
148 textStyle.emphasisMarkColor = textColorForWhiteBackground(textStyle. emphasisMarkColor); 144 textStyle.emphasisMarkColor = textColorForWhiteBackground(textStyle. emphasisMarkColor);
149 } 145 }
150 146
151 // Text shadows are disabled when printing. http://crbug.com/258321 147 // Text shadows are disabled when printing. http://crbug.com/258321
152 if (isPrinting) 148 if (isPrinting)
153 textStyle.shadow = 0; 149 textStyle.shadow = 0;
154 } 150 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 DEFINE_STATIC_LOCAL(TextRun, placeholderTextRun, (&ideographicFullStopCharac ter, 1)); 217 DEFINE_STATIC_LOCAL(TextRun, placeholderTextRun, (&ideographicFullStopCharac ter, 1));
222 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y ().toFloat() + m_font.fontMetrics().ascent() + m_emphasisMarkOffset); 218 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y ().toFloat() + m_font.fontMetrics().ascent() + m_emphasisMarkOffset);
223 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); 219 TextRunPaintInfo textRunPaintInfo(placeholderTextRun);
224 textRunPaintInfo.bounds = m_textBounds; 220 textRunPaintInfo.bounds = m_textBounds;
225 m_graphicsContext->concatCTM(rotation(m_textBounds, Clockwise)); 221 m_graphicsContext->concatCTM(rotation(m_textBounds, Clockwise));
226 m_graphicsContext->drawEmphasisMarks(m_combinedText->originalFont(), textRun PaintInfo, m_emphasisMark, emphasisMarkTextOrigin); 222 m_graphicsContext->drawEmphasisMarks(m_combinedText->originalFont(), textRun PaintInfo, m_emphasisMark, emphasisMarkTextOrigin);
227 m_graphicsContext->concatCTM(rotation(m_textBounds, Counterclockwise)); 223 m_graphicsContext->concatCTM(rotation(m_textBounds, Counterclockwise));
228 } 224 }
229 225
230 } // namespace blink 226 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698