Changeset 121129 in webkit


Ignore:
Timestamp:
Jun 24, 2012 7:03:45 PM (12 years ago)
Author:
macpherson@chromium.org
Message:

Add runtime flag to enable/disable CSS variables (in addition to existing compile-time flag).
https://bugs.webkit.org/show_bug.cgi?id=89542

Reviewed by Dimitri Glazkov.

Source/WebCore:

Added fast/css/variables/build-supports-variables.html to test runtime flag in test environment.
Updated all other css variables tests to enable the runtime flag from JS.

  • css/CSSParser.cpp:

(WebCore::CSSParserContext::CSSParserContext):
(WebCore::operator==):
(WebCore::CSSParser::cssVariablesEnabled):
(WebCore):
(WebCore::CSSParser::detectDashToken):
(WebCore::CSSParser::lex):

  • css/CSSParser.h:

(CSSParser):

  • css/CSSParserMode.h:

(CSSParserContext):

  • page/Settings.h:

(Settings):
(WebCore::Settings::setCSSVariablesEnabled):
(WebCore::Settings::cssVariablesEnabled):

Source/WebKit/chromium:

  • features.gypi:
  • public/WebSettings.h:
  • src/WebSettingsImpl.cpp:

(WebKit::WebSettingsImpl::setExperimentalCSSVariablesEnabled):
(WebKit):

  • src/WebSettingsImpl.h:

(WebSettingsImpl):

Location:
trunk
Files:
2 added
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/fast/css/variables/border-width.html

    r117791 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25div {
  • trunk/LayoutTests/fast/css/variables/colors-test.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/complex-cycle.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/computed-style.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/inherited-values.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/inline-styles.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<body style="-webkit-var-a: green;">
    25<div style="color: -webkit-var(a);">
  • trunk/LayoutTests/fast/css/variables/invalid-shorthand.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25div {
  • trunk/LayoutTests/fast/css/variables/invalid-variable-value.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25div {
  • trunk/LayoutTests/fast/css/variables/multi-level-cycle.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25.a {
  • trunk/LayoutTests/fast/css/variables/redefinition.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/shorthand.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25div {
  • trunk/LayoutTests/fast/css/variables/simple-cycle.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/transform-test.html

    r117791 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25div {
  • trunk/LayoutTests/fast/css/variables/undefined.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/use-before-defined.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25div {
  • trunk/LayoutTests/fast/css/variables/var-inside-shorthand.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/LayoutTests/fast/css/variables/variable-chain.html

    r117390 r121129  
     1<script>
     2internals.settings.setCSSVariablesEnabled(true);
     3</script>
    14<style>
    25body {
  • trunk/Source/WebCore/ChangeLog

    r121128 r121129  
     12012-06-24  Luke Macpherson  <macpherson@chromium.org>
     2
     3        Add runtime flag to enable/disable CSS variables (in addition to existing compile-time flag).
     4        https://bugs.webkit.org/show_bug.cgi?id=89542
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Added fast/css/variables/build-supports-variables.html to test runtime flag in test environment.
     9        Updated all other css variables tests to enable the runtime flag from JS.
     10
     11        * css/CSSParser.cpp:
     12        (WebCore::CSSParserContext::CSSParserContext):
     13        (WebCore::operator==):
     14        (WebCore::CSSParser::cssVariablesEnabled):
     15        (WebCore):
     16        (WebCore::CSSParser::detectDashToken):
     17        (WebCore::CSSParser::lex):
     18        * css/CSSParser.h:
     19        (CSSParser):
     20        * css/CSSParserMode.h:
     21        (CSSParserContext):
     22        * page/Settings.h:
     23        (Settings):
     24        (WebCore::Settings::setCSSVariablesEnabled):
     25        (WebCore::Settings::cssVariablesEnabled):
     26
    1272012-06-22  Kent Tamura  <tkent@chromium.org>
    228
  • trunk/Source/WebCore/css/CSSParser.cpp

    r121127 r121129  
    195195    , isCSSRegionsEnabled(false)
    196196    , isCSSGridLayoutEnabled(false)
     197#if ENABLE(CSS_VARIABLES)
     198    , isCSSVariablesEnabled(false)
     199#endif
    197200    , needsSiteSpecificQuirks(false)
    198201    , enforcesCSSMIMETypeInNoQuirksMode(true)
     
    208211    , isCSSRegionsEnabled(document->cssRegionsEnabled())
    209212    , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled())
     213#if ENABLE(CSS_VARIABLES)
     214    , isCSSVariablesEnabled(document->settings() ? document->settings()->cssVariablesEnabled() : false)
     215#endif
    210216    , needsSiteSpecificQuirks(document->settings() ? document->settings()->needsSiteSpecificQuirks() : false)
    211217    , enforcesCSSMIMETypeInNoQuirksMode(!document->settings() || document->settings()->enforceCSSMIMETypeInNoQuirksMode())
     
    222228        && a.isCSSRegionsEnabled == b.isCSSRegionsEnabled
    223229        && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled
     230#if ENABLE(CSS_VARIABLES)
     231        && a.isCSSVariablesEnabled == b.isCSSVariablesEnabled
     232#endif
    224233        && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
    225234        && a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode;
     
    10151024}
    10161025
     1026#if ENABLE(CSS_VARIABLES)
     1027bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, Document* document)
     1028{
     1029    ASSERT(!string.isEmpty());
     1030
     1031    CSSParserContext context(document);
     1032
     1033    if (parseSimpleLengthValue(declaration, propertyID, string, important, context.mode))
     1034        return true;
     1035    if (parseColorValue(declaration, propertyID, string, important, context.mode))
     1036        return true;
     1037    if (parseKeywordValue(declaration, propertyID, string, important, context))
     1038        return true;
     1039
     1040    CSSParser parser(context);
     1041    return parser.parseValue(declaration, propertyID, string, important, static_cast<StyleSheetContents*>(0));
     1042}
     1043#endif
     1044
    10171045bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
    10181046{
     
    28942922
    28952923#if ENABLE(CSS_VARIABLES)
     2924bool CSSParser::cssVariablesEnabled() const
     2925{
     2926    return m_context.isCSSVariablesEnabled;
     2927}
     2928
    28962929void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr<CSSParserValueList> value, bool important)
    28972930{
     
    85238556            m_token = MAXFUNCTION;
    85248557#if ENABLE(CSS_VARIABLES)
    8525         else if (isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va"))
     8558        else if (cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va"))
    85268559            m_token = VARFUNCTION;
    85278560#endif
     
    88658898    case CharacterDash:
    88668899#if ENABLE(CSS_VARIABLES)
    8867         if (m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) {
     8900        if (cssVariablesEnabled() && m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) {
    88688901            // handle variable declarations
    88698902            m_currentCharacter += 11;
  • trunk/Source/WebCore/css/CSSParser.h

    r120469 r121129  
    9393
    9494#if ENABLE(CSS_VARIABLES)
     95    static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, Document*);
     96    bool cssVariablesEnabled() const;
    9597    void storeVariableDeclaration(const CSSParserString&, PassOwnPtr<CSSParserValueList>, bool important);
    9698#endif
  • trunk/Source/WebCore/css/CSSParserMode.h

    r117613 r121129  
    6666    bool isCSSRegionsEnabled;
    6767    bool isCSSGridLayoutEnabled;
     68#if ENABLE(CSS_VARIABLES)
     69    bool isCSSVariablesEnabled;
     70#endif
    6871    bool needsSiteSpecificQuirks;
    6972    bool enforcesCSSMIMETypeInNoQuirksMode;
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r121123 r121129  
    33243324    // FIXME: It would be faster not to re-parse from strings, but for now CSS property validation lives inside the parser so we do it there.
    33253325    RefPtr<StylePropertySet> resultSet = StylePropertySet::create();
    3326     if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, CSSStrictMode, 0))
     3326    if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, document()))
    33273327        return; // expression failed to parse.
    33283328
  • trunk/Source/WebCore/page/Settings.h

    r120885 r121129  
    330330        void setCSSRegionsEnabled(bool) { }
    331331        bool cssRegionsEnabled() const { return false; }
     332#endif
     333
     334#if ENABLE(CSS_VARIABLES)
     335        void setCSSVariablesEnabled(bool enabled) { m_cssVariablesEnabled = enabled; }
     336        bool cssVariablesEnabled() const { return true; }
     337#else
     338        void setCSSVariablesEnabled(bool) { }
     339        bool cssVariablesEnabled() const { return false; }
    332340#endif
    333341
     
    678686        bool m_cssRegionsEnabled : 1;
    679687#endif
     688#if ENABLE(CSS_VARIABLES)
     689        bool m_cssVariablesEnabled : 1;
     690#endif
    680691        bool m_regionBasedColumnsEnabled : 1;
    681692        bool m_cssGridLayoutEnabled : 1;
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r120883 r121129  
    349349}
    350350
     351void InternalSettings::setCSSVariablesEnabled(bool enabled, ExceptionCode& ec)
     352{
     353    InternalSettingsGuardForSettings();
     354    settings()->setCSSVariablesEnabled(enabled);
     355}
     356
     357bool InternalSettings::cssVariablesEnabled(ExceptionCode& ec)
     358{
     359    InternalSettingsGuardForSettingsReturn(false);
     360    return settings()->cssVariablesEnabled();
     361}
     362
    351363void InternalSettings::setMediaPlaybackRequiresUserGesture(bool enabled, ExceptionCode& ec)
    352364{
  • trunk/Source/WebCore/testing/InternalSettings.h

    r120883 r121129  
    7676    bool scrollAnimatorEnabled(ExceptionCode&);
    7777    void setCSSExclusionsEnabled(bool enabled, ExceptionCode&);
     78    void setCSSVariablesEnabled(bool enabled, ExceptionCode&);
     79    bool cssVariablesEnabled(ExceptionCode&);
    7880    void setMediaPlaybackRequiresUserGesture(bool, ExceptionCode&);
    7981    void setEditingBehavior(const String&, ExceptionCode&);
  • trunk/Source/WebCore/testing/InternalSettings.idl

    r120883 r121129  
    5555        boolean scrollAnimatorEnabled() raises(DOMException);
    5656        void setCSSExclusionsEnabled(in boolean enabled) raises(DOMException);
     57        void setCSSVariablesEnabled(in boolean enabled) raises(DOMException);
     58        boolean cssVariablesEnabled() raises(DOMException);
    5759        void setMediaPlaybackRequiresUserGesture(in boolean enabled) raises(DOMException);
    5860        void setEditingBehavior(in DOMString behavior) raises(DOMException);
  • trunk/Source/WebKit/chromium/ChangeLog

    r121108 r121129  
     12012-06-24  Luke Macpherson  <macpherson@chromium.org>
     2
     3        Add runtime flag to enable/disable CSS variables (in addition to existing compile-time flag).
     4        https://bugs.webkit.org/show_bug.cgi?id=89542
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * features.gypi:
     9        * public/WebSettings.h:
     10        * src/WebSettingsImpl.cpp:
     11        (WebKit::WebSettingsImpl::setExperimentalCSSVariablesEnabled):
     12        (WebKit):
     13        * src/WebSettingsImpl.h:
     14        (WebSettingsImpl):
     15
    1162012-06-23  Kwang Yul Seo  <skyul@company100.net>
    217
  • trunk/Source/WebKit/chromium/features.gypi

    r120972 r121129  
    4747      'ENABLE_CSS_REGIONS=1',
    4848      'ENABLE_CSS_SHADERS=1',
    49       'ENABLE_CSS_VARIABLES=0',
     49      'ENABLE_CSS_VARIABLES=1',
    5050      'ENABLE_CUSTOM_SCHEME_HANDLER=0',
    5151      'ENABLE_DATALIST=1',
  • trunk/Source/WebKit/chromium/public/WebSettings.h

    r120885 r121129  
    106106    virtual void setExperimentalCSSGridLayoutEnabled(bool) = 0;
    107107    virtual void setExperimentalCSSCustomFilterEnabled(bool) = 0;
     108    virtual void setExperimentalCSSVariablesEnabled(bool) = 0;
    108109    virtual void setOpenGLMultisamplingEnabled(bool) = 0;
    109110    virtual void setPrivilegedWebGLExtensionsEnabled(bool) = 0;
  • trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp

    r120885 r121129  
    339339}
    340340
     341void WebSettingsImpl::setExperimentalCSSVariablesEnabled(bool enabled)
     342{
     343    m_settings->setCSSVariablesEnabled(enabled);
     344}
     345
    341346void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled)
    342347{
  • trunk/Source/WebKit/chromium/src/WebSettingsImpl.h

    r120885 r121129  
    9898    virtual void setExperimentalCSSGridLayoutEnabled(bool);
    9999    virtual void setExperimentalCSSCustomFilterEnabled(bool);
     100    virtual void setExperimentalCSSVariablesEnabled(bool);
    100101    virtual void setOpenGLMultisamplingEnabled(bool);
    101102    virtual void setPrivilegedWebGLExtensionsEnabled(bool);
Note: See TracChangeset for help on using the changeset viewer.