Changeset 87281 in webkit


Ignore:
Timestamp:
May 25, 2011 2:35:43 AM (13 years ago)
Author:
apavlov@chromium.org
Message:

2011-05-16 Alexander Pavlov <apavlov@chromium.org>

Reviewed by David Levin.

CSSParser: m_implicitShorthand should probably be RAII
https://bugs.webkit.org/show_bug.cgi?id=51586

It was impossible to entirely eliminate the m_implicitShorthand manual changes
due to the parseFill*() method stateful call chains.

No new tests, as this is a refactoring.

  • css/CSSParser.cpp: (ImplicitScope::ImplicitScope): (ImplicitScope::~ImplicitScope): (WebCore::CSSParser::parseShorthand): (WebCore::CSSParser::parse4Values): (WebCore::CSSParser::parseBorderRadius):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87280 r87281  
     12011-05-16  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        CSSParser: m_implicitShorthand should probably be RAII
     6        https://bugs.webkit.org/show_bug.cgi?id=51586
     7
     8        It was impossible to entirely eliminate the m_implicitShorthand manual changes
     9        due to the parseFill*() method stateful call chains.
     10
     11        No new tests, as this is a refactoring.
     12
     13        * css/CSSParser.cpp:
     14        (ImplicitScope::ImplicitScope):
     15        (ImplicitScope::~ImplicitScope):
     16        (WebCore::CSSParser::parseShorthand):
     17        (WebCore::CSSParser::parse4Values):
     18        (WebCore::CSSParser::parseBorderRadius):
     19
    1202011-05-24  Pavel Podivilov  <podivilov@chromium.org>
    221
  • trunk/Source/WebCore/css/CSSParser.cpp

    r87121 r87281  
    9393using namespace WTF;
    9494
     95namespace {
     96
     97enum PropertyType {
     98    PropertyExplicit,
     99    PropertyImplicit
     100};
     101
     102class ImplicitScope {
     103    WTF_MAKE_NONCOPYABLE(ImplicitScope);
     104public:
     105    ImplicitScope(WebCore::CSSParser* parser, PropertyType propertyType)
     106        : m_parser(parser)
     107    {
     108        m_parser->m_implicitShorthand = propertyType == PropertyImplicit;
     109    }
     110
     111    ~ImplicitScope()
     112    {
     113        m_parser->m_implicitShorthand = false;
     114    }
     115
     116private:
     117    WebCore::CSSParser* m_parser;
     118};
     119
     120} // namespace
     121
    95122namespace WebCore {
    96123
     
    23832410
    23842411    // Fill in any remaining properties with the initial value.
    2385     m_implicitShorthand = true;
     2412    ImplicitScope implicitScope(this, PropertyImplicit);
    23862413    for (int i = 0; i < numProperties; ++i) {
    23872414        if (!fnd[i])
    23882415            addProperty(properties[i], CSSInitialValue::createImplicit(), important);
    23892416    }
    2390     m_implicitShorthand = false;
    23912417
    23922418    return true;
     
    24132439                return false;
    24142440            CSSValue *value = m_parsedProperties[m_numParsedProperties-1]->value();
    2415             m_implicitShorthand = true;
     2441            ImplicitScope implicitScope(this, PropertyImplicit);
    24162442            addProperty(properties[1], value, important);
    24172443            addProperty(properties[2], value, important);
    24182444            addProperty(properties[3], value, important);
    2419             m_implicitShorthand = false;
    24202445            break;
    24212446        }
     
    24242449                return false;
    24252450            CSSValue *value = m_parsedProperties[m_numParsedProperties-2]->value();
    2426             m_implicitShorthand = true;
     2451            ImplicitScope implicitScope(this, PropertyImplicit);
    24272452            addProperty(properties[2], value, important);
    24282453            value = m_parsedProperties[m_numParsedProperties-2]->value();
    24292454            addProperty(properties[3], value, important);
    2430             m_implicitShorthand = false;
    24312455            break;
    24322456        }
     
    24352459                return false;
    24362460            CSSValue *value = m_parsedProperties[m_numParsedProperties-2]->value();
    2437             m_implicitShorthand = true;
     2461            ImplicitScope implicitScope(this, PropertyImplicit);
    24382462            addProperty(properties[3], value, important);
    2439             m_implicitShorthand = false;
    24402463            break;
    24412464        }
     
    49965019        completeBorderRadii(radii[1]);
    49975020
    4998     m_implicitShorthand = true;
     5021    ImplicitScope implicitScope(this, PropertyImplicit);
    49995022    addProperty(CSSPropertyBorderTopLeftRadius, primitiveValueCache()->createValue(Pair::create(radii[0][0].release(), radii[1][0].release())), important);
    50005023    addProperty(CSSPropertyBorderTopRightRadius, primitiveValueCache()->createValue(Pair::create(radii[0][1].release(), radii[1][1].release())), important);
    50015024    addProperty(CSSPropertyBorderBottomRightRadius, primitiveValueCache()->createValue(Pair::create(radii[0][2].release(), radii[1][2].release())), important);
    50025025    addProperty(CSSPropertyBorderBottomLeftRadius, primitiveValueCache()->createValue(Pair::create(radii[0][3].release(), radii[1][3].release())), important);
    5003     m_implicitShorthand = false;
    50045026    return true;
    50055027}
Note: See TracChangeset for help on using the changeset viewer.