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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121229 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ed7b727a
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
div {
border-color: green;
......
<body>NO</body>
<script>
if (window.testRunner)
testRunner.dumpAsText();
internals.settings.setCSSVariablesEnabled(true);
if (internals.settings.cssVariablesEnabled())
document.body.innerHTML = "YES";
</script>
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-foreground: green;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-a: -webkit-var(f);
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-a: bold;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-foreground: green;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<body style="-webkit-var-a: green;">
<div style="color: -webkit-var(a);">
This text should be green on a white background.
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
div {
-webkit-var-a: 10px solid green;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
div {
-webkit-var-a: green;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
.a {
-webkit-var-a: -webkit-var(b);
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-a: red;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
div {
-webkit-var-myborder: 10px solid green;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-a: -webkit-var(a);
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
div {
display: inline-block;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
border: -webkit-var(myborder);
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
div {
color: -webkit-var(a);
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-MyBorderColor: green;
......
<script>
internals.settings.setCSSVariablesEnabled(true);
</script>
<style>
body {
-webkit-var-c: green;
......
2012-06-25 Luke Macpherson <macpherson@chromium.org>
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.
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):
2012-06-25 Simon Hausmann <simon.hausmann@nokia.com>
Unreviewed build fix after r121223.
......@@ -194,6 +194,9 @@ CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL)
, isCSSCustomFilterEnabled(false)
, isCSSRegionsEnabled(false)
, isCSSGridLayoutEnabled(false)
#if ENABLE(CSS_VARIABLES)
, isCSSVariablesEnabled(false)
#endif
, needsSiteSpecificQuirks(false)
, enforcesCSSMIMETypeInNoQuirksMode(true)
{
......@@ -207,6 +210,9 @@ CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
, isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCSSCustomFilterEnabled() : false)
, isCSSRegionsEnabled(document->cssRegionsEnabled())
, isCSSGridLayoutEnabled(document->cssGridLayoutEnabled())
#if ENABLE(CSS_VARIABLES)
, isCSSVariablesEnabled(document->settings() ? document->settings()->cssVariablesEnabled() : false)
#endif
, needsSiteSpecificQuirks(document->settings() ? document->settings()->needsSiteSpecificQuirks() : false)
, enforcesCSSMIMETypeInNoQuirksMode(!document->settings() || document->settings()->enforceCSSMIMETypeInNoQuirksMode())
{
......@@ -221,6 +227,9 @@ bool operator==(const CSSParserContext& a, const CSSParserContext& b)
&& a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled
&& a.isCSSRegionsEnabled == b.isCSSRegionsEnabled
&& a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled
#if ENABLE(CSS_VARIABLES)
&& a.isCSSVariablesEnabled == b.isCSSVariablesEnabled
#endif
&& a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
&& a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode;
}
......@@ -1082,6 +1091,25 @@ PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& strin
return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
}
#if ENABLE(CSS_VARIABLES)
bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, Document* document)
{
ASSERT(!string.isEmpty());
CSSParserContext context(document);
if (parseSimpleLengthValue(declaration, propertyID, string, important, context.mode))
return true;
if (parseColorValue(declaration, propertyID, string, important, context.mode))
return true;
if (parseKeywordValue(declaration, propertyID, string, important, context))
return true;
CSSParser parser(context);
return parser.parseValue(declaration, propertyID, string, important, static_cast<StyleSheetContents*>(0));
}
#endif
bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
{
ASSERT(!string.isEmpty());
......@@ -2968,6 +2996,11 @@ bool CSSParser::parseFillShorthand(CSSPropertyID propId, const CSSPropertyID* pr
}
#if ENABLE(CSS_VARIABLES)
bool CSSParser::cssVariablesEnabled() const
{
return m_context.isCSSVariablesEnabled;
}
void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr<CSSParserValueList> value, bool important)
{
StringBuilder builder;
......@@ -8597,7 +8630,7 @@ inline void CSSParser::detectDashToken(int length)
else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentifier(name + 1, "webkit-ma"))
m_token = MAXFUNCTION;
#if ENABLE(CSS_VARIABLES)
else if (isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va"))
else if (cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va"))
m_token = VARFUNCTION;
#endif
} else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc"))
......@@ -8939,7 +8972,7 @@ restartAfterComment:
case CharacterDash:
#if ENABLE(CSS_VARIABLES)
if (m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) {
if (cssVariablesEnabled() && m_currentCharacter[10] == '-' && isEqualToCSSIdentifier(m_currentCharacter, "webkit-var") && isIdentifierStartAfterDash(m_currentCharacter + 11)) {
// handle variable declarations
m_currentCharacter += 11;
parseIdentifier(result, hasEscape);
......
......@@ -92,6 +92,8 @@ public:
bool parseQuotes(CSSPropertyID, bool important);
#if ENABLE(CSS_VARIABLES)
static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, Document*);
bool cssVariablesEnabled() const;
void storeVariableDeclaration(const CSSParserString&, PassOwnPtr<CSSParserValueList>, bool important);
#endif
......
......@@ -65,6 +65,9 @@ struct CSSParserContext {
bool isCSSCustomFilterEnabled;
bool isCSSRegionsEnabled;
bool isCSSGridLayoutEnabled;
#if ENABLE(CSS_VARIABLES)
bool isCSSVariablesEnabled;
#endif
bool needsSiteSpecificQuirks;
bool enforcesCSSMIMETypeInNoQuirksMode;
};
......
......@@ -3325,7 +3325,7 @@ void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<s
// 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.
RefPtr<StylePropertySet> resultSet = StylePropertySet::create();
if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, CSSStrictMode, 0))
if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, document()))
return; // expression failed to parse.
for (unsigned i = 0; i < resultSet->propertyCount(); i++) {
......
......@@ -331,6 +331,14 @@ namespace WebCore {
bool cssRegionsEnabled() const { return false; }
#endif
#if ENABLE(CSS_VARIABLES)
void setCSSVariablesEnabled(bool enabled) { m_cssVariablesEnabled = enabled; }
bool cssVariablesEnabled() const { return true; }
#else
void setCSSVariablesEnabled(bool) { }
bool cssVariablesEnabled() const { return false; }
#endif
void setRegionBasedColumnsEnabled(bool enabled) { m_regionBasedColumnsEnabled = enabled; }
bool regionBasedColumnsEnabled() const { return m_regionBasedColumnsEnabled; }
......@@ -676,6 +684,9 @@ namespace WebCore {
bool m_isCSSCustomFilterEnabled : 1;
#if ENABLE(CSS_REGIONS)
bool m_cssRegionsEnabled : 1;
#endif
#if ENABLE(CSS_VARIABLES)
bool m_cssVariablesEnabled : 1;
#endif
bool m_regionBasedColumnsEnabled : 1;
bool m_cssGridLayoutEnabled : 1;
......
......@@ -348,6 +348,18 @@ void InternalSettings::setCSSExclusionsEnabled(bool enabled, ExceptionCode& ec)
RuntimeEnabledFeatures::setCSSExclusionsEnabled(enabled);
}
void InternalSettings::setCSSVariablesEnabled(bool enabled, ExceptionCode& ec)
{
InternalSettingsGuardForSettings();
settings()->setCSSVariablesEnabled(enabled);
}
bool InternalSettings::cssVariablesEnabled(ExceptionCode& ec)
{
InternalSettingsGuardForSettingsReturn(false);
return settings()->cssVariablesEnabled();
}
void InternalSettings::setMediaPlaybackRequiresUserGesture(bool enabled, ExceptionCode& ec)
{
InternalSettingsGuardForSettings();
......
......@@ -75,6 +75,8 @@ public:
void setEnableScrollAnimator(bool enabled, ExceptionCode&);
bool scrollAnimatorEnabled(ExceptionCode&);
void setCSSExclusionsEnabled(bool enabled, ExceptionCode&);
void setCSSVariablesEnabled(bool enabled, ExceptionCode&);
bool cssVariablesEnabled(ExceptionCode&);
void setMediaPlaybackRequiresUserGesture(bool, ExceptionCode&);
void setEditingBehavior(const String&, ExceptionCode&);
void setFixedPositionCreatesStackingContext(bool, ExceptionCode&);
......
......@@ -54,6 +54,8 @@ module window {
void setEnableScrollAnimator(in boolean enabled) raises(DOMException);
boolean scrollAnimatorEnabled() raises(DOMException);
void setCSSExclusionsEnabled(in boolean enabled) raises(DOMException);
void setCSSVariablesEnabled(in boolean enabled) raises(DOMException);
boolean cssVariablesEnabled() raises(DOMException);
void setMediaPlaybackRequiresUserGesture(in boolean enabled) raises(DOMException);
void setEditingBehavior(in DOMString behavior) raises(DOMException);
void setFixedPositionCreatesStackingContext(in boolean creates) raises(DOMException);
......
2012-06-25 Luke Macpherson <macpherson@chromium.org>
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.
* features.gypi:
* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setExperimentalCSSVariablesEnabled):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):
2012-06-25 Adrienne Walker <enne@google.com>
[chromium] Add WebPluginScrollbar and WebPluginScrollbarClient stub implementations
......
......@@ -105,6 +105,7 @@ public:
virtual void setExperimentalCSSRegionsEnabled(bool) = 0;
virtual void setExperimentalCSSGridLayoutEnabled(bool) = 0;
virtual void setExperimentalCSSCustomFilterEnabled(bool) = 0;
virtual void setExperimentalCSSVariablesEnabled(bool) = 0;
virtual void setOpenGLMultisamplingEnabled(bool) = 0;
virtual void setPrivilegedWebGLExtensionsEnabled(bool) = 0;
virtual void setWebGLErrorsToConsoleEnabled(bool) = 0;
......
......@@ -338,6 +338,11 @@ void WebSettingsImpl::setExperimentalCSSCustomFilterEnabled(bool enabled)
m_settings->setCSSCustomFilterEnabled(enabled);
}
void WebSettingsImpl::setExperimentalCSSVariablesEnabled(bool enabled)
{
m_settings->setCSSVariablesEnabled(enabled);
}
void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled)
{
m_settings->setOpenGLMultisamplingEnabled(enabled);
......
......@@ -97,6 +97,7 @@ public:
virtual void setExperimentalCSSRegionsEnabled(bool);
virtual void setExperimentalCSSGridLayoutEnabled(bool);
virtual void setExperimentalCSSCustomFilterEnabled(bool);
virtual void setExperimentalCSSVariablesEnabled(bool);
virtual void setOpenGLMultisamplingEnabled(bool);
virtual void setPrivilegedWebGLExtensionsEnabled(bool);
virtual void setWebGLErrorsToConsoleEnabled(bool);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment