| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth
); ++i) | 209 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth
); ++i) |
| 210 fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWi
thInvalidCharWidth[i])); | 210 fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWi
thInvalidCharWidth[i])); |
| 211 } | 211 } |
| 212 | 212 |
| 213 return !fontFamiliesWithInvalidCharWidthMap->contains(family); | 213 return !fontFamiliesWithInvalidCharWidthMap->contains(family); |
| 214 } | 214 } |
| 215 | 215 |
| 216 float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const | 216 float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const |
| 217 { | 217 { |
| 218 const Font& font = style()->font(); | 218 const Font& font = style()->font(); |
| 219 |
| 219 const SimpleFontData* primaryFont = font.primaryFont(); | 220 const SimpleFontData* primaryFont = font.primaryFont(); |
| 220 if (hasValidAvgCharWidth(primaryFont, family)) | 221 if (primaryFont && hasValidAvgCharWidth(primaryFont, family)) |
| 221 return roundf(primaryFont->avgCharWidth()); | 222 return roundf(primaryFont->avgCharWidth()); |
| 222 | 223 |
| 223 const UChar ch = '0'; | 224 const UChar ch = '0'; |
| 224 const String str = String(&ch, 1); | 225 const String str = String(&ch, 1); |
| 225 TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrai
lingExpansion); | 226 TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrai
lingExpansion); |
| 226 return font.width(textRun); | 227 return font.width(textRun); |
| 227 } | 228 } |
| 228 | 229 |
| 229 float LayoutTextControl::scaleEmToUnits(int x) const | 230 float LayoutTextControl::scaleEmToUnits(int x) const |
| 230 { | 231 { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); | 286 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); |
| 286 LayoutObject* placeholderLayoutObject = placeholder ? placeholder->layoutObj
ect() : nullptr; | 287 LayoutObject* placeholderLayoutObject = placeholder ? placeholder->layoutObj
ect() : nullptr; |
| 287 if (!placeholderLayoutObject) | 288 if (!placeholderLayoutObject) |
| 288 return nullptr; | 289 return nullptr; |
| 289 if (relayoutChildren) | 290 if (relayoutChildren) |
| 290 layoutScope.setChildNeedsLayout(placeholderLayoutObject); | 291 layoutScope.setChildNeedsLayout(placeholderLayoutObject); |
| 291 return placeholderLayoutObject; | 292 return placeholderLayoutObject; |
| 292 } | 293 } |
| 293 | 294 |
| 294 } // namespace blink | 295 } // namespace blink |
| OLD | NEW |