Changeset 86120 in webkit
- Timestamp:
- May 9, 2011 6:52:55 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86115 r86120 1 2011-05-09 Luke Macpherson <macpherson@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Enable casting between CSSPrimitiveValue and FontWeight enum 6 https://bugs.webkit.org/show_bug.cgi?id=60516 7 8 No new tests added as no functionality changed. 9 10 * css/CSSPrimitiveValueMappings.h: 11 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): 12 Implement cast from FontWeight to CSSPrimitiveValue. 13 (WebCore::CSSPrimitiveValue::operator FontWeight): 14 Implement cast from CSSPrimitiveValue to FontWeight 15 * css/CSSStyleSelector.cpp: 16 (WebCore::CSSStyleSelector::applyProperty): 17 Use new cast to reduce code size. 18 Flatten switch inside if. 19 1 20 2011-05-09 Simon Fraser <simon.fraser@apple.com> 2 21 -
trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h
r85327 r86120 2325 2325 } 2326 2326 2327 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontWeight weight) 2328 : m_type(CSS_IDENT) 2329 , m_hasCachedCSSText(false) 2330 { 2331 switch (weight) { 2332 case FontWeight900: 2333 m_value.ident = CSSValue900; 2334 return; 2335 case FontWeight800: 2336 m_value.ident = CSSValue800; 2337 return; 2338 case FontWeight700: 2339 m_value.ident = CSSValue700; 2340 return; 2341 case FontWeight600: 2342 m_value.ident = CSSValue600; 2343 return; 2344 case FontWeight500: 2345 m_value.ident = CSSValue500; 2346 return; 2347 case FontWeight400: 2348 m_value.ident = CSSValue400; 2349 return; 2350 case FontWeight300: 2351 m_value.ident = CSSValue300; 2352 return; 2353 case FontWeight200: 2354 m_value.ident = CSSValue200; 2355 return; 2356 case FontWeight100: 2357 m_value.ident = CSSValue100; 2358 return; 2359 } 2360 2361 ASSERT_NOT_REACHED(); 2362 m_value.ident = CSSValueNormal; 2363 } 2364 2365 template<> inline CSSPrimitiveValue::operator FontWeight() const 2366 { 2367 switch (m_value.ident) { 2368 case CSSValueBold: 2369 return FontWeightBold; 2370 case CSSValueNormal: 2371 return FontWeightNormal; 2372 case CSSValue900: 2373 return FontWeight900; 2374 case CSSValue800: 2375 return FontWeight800; 2376 case CSSValue700: 2377 return FontWeight700; 2378 case CSSValue600: 2379 return FontWeight600; 2380 case CSSValue500: 2381 return FontWeight500; 2382 case CSSValue400: 2383 return FontWeight400; 2384 case CSSValue300: 2385 return FontWeight300; 2386 case CSSValue200: 2387 return FontWeight200; 2388 case CSSValue100: 2389 return FontWeight100; 2390 } 2391 2392 ASSERT_NOT_REACHED(); 2393 return FontWeightNormal; 2394 } 2395 2327 2396 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontItalic italic) 2328 2397 : m_type(CSS_IDENT) -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r86044 r86120 3677 3677 if (!primitiveValue) 3678 3678 return; 3679 if (primitiveValue->getIdent()) { 3680 switch (primitiveValue->getIdent()) { 3681 case CSSValueBolder: 3682 fontDescription.setWeight(fontDescription.bolderWeight()); 3683 break; 3684 case CSSValueLighter: 3685 fontDescription.setWeight(fontDescription.lighterWeight()); 3686 break; 3687 case CSSValueBold: 3688 case CSSValue700: 3689 fontDescription.setWeight(FontWeightBold); 3690 break; 3691 case CSSValueNormal: 3692 case CSSValue400: 3693 fontDescription.setWeight(FontWeightNormal); 3694 break; 3695 case CSSValue900: 3696 fontDescription.setWeight(FontWeight900); 3697 break; 3698 case CSSValue800: 3699 fontDescription.setWeight(FontWeight800); 3700 break; 3701 case CSSValue600: 3702 fontDescription.setWeight(FontWeight600); 3703 break; 3704 case CSSValue500: 3705 fontDescription.setWeight(FontWeight500); 3706 break; 3707 case CSSValue300: 3708 fontDescription.setWeight(FontWeight300); 3709 break; 3710 case CSSValue200: 3711 fontDescription.setWeight(FontWeight200); 3712 break; 3713 case CSSValue100: 3714 fontDescription.setWeight(FontWeight100); 3715 break; 3716 default: 3717 return; 3718 } 3719 } else 3679 switch (primitiveValue->getIdent()) { 3680 case CSSValueInvalid: 3720 3681 ASSERT_NOT_REACHED(); 3682 break; 3683 case CSSValueBolder: 3684 fontDescription.setWeight(fontDescription.bolderWeight()); 3685 break; 3686 case CSSValueLighter: 3687 fontDescription.setWeight(fontDescription.lighterWeight()); 3688 break; 3689 default: 3690 fontDescription.setWeight(*primitiveValue); 3691 } 3721 3692 } 3722 3693 if (m_style->setFontDescription(fontDescription))
Note: See TracChangeset
for help on using the changeset viewer.