| 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/layout/LayoutTheme.h" | 29 #include "core/layout/LayoutTheme.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() |
| 82 { | 56 { |
| 83 FontDescriptionChangeScope scope(this); | 57 set(PropertySetFlag::EffectiveZoom); |
| 84 | |
| 85 m_fontDescription = fontDescription; | |
| 86 } | 58 } |
| 87 | 59 |
| 88 void FontBuilder::didChangeFontParameters(bool changed) | 60 void FontBuilder::didChangeTextOrientation() |
| 89 { | 61 { |
| 90 m_fontDirty |= changed; | 62 set(PropertySetFlag::TextOrientation); |
| 63 } |
| 64 |
| 65 void FontBuilder::didChangeWritingMode() |
| 66 { |
| 67 set(PropertySetFlag::WritingMode); |
| 91 } | 68 } |
| 92 | 69 |
| 93 FontFamily FontBuilder::standardFontFamily() const | 70 FontFamily FontBuilder::standardFontFamily() const |
| 94 { | 71 { |
| 95 FontFamily family; | 72 FontFamily family; |
| 96 family.setFamily(standardFontFamilyName()); | 73 family.setFamily(standardFontFamilyName()); |
| 97 return family; | 74 return family; |
| 98 } | 75 } |
| 99 | 76 |
| 100 AtomicString FontBuilder::standardFontFamilyName() const | 77 AtomicString FontBuilder::standardFontFamilyName() const |
| (...skipping 23 matching lines...) Expand all Loading... |
| 124 return FontFamilyNames::webkit_cursive; | 101 return FontFamilyNames::webkit_cursive; |
| 125 case FontDescription::FantasyFamily: | 102 case FontDescription::FantasyFamily: |
| 126 return FontFamilyNames::webkit_fantasy; | 103 return FontFamilyNames::webkit_fantasy; |
| 127 case FontDescription::PictographFamily: | 104 case FontDescription::PictographFamily: |
| 128 return FontFamilyNames::webkit_pictograph; | 105 return FontFamilyNames::webkit_pictograph; |
| 129 } | 106 } |
| 130 } | 107 } |
| 131 | 108 |
| 132 void FontBuilder::setFamilyDescription(const FontDescription::FamilyDescription&
familyDescription) | 109 void FontBuilder::setFamilyDescription(const FontDescription::FamilyDescription&
familyDescription) |
| 133 { | 110 { |
| 134 FontDescriptionChangeScope scope(this); | |
| 135 | |
| 136 setFamilyDescription(m_fontDescription, familyDescription); | 111 setFamilyDescription(m_fontDescription, familyDescription); |
| 137 } | 112 } |
| 138 | 113 |
| 139 void FontBuilder::setWeight(FontWeight fontWeight) | 114 void FontBuilder::setWeight(FontWeight fontWeight) |
| 140 { | 115 { |
| 141 FontDescriptionChangeScope scope(this); | 116 set(PropertySetFlag::Weight); |
| 142 | 117 |
| 143 m_fontDescription.setWeight(fontWeight); | 118 m_fontDescription.setWeight(fontWeight); |
| 144 } | 119 } |
| 145 | 120 |
| 146 void FontBuilder::setSize(const FontDescription::Size& size) | 121 void FontBuilder::setSize(const FontDescription::Size& size) |
| 147 { | 122 { |
| 148 FontDescriptionChangeScope scope(this); | |
| 149 | |
| 150 setSize(m_fontDescription, size); | 123 setSize(m_fontDescription, size); |
| 151 } | 124 } |
| 152 | 125 |
| 153 void FontBuilder::setStretch(FontStretch fontStretch) | 126 void FontBuilder::setStretch(FontStretch fontStretch) |
| 154 { | 127 { |
| 155 FontDescriptionChangeScope scope(this); | 128 set(PropertySetFlag::Stretch); |
| 156 | 129 |
| 157 m_fontDescription.setStretch(fontStretch); | 130 m_fontDescription.setStretch(fontStretch); |
| 158 } | 131 } |
| 159 | 132 |
| 160 void FontBuilder::setScript(const String& locale) | 133 void FontBuilder::setScript(const String& locale) |
| 161 { | 134 { |
| 162 FontDescriptionChangeScope scope(this); | 135 set(PropertySetFlag::Script); |
| 163 | 136 |
| 164 m_fontDescription.setLocale(locale); | 137 m_fontDescription.setLocale(locale); |
| 165 m_fontDescription.setScript(localeToScriptCodeForFontSelection(locale)); | 138 m_fontDescription.setScript(localeToScriptCodeForFontSelection(locale)); |
| 166 } | 139 } |
| 167 | 140 |
| 168 void FontBuilder::setStyle(FontStyle italic) | 141 void FontBuilder::setStyle(FontStyle italic) |
| 169 { | 142 { |
| 170 FontDescriptionChangeScope scope(this); | 143 set(PropertySetFlag::Style); |
| 171 | 144 |
| 172 m_fontDescription.setStyle(italic); | 145 m_fontDescription.setStyle(italic); |
| 173 } | 146 } |
| 174 | 147 |
| 175 void FontBuilder::setVariant(FontVariant smallCaps) | 148 void FontBuilder::setVariant(FontVariant smallCaps) |
| 176 { | 149 { |
| 177 FontDescriptionChangeScope scope(this); | 150 set(PropertySetFlag::Variant); |
| 178 | 151 |
| 179 m_fontDescription.setVariant(smallCaps); | 152 m_fontDescription.setVariant(smallCaps); |
| 180 } | 153 } |
| 181 | 154 |
| 182 void FontBuilder::setVariantLigatures(const FontDescription::VariantLigatures& l
igatures) | 155 void FontBuilder::setVariantLigatures(const FontDescription::VariantLigatures& l
igatures) |
| 183 { | 156 { |
| 184 FontDescriptionChangeScope scope(this); | 157 set(PropertySetFlag::VariantLigatures); |
| 185 | 158 |
| 186 m_fontDescription.setVariantLigatures(ligatures); | 159 m_fontDescription.setVariantLigatures(ligatures); |
| 187 } | 160 } |
| 188 | 161 |
| 189 void FontBuilder::setTextRendering(TextRenderingMode textRenderingMode) | 162 void FontBuilder::setTextRendering(TextRenderingMode textRenderingMode) |
| 190 { | 163 { |
| 191 FontDescriptionChangeScope scope(this); | 164 set(PropertySetFlag::TextRendering); |
| 192 | 165 |
| 193 m_fontDescription.setTextRendering(textRenderingMode); | 166 m_fontDescription.setTextRendering(textRenderingMode); |
| 194 } | 167 } |
| 195 | 168 |
| 196 void FontBuilder::setKerning(FontDescription::Kerning kerning) | 169 void FontBuilder::setKerning(FontDescription::Kerning kerning) |
| 197 { | 170 { |
| 198 FontDescriptionChangeScope scope(this); | 171 set(PropertySetFlag::Kerning); |
| 199 | 172 |
| 200 m_fontDescription.setKerning(kerning); | 173 m_fontDescription.setKerning(kerning); |
| 201 } | 174 } |
| 202 | 175 |
| 203 void FontBuilder::setFontSmoothing(FontSmoothingMode foontSmoothingMode) | 176 void FontBuilder::setFontSmoothing(FontSmoothingMode foontSmoothingMode) |
| 204 { | 177 { |
| 205 FontDescriptionChangeScope scope(this); | 178 set(PropertySetFlag::FontSmoothing); |
| 206 | 179 |
| 207 m_fontDescription.setFontSmoothing(foontSmoothingMode); | 180 m_fontDescription.setFontSmoothing(foontSmoothingMode); |
| 208 } | 181 } |
| 209 | 182 |
| 210 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) | 183 void FontBuilder::setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) |
| 211 { | 184 { |
| 212 FontDescriptionChangeScope scope(this); | 185 set(PropertySetFlag::FeatureSettings); |
| 213 | 186 |
| 214 m_fontDescription.setFeatureSettings(settings); | 187 m_fontDescription.setFeatureSettings(settings); |
| 215 } | 188 } |
| 216 | 189 |
| 217 void FontBuilder::setFamilyDescription(FontDescription& fontDescription, const F
ontDescription::FamilyDescription& familyDescription) | 190 void FontBuilder::setFamilyDescription(FontDescription& fontDescription, const F
ontDescription::FamilyDescription& familyDescription) |
| 218 { | 191 { |
| 219 FixedPitchFontType oldFixedPitchFontType = fontDescription.fixedPitchFontTyp
e(); | 192 set(PropertySetFlag::Family); |
| 220 | 193 |
| 221 bool isInitial = familyDescription.genericFamily == FontDescription::Standar
dFamily && familyDescription.family.familyIsEmpty(); | 194 bool isInitial = familyDescription.genericFamily == FontDescription::Standar
dFamily && familyDescription.family.familyIsEmpty(); |
| 222 | 195 |
| 223 fontDescription.setGenericFamily(familyDescription.genericFamily); | 196 fontDescription.setGenericFamily(familyDescription.genericFamily); |
| 224 fontDescription.setFamily(isInitial ? standardFontFamily() : familyDescripti
on.family); | 197 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 } | 198 } |
| 229 | 199 |
| 230 void FontBuilder::setSize(FontDescription& fontDescription, const FontDescriptio
n::Size& size) | 200 void FontBuilder::setSize(FontDescription& fontDescription, const FontDescriptio
n::Size& size) |
| 231 { | 201 { |
| 232 float specifiedSize = size.value; | 202 float specifiedSize = size.value; |
| 233 | 203 |
| 234 if (!specifiedSize && size.keyword) | |
| 235 specifiedSize = FontSize::fontSizeForKeyword(&m_document, size.keyword,
fontDescription.fixedPitchFontType()); | |
| 236 | |
| 237 if (specifiedSize < 0) | 204 if (specifiedSize < 0) |
| 238 return; | 205 return; |
| 239 | 206 |
| 207 set(PropertySetFlag::Size); |
| 208 |
| 240 // Overly large font sizes will cause crashes on some platforms (such as Win
dows). | 209 // 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. | 210 // Cap font size here to make sure that doesn't happen. |
| 242 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize); | 211 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize); |
| 243 | 212 |
| 244 fontDescription.setKeywordSize(size.keyword); | 213 fontDescription.setKeywordSize(size.keyword); |
| 245 fontDescription.setSpecifiedSize(specifiedSize); | 214 fontDescription.setSpecifiedSize(specifiedSize); |
| 246 fontDescription.setIsAbsoluteSize(size.isAbsolute); | 215 fontDescription.setIsAbsoluteSize(size.isAbsolute); |
| 247 } | 216 } |
| 248 | 217 |
| 249 float FontBuilder::getComputedSizeFromSpecifiedSize(FontDescription& fontDescrip
tion, float effectiveZoom, float specifiedSize) | 218 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; | 257 glyphOrientation = NonCJKGlyphOrientationVerticalRight; |
| 289 return; | 258 return; |
| 290 default: | 259 default: |
| 291 ASSERT_NOT_REACHED(); | 260 ASSERT_NOT_REACHED(); |
| 292 fontOrientation = Horizontal; | 261 fontOrientation = Horizontal; |
| 293 glyphOrientation = NonCJKGlyphOrientationVerticalRight; | 262 glyphOrientation = NonCJKGlyphOrientationVerticalRight; |
| 294 return; | 263 return; |
| 295 } | 264 } |
| 296 } | 265 } |
| 297 | 266 |
| 298 void FontBuilder::checkForOrientationChange(RenderStyle* style) | 267 void FontBuilder::updateOrientation(FontDescription& description, RenderStyle* s
tyle) |
| 299 { | 268 { |
| 300 FontOrientation fontOrientation; | 269 FontOrientation fontOrientation; |
| 301 NonCJKGlyphOrientation glyphOrientation; | 270 NonCJKGlyphOrientation glyphOrientation; |
| 302 getFontAndGlyphOrientation(style, fontOrientation, glyphOrientation); | 271 getFontAndGlyphOrientation(style, fontOrientation, glyphOrientation); |
| 303 | 272 |
| 304 FontDescriptionChangeScope scope(this); | 273 description.setNonCJKGlyphOrientation(glyphOrientation); |
| 274 description.setOrientation(fontOrientation); |
| 275 } |
| 305 | 276 |
| 306 if (m_fontDescription.orientation() == fontOrientation && m_fontDescription.
nonCJKGlyphOrientation() == glyphOrientation) | 277 void FontBuilder::checkForGenericFamilyChange(const FontDescription& oldDescript
ion, FontDescription& newDescription) |
| 278 { |
| 279 if (newDescription.isAbsoluteSize()) |
| 307 return; | 280 return; |
| 308 | 281 |
| 309 m_fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 282 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; | 283 return; |
| 323 | 284 |
| 324 // For now, lump all families but monospace together. | 285 // For now, lump all families but monospace together. |
| 325 if (m_fontDescription.genericFamily() != FontDescription::MonospaceFamily | 286 if (newDescription.genericFamily() != FontDescription::MonospaceFamily |
| 326 && parentFontDescription.genericFamily() != FontDescription::MonospaceFa
mily) | 287 && oldDescription.genericFamily() != FontDescription::MonospaceFamily) |
| 327 return; | 288 return; |
| 328 | 289 |
| 329 // We know the parent is monospace or the child is monospace, and that font | 290 // 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. | 291 // 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 | 292 // If the font uses a keyword size, then we refetch from the table rather th
an |
| 332 // multiplying by our scale factor. | 293 // multiplying by our scale factor. |
| 333 float size; | 294 float size; |
| 334 if (m_fontDescription.keywordSize()) { | 295 if (newDescription.keywordSize()) { |
| 335 size = FontSize::fontSizeForKeyword(&m_document, m_fontDescription.keywo
rdSize(), m_fontDescription.fixedPitchFontType()); | 296 size = FontSize::fontSizeForKeyword(&m_document, newDescription.keywordS
ize(), newDescription.fixedPitchFontType()); |
| 336 } else { | 297 } else { |
| 337 Settings* settings = m_document.settings(); | 298 Settings* settings = m_document.settings(); |
| 338 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() &
& settings->defaultFontSize()) | 299 float fixedScaleFactor = (settings && settings->defaultFixedFontSize() &
& settings->defaultFontSize()) |
| 339 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d
efaultFontSize() | 300 ? static_cast<float>(settings->defaultFixedFontSize()) / settings->d
efaultFontSize() |
| 340 : 1; | 301 : 1; |
| 341 size = parentFontDescription.fixedPitchFontType() == FixedPitchFont ? | 302 size = oldDescription.fixedPitchFontType() == FixedPitchFont ? |
| 342 m_fontDescription.specifiedSize() / fixedScaleFactor : | 303 newDescription.specifiedSize() / fixedScaleFactor : |
| 343 m_fontDescription.specifiedSize() * fixedScaleFactor; | 304 newDescription.specifiedSize() * fixedScaleFactor; |
| 344 } | 305 } |
| 345 | 306 |
| 346 m_fontDescription.setSpecifiedSize(size); | 307 newDescription.setSpecifiedSize(size); |
| 347 updateComputedSize(m_fontDescription, style); | |
| 348 } | 308 } |
| 349 | 309 |
| 350 void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* pare
ntStyle) | 310 void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, RenderSt
yle* style) |
| 351 { | 311 { |
| 352 FontDescriptionChangeScope scope(this); | 312 float specifiedSize = fontDescription.specifiedSize(); |
| 353 updateComputedSize(m_fontDescription, style); | 313 |
| 314 if (!specifiedSize && fontDescription.keywordSize()) |
| 315 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio
n.keywordSize(), fontDescription.fixedPitchFontType()); |
| 316 |
| 317 fontDescription.setSpecifiedSize(specifiedSize); |
| 318 |
| 319 checkForGenericFamilyChange(style->fontDescription(), fontDescription); |
| 354 } | 320 } |
| 355 | 321 |
| 356 void FontBuilder::updateComputedSize(FontDescription& fontDescription, RenderSty
le* style) | 322 void FontBuilder::updateComputedSize(FontDescription& fontDescription, RenderSty
le* style) |
| 357 { | 323 { |
| 358 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style
->effectiveZoom(), fontDescription.specifiedSize()); | 324 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style
->effectiveZoom(), fontDescription.specifiedSize()); |
| 359 float multiplier = style->textAutosizingMultiplier(); | 325 float multiplier = style->textAutosizingMultiplier(); |
| 360 if (multiplier > 1) | 326 if (multiplier > 1) |
| 361 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul
tiplier); | 327 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul
tiplier); |
| 362 fontDescription.setComputedSize(computedSize); | 328 fontDescription.setComputedSize(computedSize); |
| 363 } | 329 } |
| 364 | 330 |
| 365 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector,
RenderStyle* style, const RenderStyle* parentStyle) | 331 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector,
RenderStyle* style) |
| 366 { | 332 { |
| 367 if (!m_fontDirty) | 333 if (!m_flags) |
| 368 return; | 334 return; |
| 369 | 335 |
| 370 updateComputedSize(style, parentStyle); | 336 FontDescription description = style->fontDescription(); |
| 371 checkForGenericFamilyChange(style, parentStyle); | 337 |
| 372 checkForOrientationChange(style); | 338 if (isSet(PropertySetFlag::Family)) { |
| 373 style->setFontDescription(m_fontDescription); | 339 description.setGenericFamily(m_fontDescription.genericFamily()); |
| 340 description.setFamily(m_fontDescription.family()); |
| 341 } |
| 342 if (isSet(PropertySetFlag::Size)) { |
| 343 description.setKeywordSize(m_fontDescription.keywordSize()); |
| 344 description.setSpecifiedSize(m_fontDescription.specifiedSize()); |
| 345 description.setIsAbsoluteSize(m_fontDescription.isAbsoluteSize()); |
| 346 } |
| 347 if (isSet(PropertySetFlag::Weight)) |
| 348 description.setWeight(m_fontDescription.weight()); |
| 349 if (isSet(PropertySetFlag::Stretch)) |
| 350 description.setStretch(m_fontDescription.stretch()); |
| 351 if (isSet(PropertySetFlag::FeatureSettings)) |
| 352 description.setFeatureSettings(m_fontDescription.featureSettings()); |
| 353 if (isSet(PropertySetFlag::Script)) { |
| 354 description.setLocale(m_fontDescription.locale()); |
| 355 description.setScript(m_fontDescription.script()); |
| 356 } |
| 357 if (isSet(PropertySetFlag::Style)) |
| 358 description.setStyle(m_fontDescription.style()); |
| 359 if (isSet(PropertySetFlag::Variant)) |
| 360 description.setVariant(m_fontDescription.variant()); |
| 361 if (isSet(PropertySetFlag::VariantLigatures)) |
| 362 description.setVariantLigatures(m_fontDescription.variantLigatures()); |
| 363 if (isSet(PropertySetFlag::TextRendering)) |
| 364 description.setTextRendering(m_fontDescription.textRendering()); |
| 365 if (isSet(PropertySetFlag::Kerning)) |
| 366 description.setKerning(m_fontDescription.kerning()); |
| 367 if (isSet(PropertySetFlag::FontSmoothing)) |
| 368 description.setFontSmoothing(m_fontDescription.fontSmoothing()); |
| 369 if (isSet(PropertySetFlag::TextOrientation) || isSet(PropertySetFlag::Writin
gMode)) |
| 370 updateOrientation(description, style); |
| 371 |
| 372 updateSpecifiedSize(description, style); |
| 373 updateComputedSize(description, style); |
| 374 |
| 375 style->setFontDescription(description); |
| 374 style->font().update(fontSelector); | 376 style->font().update(fontSelector); |
| 375 m_fontDirty = false; | 377 m_flags = 0; |
| 376 } | 378 } |
| 377 | 379 |
| 378 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon
tSelector, RenderStyle* documentStyle) | 380 void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fon
tSelector, RenderStyle* documentStyle) |
| 379 { | 381 { |
| 380 FontDescription fontDescription = FontDescription(); | 382 FontDescription fontDescription = FontDescription(); |
| 381 fontDescription.setLocale(documentStyle->locale()); | 383 fontDescription.setLocale(documentStyle->locale()); |
| 382 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->
locale())); | 384 fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->
locale())); |
| 383 | 385 |
| 384 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription(
)); | 386 setFamilyDescription(fontDescription, FontBuilder::initialFamilyDescription(
)); |
| 385 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize(
), 0.0f, false)); | 387 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize(
), 0.0f, false)); |
| 388 updateSpecifiedSize(fontDescription, documentStyle); |
| 386 updateComputedSize(fontDescription, documentStyle); | 389 updateComputedSize(fontDescription, documentStyle); |
| 387 | 390 |
| 388 FontOrientation fontOrientation; | 391 FontOrientation fontOrientation; |
| 389 NonCJKGlyphOrientation glyphOrientation; | 392 NonCJKGlyphOrientation glyphOrientation; |
| 390 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; | 393 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; |
| 391 fontDescription.setOrientation(fontOrientation); | 394 fontDescription.setOrientation(fontOrientation); |
| 392 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 395 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); |
| 393 documentStyle->setFontDescription(fontDescription); | 396 documentStyle->setFontDescription(fontDescription); |
| 394 documentStyle->font().update(fontSelector); | 397 documentStyle->font().update(fontSelector); |
| 395 } | 398 } |
| 396 | 399 |
| 397 } | 400 } |
| OLD | NEW |