| 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/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
| 9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 TextPaintingStyle_ForceBackgroundToWhite_NoAdjustmentNeeded) { | 122 TextPaintingStyle_ForceBackgroundToWhite_NoAdjustmentNeeded) { |
| 123 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, | 123 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, |
| 124 CSSValueRed); | 124 CSSValueRed); |
| 125 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, | 125 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, |
| 126 CSSValueLime); | 126 CSSValueLime); |
| 127 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, | 127 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, |
| 128 CSSValueBlue); | 128 CSSValueBlue); |
| 129 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, | 129 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, |
| 130 CSSValueEconomy); | 130 CSSValueEconomy); |
| 131 document().settings()->setShouldPrintBackgrounds(false); | 131 document().settings()->setShouldPrintBackgrounds(false); |
| 132 document().setPrinting(true); | 132 document().setPrinting(Document::Printing); |
| 133 document().view()->updateAllLifecyclePhases(); | 133 document().view()->updateAllLifecyclePhases(); |
| 134 | 134 |
| 135 TextPainter::Style textStyle = TextPainter::textPaintingStyle( | 135 TextPainter::Style textStyle = TextPainter::textPaintingStyle( |
| 136 getLineLayoutText(), getLineLayoutText().styleRef(), | 136 getLineLayoutText(), getLineLayoutText().styleRef(), |
| 137 createPaintInfo(false /* usesTextAsClip */, true /* isPrinting */)); | 137 createPaintInfo(false /* usesTextAsClip */, true /* isPrinting */)); |
| 138 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor); | 138 EXPECT_EQ(Color(255, 0, 0), textStyle.fillColor); |
| 139 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor); | 139 EXPECT_EQ(Color(0, 255, 0), textStyle.strokeColor); |
| 140 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor); | 140 EXPECT_EQ(Color(0, 0, 255), textStyle.emphasisMarkColor); |
| 141 } | 141 } |
| 142 | 142 |
| 143 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened) { | 143 TEST_F(TextPainterTest, TextPaintingStyle_ForceBackgroundToWhite_Darkened) { |
| 144 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, | 144 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextFillColor, |
| 145 "rgb(255, 220, 220)"); | 145 "rgb(255, 220, 220)"); |
| 146 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, | 146 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextStrokeColor, |
| 147 "rgb(220, 255, 220)"); | 147 "rgb(220, 255, 220)"); |
| 148 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, | 148 document().body()->setInlineStyleProperty(CSSPropertyWebkitTextEmphasisColor, |
| 149 "rgb(220, 220, 255)"); | 149 "rgb(220, 220, 255)"); |
| 150 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, | 150 document().body()->setInlineStyleProperty(CSSPropertyWebkitPrintColorAdjust, |
| 151 CSSValueEconomy); | 151 CSSValueEconomy); |
| 152 document().settings()->setShouldPrintBackgrounds(false); | 152 document().settings()->setShouldPrintBackgrounds(false); |
| 153 document().setPrinting(true); | 153 document().setPrinting(Document::Printing); |
| 154 document().view()->updateAllLifecyclePhases(); | 154 document().view()->updateAllLifecyclePhases(); |
| 155 | 155 |
| 156 TextPainter::Style textStyle = TextPainter::textPaintingStyle( | 156 TextPainter::Style textStyle = TextPainter::textPaintingStyle( |
| 157 getLineLayoutText(), getLineLayoutText().styleRef(), | 157 getLineLayoutText(), getLineLayoutText().styleRef(), |
| 158 createPaintInfo(false /* usesTextAsClip */, true /* isPrinting */)); | 158 createPaintInfo(false /* usesTextAsClip */, true /* isPrinting */)); |
| 159 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor); | 159 EXPECT_EQ(Color(255, 220, 220).dark(), textStyle.fillColor); |
| 160 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor); | 160 EXPECT_EQ(Color(220, 255, 220).dark(), textStyle.strokeColor); |
| 161 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor); | 161 EXPECT_EQ(Color(220, 220, 255).dark(), textStyle.emphasisMarkColor); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace | 164 } // namespace |
| 165 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |