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

Side by Side Diff: Source/core/paint/TextPainter.cpp

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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
« no previous file with comments | « Source/core/paint/TextPainter.h ('k') | Source/core/paint/ViewPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/layout/style/LayoutStyle.h" 13 #include "core/layout/style/ComputedStyle.h"
14 #include "core/layout/style/ShadowList.h" 14 #include "core/layout/style/ShadowList.h"
15 #include "platform/fonts/Font.h" 15 #include "platform/fonts/Font.h"
16 #include "platform/graphics/GraphicsContext.h" 16 #include "platform/graphics/GraphicsContext.h"
17 #include "platform/graphics/GraphicsContextStateSaver.h" 17 #include "platform/graphics/GraphicsContextStateSaver.h"
18 #include "platform/text/TextRun.h" 18 #include "platform/text/TextRun.h"
19 #include "wtf/Assertions.h" 19 #include "wtf/Assertions.h"
20 #include "wtf/unicode/CharacterNames.h" 20 #include "wtf/unicode/CharacterNames.h"
21 21
22 namespace blink { 22 namespace blink {
23 23
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 static Color textColorForWhiteBackground(Color textColor) 110 static Color textColorForWhiteBackground(Color textColor)
111 { 111 {
112 int distanceFromWhite = differenceSquared(textColor, Color::white); 112 int distanceFromWhite = differenceSquared(textColor, Color::white);
113 // semi-arbitrarily chose 65025 (255^2) value here after a few tests; 113 // semi-arbitrarily chose 65025 (255^2) value here after a few tests;
114 return distanceFromWhite > 65025 ? textColor : textColor.dark(); 114 return distanceFromWhite > 65025 ? textColor : textColor.dark();
115 } 115 }
116 116
117 // static 117 // static
118 TextPainter::Style TextPainter::textPaintingStyle(LayoutObject& renderer, const LayoutStyle& style, bool forceBlackText, bool isPrinting) 118 TextPainter::Style TextPainter::textPaintingStyle(LayoutObject& renderer, const ComputedStyle& style, bool forceBlackText, bool isPrinting)
119 { 119 {
120 TextPainter::Style textStyle; 120 TextPainter::Style textStyle;
121 121
122 if (forceBlackText) { 122 if (forceBlackText) {
123 textStyle.fillColor = Color::black; 123 textStyle.fillColor = Color::black;
124 textStyle.strokeColor = Color::black; 124 textStyle.strokeColor = Color::black;
125 textStyle.emphasisMarkColor = Color::black; 125 textStyle.emphasisMarkColor = Color::black;
126 textStyle.strokeWidth = style.textStrokeWidth(); 126 textStyle.strokeWidth = style.textStrokeWidth();
127 textStyle.shadow = 0; 127 textStyle.shadow = 0;
128 } else { 128 } else {
(...skipping 28 matching lines...) Expand all
157 TextPainter::Style TextPainter::selectionPaintingStyle(LayoutObject& renderer, b ool haveSelection, bool forceBlackText, bool isPrinting, const TextPainter::Styl e& textStyle) 157 TextPainter::Style TextPainter::selectionPaintingStyle(LayoutObject& renderer, b ool haveSelection, bool forceBlackText, bool isPrinting, const TextPainter::Styl e& textStyle)
158 { 158 {
159 TextPainter::Style selectionStyle = textStyle; 159 TextPainter::Style selectionStyle = textStyle;
160 160
161 if (haveSelection) { 161 if (haveSelection) {
162 if (!forceBlackText) { 162 if (!forceBlackText) {
163 selectionStyle.fillColor = renderer.selectionForegroundColor(); 163 selectionStyle.fillColor = renderer.selectionForegroundColor();
164 selectionStyle.emphasisMarkColor = renderer.selectionEmphasisMarkCol or(); 164 selectionStyle.emphasisMarkColor = renderer.selectionEmphasisMarkCol or();
165 } 165 }
166 166
167 if (const LayoutStyle* pseudoStyle = renderer.getCachedPseudoStyle(SELEC TION)) { 167 if (const ComputedStyle* pseudoStyle = renderer.getCachedPseudoStyle(SEL ECTION)) {
168 selectionStyle.strokeColor = forceBlackText ? Color::black : rendere r.resolveColor(*pseudoStyle, CSSPropertyWebkitTextStrokeColor); 168 selectionStyle.strokeColor = forceBlackText ? Color::black : rendere r.resolveColor(*pseudoStyle, CSSPropertyWebkitTextStrokeColor);
169 selectionStyle.strokeWidth = pseudoStyle->textStrokeWidth(); 169 selectionStyle.strokeWidth = pseudoStyle->textStrokeWidth();
170 selectionStyle.shadow = forceBlackText ? 0 : pseudoStyle->textShadow (); 170 selectionStyle.shadow = forceBlackText ? 0 : pseudoStyle->textShadow ();
171 } 171 }
172 172
173 // Text shadows are disabled when printing. http://crbug.com/258321 173 // Text shadows are disabled when printing. http://crbug.com/258321
174 if (isPrinting) 174 if (isPrinting)
175 selectionStyle.shadow = 0; 175 selectionStyle.shadow = 0;
176 } 176 }
177 177
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DEFINE_STATIC_LOCAL(TextRun, placeholderTextRun, (&ideographicFullStop, 1)); 219 DEFINE_STATIC_LOCAL(TextRun, placeholderTextRun, (&ideographicFullStop, 1));
220 FloatPoint emphasisMarkTextOrigin(m_textBounds.x(), m_textBounds.y() + m_fon t.fontMetrics().ascent() + m_emphasisMarkOffset); 220 FloatPoint emphasisMarkTextOrigin(m_textBounds.x(), m_textBounds.y() + m_fon t.fontMetrics().ascent() + m_emphasisMarkOffset);
221 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); 221 TextRunPaintInfo textRunPaintInfo(placeholderTextRun);
222 textRunPaintInfo.bounds = m_textBounds; 222 textRunPaintInfo.bounds = m_textBounds;
223 m_graphicsContext->concatCTM(rotation(m_textBounds, Clockwise)); 223 m_graphicsContext->concatCTM(rotation(m_textBounds, Clockwise));
224 m_graphicsContext->drawEmphasisMarks(m_combinedText->originalFont(), textRun PaintInfo, m_emphasisMark, emphasisMarkTextOrigin); 224 m_graphicsContext->drawEmphasisMarks(m_combinedText->originalFont(), textRun PaintInfo, m_emphasisMark, emphasisMarkTextOrigin);
225 m_graphicsContext->concatCTM(rotation(m_textBounds, Counterclockwise)); 225 m_graphicsContext->concatCTM(rotation(m_textBounds, Counterclockwise));
226 } 226 }
227 227
228 } // namespace blink 228 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/TextPainter.h ('k') | Source/core/paint/ViewPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698