Changeset 102552 in webkit
- Timestamp:
- Dec 11, 2011 6:24:28 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r102548 r102552 1 2011-12-11 Luke Macpherson <macpherson@chromium.org> 2 3 Implement CSS display property in CSSStyleApplyProperty. 4 https://bugs.webkit.org/show_bug.cgi?id=73500 5 6 Reviewed by Andreas Kling. 7 8 Refactoring only / no functionality changed. 9 10 * css/CSSStyleApplyProperty.cpp: 11 (WebCore::ApplyPropertyDisplay::isValidDisplayValue): 12 (WebCore::ApplyPropertyDisplay::applyInheritValue): 13 (WebCore::ApplyPropertyDisplay::applyInitialValue): 14 (WebCore::ApplyPropertyDisplay::applyValue): 15 (WebCore::ApplyPropertyDisplay::createHandler): 16 (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): 17 * css/CSSStyleSelector.cpp: 18 (WebCore::CSSStyleSelector::applyProperty): 19 1 20 2011-12-11 Geoffrey Garen <ggaren@apple.com> 2 21 -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r102544 r102552 1350 1350 }; 1351 1351 1352 class ApplyPropertyDisplay { 1353 private: 1354 static inline bool isValidDisplayValue(CSSStyleSelector* selector, EDisplay displayPropertyValue) 1355 { 1356 #if ENABLE(SVG) 1357 if (selector->element() && selector->element()->isSVGElement() && selector->style()->styleType() == NOPSEUDO) 1358 return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE); 1359 #endif 1360 return true; 1361 } 1362 public: 1363 static void applyInheritValue(CSSStyleSelector* selector) 1364 { 1365 EDisplay display = selector->parentStyle()->display(); 1366 if (!isValidDisplayValue(selector, display)) 1367 return; 1368 selector->style()->setDisplay(display); 1369 } 1370 1371 static void applyInitialValue(CSSStyleSelector* selector) 1372 { 1373 selector->style()->setDisplay(RenderStyle::initialDisplay()); 1374 } 1375 1376 static void applyValue(CSSStyleSelector* selector, CSSValue* value) 1377 { 1378 if (!value->isPrimitiveValue()) 1379 return; 1380 1381 EDisplay display = *static_cast<CSSPrimitiveValue*>(value); 1382 1383 if (!isValidDisplayValue(selector, display)) 1384 return; 1385 1386 selector->style()->setDisplay(display); 1387 } 1388 1389 static PropertyHandler createHandler() 1390 { 1391 return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); 1392 } 1393 }; 1394 1352 1395 const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty() 1353 1396 { … … 1373 1416 setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, 1374 1417 &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite>::createHandler()); 1418 1419 setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler()); 1375 1420 1376 1421 setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r102544 r102552 2505 2505 } 2506 2506 2507 class SVGDisplayPropertyGuard {2508 WTF_MAKE_NONCOPYABLE(SVGDisplayPropertyGuard);2509 public:2510 SVGDisplayPropertyGuard(Element*, RenderStyle*);2511 ~SVGDisplayPropertyGuard();2512 private:2513 #if ENABLE(SVG)2514 RenderStyle* m_style;2515 EDisplay m_originalDisplayPropertyValue;2516 #endif2517 };2518 2519 #if !ENABLE(SVG)2520 inline SVGDisplayPropertyGuard::SVGDisplayPropertyGuard(Element*, RenderStyle*)2521 {2522 }2523 2524 inline SVGDisplayPropertyGuard::~SVGDisplayPropertyGuard()2525 {2526 }2527 #else2528 static inline bool isAcceptableForSVGElement(EDisplay displayPropertyValue)2529 {2530 return displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE;2531 }2532 2533 inline SVGDisplayPropertyGuard::SVGDisplayPropertyGuard(Element* element, RenderStyle* style)2534 {2535 if (!(element && element->isSVGElement() && style->styleType() == NOPSEUDO)) {2536 m_originalDisplayPropertyValue = NONE;2537 m_style = 0;2538 return;2539 }2540 m_style = style;2541 m_originalDisplayPropertyValue = style->display();2542 ASSERT(isAcceptableForSVGElement(m_originalDisplayPropertyValue));2543 }2544 2545 inline SVGDisplayPropertyGuard::~SVGDisplayPropertyGuard()2546 {2547 if (!m_style || isAcceptableForSVGElement(m_style->display()))2548 return;2549 m_style->setDisplay(m_originalDisplayPropertyValue);2550 }2551 #endif2552 2553 2554 2507 // SVG handles zooming in a different way compared to CSS. The whole document is scaled instead 2555 2508 // of each individual length value in the render style / tree. CSSPrimitiveValue::computeLength*() … … 2671 2624 HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(clear, Clear) 2672 2625 return; 2673 case CSSPropertyDisplay: {2674 SVGDisplayPropertyGuard guard(m_element, m_style.get());2675 HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(display, Display)2676 return;2677 }2678 2626 case CSSPropertyEmptyCells: 2679 2627 HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(emptyCells, EmptyCells) … … 3797 3745 case CSSPropertyColor: 3798 3746 case CSSPropertyDirection: 3747 case CSSPropertyDisplay: 3799 3748 case CSSPropertyBackgroundAttachment: 3800 3749 case CSSPropertyBackgroundClip:
Note: See TracChangeset
for help on using the changeset viewer.