| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 "#HeadLineA", | 196 "#HeadLineA", |
| 197 "#PCMyungjo", | 197 "#PCMyungjo", |
| 198 "#PilGi", | 198 "#PilGi", |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 // For font families where any of the fonts don't have a valid entry in the OS/2
table | 201 // For font families where any of the fonts don't have a valid entry in the OS/2
table |
| 202 // for avgCharWidth, fallback to the legacy webkit behavior of getting the avgCh
arWidth | 202 // for avgCharWidth, fallback to the legacy webkit behavior of getting the avgCh
arWidth |
| 203 // from the width of a '0'. This only seems to apply to a fixed number of Mac fo
nts, | 203 // from the width of a '0'. This only seems to apply to a fixed number of Mac fo
nts, |
| 204 // but, in order to get similar rendering across platforms, we do this check for | 204 // but, in order to get similar rendering across platforms, we do this check for |
| 205 // all platforms. | 205 // all platforms. |
| 206 bool LayoutTextControl::hasValidAvgCharWidth(AtomicString family) | 206 bool LayoutTextControl::hasValidAvgCharWidth(const AtomicString& family) |
| 207 { | 207 { |
| 208 static HashSet<AtomicString>* fontFamiliesWithInvalidCharWidthMap = nullptr; | 208 static HashSet<AtomicString>* fontFamiliesWithInvalidCharWidthMap = nullptr; |
| 209 | 209 |
| 210 if (family.isEmpty()) | 210 if (family.isEmpty()) |
| 211 return false; | 211 return false; |
| 212 | 212 |
| 213 if (!fontFamiliesWithInvalidCharWidthMap) { | 213 if (!fontFamiliesWithInvalidCharWidthMap) { |
| 214 fontFamiliesWithInvalidCharWidthMap = new HashSet<AtomicString>; | 214 fontFamiliesWithInvalidCharWidthMap = new HashSet<AtomicString>; |
| 215 | 215 |
| 216 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth
); ++i) | 216 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontFamiliesWithInvalidCharWidth
); ++i) |
| 217 fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWi
thInvalidCharWidth[i])); | 217 fontFamiliesWithInvalidCharWidthMap->add(AtomicString(fontFamiliesWi
thInvalidCharWidth[i])); |
| 218 } | 218 } |
| 219 | 219 |
| 220 return !fontFamiliesWithInvalidCharWidthMap->contains(family); | 220 return !fontFamiliesWithInvalidCharWidthMap->contains(family); |
| 221 } | 221 } |
| 222 | 222 |
| 223 float LayoutTextControl::getAvgCharWidth(AtomicString family) | 223 float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const |
| 224 { | 224 { |
| 225 if (hasValidAvgCharWidth(family)) | 225 if (hasValidAvgCharWidth(family)) |
| 226 return roundf(style()->font().primaryFont()->avgCharWidth()); | 226 return roundf(style()->font().primaryFont()->avgCharWidth()); |
| 227 | 227 |
| 228 const UChar ch = '0'; | 228 const UChar ch = '0'; |
| 229 const String str = String(&ch, 1); | 229 const String str = String(&ch, 1); |
| 230 const Font& font = style()->font(); | 230 const Font& font = style()->font(); |
| 231 TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrai
lingExpansion); | 231 TextRun textRun = constructTextRun(font, str, styleRef(), TextRun::AllowTrai
lingExpansion); |
| 232 return font.width(textRun); | 232 return font.width(textRun); |
| 233 } | 233 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); | 292 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholder
Element(); |
| 293 LayoutObject* placeholderLayoutObject = placeholder ? placeholder->layoutObj
ect() : nullptr; | 293 LayoutObject* placeholderLayoutObject = placeholder ? placeholder->layoutObj
ect() : nullptr; |
| 294 if (!placeholderLayoutObject) | 294 if (!placeholderLayoutObject) |
| 295 return nullptr; | 295 return nullptr; |
| 296 if (relayoutChildren) | 296 if (relayoutChildren) |
| 297 layoutScope.setChildNeedsLayout(placeholderLayoutObject); | 297 layoutScope.setChildNeedsLayout(placeholderLayoutObject); |
| 298 return placeholderLayoutObject; | 298 return placeholderLayoutObject; |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace blink | 301 } // namespace blink |
| OLD | NEW |