| 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 * Copyright (C) 2015 Collabora Ltd. All rights reserved. | 5 * Copyright (C) 2015 Collabora Ltd. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, const Co
mputedStyle& style) | 294 void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, const Co
mputedStyle& style) |
| 295 { | 295 { |
| 296 float specifiedSize = fontDescription.specifiedSize(); | 296 float specifiedSize = fontDescription.specifiedSize(); |
| 297 | 297 |
| 298 if (!specifiedSize && fontDescription.keywordSize()) | 298 if (!specifiedSize && fontDescription.keywordSize()) |
| 299 specifiedSize = fontSizeForKeyword(fontDescription.keywordSize(), fontDe
scription.isMonospace()); | 299 specifiedSize = fontSizeForKeyword(fontDescription.keywordSize(), fontDe
scription.isMonospace()); |
| 300 | 300 |
| 301 fontDescription.setSpecifiedSize(specifiedSize); | 301 fontDescription.setSpecifiedSize(specifiedSize); |
| 302 | 302 |
| 303 checkForGenericFamilyChange(style.fontDescription(), fontDescription); | 303 checkForGenericFamilyChange(style.getFontDescription(), fontDescription); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Com
putedStyle& style, FontSelector* fontSelector) | 306 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Com
putedStyle& style, FontSelector* fontSelector) |
| 307 { | 307 { |
| 308 const float specifiedSize = fontDescription.specifiedSize(); | 308 const float specifiedSize = fontDescription.specifiedSize(); |
| 309 if (!fontDescription.hasSizeAdjust() || !specifiedSize) | 309 if (!fontDescription.hasSizeAdjust() || !specifiedSize) |
| 310 return; | 310 return; |
| 311 | 311 |
| 312 // We need to create a temporal Font to get xHeight of a primary font. | 312 // We need to create a temporal Font to get xHeight of a primary font. |
| 313 // The aspect value is based on the xHeight of the font for the computed fon
t size, | 313 // The aspect value is based on the xHeight of the font for the computed fon
t size, |
| 314 // so we need to reset the adjustedSize to computedSize. See FontDescription
::effectiveFontSize. | 314 // so we need to reset the adjustedSize to computedSize. See FontDescription
::effectiveFontSize. |
| 315 fontDescription.setAdjustedSize(fontDescription.computedSize()); | 315 fontDescription.setAdjustedSize(fontDescription.computedSize()); |
| 316 | 316 |
| 317 Font font(fontDescription); | 317 Font font(fontDescription); |
| 318 font.update(fontSelector); | 318 font.update(fontSelector); |
| 319 if (!font.fontMetrics().hasXHeight()) | 319 if (!font.getFontMetrics().hasXHeight()) |
| 320 return; | 320 return; |
| 321 | 321 |
| 322 const float sizeAdjust = fontDescription.sizeAdjust(); | 322 const float sizeAdjust = fontDescription.sizeAdjust(); |
| 323 float aspectValue = font.fontMetrics().xHeight() / specifiedSize; | 323 float aspectValue = font.getFontMetrics().xHeight() / specifiedSize; |
| 324 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; | 324 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; |
| 325 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec
tiveZoom(), adjustedSize); | 325 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec
tiveZoom(), adjustedSize); |
| 326 | 326 |
| 327 float multiplier = style.textAutosizingMultiplier(); | 327 float multiplier = style.textAutosizingMultiplier(); |
| 328 if (multiplier > 1) | 328 if (multiplier > 1) |
| 329 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul
tiplier); | 329 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul
tiplier); |
| 330 fontDescription.setAdjustedSize(adjustedSize); | 330 fontDescription.setAdjustedSize(adjustedSize); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void FontBuilder::updateComputedSize(FontDescription& fontDescription, const Com
putedStyle& style) | 333 void FontBuilder::updateComputedSize(FontDescription& fontDescription, const Com
putedStyle& style) |
| 334 { | 334 { |
| 335 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style
.effectiveZoom(), fontDescription.specifiedSize()); | 335 float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style
.effectiveZoom(), fontDescription.specifiedSize()); |
| 336 float multiplier = style.textAutosizingMultiplier(); | 336 float multiplier = style.textAutosizingMultiplier(); |
| 337 if (multiplier > 1) | 337 if (multiplier > 1) |
| 338 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul
tiplier); | 338 computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, mul
tiplier); |
| 339 fontDescription.setComputedSize(computedSize); | 339 fontDescription.setComputedSize(computedSize); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector,
ComputedStyle& style) | 342 void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector,
ComputedStyle& style) |
| 343 { | 343 { |
| 344 if (!m_flags) | 344 if (!m_flags) |
| 345 return; | 345 return; |
| 346 | 346 |
| 347 FontDescription description = style.fontDescription(); | 347 FontDescription description = style.getFontDescription(); |
| 348 | 348 |
| 349 if (isSet(PropertySetFlag::Family)) { | 349 if (isSet(PropertySetFlag::Family)) { |
| 350 description.setGenericFamily(m_fontDescription.genericFamily()); | 350 description.setGenericFamily(m_fontDescription.genericFamily()); |
| 351 description.setFamily(m_fontDescription.family()); | 351 description.setFamily(m_fontDescription.family()); |
| 352 } | 352 } |
| 353 if (isSet(PropertySetFlag::Size)) { | 353 if (isSet(PropertySetFlag::Size)) { |
| 354 description.setKeywordSize(m_fontDescription.keywordSize()); | 354 description.setKeywordSize(m_fontDescription.keywordSize()); |
| 355 description.setSpecifiedSize(m_fontDescription.specifiedSize()); | 355 description.setSpecifiedSize(m_fontDescription.specifiedSize()); |
| 356 description.setIsAbsoluteSize(m_fontDescription.isAbsoluteSize()); | 356 description.setIsAbsoluteSize(m_fontDescription.isAbsoluteSize()); |
| 357 } | 357 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize(
), 0.0f, false)); | 398 setSize(fontDescription, FontDescription::Size(FontSize::initialKeywordSize(
), 0.0f, false)); |
| 399 updateSpecifiedSize(fontDescription, documentStyle); | 399 updateSpecifiedSize(fontDescription, documentStyle); |
| 400 updateComputedSize(fontDescription, documentStyle); | 400 updateComputedSize(fontDescription, documentStyle); |
| 401 | 401 |
| 402 updateOrientation(fontDescription, documentStyle); | 402 updateOrientation(fontDescription, documentStyle); |
| 403 documentStyle.setFontDescription(fontDescription); | 403 documentStyle.setFontDescription(fontDescription); |
| 404 documentStyle.font().update(fontSelector); | 404 documentStyle.font().update(fontSelector); |
| 405 } | 405 } |
| 406 | 406 |
| 407 } // namespace blink | 407 } // namespace blink |
| OLD | NEW |