| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth
); ++i) | 204 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth
); ++i) |
| 205 fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWi
thInvalidCharWidth[i])); | 205 fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWi
thInvalidCharWidth[i])); |
| 206 } | 206 } |
| 207 | 207 |
| 208 return !fontFamiliesWithInvalidCharWidthMap->contains(family); | 208 return !fontFamiliesWithInvalidCharWidthMap->contains(family); |
| 209 } | 209 } |
| 210 | 210 |
| 211 float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const | 211 float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const |
| 212 { | 212 { |
| 213 if (hasValidAvgCharWidth(family)) | 213 const Font& font = style()->font(); |
| 214 return roundf(style()->font().primaryFont()->avgCharWidth()); | 214 if (hasValidAvgCharWidth(family)) { |
| 215 ASSERT(font.primaryFont()); |
| 216 return roundf(font.primaryFont()->avgCharWidth()); |
| 217 } |
| 215 | 218 |
| 216 const UChar ch = '0'; | 219 const UChar ch = '0'; |
| 217 const String str = String(&ch, 1); | 220 const String str = String(&ch, 1); |
| 218 const Font& font = style()->font(); | |
| 219 TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrai
lingExpansion); | 221 TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrai
lingExpansion); |
| 220 return font.width(textRun); | 222 return font.width(textRun); |
| 221 } | 223 } |
| 222 | 224 |
| 223 float LayoutTextControl::scaleEmToUnits(int x) const | 225 float LayoutTextControl::scaleEmToUnits(int x) const |
| 224 { | 226 { |
| 225 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from t
he "head" font table. | 227 // This matches the unitsPerEm value for MS Shell Dlg and Courier New from t
he "head" font table. |
| 226 float unitsPerEm = 2048.0f; | 228 float unitsPerEm = 2048.0f; |
| 227 return roundf(style()->font().fontDescription().computedSize() * x / unitsPe
rEm); | 229 return roundf(style()->font().fontDescription().computedSize() * x / unitsPe
rEm); |
| 228 } | 230 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); | 281 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); |
| 280 LayoutObject* placeholderLayoutObject = placeholder ? placeholder->layoutObj
ect() : nullptr; | 282 LayoutObject* placeholderLayoutObject = placeholder ? placeholder->layoutObj
ect() : nullptr; |
| 281 if (!placeholderLayoutObject) | 283 if (!placeholderLayoutObject) |
| 282 return nullptr; | 284 return nullptr; |
| 283 if (relayoutChildren) | 285 if (relayoutChildren) |
| 284 layoutScope.setChildNeedsLayout(placeholderLayoutObject); | 286 layoutScope.setChildNeedsLayout(placeholderLayoutObject); |
| 285 return placeholderLayoutObject; | 287 return placeholderLayoutObject; |
| 286 } | 288 } |
| 287 | 289 |
| 288 } // namespace blink | 290 } // namespace blink |
| OLD | NEW |