| 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. |
| 4 * All rights reserved. |
| 4 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 * Copyright (C) 2015 Collabora Ltd. All rights reserved. | 6 * Copyright (C) 2015 Collabora Ltd. All rights reserved. |
| 6 * | 7 * |
| 7 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 11 * | 12 * |
| 12 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 202 |
| 202 void FontBuilder::setSize(FontDescription& fontDescription, | 203 void FontBuilder::setSize(FontDescription& fontDescription, |
| 203 const FontDescription::Size& size) { | 204 const FontDescription::Size& size) { |
| 204 float specifiedSize = size.value; | 205 float specifiedSize = size.value; |
| 205 | 206 |
| 206 if (specifiedSize < 0) | 207 if (specifiedSize < 0) |
| 207 return; | 208 return; |
| 208 | 209 |
| 209 set(PropertySetFlag::Size); | 210 set(PropertySetFlag::Size); |
| 210 | 211 |
| 211 // Overly large font sizes will cause crashes on some platforms (such as Windo
ws). | 212 // Overly large font sizes will cause crashes on some platforms (such as |
| 212 // Cap font size here to make sure that doesn't happen. | 213 // Windows). Cap font size here to make sure that doesn't happen. |
| 213 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize); | 214 specifiedSize = std::min(maximumAllowedFontSize, specifiedSize); |
| 214 | 215 |
| 215 fontDescription.setKeywordSize(size.keyword); | 216 fontDescription.setKeywordSize(size.keyword); |
| 216 fontDescription.setSpecifiedSize(specifiedSize); | 217 fontDescription.setSpecifiedSize(specifiedSize); |
| 217 fontDescription.setIsAbsoluteSize(size.isAbsolute); | 218 fontDescription.setIsAbsoluteSize(size.isAbsolute); |
| 218 } | 219 } |
| 219 | 220 |
| 220 float FontBuilder::getComputedSizeFromSpecifiedSize( | 221 float FontBuilder::getComputedSizeFromSpecifiedSize( |
| 221 FontDescription& fontDescription, | 222 FontDescription& fontDescription, |
| 222 float effectiveZoom, | 223 float effectiveZoom, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 305 } |
| 305 | 306 |
| 306 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, | 307 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, |
| 307 const ComputedStyle& style, | 308 const ComputedStyle& style, |
| 308 FontSelector* fontSelector) { | 309 FontSelector* fontSelector) { |
| 309 const float specifiedSize = fontDescription.specifiedSize(); | 310 const float specifiedSize = fontDescription.specifiedSize(); |
| 310 if (!fontDescription.hasSizeAdjust() || !specifiedSize) | 311 if (!fontDescription.hasSizeAdjust() || !specifiedSize) |
| 311 return; | 312 return; |
| 312 | 313 |
| 313 // We need to create a temporal Font to get xHeight of a primary font. | 314 // We need to create a temporal Font to get xHeight of a primary font. |
| 314 // The aspect value is based on the xHeight of the font for the computed font
size, | 315 // The aspect value is based on the xHeight of the font for the computed font |
| 315 // so we need to reset the adjustedSize to computedSize. See FontDescription::
effectiveFontSize. | 316 // size, so we need to reset the adjustedSize to computedSize. See |
| 317 // FontDescription::effectiveFontSize. |
| 316 fontDescription.setAdjustedSize(fontDescription.computedSize()); | 318 fontDescription.setAdjustedSize(fontDescription.computedSize()); |
| 317 | 319 |
| 318 Font font(fontDescription); | 320 Font font(fontDescription); |
| 319 font.update(fontSelector); | 321 font.update(fontSelector); |
| 320 if (!font.getFontMetrics().hasXHeight()) | 322 if (!font.getFontMetrics().hasXHeight()) |
| 321 return; | 323 return; |
| 322 | 324 |
| 323 const float sizeAdjust = fontDescription.sizeAdjust(); | 325 const float sizeAdjust = fontDescription.sizeAdjust(); |
| 324 float aspectValue = font.getFontMetrics().xHeight() / specifiedSize; | 326 float aspectValue = font.getFontMetrics().xHeight() / specifiedSize; |
| 325 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; | 327 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false)); | 407 FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false)); |
| 406 updateSpecifiedSize(fontDescription, documentStyle); | 408 updateSpecifiedSize(fontDescription, documentStyle); |
| 407 updateComputedSize(fontDescription, documentStyle); | 409 updateComputedSize(fontDescription, documentStyle); |
| 408 | 410 |
| 409 updateOrientation(fontDescription, documentStyle); | 411 updateOrientation(fontDescription, documentStyle); |
| 410 documentStyle.setFontDescription(fontDescription); | 412 documentStyle.setFontDescription(fontDescription); |
| 411 documentStyle.font().update(fontSelector); | 413 documentStyle.font().update(fontSelector); |
| 412 } | 414 } |
| 413 | 415 |
| 414 } // namespace blink | 416 } // namespace blink |
| OLD | NEW |