Changeset 102552 in webkit


Ignore:
Timestamp:
Dec 11, 2011 6:24:28 PM (12 years ago)
Author:
macpherson@chromium.org
Message:

Implement CSS display property in CSSStyleApplyProperty.
https://bugs.webkit.org/show_bug.cgi?id=73500

Reviewed by Andreas Kling.

Refactoring only / no functionality changed.

  • css/CSSStyleApplyProperty.cpp:

(WebCore::ApplyPropertyDisplay::isValidDisplayValue):
(WebCore::ApplyPropertyDisplay::applyInheritValue):
(WebCore::ApplyPropertyDisplay::applyInitialValue):
(WebCore::ApplyPropertyDisplay::applyValue):
(WebCore::ApplyPropertyDisplay::createHandler):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102548 r102552  
     12011-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
    1202011-12-11  Geoffrey Garen  <ggaren@apple.com>
    221
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r102544 r102552  
    13501350};
    13511351
     1352class ApplyPropertyDisplay {
     1353private:
     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    }
     1362public:
     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
    13521395const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
    13531396{
     
    13731416    setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
    13741417                       &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite>::createHandler());
     1418
     1419    setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
    13751420
    13761421    setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r102544 r102552  
    25052505}
    25062506
    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 #endif
    2517 };
    2518 
    2519 #if !ENABLE(SVG)
    2520 inline SVGDisplayPropertyGuard::SVGDisplayPropertyGuard(Element*, RenderStyle*)
    2521 {
    2522 }
    2523 
    2524 inline SVGDisplayPropertyGuard::~SVGDisplayPropertyGuard()
    2525 {
    2526 }
    2527 #else
    2528 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 #endif
    2552 
    2553 
    25542507// SVG handles zooming in a different way compared to CSS. The whole document is scaled instead
    25552508// of each individual length value in the render style / tree. CSSPrimitiveValue::computeLength*()
     
    26712624        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(clear, Clear)
    26722625        return;
    2673     case CSSPropertyDisplay: {
    2674         SVGDisplayPropertyGuard guard(m_element, m_style.get());
    2675         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(display, Display)
    2676         return;
    2677     }
    26782626    case CSSPropertyEmptyCells:
    26792627        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(emptyCells, EmptyCells)
     
    37973745    case CSSPropertyColor:
    37983746    case CSSPropertyDirection:
     3747    case CSSPropertyDisplay:
    37993748    case CSSPropertyBackgroundAttachment:
    38003749    case CSSPropertyBackgroundClip:
Note: See TracChangeset for help on using the changeset viewer.