| OLD | NEW |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 context.setStrokeThickness(textStyle.strokeWidth); | 102 context.setStrokeThickness(textStyle.strokeWidth); |
| 103 } | 103 } |
| 104 | 104 |
| 105 if (textStyle.shadow) { | 105 if (textStyle.shadow) { |
| 106 if (!stateSaver.saved()) | 106 if (!stateSaver.saved()) |
| 107 stateSaver.save(); | 107 stateSaver.save(); |
| 108 context.setDrawLooper(textStyle.shadow->createDrawLooper(DrawLooperBuild
er::ShadowIgnoresAlpha, textStyle.currentColor, horizontal)); | 108 context.setDrawLooper(textStyle.shadow->createDrawLooper(DrawLooperBuild
er::ShadowIgnoresAlpha, textStyle.currentColor, horizontal)); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 static Color textColorForWhiteBackground(Color textColor) | 112 Color TextPainter::textColorForWhiteBackground(Color textColor) |
| 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; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |