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

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

Issue 2345543002: debugging for crbug.com/646539
Patch Set: 3 TUs, 2 .h Created 4 years, 3 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
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 "core/paint/TextPainter.h" 5 #include "core/paint/TextPainter.h"
6 6
7 #include "core/CSSPropertyNames.h" 7 #include "core/CSSPropertyNames.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/LayoutObject.h" 9 #include "core/layout/LayoutObject.h"
10 #include "core/layout/LayoutTextCombine.h" 10 #include "core/layout/LayoutTextCombine.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 { 113 {
114 int distanceFromWhite = differenceSquared(textColor, Color::white); 114 int distanceFromWhite = differenceSquared(textColor, Color::white);
115 // semi-arbitrarily chose 65025 (255^2) value here after a few tests; 115 // semi-arbitrarily chose 65025 (255^2) value here after a few tests;
116 return distanceFromWhite > 65025 ? textColor : textColor.dark(); 116 return distanceFromWhite > 65025 ? textColor : textColor.dark();
117 } 117 }
118 118
119 // static 119 // static
120 TextPainter::Style TextPainter::textPaintingStyle(LineLayoutItem lineLayoutItem, const ComputedStyle& style, const PaintInfo& paintInfo) 120 TextPainter::Style TextPainter::textPaintingStyle(LineLayoutItem lineLayoutItem, const ComputedStyle& style, const PaintInfo& paintInfo)
121 { 121 {
122 TextPainter::Style textStyle; 122 TextPainter::Style textStyle;
123 bool isPrinting = paintInfo.isPrinting(); 123 //bool isPrinting = paintInfo.isPrinting();
124 124
125 if (paintInfo.phase == PaintPhaseTextClip) { 125 //if (paintInfo.phase == PaintPhaseTextClip) {
126 // When we use the text as a clip, we only care about the alpha, thus we make all the colors black. 126 //// When we use the text as a clip, we only care about the alpha, thus we make all the colors black.
127 textStyle.currentColor = Color::black; 127 //textStyle.currentColor = Color::black;
128 textStyle.fillColor = Color::black; 128 //textStyle.fillColor = Color::black;
129 textStyle.strokeColor = Color::black; 129 //textStyle.strokeColor = Color::black;
130 textStyle.emphasisMarkColor = Color::black; 130 //textStyle.emphasisMarkColor = Color::black;
131 textStyle.strokeWidth = style.textStrokeWidth(); 131 //textStyle.strokeWidth = style.textStrokeWidth();
132 textStyle.shadow = 0; 132 //textStyle.shadow = 0;
133 } else { 133 //} else {
134 textStyle.currentColor = style.visitedDependentColor(CSSPropertyColor); 134 //textStyle.currentColor = style.visitedDependentColor(CSSPropertyColor) ;
135 textStyle.fillColor = lineLayoutItem.resolveColor(style, CSSPropertyWebk itTextFillColor); 135 textStyle.fillColor = lineLayoutItem.resolveColor(style, CSSPropertyWebk itTextFillColor);
136 textStyle.strokeColor = lineLayoutItem.resolveColor(style, CSSPropertyWe bkitTextStrokeColor); 136 //textStyle.strokeColor = lineLayoutItem.resolveColor(style, CSSProperty WebkitTextStrokeColor);
137 textStyle.emphasisMarkColor = lineLayoutItem.resolveColor(style, CSSProp ertyWebkitTextEmphasisColor); 137 //textStyle.emphasisMarkColor = lineLayoutItem.resolveColor(style, CSSPr opertyWebkitTextEmphasisColor);
138 textStyle.strokeWidth = style.textStrokeWidth(); 138 //textStyle.strokeWidth = style.textStrokeWidth();
139 textStyle.shadow = style.textShadow(); 139 //textStyle.shadow = style.textShadow();
140 140
141 // Adjust text color when printing with a white background. 141 // Adjust text color when printing with a white background.
142 ASSERT(lineLayoutItem.document().printing() == isPrinting); 142 //ASSERT(lineLayoutItem.document().printing() == isPrinting);
143 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForP rintEconomy(style, lineLayoutItem.document()); 143 //bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundFo rPrintEconomy(style, lineLayoutItem.document());
144 if (forceBackgroundToWhite) { 144 //if (forceBackgroundToWhite) {
145 textStyle.fillColor = textColorForWhiteBackground(textStyle.fillColo r); 145 //textStyle.fillColor = textColorForWhiteBackground(textStyle.fillCo lor);
146 textStyle.strokeColor = textColorForWhiteBackground(textStyle.stroke Color); 146 //textStyle.strokeColor = textColorForWhiteBackground(textStyle.stro keColor);
147 textStyle.emphasisMarkColor = textColorForWhiteBackground(textStyle. emphasisMarkColor); 147 //textStyle.emphasisMarkColor = textColorForWhiteBackground(textStyl e.emphasisMarkColor);
148 } 148 //}
149 149
150 // Text shadows are disabled when printing. http://crbug.com/258321 150 // Text shadows are disabled when printing. http://crbug.com/258321
151 if (isPrinting) 151 //if (isPrinting)
152 textStyle.shadow = 0; 152 //textStyle.shadow = 0;
153 } 153 //}
154 154
155 return textStyle; 155 return textStyle;
156 } 156 }
157 157
158 TextPainter::Style TextPainter::selectionPaintingStyle(LineLayoutItem lineLayout Item, bool haveSelection, const PaintInfo& paintInfo, const TextPainter::Style& textStyle) 158 TextPainter::Style TextPainter::selectionPaintingStyle(LineLayoutItem lineLayout Item, bool haveSelection, const PaintInfo& paintInfo, const TextPainter::Style& textStyle)
159 { 159 {
160 const LayoutObject& layoutObject = *LineLayoutAPIShim::constLayoutObjectFrom (lineLayoutItem); 160 const LayoutObject& layoutObject = *LineLayoutAPIShim::constLayoutObjectFrom (lineLayoutItem);
161 TextPainter::Style selectionStyle = textStyle; 161 TextPainter::Style selectionStyle = textStyle;
162 bool usesTextAsClip = paintInfo.phase == PaintPhaseTextClip; 162 bool usesTextAsClip = paintInfo.phase == PaintPhaseTextClip;
163 bool isPrinting = paintInfo.isPrinting(); 163 bool isPrinting = paintInfo.isPrinting();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1); 223 TextRun placeholderTextRun(&ideographicFullStopCharacter, 1);
224 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y ().toFloat() + m_font.getFontMetrics().ascent() + m_emphasisMarkOffset); 224 FloatPoint emphasisMarkTextOrigin(m_textBounds.x().toFloat(), m_textBounds.y ().toFloat() + m_font.getFontMetrics().ascent() + m_emphasisMarkOffset);
225 TextRunPaintInfo textRunPaintInfo(placeholderTextRun); 225 TextRunPaintInfo textRunPaintInfo(placeholderTextRun);
226 textRunPaintInfo.bounds = FloatRect(m_textBounds); 226 textRunPaintInfo.bounds = FloatRect(m_textBounds);
227 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise)); 227 m_graphicsContext.concatCTM(rotation(m_textBounds, Clockwise));
228 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), textRunP aintInfo, m_emphasisMark, emphasisMarkTextOrigin); 228 m_graphicsContext.drawEmphasisMarks(m_combinedText->originalFont(), textRunP aintInfo, m_emphasisMark, emphasisMarkTextOrigin);
229 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise)); 229 m_graphicsContext.concatCTM(rotation(m_textBounds, Counterclockwise));
230 } 230 }
231 231
232 } // namespace blink 232 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BUILD.gn ('k') | third_party/WebKit/Source/core/paint/TextPainterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698