| 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/css/resolver/FontBuilder.h" | 5 #include "core/css/resolver/FontBuilder.h" |
| 6 | 6 |
| 7 #include "core/css/CSSFontSelector.h" | 7 #include "core/css/CSSFontSelector.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/StyleEngine.h" | 9 #include "core/dom/StyleEngine.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 class FontBuilderAdditiveTest : public FontBuilderTest, public ::testing::TestWi
thParam<FunctionPair> { }; | 47 class FontBuilderAdditiveTest : public FontBuilderTest, public ::testing::TestWi
thParam<FunctionPair> { }; |
| 48 | 48 |
| 49 TEST_F(FontBuilderInitTest, InitialFontSizeNotScaled) | 49 TEST_F(FontBuilderInitTest, InitialFontSizeNotScaled) |
| 50 { | 50 { |
| 51 RefPtr<ComputedStyle> initial = ComputedStyle::create(); | 51 RefPtr<ComputedStyle> initial = ComputedStyle::create(); |
| 52 | 52 |
| 53 FontBuilder builder(document()); | 53 FontBuilder builder(document()); |
| 54 builder.setInitial(1.0f); // FIXME: Remove unused param. | 54 builder.setInitial(1.0f); // FIXME: Remove unused param. |
| 55 builder.createFont(document().styleEngine().fontSelector(), *initial); | 55 builder.createFont(document().styleEngine().fontSelector(), *initial); |
| 56 | 56 |
| 57 EXPECT_EQ(16.0f, initial->fontDescription().computedSize()); | 57 EXPECT_EQ(16.0f, initial->getFontDescription().computedSize()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST_F(FontBuilderInitTest, NotDirty) | 60 TEST_F(FontBuilderInitTest, NotDirty) |
| 61 { | 61 { |
| 62 FontBuilder builder(document()); | 62 FontBuilder builder(document()); |
| 63 ASSERT_FALSE(builder.fontDirty()); | 63 ASSERT_FALSE(builder.fontDirty()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // This test verifies that when you are setting some field F via FontBuilder, | 66 // This test verifies that when you are setting some field F via FontBuilder, |
| 67 // only F is actually modified on the incoming ComputedStyle::fontDescription. | 67 // only F is actually modified on the incoming ComputedStyle::fontDescription. |
| 68 TEST_P(FontBuilderAdditiveTest, OnlySetValueIsModified) | 68 TEST_P(FontBuilderAdditiveTest, OnlySetValueIsModified) |
| 69 { | 69 { |
| 70 FunctionPair funcs = GetParam(); | 70 FunctionPair funcs = GetParam(); |
| 71 | 71 |
| 72 FontDescription parentDescription; | 72 FontDescription parentDescription; |
| 73 funcs.setBaseValue(parentDescription); | 73 funcs.setBaseValue(parentDescription); |
| 74 | 74 |
| 75 RefPtr<ComputedStyle> style = ComputedStyle::create(); | 75 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
| 76 style->setFontDescription(parentDescription); | 76 style->setFontDescription(parentDescription); |
| 77 | 77 |
| 78 FontBuilder fontBuilder(document()); | 78 FontBuilder fontBuilder(document()); |
| 79 funcs.setValue(fontBuilder); | 79 funcs.setValue(fontBuilder); |
| 80 fontBuilder.createFont(document().styleEngine().fontSelector(), *style); | 80 fontBuilder.createFont(document().styleEngine().fontSelector(), *style); |
| 81 | 81 |
| 82 FontDescription outputDescription = style->fontDescription(); | 82 FontDescription outputDescription = style->getFontDescription(); |
| 83 | 83 |
| 84 // FontBuilder should have overwritten our base value set in the parent, | 84 // FontBuilder should have overwritten our base value set in the parent, |
| 85 // hence the descriptions should not be equal. | 85 // hence the descriptions should not be equal. |
| 86 ASSERT_NE(parentDescription, outputDescription); | 86 ASSERT_NE(parentDescription, outputDescription); |
| 87 | 87 |
| 88 // Overwrite the value set by FontBuilder with the base value, directly | 88 // Overwrite the value set by FontBuilder with the base value, directly |
| 89 // on outputDescription. | 89 // on outputDescription. |
| 90 funcs.setBaseValue(outputDescription); | 90 funcs.setBaseValue(outputDescription); |
| 91 | 91 |
| 92 // Now the descriptions should be equal again. If they are, we know that | 92 // Now the descriptions should be equal again. If they are, we know that |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 FunctionPair(fontStyleBase, fontStyleValue), | 153 FunctionPair(fontStyleBase, fontStyleValue), |
| 154 FunctionPair(fontVariantBase, fontVariantValue), | 154 FunctionPair(fontVariantBase, fontVariantValue), |
| 155 FunctionPair(fontVariantLigaturesBase, fontVariantLigaturesValue), | 155 FunctionPair(fontVariantLigaturesBase, fontVariantLigaturesValue), |
| 156 FunctionPair(fontTextRenderingBase, fontTextRenderingValue), | 156 FunctionPair(fontTextRenderingBase, fontTextRenderingValue), |
| 157 FunctionPair(fontKerningBase, fontKerningValue), | 157 FunctionPair(fontKerningBase, fontKerningValue), |
| 158 FunctionPair(fontFontSmoothingBase, fontFontSmoothingValue), | 158 FunctionPair(fontFontSmoothingBase, fontFontSmoothingValue), |
| 159 FunctionPair(fontSizeBase, fontSizeValue), | 159 FunctionPair(fontSizeBase, fontSizeValue), |
| 160 FunctionPair(fontScriptBase, fontScriptValue))); | 160 FunctionPair(fontScriptBase, fontScriptValue))); |
| 161 | 161 |
| 162 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |