| 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 24 matching lines...) Expand all Loading... |
| 35 #include "wtf/text/StringHash.h" | 35 #include "wtf/text/StringHash.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 struct SameSizeAsFontDescription { | 39 struct SameSizeAsFontDescription { |
| 40 FontFamily familyList; | 40 FontFamily familyList; |
| 41 RefPtr<FontFeatureSettings> m_featureSettings; | 41 RefPtr<FontFeatureSettings> m_featureSettings; |
| 42 float sizes[4]; | 42 float sizes[4]; |
| 43 // FXIME: Make them fit into one word. | 43 // FXIME: Make them fit into one word. |
| 44 uint32_t bitfields; | 44 uint32_t bitfields; |
| 45 uint32_t bitfields2 : 8; | 45 uint32_t bitfields2 : 12; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), Fon
tDescription_should_stay_small); | 48 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), Fon
tDescription_should_stay_small); |
| 49 | 49 |
| 50 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; | 50 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; |
| 51 | 51 |
| 52 bool FontDescription::s_useSubpixelTextPositioning = false; | 52 bool FontDescription::s_useSubpixelTextPositioning = false; |
| 53 | 53 |
| 54 FontWeight FontDescription::lighterWeight(void) const | 54 FontWeight FontDescription::lighterWeight(void) const |
| 55 { | 55 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return FontWeight900; | 92 return FontWeight900; |
| 93 } | 93 } |
| 94 ASSERT_NOT_REACHED(); | 94 ASSERT_NOT_REACHED(); |
| 95 return FontWeightNormal; | 95 return FontWeightNormal; |
| 96 } | 96 } |
| 97 | 97 |
| 98 FontTraitsMask FontDescription::traitsMask() const | 98 FontTraitsMask FontDescription::traitsMask() const |
| 99 { | 99 { |
| 100 return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontSty
leNormalMask) | 100 return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontSty
leNormalMask) |
| 101 | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask) | 101 | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask) |
| 102 | (FontWeight100Mask << (m_weight - FontWeight100))); | 102 | (FontWeight100Mask << (m_weight - FontWeight100)) |
| 103 | 103 | (m_stretch << FontStretchBit1)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void FontDescription::setTraitsMask(FontTraitsMask traitsMask) | 106 void FontDescription::setTraitsMask(FontTraitsMask traitsMask) |
| 107 { | 107 { |
| 108 switch (traitsMask & FontWeightMask) { | 108 switch (traitsMask & FontWeightMask) { |
| 109 case FontWeight100Mask: | 109 case FontWeight100Mask: |
| 110 setWeight(FontWeight100); | 110 setWeight(FontWeight100); |
| 111 break; | 111 break; |
| 112 case FontWeight200Mask: | 112 case FontWeight200Mask: |
| 113 setWeight(FontWeight200); | 113 setWeight(FontWeight200); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 131 setWeight(FontWeight800); | 131 setWeight(FontWeight800); |
| 132 break; | 132 break; |
| 133 case FontWeight900Mask: | 133 case FontWeight900Mask: |
| 134 setWeight(FontWeight900); | 134 setWeight(FontWeight900); |
| 135 break; | 135 break; |
| 136 default: | 136 default: |
| 137 ASSERT_NOT_REACHED(); | 137 ASSERT_NOT_REACHED(); |
| 138 } | 138 } |
| 139 setItalic((traitsMask & FontStyleItalicMask) ? FontItalicOn : FontItalicOff)
; | 139 setItalic((traitsMask & FontStyleItalicMask) ? FontItalicOn : FontItalicOff)
; |
| 140 setSmallCaps((traitsMask & FontVariantSmallCapsMask) ? FontSmallCapsOn : Fon
tSmallCapsOff); | 140 setSmallCaps((traitsMask & FontVariantSmallCapsMask) ? FontSmallCapsOn : Fon
tSmallCapsOff); |
| 141 setStretch(static_cast<FontStretch>((traitsMask & FontStretchMask) >> FontSt
retchBit1)); |
| 141 } | 142 } |
| 142 | 143 |
| 143 FontDescription FontDescription::makeNormalFeatureSettings() const | 144 FontDescription FontDescription::makeNormalFeatureSettings() const |
| 144 { | 145 { |
| 145 FontDescription normalDescription(*this); | 146 FontDescription normalDescription(*this); |
| 146 normalDescription.setFeatureSettings(nullptr); | 147 normalDescription.setFeatureSettings(nullptr); |
| 147 return normalDescription; | 148 return normalDescription; |
| 148 } | 149 } |
| 149 | 150 |
| 150 float FontDescription::effectiveFontSize() const | 151 float FontDescription::effectiveFontSize() const |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 break; | 221 break; |
| 221 case FontDescription::EnabledLigaturesState: | 222 case FontDescription::EnabledLigaturesState: |
| 222 m_typesettingFeatures |= Ligatures; | 223 m_typesettingFeatures |= Ligatures; |
| 223 break; | 224 break; |
| 224 case FontDescription::NormalLigaturesState: | 225 case FontDescription::NormalLigaturesState: |
| 225 break; | 226 break; |
| 226 } | 227 } |
| 227 } | 228 } |
| 228 | 229 |
| 229 } // namespace WebCore | 230 } // namespace WebCore |
| OLD | NEW |