Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "core/frame/Settings.h" | 28 #include "core/frame/Settings.h" |
| 29 #include "core/rendering/RenderTheme.h" | 29 #include "core/rendering/RenderTheme.h" |
| 30 #include "core/rendering/RenderView.h" | 30 #include "core/rendering/RenderView.h" |
| 31 #include "core/rendering/TextAutosizer.h" | 31 #include "core/rendering/TextAutosizer.h" |
| 32 #include "platform/FontFamilyNames.h" | 32 #include "platform/FontFamilyNames.h" |
| 33 #include "platform/fonts/FontDescription.h" | 33 #include "platform/fonts/FontDescription.h" |
| 34 #include "platform/text/LocaleToScriptMapping.h" | 34 #include "platform/text/LocaleToScriptMapping.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 // FIXME: This scoping class is a short-term fix to minimize the changes in | |
| 39 // Font-constructing logic. | |
| 40 class FontDescriptionChangeScope { | |
| 41 STACK_ALLOCATED(); | |
| 42 public: | |
| 43 FontDescriptionChangeScope(FontBuilder* fontBuilder) | |
| 44 : m_fontBuilder(fontBuilder) | |
| 45 , m_fontDescription(fontBuilder->fontDescription()) | |
| 46 { | |
| 47 } | |
| 48 | |
| 49 ~FontDescriptionChangeScope() | |
| 50 { | |
| 51 if (m_fontBuilder->fontDirty()) | |
| 52 return; | |
| 53 m_fontBuilder->didChangeFontParameters(m_fontBuilder->fontDescription() != m_fontDescription); | |
| 54 } | |
| 55 | |
| 56 private: | |
| 57 RawPtrWillBeMember<FontBuilder> m_fontBuilder; | |
| 58 FontDescription m_fontDescription; | |
| 59 }; | |
| 60 | |
| 61 FontBuilder::FontBuilder(const Document& document) | 38 FontBuilder::FontBuilder(const Document& document) |
| 62 : m_document(document) | 39 : m_document(document) |
| 63 , m_fontDirty(false) | 40 , m_flags(0) |
| 64 { | 41 { |
| 65 ASSERT(document.frame()); | 42 ASSERT(document.frame()); |
| 66 } | 43 } |
| 67 | 44 |
| 68 void FontBuilder::setInitial(float effectiveZoom) | 45 void FontBuilder::setInitial(float effectiveZoom) |
| 69 { | 46 { |
| 70 ASSERT(m_document.settings()); | 47 ASSERT(m_document.settings()); |
| 71 if (!m_document.settings()) | 48 if (!m_document.settings()) |
| 72 return; | 49 return; |
| 73 | 50 |
| 74 FontDescriptionChangeScope scope(this); | |
| 75 | |
| 76 m_fontDescription = FontDescription(); | |
| 77 setFamilyDescription(m_fontDescription, FontBuilder::initialFamilyDescriptio n()); | 51 setFamilyDescription(m_fontDescription, FontBuilder::initialFamilyDescriptio n()); |
| 78 setSize(m_fontDescription, FontBuilder::initialSize()); | 52 setSize(m_fontDescription, FontBuilder::initialSize()); |
| 79 } | 53 } |
| 80 | 54 |
| 81 void FontBuilder::inheritFrom(const FontDescription& fontDescription) | 55 void FontBuilder::didChangeEffectiveZoom(bool changed) |
| 82 { | 56 { |
| 83 FontDescriptionChangeScope scope(this); | 57 if (changed) |
| 84 | 58 set(IsSetFlag::EffectiveZoom); |
| 85 m_fontDescription = fontDescription; | |
| 86 } | 59 } |
| 87 | 60 |
| 88 void FontBuilder::didChangeFontParameters(bool changed) | 61 void FontBuilder::didChangeTextOrientation(bool changed) |
| 89 { | 62 { |
| 90 m_fontDirty |= changed; | 63 if (changed) |
| 64 set(IsSetFlag::TextOrientation); | |
| 65 } | |
| 66 | |
| 67 void FontBuilder::didChangeWritingMode(bool changed) | |
| 68 { | |
| 69 if (changed) | |
| 70 set(IsSetFlag::WritingMode); | |
| 91 } | 71 } |
| 92 | 72 |
| 93 FontFamily FontBuilder::standardFontFamily() const | 73 FontFamily FontBuilder::standardFontFamily() const |
| 94 { | 74 { |
| 95 FontFamily family; | 75 FontFamily family; |
| 96 family.setFamily(standardFontFamilyName()); | 76 family.setFamily(standardFontFamilyName()); |
| 97 return family; | 77 return family; |
| 98 } | 78 } |
| 99 | 79 |
| 100 AtomicString FontBuilder::standardFontFamilyName() const | 80 AtomicString FontBuilder::standardFontFamilyName() const |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 124 return FontFamilyNames::webkit_cursive; | 104 return FontFamilyNames::webkit_cursive; |
| 125 case FontDescription::FantasyFamily: | 105 case FontDescription::FantasyFamily: |
| 126 return FontFamilyNames::webkit_fantasy; | 106 return FontFamilyNames::webkit_fantasy; |
| 127 case FontDescription::PictographFamily: | 107 case FontDescription::PictographFamily: |
| 128 return FontFamilyNames::webkit_pictograph; | 108 return FontFamilyNames::webkit_pictograph; |
| 129 } | 109 } |
| 130 } | 110 } |
| 131 | 111 |
| 132 void FontBuilder::setFamilyDescription(const FontDescription::FamilyDescription& familyDescription) | 112 void FontBuilder::setFamilyDescription(const FontDescription::FamilyDescription& familyDescription) |
| 133 { | 113 { |
| 134 FontDescriptionChangeScope scope(this); | |
| 135 | |
| 136 setFamilyDescription(m_fontDescription, familyDescription); | 114 setFamilyDescription(m_fontDescription, familyDescription); |
| 137 } | 115 } |
| 138 | 116 |
| 139 void FontBuilder::setWeight(FontWeight fontWeight) | 117 void FontBuilder::setWeight(FontWeight fontWeight) |
| 140 { | 118 { |
| 141 FontDescriptionChangeScope scope(this); | 119 set(IsSetFlag::Weight); |
| 142 | 120 |
| 143 m_fontDescription.setWeight(fontWeight); | 121 m_fontDescription.setWeight(fontWeight); |
| 144 } | 122 } |
| 145 | 123 |
| 146 void FontBuilder::setSize(const FontDescription::Size& size) | 124 void FontBuilder::setSize(const FontDescription::Size& size) |
| 147 { | 125 { |
| 148 FontDescriptionChangeScope scope(this); | |
| 149 | |
| 150 setSize(m_fontDescription, size); | 126 setSize(m_fontDescription, size); |
| 151 } | 127 } |
| 152 | 128 |
| 153 void FontBuilder::setStretch(FontStretch fontStretch) | 129 void FontBuilder::setStretch(FontStretch fontStretch) |
| 154 { | 130 { |
| 155 FontDescriptionChangeScope scope(this); | 131 set(IsSetFlag::Stretch); |
| 156 | 132 |
| 157 m_fontDescription.setStretch(fontStretch); | 133 m_fontDescription.setStretch(fontStretch); |
| 158 } | 134 } |
| 159 | 135 |
| 160 void FontBuilder::setScript(const String& locale) | 136 void FontBuilder::setScript(const String& locale) |
| 161 { | 137 { |
| 162 FontDescriptionChangeScope scope(this); | 138 set(IsSetFlag::Script); |
| 163 | 139 |
| 164 m_fontDescription.setLocale(locale); | 140 m_fontDescription.setLocale(locale); |
| 165 m_fontDescription.setScript(localeToScriptCodeForFontSelection(locale)); | 141 m_fontDescription.setScript(localeToScriptCodeForFontSelection(locale)); |
| 166 } | 142 } |
| 167 | 143 |
| 168 void FontBuilder::setStyle(FontStyle italic) | 144 void FontBuilder::setStyle(FontStyle italic) |
| 169 { | 145 { |
| 170 FontDescriptionChangeScope scope(this); | 146 set(IsSetFlag::Style); |
| 171 | 147 |
| 172 m_fontDescription.setStyle(italic); | 148 m_fontDescription.setStyle(italic); |
| 173 } | 149 } |
| 174 | 150 |
| 175 void FontBuilder::setVariant(FontVariant smallCaps) | 151 void FontBuilder::setVariant(FontVariant smallCaps) |
| 176 { | 152 { |
| 177 FontDescriptionChangeScope scope(this); | 153 set(IsSetFlag::Variant); |
| 178 | 154 |
| 179 m_fontDescription.setVariant(smallCaps); | 155 m_fontDescription.setVariant(smallCaps); |
| 180 } | 156 } |
| 181 | 157 |
| 182 void FontBuilder::setVariantLigatures(const FontDescription::VariantLigatures& l igatures) | 158 void FontBuilder::setVariantLigatures(const FontDescription::VariantLigatures& l igatures) |
| 183 { | 159 { |
| 184 FontDescriptionChangeScope scope(this); | 160 set(IsSetFlag::VariantLigatures); |
| 185 | 161 |
| 186 m_fontDescription.setVariantLigatures(ligatures); | 162 m_fontDescription.setVariantLigatures(ligatures); |
| 187 } | 163 } |
| 188 | 164 |
| 189 void FontBuilder::setTextRendering(TextRenderingMode textRenderingMode) | 165 void FontBuilder::setTextRendering(TextRenderingMode textRenderingMode) |
| 190 { | 166 { |
| 191 FontDescriptionChangeScope scope(this); | 167 set(IsSetFlag::TextRendering); |
| 192 | 168 |
| 193 m_fontDescription.setTextRendering(textRenderingMode); | 169 m_fontDescription.setTextRendering(textRenderingMode); |
| 194 } | 170 } |
| 195 | 171 |
| 196 void FontBuilder::setKerning(FontDescription::Kerning kerning) | 172 void FontBuilder::setKerning(FontDescription::Kerning kerning) |
| 197 { | 173 { |
| 198 FontDescriptionChangeScope scope(this); | 174 set(IsSetFlag::Kerning); |
| 199 | 175 |
| 200 m_fontDescription.setKerning(kerning); | 176 m_fontDescription.setKerning(kerning); |
| 201 } | 177 } |
| 202 | 178 |
| 203 void FontBuilder::setFontSmoothing(FontSmoothingMode foontSmoothingMode) | 179 void FontBuilder::setFontSmoothing(FontSmoothingMode foontSmoothingMode) |
| 204 { | 180 { |
| 205 FontDescriptionChangeScope scope(this); | 181 set(IsSetFlag::FontSmoothing); |
| 206 | 182 |
| 207 m_fontDescription.setFontSmoothing(foontSmoothingMode); | 183 m_fontDescription.setFontSmoothing(foontSmoothingMode); |
| 208 } | 184 } |
| 209 | 185 |
| 210 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) | 186 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) |
| 211 { | 187 { |
| 212 FontDescriptionChangeScope scope(this); | 188 set(IsSetFlag::FeatureSettings); |
| 213 | 189 |
| 214 m_fontDescription.setFeatureSettings(settings); | 190 m_fontDescription.setFeatureSettings(settings); |
| 215 } | 191 } |
| 216 | 192 |
| 217 void FontBuilder::setFamilyDescription(FontDescription& fontDescription, const F ontDescription::FamilyDescription& familyDescription) | 193 void FontBuilder::setFamilyDescription(FontDescription& fontDescription, const F ontDescription::FamilyDescription& familyDescription) |
| 218 { | 194 { |
| 219 FixedPitchFontType oldFixedPitchFontType = fontDescription.fixedPitchFontTyp e(); | 195 set(IsSetFlag::Family); |
| 220 | 196 |
| 221 bool isInitial = familyDescription.genericFamily == FontDescription::Standar dFamily && familyDescription.family.familyIsEmpty(); | 197 bool isInitial = familyDescription.genericFamily == FontDescription::Standar dFamily && familyDescription.family.familyIsEmpty(); |
| 222 | 198 |
| 223 fontDescription.setGenericFamily(familyDescription.genericFamily); | 199 fontDescription.setGenericFamily(familyDescription.genericFamily); |
| 224 fontDescription.setFamily(isInitial ? standardFontFamily() : familyDescripti on.family); | 200 fontDescription.setFamily(isInitial ? standardFontFamily() : familyDescripti on.family); |
| 225 | |
| 226 if (fontDescription.keywordSize() && fontDescription.fixedPitchFontType() != oldFixedPitchFontType) | |
| 227 setSize(fontDescription, FontDescription::Size(fontDescription.keywordSi ze(), 0.0f, false)); | |
| 228 } | 201 } |
| 229 | 202 |
| 230 void FontBuilder::setSize(FontDescription& fontDescription, const FontDescriptio n::Size& size) | 203 void FontBuilder::setSize(FontDescription& fontDescription, const FontDescriptio n::Size& size) |
| 231 { | 204 { |
| 232 float specifiedSize = size.value; | 205 float specifiedSize = size.value; |
| 233 | 206 |
| 234 if (!specifiedSize && size.keyword) | |
| 235 specifiedSize = FontSize::fontSizeForKeyword(&m_document, size.keyword, fontDescription.fixedPitchFontType()); | |
| 236 | |
| 237 if (specifiedSize < 0) | 207 if (specifiedSize < 0) |
| 238 return; | 208 return; |
| 239 | 209 |
| 210 set(IsSetFlag::Size); | |
| 211 | |
| 240 // Overly large font sizes will cause crashes on some platforms (such as Win dows). | 212 // Overly large font sizes will cause crashes on some platforms (such as Win dows). |
| 241 // Cap font size here to make sure that doesn't happen. | 213 // Cap font size here to make sure that doesn't happen. |
| 242 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize); | 214 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize); |
| 243 | 215 |
| 244 fontDescription.setKeywordSize(size.keyword); | 216 fontDescription.setKeywordSize(size.keyword); |
| 245 fontDescription.setSpecifiedSize(specifiedSize); | 217 fontDescription.setSpecifiedSize(specifiedSize); |
| 246 fontDescription.setIsAbsoluteSize(size.isAbsolute); | 218 fontDescription.setIsAbsoluteSize(size.isAbsolute); |
| 247 } | 219 } |
| 248 | 220 |
| 249 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize) | 221 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip tion, float effectiveZoom, float specifiedSize) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 glyphOrientation = NonCJKGlyphOrientationVerticalRight; | 260 glyphOrientation = NonCJKGlyphOrientationVerticalRight; |
| 289 return; | 261 return; |
| 290 default: | 262 default: |
| 291 ASSERT_NOT_REACHED(); | 263 ASSERT_NOT_REACHED(); |
| 292 fontOrientation = Horizontal; | 264 fontOrientation = Horizontal; |
| 293 glyphOrientation = NonCJKGlyphOrientationVerticalRight; | 265 glyphOrientation = NonCJKGlyphOrientationVerticalRight; |
| 294 return; | 266 return; |
| 295 } | 267 } |
| 296 } | 268 } |
| 297 | 269 |
| 298 void FontBuilder::checkForOrientationChange(RenderStyle* style) | 270 void FontBuilder::updateOrientation(FontDescription& description, RenderStyle* s tyle) |
| 299 { | 271 { |
| 300 FontOrientation fontOrientation; | 272 FontOrientation fontOrientation; |
| 301 NonCJKGlyphOrientation glyphOrientation; | 273 NonCJKGlyphOrientation glyphOrientation; |
| 302 getFontAndGlyphOrientation(style, fontOrientation, glyphOrientation); | 274 getFontAndGlyphOrientation(style, fontOrientation, glyphOrientation); |
| 303 | 275 |
| 304 FontDescriptionChangeScope scope(this); | 276 description.setNonCJKGlyphOrientation(glyphOrientation); |
| 277 description.setOrientation(fontOrientation); | |
| 278 } | |
| 305 | 279 |
| 306 if (m_fontDescription.orientation() == fontOrientation && m_fontDescription. nonCJKGlyphOrientation() == glyphOrientation) | 280 void FontBuilder::checkForGenericFamilyChange(const FontDescription& oldDescript ion, FontDescription& newDescription) |
| 281 { | |
| 282 if (newDescription.isAbsoluteSize()) | |
| 307 return; | 283 return; |
| 308 | 284 |
| 309 m_fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 285 if (newDescription.fixedPitchFontType() == oldDescription.fixedPitchFontType ()) |
| 310 m_fontDescription.setOrientation(fontOrientation); | |
| 311 } | |
| 312 | |
| 313 void FontBuilder::checkForGenericFamilyChange(RenderStyle* style, const RenderSt yle* parentStyle) | |
| 314 { | |
| 315 FontDescriptionChangeScope scope(this); | |
| 316 | |
| 317 if (m_fontDescription.isAbsoluteSize() || !parentStyle) | |
| 318 return; | |
| 319 | |
| 320 const FontDescription& parentFontDescription = parentStyle->fontDescription( ); | |
| 321 if (m_fontDescription.fixedPitchFontType() == parentFontDescription.fixedPit chFontType()) | |
| 322 return; | 286 return; |
| 323 | 287 |
| 324 // For now, lump all families but monospace together. | 288 // For now, lump all families but monospace together. |
| 325 if (m_fontDescription.genericFamily() != FontDescription::MonospaceFamily | 289 if (newDescription.genericFamily() != FontDescription::MonospaceFamily |
| 326 && parentFontDescription.genericFamily() != FontDescription::MonospaceFa mily) | 290 && oldDescription.genericFamily() != FontDescription::MonospaceFamily) |
| 327 return; | 291 return; |
| 328 | 292 |
| 329 // We know the parent is monospace or the child is monospace, and that font | 293 // We know the parent is monospace or the child is monospace, and that font |
| 330 // size was unspecified. We want to scale our font size as appropriate. | 294 // size was unspecified. We want to scale our font size as appropriate. |
| 331 // If the font uses a keyword size, then we refetch from the table rather th an | 295 // If the font uses a keyword size, then we refetch from the table rather th an |
| 332 // multiplying by our scale factor. | 296 // multiplying by our scale factor. |
| 333 float size; | 297 float size; |
| 334 if (m_fontDescription.keywordSize()) { | 298 if (newDescription.keywordSize()) { |
| 335 size = FontSize::fontSizeForKeyword(&m_document, m_fontDescription.keywo rdSize(), m_fontDescription.fixedPitchFontType()); | 299 size = FontSize::fontSizeForKeyword(&m_document, newDescription.keywordS ize(), newDescription.fixedPitchFontType()); |
| 336 } else { | 300 } else { |
| 337 Settings* settings = m_document.settings(); | 301 Settings* settings = m_document.settings(); |
| 338 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() & & settings->defaultFontSize()) | 302 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() & & settings->defaultFontSize()) |
| 339 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d efaultFontSize() | 303 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d efaultFontSize() |
| 340 : 1; | 304 : 1; |
| 341 size = parentFontDescription.fixedPitchFontType() == FixedPitchFont ? | 305 size = oldDescription.fixedPitchFontType() == FixedPitchFont ? |
| 342 m_fontDescription.specifiedSize() / fixedScaleFactor : | 306 newDescription.specifiedSize() / fixedScaleFactor : |
| 343 m_fontDescription.specifiedSize() * fixedScaleFactor; | 307 newDescription.specifiedSize() * fixedScaleFactor; |
| 344 } | 308 } |
| 345 | 309 |
| 346 m_fontDescription.setSpecifiedSize(size); | 310 newDescription.setSpecifiedSize(size); |
| 347 updateComputedSize(m_fontDescription, style); | |
| 348 } | 311 } |
| 349 | 312 |
| 350 void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* pare ntStyle) | 313 void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, RenderSt yle* style) |
| 351 { | 314 { |
| 352 FontDescriptionChangeScope scope(this); | 315 float specifiedSize = fontDescription.specifiedSize(); |
| 353 updateComputedSize(m_fontDescription, style); | 316 |
| 317 if (!specifiedSize && fontDescription.keywordSize()) | |
| 318 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio n.keywordSize(), fontDescription.fixedPitchFontType()); | |
| 319 | |
| 320 fontDescription.setSpecifiedSize(specifiedSize); | |
| 321 | |
| 322 checkForGenericFamilyChange(style->fontDescription(), fontDescription); | |
| 354 } | 323 } |
| 355 | 324 |
| 356 void FontBuilder::updateComputedSize(FontDescription& fontDescription, RenderSty le* style) | 325 void FontBuilder::updateComputedSize(FontDescription& fontDescription, RenderSty le* style) |
| 357 { | 326 { |
| 358 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style ->effectiveZoom(), fontDescription.specifiedSize()); | 327 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style ->effectiveZoom(), fontDescription.specifiedSize()); |
| 359 float multiplier = style->textAutosizingMultiplier(); | 328 float multiplier = style->textAutosizingMultiplier(); |
| 360 if (multiplier > 1) | 329 if (multiplier > 1) |
| 361 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul tiplier); | 330 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul tiplier); |
| 362 fontDescription.setComputedSize(computedSize); | 331 fontDescription.setComputedSize(computedSize); |
| 363 } | 332 } |
| 364 | 333 |
| 365 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, RenderStyle* style, const RenderStyle* parentStyle) | 334 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, RenderStyle* style) |
| 366 { | 335 { |
| 367 if (!m_fontDirty) | 336 if (!m_flags) |
| 368 return; | 337 return; |
| 369 | 338 |
| 370 updateComputedSize(style, parentStyle); | 339 FontDescription description = style->fontDescription(); |
| 371 checkForGenericFamilyChange(style, parentStyle); | 340 |
| 372 checkForOrientationChange(style); | 341 if (isSet(IsSetFlag::Family)) { |
|
andersr
2014/12/18 13:01:59
Note: I've verified with a microbenchmark that all
| |
| 373 style->setFontDescription(m_fontDescription); | 342 description.setGenericFamily(m_fontDescription.genericFamily()); |
| 343 description.setFamily(m_fontDescription.family()); | |
| 344 } | |
| 345 if (isSet(IsSetFlag::Size)) { | |
| 346 description.setKeywordSize(m_fontDescription.keywordSize()); | |
| 347 description.setSpecifiedSize(m_fontDescription.specifiedSize()); | |
| 348 description.setIsAbsoluteSize(m_fontDescription.isAbsoluteSize()); | |
| 349 } | |
| 350 if (isSet(IsSetFlag::Weight)) | |
| 351 description.setWeight(m_fontDescription.weight()); | |
| 352 if (isSet(IsSetFlag::Stretch)) | |
| 353 description.setStretch(m_fontDescription.stretch()); | |
| 354 if (isSet(IsSetFlag::FeatureSettings)) | |
| 355 description.setFeatureSettings(m_fontDescription.featureSettings()); | |
| 356 if (isSet(IsSetFlag::Script)) { | |
| 357 description.setLocale(m_fontDescription.locale()); | |
| 358 description.setScript(m_fontDescription.script()); | |
| 359 } | |
| 360 if (isSet(IsSetFlag::Style)) | |
| 361 description.setStyle(m_fontDescription.style()); | |
| 362 if (isSet(IsSetFlag::Variant)) | |
| 363 description.setVariant(m_fontDescription.variant()); | |
| 364 if (isSet(IsSetFlag::VariantLigatures)) | |
| 365 description.setVariantLigatures(m_fontDescription.variantLigatures()); | |
| 366 if (isSet(IsSetFlag::TextRendering)) | |
| 367 description.setTextRendering(m_fontDescription.textRendering()); | |
| 368 if (isSet(IsSetFlag::Kerning)) | |
| 369 description.setKerning(m_fontDescription.kerning()); | |
| 370 if (isSet(IsSetFlag::FontSmoothing)) | |
| 371 description.setFontSmoothing(m_fontDescription.fontSmoothing()); | |
| 372 if (isSet(IsSetFlag::TextOrientation) || isSet(IsSetFlag::WritingMode)) | |
| 373 updateOrientation(description, style); | |
| 374 | |
| 375 updateSpecifiedSize(description, style); | |
| 376 updateComputedSize(description, style); | |
| 377 | |
| 378 style->setFontDescription(description); | |
| 374 style->font().update(fontSelector); | 379 style->font().update(fontSelector); |
| 375 m_fontDirty = false; | 380 m_flags = 0; |
| 376 } | 381 } |
| 377 | 382 |
| 378 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon tSelector, RenderStyle* documentStyle) | 383 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon tSelector, RenderStyle* documentStyle) |
| 379 { | 384 { |
| 380 FontDescription fontDescription = FontDescription(); | 385 FontDescription fontDescription = FontDescription(); |
| 381 fontDescription.setLocale(documentStyle->locale()); | 386 fontDescription.setLocale(documentStyle->locale()); |
| 382 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle-> locale())); | 387 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle-> locale())); |
| 383 | 388 |
| 384 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription( )); | 389 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription( )); |
| 385 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false)); | 390 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize( ), 0.0f, false)); |
| 391 updateSpecifiedSize(fontDescription, documentStyle); | |
| 386 updateComputedSize(fontDescription, documentStyle); | 392 updateComputedSize(fontDescription, documentStyle); |
| 387 | 393 |
| 388 FontOrientation fontOrientation; | 394 FontOrientation fontOrientation; |
| 389 NonCJKGlyphOrientation glyphOrientation; | 395 NonCJKGlyphOrientation glyphOrientation; |
| 390 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ; | 396 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation) ; |
| 391 fontDescription.setOrientation(fontOrientation); | 397 fontDescription.setOrientation(fontOrientation); |
| 392 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 398 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); |
| 393 documentStyle->setFontDescription(fontDescription); | 399 documentStyle->setFontDescription(fontDescription); |
| 394 documentStyle->font().update(fontSelector); | 400 documentStyle->font().update(fontSelector); |
| 395 } | 401 } |
| 396 | 402 |
| 397 } | 403 } |
| OLD | NEW |