Changeset 121874 in webkit


Ignore:
Timestamp:
Jul 4, 2012 5:15:54 PM (12 years ago)
Author:
macpherson@chromium.org
Message:

Inspector crashes when trying to inspect a page with CSS variables
https://bugs.webkit.org/show_bug.cgi?id=89818

Reviewed by Antti Koivisto.

Patch works by fixing treating handling of CSSPropertyID == CSSPropertyVariable as a special case,
and looking up the author-defined property name from the CSSValue.

Added test inspector/styles/variables/css-variables.html that inspects an element using CSS variables.
Test is skipped when variables are compiled out.

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::cssName):
(WebCore):
(WebCore::CSSProperty::cssText):

  • css/CSSProperty.h:

(CSSProperty):

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::PropertySetCSSStyleDeclaration::item):

  • css/StylePropertySet.cpp:

(WebCore::StylePropertySet::asText):

  • inspector/InspectorStyleSheet.cpp:

(WebCore::InspectorStyle::populateAllProperties):

Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r121832 r121874  
    159159// CSS Variables are not yet enabled.
    160160BUGWK85580 SKIP : fast/css/variables = PASS
     161BUGWK85580 SKIP : inspector/styles/variables = PASS
    161162
    162163// CSS image-resolution is not yet enabled.
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r121868 r121874  
    319319// CSS Variables are not yet enabled.
    320320BUGWK85580 SKIP : fast/css/variables = PASS TEXT
     321BUGWK85580 SKIP : inspector/styles/variables = PASS
    321322
    322323// CSS image-resolution is not yet enabled.
  • trunk/LayoutTests/platform/mac/TestExpectations

    r121794 r121874  
    1212// CSS Variables are not yet enabled.
    1313BUGWK85580 SKIP : fast/css/variables = PASS
     14BUGWK85580 SKIP : inspector/styles/variables = PASS
    1415
    1516// UndoManager is not yet enabled.
  • trunk/LayoutTests/platform/qt/TestExpectations

    r121794 r121874  
    7474// CSS Variables are not yet enabled.
    7575BUGWK85580 SKIP : fast/css/variables = PASS
     76BUGWK85580 SKIP : inspector/styles/variables = PASS
    7677
    7778// UndoManager is not yet enabled.
  • trunk/Source/WebCore/ChangeLog

    r121871 r121874  
     12012-07-04  Luke Macpherson  <macpherson@chromium.org>
     2
     3        Inspector crashes when trying to inspect a page with CSS variables
     4        https://bugs.webkit.org/show_bug.cgi?id=89818
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Patch works by fixing treating handling of CSSPropertyID == CSSPropertyVariable as a special case,
     9        and looking up the author-defined property name from the CSSValue.
     10
     11        Added test inspector/styles/variables/css-variables.html that inspects an element using CSS variables.
     12        Test is skipped when variables are compiled out.
     13
     14        * css/CSSProperty.cpp:
     15        (WebCore::CSSProperty::cssName):
     16        (WebCore):
     17        (WebCore::CSSProperty::cssText):
     18        * css/CSSProperty.h:
     19        (CSSProperty):
     20        * css/PropertySetCSSStyleDeclaration.cpp:
     21        (WebCore::PropertySetCSSStyleDeclaration::item):
     22        * css/StylePropertySet.cpp:
     23        (WebCore::StylePropertySet::asText):
     24        * inspector/InspectorStyleSheet.cpp:
     25        (WebCore::InspectorStyle::populateAllProperties):
     26
    1272012-07-04  Anthony Scian  <ascian@rim.com>
    228
  • trunk/Source/WebCore/css/CSSGrammar.y

    r121551 r121874  
    13611361        p->storeVariableDeclaration($1, p->sinkFloatingValueList($4), $5);
    13621362        $$ = true;
    1363         p->markPropertyEnd($5, $$);
     1363        p->markPropertyEnd($5, true);
    13641364#else
    13651365        $$ = false;
  • trunk/Source/WebCore/css/CSSParser.cpp

    r121764 r121874  
    30133013void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr<CSSParserValueList> value, bool important)
    30143014{
     3015    ASSERT(name.length > 12);
     3016    AtomicString variableName = String(name.characters + 12, name.length - 12);
     3017
    30153018    StringBuilder builder;
    30163019    for (unsigned i = 0, size = value->size(); i < size; i++) {
     
    30193022        builder.append(value->valueAt(i)->createCSSValue()->cssText());
    30203023    }
    3021     addProperty(CSSPropertyVariable, CSSVariableValue::create(name, builder.toString()), important, false);
     3024    addProperty(CSSPropertyVariable, CSSVariableValue::create(variableName, builder.toString()), important, false);
    30223025}
    30233026#endif
     
    89828985
    89838986    case CharacterDash:
    8984 #if ENABLE(CSS_VARIABLES)
    8985         if (cssVariablesEnabled() && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && m_currentCharacter[10] == '-' && isIdentifierStartAfterDash(m_currentCharacter + 11)) {
    8986             // handle variable declarations
    8987             m_currentCharacter += 11;
    8988             parseIdentifier(result, hasEscape);
    8989             m_token = VAR_DEFINITION;
    8990             yylval->string.characters = m_tokenStart;
    8991             yylval->string.length = result - m_tokenStart;
    8992         } else
    8993 #endif
    89948987        if (isIdentifierStartAfterDash(m_currentCharacter)) {
    89958988            --m_currentCharacter;
     
    89978990            m_token = IDENT;
    89988991
     8992#if ENABLE(CSS_VARIABLES)
     8993            if (cssVariablesEnabled() && isEqualToCSSIdentifier(m_tokenStart + 1, "webkit-var") && m_tokenStart[11] == '-' && isIdentifierStartAfterDash(m_tokenStart + 12))
     8994                m_token = VAR_DEFINITION;
     8995            else
     8996#endif
    89998997            if (*m_currentCharacter == '(') {
    90008998                m_token = FUNCTION;
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r121442 r121874  
    2727#include "StylePropertyShorthand.h"
    2828
     29#if ENABLE(CSS_VARIABLES)
     30#include "CSSVariableValue.h"
     31#endif
     32
    2933namespace WebCore {
    3034
     
    3640COMPILE_ASSERT(sizeof(CSSProperty) == sizeof(SameSizeAsCSSProperty), CSSProperty_should_stay_small);
    3741
     42String CSSProperty::cssName() const
     43{
     44#if ENABLE(CSS_VARIABLES)
     45    if (id() == CSSPropertyVariable) {
     46        ASSERT(value()->isVariableValue());
     47        return "-webkit-var-" + static_cast<CSSVariableValue*>(value())->name();
     48    }
     49#endif
     50    return String(getPropertyName(id()));
     51}
     52
    3853String CSSProperty::cssText() const
    3954{
    40     return String(getPropertyName(id())) + ": " + m_value->cssText() + (isImportant() ? " !important" : "") + "; ";
     55    return cssName() + ": " + m_value->cssText() + (isImportant() ? " !important" : "") + "; ";
    4156}
    4257
  • trunk/Source/WebCore/css/CSSProperty.h

    r118712 r121874  
    5252    CSSValue* value() const { return m_value.get(); }
    5353
     54    String cssName() const;
    5455    String cssText() const;
    5556
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r121570 r121874  
    140140    if (i >= m_propertySet->propertyCount())
    141141        return "";
    142     return getPropertyName(m_propertySet->propertyAt(i).id());
     142    return m_propertySet->propertyAt(i).cssName();
    143143}
    144144
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r121570 r121874  
    663663
    664664        switch (propertyID) {
     665#if ENABLE(CSS_VARIABLES)
     666        case CSSPropertyVariable:
     667            result.append(prop.cssText());
     668            continue;
     669#endif
    665670        case CSSPropertyBackgroundPositionX:
    666671            positionXProp = &prop;
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r121551 r121874  
    11171117
    11181118    RefPtr<StyleSheetContents> newStyleSheet = StyleSheetContents::create();
    1119     CSSParser p(CSSStrictMode);
     1119    CSSParser p(m_pageStyleSheet->ownerDocument());
    11201120    OwnPtr<RuleSourceDataList> ruleSourceDataResult = adoptPtr(new RuleSourceDataList());
    11211121    p.parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, ruleSourceDataResult.get());
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py

    r121497 r121874  
    299299            "WebGLShader": ["fast/canvas/webgl", "compositing/webgl", "http/tests/canvas/webgl"],
    300300            "MHTMLArchive": ["mhtml"],
    301             "CSSVariableValue": ["fast/css/variables"],
     301            "CSSVariableValue": ["fast/css/variables", "inspector/styles/variables"],
    302302        }
    303303
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py

    r121497 r121874  
    101101            "mhtml",  # Requires MHTMLArchive
    102102            "fast/css/variables",  # Requires CSS Variables
     103            "inspector/styles/variables",  # Requires CSS Variables
    103104        ])
    104105
Note: See TracChangeset for help on using the changeset viewer.