+<script>
+internals.settings.setCSSVariablesEnabled(true);
+</script>
<style>
div {
border-color: green;
--- /dev/null
+<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.
, isCSSCustomFilterEnabled(false)
, isCSSRegionsEnabled(false)
, isCSSGridLayoutEnabled(false)
+#if ENABLE(CSS_VARIABLES)
+ , isCSSVariablesEnabled(false)
+#endif
, needsSiteSpecificQuirks(false)
, enforcesCSSMIMETypeInNoQuirksMode(true)
{
, 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())
{
&& 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;
}
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());
}
#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;
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"))
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);
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
bool isCSSCustomFilterEnabled;
bool isCSSRegionsEnabled;
bool isCSSGridLayoutEnabled;
+#if ENABLE(CSS_VARIABLES)
+ bool isCSSVariablesEnabled;
+#endif
bool needsSiteSpecificQuirks;
bool enforcesCSSMIMETypeInNoQuirksMode;
};
// 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++) {
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; }
#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;
bool m_downloadableBinaryFontsEnabled : 1;
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();
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&);
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
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;
m_settings->setCSSCustomFilterEnabled(enabled);
}
+void WebSettingsImpl::setExperimentalCSSVariablesEnabled(bool enabled)
+{
+ m_settings->setCSSVariablesEnabled(enabled);
+}
+
void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled)
{
m_settings->setOpenGLMultisamplingEnabled(enabled);
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);