Changeset 84609 in webkit
- Timestamp:
- Apr 22, 2011 12:40:32 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84607 r84609 1 2011-04-22 Luke Macpherson <macpherson@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Add FontItalics and FontSmallCaps enums to be used instead of boolean values. 6 https://bugs.webkit.org/show_bug.cgi?id=59080 7 8 No new tests as no new functionality added. 9 10 * css/CSSPrimitiveValueMappings.h: 11 Add casts to/from FontItalics and FontSmallCaps 12 * css/CSSStyleSelector.cpp: 13 Use new casts defined in PrimitiveValueMappings.h 14 * platform/graphics/Font.h: 15 Use FontItalics enum. 16 * platform/graphics/FontDescription.h: 17 Define and use FontItalics and FontSmallCaps enums. 18 1 19 2011-04-21 Andrey Kosyakov <caseq@chromium.org> 2 20 -
trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h
r84385 r84609 34 34 #include "CSSPrimitiveValue.h" 35 35 #include "CSSValueKeywords.h" 36 #include "FontDescription.h" 36 37 #include "FontSmoothingMode.h" 37 38 #include "GraphicsTypes.h" … … 2324 2325 } 2325 2326 2327 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontItalic italic) 2328 : m_type(CSS_IDENT) 2329 , m_hasCachedCSSText(false) 2330 { 2331 switch (italic) { 2332 case FontItalicOff: 2333 m_value.ident = CSSValueNormal; 2334 return; 2335 case FontItalicOn: 2336 m_value.ident = CSSValueItalic; 2337 return; 2338 } 2339 2340 ASSERT_NOT_REACHED(); 2341 m_value.ident = CSSValueNormal; 2342 } 2343 2344 template<> inline CSSPrimitiveValue::operator FontItalic() const 2345 { 2346 switch (m_value.ident) { 2347 case CSSValueOblique: 2348 // FIXME: oblique is the same as italic for the moment... 2349 case CSSValueItalic: 2350 return FontItalicOn; 2351 case CSSValueNormal: 2352 return FontItalicOff; 2353 } 2354 ASSERT_NOT_REACHED(); 2355 return FontItalicOff; 2356 } 2357 2358 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmallCaps smallCaps) 2359 : m_type(CSS_IDENT) 2360 , m_hasCachedCSSText(false) 2361 { 2362 switch (smallCaps) { 2363 case FontSmallCapsOff: 2364 m_value.ident = CSSValueNormal; 2365 return; 2366 case FontSmallCapsOn: 2367 m_value.ident = CSSValueSmallCaps; 2368 return; 2369 } 2370 2371 ASSERT_NOT_REACHED(); 2372 m_value.ident = CSSValueNormal; 2373 } 2374 2375 template<> inline CSSPrimitiveValue::operator FontSmallCaps() const 2376 { 2377 switch (m_value.ident) { 2378 case CSSValueSmallCaps: 2379 return FontSmallCapsOn; 2380 case CSSValueNormal: 2381 return FontSmallCapsOff; 2382 } 2383 ASSERT_NOT_REACHED(); 2384 return FontSmallCapsOff; 2385 } 2386 2326 2387 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e) 2327 2388 : m_type(CSS_IDENT) -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r84603 r84609 3677 3677 fontDescription.setItalic(m_parentStyle->fontDescription().italic()); 3678 3678 else if (isInitial) 3679 fontDescription.setItalic( false);3679 fontDescription.setItalic(FontItalicOff); 3680 3680 else { 3681 3681 if (!primitiveValue) 3682 3682 return; 3683 switch (primitiveValue->getIdent()) { 3684 case CSSValueOblique: 3685 // FIXME: oblique is the same as italic for the moment... 3686 case CSSValueItalic: 3687 fontDescription.setItalic(true); 3688 break; 3689 case CSSValueNormal: 3690 fontDescription.setItalic(false); 3691 break; 3692 default: 3693 return; 3694 } 3683 fontDescription.setItalic((FontItalic)*primitiveValue); 3695 3684 } 3696 3685 if (m_style->setFontDescription(fontDescription)) … … 3705 3694 fontDescription.setSmallCaps(m_parentStyle->fontDescription().smallCaps()); 3706 3695 else if (isInitial) 3707 fontDescription.setSmallCaps( false);3696 fontDescription.setSmallCaps(FontSmallCapsOff); 3708 3697 else { 3709 3698 if (!primitiveValue) 3710 3699 return; 3711 int id = primitiveValue->getIdent(); 3712 if (id == CSSValueNormal) 3713 fontDescription.setSmallCaps(false); 3714 else if (id == CSSValueSmallCaps) 3715 fontDescription.setSmallCaps(true); 3716 else 3717 return; 3700 fontDescription.setSmallCaps((FontSmallCaps)*primitiveValue); 3718 3701 } 3719 3702 if (m_style->setFontDescription(fontDescription)) -
trunk/Source/WebCore/platform/graphics/Font.h
r84264 r84609 124 124 const FontFamily& family() const { return m_fontDescription.family(); } 125 125 126 boolitalic() const { return m_fontDescription.italic(); }126 FontItalic italic() const { return m_fontDescription.italic(); } 127 127 FontWeight weight() const { return m_fontDescription.weight(); } 128 128 FontWidthVariant widthVariant() const { return m_fontDescription.widthVariant(); } -
trunk/Source/WebCore/platform/graphics/FontDescription.h
r80582 r84609 51 51 }; 52 52 53 enum FontItalic { 54 FontItalicOff = 0, 55 FontItalicOn = 1 56 }; 57 58 enum FontSmallCaps { 59 FontSmallCapsOff = 0, 60 FontSmallCapsOn = 1 61 }; 62 53 63 class FontDescription { 54 64 public: … … 62 72 , m_textOrientation(TextOrientationVerticalRight) 63 73 , m_widthVariant(RegularWidth) 64 , m_italic( false)65 , m_smallCaps( false)74 , m_italic(FontItalicOff) 75 , m_smallCaps(FontSmallCapsOff) 66 76 , m_isAbsoluteSize(false) 67 77 , m_weight(FontWeightNormal) … … 83 93 float specifiedSize() const { return m_specifiedSize; } 84 94 float computedSize() const { return m_computedSize; } 85 bool italic() const { return m_italic; }95 FontItalic italic() const { return static_cast<FontItalic>(m_italic); } 86 96 int computedPixelSize() const { return int(m_computedSize + 0.5f); } 87 bool smallCaps() const { return m_smallCaps; }97 FontSmallCaps smallCaps() const { return static_cast<FontSmallCaps>(m_smallCaps); } 88 98 bool isAbsoluteSize() const { return m_isAbsoluteSize; } 89 99 FontWeight weight() const { return static_cast<FontWeight>(m_weight); } … … 108 118 void setComputedSize(float s) { m_computedSize = s; } 109 119 void setSpecifiedSize(float s) { m_specifiedSize = s; } 110 void setItalic(bool i) { m_italic = i; } 111 void setSmallCaps(bool c) { m_smallCaps = c; } 120 void setItalic(FontItalic i) { m_italic = i; } 121 void setItalic(bool i) { setItalic(i ? FontItalicOn : FontItalicOff); } 122 void setSmallCaps(FontSmallCaps c) { m_smallCaps = c; } 123 void setSmallCaps(bool c) { setSmallCaps(c ? FontSmallCapsOn : FontSmallCapsOff); } 112 124 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; } 113 125 void setWeight(FontWeight w) { m_weight = w; } … … 139 151 FontWidthVariant m_widthVariant; 140 152 141 bool m_italic : 1;142 bool m_smallCaps : 1;153 unsigned m_italic : 1; // FontItalic 154 unsigned m_smallCaps : 1; // FontSmallCaps 143 155 bool m_isAbsoluteSize : 1; // Whether or not CSS specified an explicit size 144 156 // (logical sizes like "medium" don't count).
Note: See TracChangeset
for help on using the changeset viewer.