| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> | 2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> |
| 3 * Copyright (C) 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "wtf/StringHasher.h" | 34 #include "wtf/StringHasher.h" |
| 35 #include "wtf/text/AtomicStringHash.h" | 35 #include "wtf/text/AtomicStringHash.h" |
| 36 #include "wtf/text/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 struct SameSizeAsFontDescription { | 40 struct SameSizeAsFontDescription { |
| 41 DISALLOW_NEW(); | 41 DISALLOW_NEW(); |
| 42 FontFamily familyList; | 42 FontFamily familyList; |
| 43 RefPtr<FontFeatureSettings> m_featureSettings; | 43 RefPtr<FontFeatureSettings> m_featureSettings; |
| 44 RefPtr<FontVariationSettings> m_variationSettings; |
| 44 AtomicString locale; | 45 AtomicString locale; |
| 45 float sizes[6]; | 46 float sizes[6]; |
| 46 FieldsAsUnsignedType bitfields; | 47 FieldsAsUnsignedType bitfields; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 static_assert(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), | 50 static_assert(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), |
| 50 "FontDescription should stay small"); | 51 "FontDescription should stay small"); |
| 51 | 52 |
| 52 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; | 53 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; |
| 53 | 54 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 m_specifiedSize == other.m_specifiedSize && | 96 m_specifiedSize == other.m_specifiedSize && |
| 96 m_computedSize == other.m_computedSize && | 97 m_computedSize == other.m_computedSize && |
| 97 m_adjustedSize == other.m_adjustedSize && | 98 m_adjustedSize == other.m_adjustedSize && |
| 98 m_sizeAdjust == other.m_sizeAdjust && | 99 m_sizeAdjust == other.m_sizeAdjust && |
| 99 m_letterSpacing == other.m_letterSpacing && | 100 m_letterSpacing == other.m_letterSpacing && |
| 100 m_wordSpacing == other.m_wordSpacing && | 101 m_wordSpacing == other.m_wordSpacing && |
| 101 m_fieldsAsUnsigned.parts[0] == other.m_fieldsAsUnsigned.parts[0] && | 102 m_fieldsAsUnsigned.parts[0] == other.m_fieldsAsUnsigned.parts[0] && |
| 102 m_fieldsAsUnsigned.parts[1] == other.m_fieldsAsUnsigned.parts[1] && | 103 m_fieldsAsUnsigned.parts[1] == other.m_fieldsAsUnsigned.parts[1] && |
| 103 (m_featureSettings == other.m_featureSettings || | 104 (m_featureSettings == other.m_featureSettings || |
| 104 (m_featureSettings && other.m_featureSettings && | 105 (m_featureSettings && other.m_featureSettings && |
| 105 *m_featureSettings == *other.m_featureSettings)); | 106 *m_featureSettings == *other.m_featureSettings)) && |
| 107 (m_variationSettings == other.m_variationSettings || |
| 108 (m_variationSettings && other.m_variationSettings && |
| 109 *m_variationSettings == *other.m_variationSettings)); |
| 106 } | 110 } |
| 107 | 111 |
| 108 FontWeight FontDescription::lighterWeight(FontWeight weight) { | 112 FontWeight FontDescription::lighterWeight(FontWeight weight) { |
| 109 switch (weight) { | 113 switch (weight) { |
| 110 case FontWeight100: | 114 case FontWeight100: |
| 111 case FontWeight200: | 115 case FontWeight200: |
| 112 case FontWeight300: | 116 case FontWeight300: |
| 113 case FontWeight400: | 117 case FontWeight400: |
| 114 case FontWeight500: | 118 case FontWeight500: |
| 115 return FontWeight100; | 119 return FontWeight100; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 const FontFeatureSettings* settings = featureSettings(); | 304 const FontFeatureSettings* settings = featureSettings(); |
| 301 if (settings) { | 305 if (settings) { |
| 302 unsigned numFeatures = settings->size(); | 306 unsigned numFeatures = settings->size(); |
| 303 for (unsigned i = 0; i < numFeatures; ++i) { | 307 for (unsigned i = 0; i < numFeatures; ++i) { |
| 304 const AtomicString& tag = settings->at(i).tag(); | 308 const AtomicString& tag = settings->at(i).tag(); |
| 305 for (unsigned j = 0; j < tag.length(); j++) | 309 for (unsigned j = 0; j < tag.length(); j++) |
| 306 stringHasher.addCharacter(tag[j]); | 310 stringHasher.addCharacter(tag[j]); |
| 307 addToHash(hash, settings->at(i).value()); | 311 addToHash(hash, settings->at(i).value()); |
| 308 } | 312 } |
| 309 } | 313 } |
| 314 const FontVariationSettings* varSettings = variationSettings(); |
| 315 if (varSettings) { |
| 316 unsigned numFeatures = varSettings->size(); |
| 317 for (unsigned i = 0; i < numFeatures; ++i) { |
| 318 const AtomicString& tag = varSettings->at(i).tag(); |
| 319 for (unsigned j = 0; j < tag.length(); j++) |
| 320 stringHasher.addCharacter(tag[j]); |
| 321 addToHash(hash, varSettings->at(i).value()); |
| 322 } |
| 323 } |
| 324 |
| 310 if (m_locale) { | 325 if (m_locale) { |
| 311 const AtomicString& locale = m_locale->localeString(); | 326 const AtomicString& locale = m_locale->localeString(); |
| 312 for (unsigned i = 0; i < locale.length(); i++) | 327 for (unsigned i = 0; i < locale.length(); i++) |
| 313 stringHasher.addCharacter(locale[i]); | 328 stringHasher.addCharacter(locale[i]); |
| 314 } | 329 } |
| 315 addToHash(hash, stringHasher.hash()); | 330 addToHash(hash, stringHasher.hash()); |
| 316 | 331 |
| 317 addFloatToHash(hash, m_specifiedSize); | 332 addFloatToHash(hash, m_specifiedSize); |
| 318 addFloatToHash(hash, m_computedSize); | 333 addFloatToHash(hash, m_computedSize); |
| 319 addFloatToHash(hash, m_adjustedSize); | 334 addFloatToHash(hash, m_adjustedSize); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 350 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); | 365 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); |
| 351 static_assert(static_cast<int>(FontStretchNormal) == | 366 static_assert(static_cast<int>(FontStretchNormal) == |
| 352 static_cast<int>(SkFontStyle::kNormal_Width), | 367 static_cast<int>(SkFontStyle::kNormal_Width), |
| 353 "FontStretchNormal should map to kNormal_Width"); | 368 "FontStretchNormal should map to kNormal_Width"); |
| 354 static_assert(static_cast<int>(FontStretchUltraExpanded) == | 369 static_assert(static_cast<int>(FontStretchUltraExpanded) == |
| 355 static_cast<int>(SkFontStyle::kUltraExpanded_Width), | 370 static_cast<int>(SkFontStyle::kUltraExpanded_Width), |
| 356 "FontStretchUltraExpanded should map to kUltraExpanded_Width"); | 371 "FontStretchUltraExpanded should map to kUltraExpanded_Width"); |
| 357 } | 372 } |
| 358 | 373 |
| 359 } // namespace blink | 374 } // namespace blink |
| OLD | NEW |