Implement CSSSupportsRule
https://bugs.webkit.org/show_bug.cgi?id=104822
Patch by Pablo Flouret <pablof@motorola.com> on 2013-01-16
Reviewed by Allan Sandfeld Jensen.
Source/WebCore:
http://dev.w3.org/csswg/css3-conditional/#the-csssupportsrule-interface
Right now, @supports is not implemented as a proper CSSRule. Apart from
the CSSOM implications it gives wrong results when, for instance, an
@supports rule is nested inside a @media rule.
Test: css3/supports-cssom.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
Add CSSSupportsRule.* and associated files.
* bindings/js/JSCSSRuleCustom.cpp:
(WebCore::toJS):
* bindings/objc/DOMCSS.mm:
(kitClass):
* bindings/v8/custom/V8CSSRuleCustom.cpp:
(WebCore::wrap):
Create the correct wrappers for the rule.
* css/CSSGrammar.y.in:
* css/CSSParser.cpp:
(WebCore::CSSParser::createSupportsRule):
(WebCore::CSSParser::markSupportsRuleHeaderStart):
(WebCore::CSSParser::markSupportsRuleHeaderEnd):
* css/CSSParser.h:
Create the supports rule when parsing and add it where it corresponds,
instead of directly adding the child rules to the stylesheet.
* css/CSSPropertySourceData.h:
* css/CSSRule.h:
* css/CSSRule.idl:
Add SUPPORTS_RULE type to enums.
* css/CSSSupportsRule.cpp: Added.
(WebCore::CSSSupportsRule::CSSSupportsRule):
(WebCore::CSSSupportsRule::~CSSSupportsRule):
(WebCore::CSSSupportsRule::cssText):
(WebCore::CSSSupportsRule::conditionText):
* css/CSSSupportsRule.h: Added.
(WebCore::CSSSupportsRule::create):
* css/CSSSupportsRule.idl: Added.
DOM interface.
* css/RuleSet.cpp:
(WebCore::RuleSet::addChildRules):
Add rules included in the @supports rule.
* css/StyleResolver.cpp:
(WebCore::collectCSSOMWrappers):
Collect CSSSupportsRule wrappers.
* css/StyleRule.cpp:
(WebCore::StyleRuleBase::reportMemoryUsage):
(WebCore::StyleRuleBase::destroy):
(WebCore::StyleRuleBase::copy):
(WebCore::StyleRuleBase::createCSSOMWrapper):
(WebCore::StyleRuleSupports::StyleRuleSupports):
* css/StyleRule.h:
(StyleRuleBase):
(WebCore::StyleRuleBase::isSupportsRule):
(StyleRuleSupports):
(WebCore::StyleRuleSupports::create):
(WebCore::StyleRuleSupports::conditionText):
(WebCore::StyleRuleSupports::conditionIsSupported):
(WebCore::StyleRuleSupports::copy):
(WebCore::toStyleRuleSupports):
New subclass of StyleRuleBlock: StyleRuleSupports.
* css/StyleSheetContents.cpp:
(WebCore::childRulesHaveFailedOrCanceledSubresources):
* inspector/InspectorStyleSheet.cpp:
(flattenSourceData):
(WebCore::asCSSRuleList):
Handle @supports rules where needed.
LayoutTests:
* css3/supports-cssom-expected.txt: Added.
* css3/supports-cssom.html: Added.
* css3/supports-expected.txt:
* css3/supports.html:
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:
* platform/wk2/TestExpectations:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@139866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e00df4d..8698cd3 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,24 @@
+2013-01-16 Pablo Flouret <pablof@motorola.com>
+
+ Implement CSSSupportsRule
+ https://bugs.webkit.org/show_bug.cgi?id=104822
+
+ Reviewed by Allan Sandfeld Jensen.
+
+ * css3/supports-cssom-expected.txt: Added.
+ * css3/supports-cssom.html: Added.
+ * css3/supports-expected.txt:
+ * css3/supports.html:
+
+ * platform/chromium/TestExpectations:
+ * platform/efl/TestExpectations:
+ * platform/gtk/TestExpectations:
+ * platform/mac/TestExpectations:
+ * platform/qt/TestExpectations:
+ * platform/win/TestExpectations:
+ * platform/wincairo/TestExpectations:
+ * platform/wk2/TestExpectations:
+
2013-01-16 Kent Tamura <tkent@chromium.org>
INPUT_MULTIPLE_FIELDS_UI: Unable to edit a time field with step=86400, and confusing appearance
diff --git a/LayoutTests/css3/supports-cssom-expected.txt b/LayoutTests/css3/supports-cssom-expected.txt
new file mode 100644
index 0000000..e6241ad
--- /dev/null
+++ b/LayoutTests/css3/supports-cssom-expected.txt
@@ -0,0 +1,62 @@
+Test CSSSupportRule.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS CSSRule.SUPPORTS_RULE is defined.
+rules = document.styleSheets[1].cssRules
+PASS rules.length is 4
+PASS rules[0].type is CSSRule.SUPPORTS_RULE
+PASS rules[0].cssRules.length is 2
+PASS rules[0].cssRules[0].type is CSSRule.STYLE_RULE
+PASS rules[0].cssRules[1].type is CSSRule.SUPPORTS_RULE
+PASS rules[0].cssRules[1].cssRules.length is 1
+PASS rules[0].cssRules[1].cssRules[0].type is CSSRule.STYLE_RULE
+PASS rules[0].conditionText is "(width: 0)"
+PASS rules[0].cssText is "@supports (width: 0) {\n s { width: 0px; }\n @supports (width: 1) {\n s { color: rgb(0, 0, 0); }\n}\n}"
+
+Inserting and deleting rules.
+rules[0].insertRule('@media all { #s { width: 0px; } }', 2)
+PASS rules[0].cssRules.length is 3
+PASS rules[0].cssRules[2].type is CSSRule.MEDIA_RULE
+rules[0].deleteRule(2)
+PASS rules[0].cssRules.length is 2
+rules[0].cssRules[1].insertRule('@supports (display: rainbow) {}', 1)
+PASS rules[0].cssRules[1].cssRules.length is 2
+PASS rules[0].cssRules[1].cssRules[1].type is CSSRule.SUPPORTS_RULE
+rules[0].cssRules[1].deleteRule(1)
+PASS rules[0].cssRules.length is 2
+
+@charset, @namespace, @import rules are not allowed inside @supports.
+PASS rules[0].insertRule('@charset "UTF-8"', 2) threw exception Error: SyntaxError: DOM Exception 12.
+PASS rules[0].insertRule('@namespace ""', 2) threw exception Error: SyntaxError: DOM Exception 12.
+PASS rules[0].insertRule('@import url("../fast/cssom/resources/import.css")', 2) threw exception Error: SyntaxError: DOM Exception 12.
+
+Whitespace and formatting should be preserved within the condition, whitespace outside the condition should be trimmed.
+PASS rules[1].conditionText is "(( ( padding: 0) and (display: none)) or (display: rainbow))"
+
+@supports rule nested inside a media rule.
+PASS rules[2].type is CSSRule.MEDIA_RULE
+PASS rules[2].cssRules.length is 1
+PASS rules[2].cssRules[0].type is CSSRule.SUPPORTS_RULE
+PASS rules[2].cssRules[0].conditionText is "( padding: 0)"
+PASS rules[0].cssRules[1].cssRules.length is 1
+PASS rules[2].cssRules[0].cssRules[0].type is CSSRule.PAGE_RULE
+PASS rules[2].cssText is "@media all { \n @supports ( padding: 0) {\n @page :left { top: 0px; }\n}\n}"
+
+No extra parens should be added to the conditionText.
+PASS rules[3].conditionText is "(border: black) and (padding: 0) and (width: 0)"
+
+Deleting a top-level rule should work correctly.
+document.styleSheets[1].deleteRule(3)
+PASS rules.length is 3
+PASS rules[0].type is CSSRule.SUPPORTS_RULE
+PASS rules[0].cssRules.length is 2
+PASS rules[0].cssRules[0].type is CSSRule.STYLE_RULE
+PASS rules[0].cssRules[1].type is CSSRule.SUPPORTS_RULE
+PASS rules[0].cssRules[1].cssRules.length is 1
+PASS rules[0].cssRules[1].cssRules[0].type is CSSRule.STYLE_RULE
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/css3/supports-cssom.html b/LayoutTests/css3/supports-cssom.html
new file mode 100644
index 0000000..9897b60
--- /dev/null
+++ b/LayoutTests/css3/supports-cssom.html
@@ -0,0 +1,116 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset=utf8>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<style>
+ @supports (width: 0) {
+ s { width: 0; }
+ @supports (width: 1) {
+ s { color: #000; }
+ @import url("../fast/cssom/resources/import.css");
+ @charset "UTF-8";
+ @namespace "";
+ }
+ }
+
+ @supports (( ( padding: 0) and (display: none)) or (display: rainbow)) {
+ dfn { width:0; }
+ @supports (width: 0) {
+ br { height:0; }
+ }
+ ol { display:none; }
+ }
+
+ @media all {
+ @supports ( padding: 0) {
+ @page :left { top: 0 }
+ }
+ }
+
+ @supports (border: black) and (padding: 0) and (width: 0) {
+ dfn { width:0; }
+ }
+</style>
+</head>
+<body>
+<script>
+ description("Test CSSSupportRule.");
+
+
+ shouldBeDefined("CSSRule.SUPPORTS_RULE");
+
+ evalAndLog("rules = document.styleSheets[1].cssRules");
+ shouldEvaluateTo("rules.length", 4);
+ shouldBe("rules[0].type", "CSSRule.SUPPORTS_RULE");
+ shouldEvaluateTo("rules[0].cssRules.length", 2);
+ shouldBe("rules[0].cssRules[0].type", "CSSRule.STYLE_RULE");
+ shouldBe("rules[0].cssRules[1].type", "CSSRule.SUPPORTS_RULE");
+ shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1);
+ shouldBe("rules[0].cssRules[1].cssRules[0].type", "CSSRule.STYLE_RULE");
+ shouldBeEqualToString("rules[0].conditionText", "(width: 0)");
+ shouldBeEqualToString("rules[0].cssText",
+ "@supports (width: 0) {\n" +
+ " s { width: 0px; }\n" +
+ " @supports (width: 1) {\n" +
+ " s { color: rgb(0, 0, 0); }\n" +
+ "}\n" +
+ "}");
+
+ debug("\nInserting and deleting rules.");
+ evalAndLog("rules[0].insertRule('@media all { #s { width: 0px; } }', 2)");
+ shouldEvaluateTo("rules[0].cssRules.length", 3);
+ shouldBe("rules[0].cssRules[2].type", "CSSRule.MEDIA_RULE");
+ evalAndLog("rules[0].deleteRule(2)");
+ shouldEvaluateTo("rules[0].cssRules.length", 2);
+
+ evalAndLog("rules[0].cssRules[1].insertRule('@supports (display: rainbow) {}', 1)");
+ shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 2);
+ shouldBe("rules[0].cssRules[1].cssRules[1].type", "CSSRule.SUPPORTS_RULE");
+ evalAndLog("rules[0].cssRules[1].deleteRule(1)");
+ shouldEvaluateTo("rules[0].cssRules.length", 2);
+
+ debug("\n@charset, @namespace, @import rules are not allowed inside @supports.")
+ shouldThrow("rules[0].insertRule('@charset \"UTF-8\"', 2)");
+ shouldThrow("rules[0].insertRule('@namespace \"\"', 2)");
+ shouldThrow("rules[0].insertRule('@import url(\"../fast/cssom/resources/import.css\")', 2)");
+
+
+ debug("\nWhitespace and formatting should be preserved within the condition, whitespace outside the condition should be trimmed.");
+ shouldBeEqualToString("rules[1].conditionText", "(( ( padding: 0) and (display: none)) or (display: rainbow))");
+
+
+ debug("\n@supports rule nested inside a media rule.");
+ shouldBe("rules[2].type", "CSSRule.MEDIA_RULE");
+ shouldEvaluateTo("rules[2].cssRules.length", 1);
+ shouldBe("rules[2].cssRules[0].type", "CSSRule.SUPPORTS_RULE");
+ shouldBeEqualToString("rules[2].cssRules[0].conditionText", "( padding: 0)");
+ shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1);
+ shouldBe("rules[2].cssRules[0].cssRules[0].type", "CSSRule.PAGE_RULE");
+ shouldBeEqualToString("rules[2].cssText",
+ "@media all { \n" +
+ " @supports ( padding: 0) {\n" +
+ " @page :left { top: 0px; }\n" +
+ "}\n" +
+ "}");
+
+
+ debug("\nNo extra parens should be added to the conditionText.");
+ shouldBeEqualToString("rules[3].conditionText", "(border: black) and (padding: 0) and (width: 0)");
+
+
+ debug("\nDeleting a top-level rule should work correctly.");
+ evalAndLog("document.styleSheets[1].deleteRule(3)");
+ shouldEvaluateTo("rules.length", 3);
+ shouldBe("rules[0].type", "CSSRule.SUPPORTS_RULE");
+ shouldEvaluateTo("rules[0].cssRules.length", 2);
+ shouldBe("rules[0].cssRules[0].type", "CSSRule.STYLE_RULE");
+ shouldBe("rules[0].cssRules[1].type", "CSSRule.SUPPORTS_RULE");
+ shouldEvaluateTo("rules[0].cssRules[1].cssRules.length", 1);
+ shouldBe("rules[0].cssRules[1].cssRules[0].type", "CSSRule.STYLE_RULE");
+
+</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
+
diff --git a/LayoutTests/css3/supports-expected.txt b/LayoutTests/css3/supports-expected.txt
index d77e72f..41a76ba 100644
--- a/LayoutTests/css3/supports-expected.txt
+++ b/LayoutTests/css3/supports-expected.txt
@@ -38,6 +38,8 @@
PASS getComputedStyle(document.getElementById('t32')).content is "APPLIED"
PASS getComputedStyle(document.getElementById('t33')).content is "APPLIED"
PASS getComputedStyle(document.getElementById('t34')).content is "UNTOUCHED"
+PASS getComputedStyle(document.getElementById('t35')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t36')).content is "UNTOUCHED"
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/LayoutTests/css3/supports.html b/LayoutTests/css3/supports.html
index 1e68c9c..44347da 100644
--- a/LayoutTests/css3/supports.html
+++ b/LayoutTests/css3/supports.html
@@ -84,24 +84,6 @@
#t17 { content: "APPLIED" }
}
- /* Nesting. */
- @supports (display: none) {
- @supports (display: deadbeef) {
- #t18 { content: "FAIL" }
- }
- @supports (display: inline) {
- #t19 { content: "APPLIED" }
- }
- @supports (display: inline) {
- }
- @media all {
- #t20 { content: "APPLIED" }
- @supports (display: inline) {
- #t21 { content: "APPLIED" }
- }
- }
- }
-
/* Whitespace/Syntax */
@supports not( display: deadbeef) {
#t22 { content: "APPLIED" }
@@ -157,6 +139,39 @@
#t34 { content: "FAIL" }
}
+ /* Nesting. */
+ @supports (display: none) {
+ @supports (display: deadbeef) {
+ #t18 { content: "FAIL" }
+ }
+ @supports (display: inline) {
+ #t19 { content: "APPLIED" }
+ }
+ @supports (display: inline) {
+ }
+ @media all {
+ #t20 { content: "APPLIED" }
+ @supports (display: inline) {
+ #t21 { content: "APPLIED" }
+ }
+ }
+ }
+
+ @media all {
+ @supports (display: inline) {
+ @media all {
+ @supports (display: none) {
+ #t35 { content: "APPLIED" }
+ }
+ }
+ }
+ }
+
+ @media not all {
+ @supports (display: none) {
+ #t36 { content: "FAIL" }
+ }
+ }
</style>
</head>
<body>
@@ -164,8 +179,8 @@
<script>
description("Test the @supports rule.");
- var numTests = 35;
- var untouchedTests = [1, 3, 5, 8, 12, 13, 14, 18, 28, 29, 34]; // Tests whose content shouldn't change from the UNTOUCHED default.
+ var numTests = 37;
+ var untouchedTests = [1, 3, 5, 8, 12, 13, 14, 18, 28, 29, 34, 36]; // Tests whose content shouldn't change from the UNTOUCHED default.
var container = document.getElementById("test_container");
for (var i=0; i < numTests; i++) {
diff --git a/LayoutTests/platform/chromium/TestExpectations b/LayoutTests/platform/chromium/TestExpectations
index 947a87e..95bd34b 100644
--- a/LayoutTests/platform/chromium/TestExpectations
+++ b/LayoutTests/platform/chromium/TestExpectations
@@ -3927,6 +3927,7 @@
# css3-conditionals support is not yet enabled.
webkit.org/b/86146 css3/supports.html
+webkit.org/b/104822 css3/supports-cssom.html
# CSS Device Adaptation is not enabled.
webkit.org/b/95959 css3/device-adapt [ Skip ]
diff --git a/LayoutTests/platform/efl/TestExpectations b/LayoutTests/platform/efl/TestExpectations
index 2e1d158..50e9ef3 100644
--- a/LayoutTests/platform/efl/TestExpectations
+++ b/LayoutTests/platform/efl/TestExpectations
@@ -1558,6 +1558,7 @@
# css3-conditionals support is not yet enabled.
webkit.org/b/86146 css3/supports.html
+webkit.org/b/104822 css3/supports-cssom.html
# Occasionally fails if run after right after
# fast/selectors/unqualified-hover-quirks.html or itself.
diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations
index 184aad6..976ec97 100644
--- a/LayoutTests/platform/gtk/TestExpectations
+++ b/LayoutTests/platform/gtk/TestExpectations
@@ -402,6 +402,7 @@
# css3-conditionals support is not yet enabled.
webkit.org/b/86146 css3/supports.html
+webkit.org/b/104822 css3/supports-cssom.html
# Requires Resolution Media Query support
webkit.org/b/100137 fast/media/mq-resolution.html [ Failure ]
diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations
index 5ad9c1f..8c2ab76 100644
--- a/LayoutTests/platform/mac/TestExpectations
+++ b/LayoutTests/platform/mac/TestExpectations
@@ -1161,6 +1161,7 @@
# css3-conditionals support is not yet enabled.
webkit.org/b/86146 css3/supports.html
+webkit.org/b/104822 css3/supports-cssom.html
# CSS Device Adaptation is not enabled.
webkit.org/b/95959 css3/device-adapt [ Skip ]
diff --git a/LayoutTests/platform/qt/TestExpectations b/LayoutTests/platform/qt/TestExpectations
index 4ee9ebb..9f2787b 100644
--- a/LayoutTests/platform/qt/TestExpectations
+++ b/LayoutTests/platform/qt/TestExpectations
@@ -2396,6 +2396,7 @@
# css3-conditionals support is not yet enabled.
webkit.org/b/86146 css3/supports.html
+webkit.org/b/104822 css3/supports-cssom.html
# CSS Device Adaptation is not enabled.
webkit.org/b/95969 css3/device-adapt [ Skip ]
diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations
index 0183bd3..87c793d 100644
--- a/LayoutTests/platform/win/TestExpectations
+++ b/LayoutTests/platform/win/TestExpectations
@@ -2388,8 +2388,9 @@
#https://bugs.webkit.org/show_bug.cgi?id=99878
css3/flexbox/flexbox-baseline-margins.html
-# css3-conditionals support is not yet enabled. http://webkit.org/b/86146
+# css3-conditionals support is not yet enabled. http://webkit.org/b/86146 http://webkit.org/b/104822
css3/supports.html
+css3/supports-cssom.html
# https://bugs.webkit.org/show_bug.cgi?id=98169
http/tests/inspector/stacktraces
diff --git a/LayoutTests/platform/wincairo/TestExpectations b/LayoutTests/platform/wincairo/TestExpectations
index ac410b3d..6daea65 100644
--- a/LayoutTests/platform/wincairo/TestExpectations
+++ b/LayoutTests/platform/wincairo/TestExpectations
@@ -2893,8 +2893,9 @@
#https://bugs.webkit.org/show_bug.cgi?id=99878
css3/flexbox/flexbox-baseline-margins.html
-# css3-conditionals support is not yet enabled. http://webkit.org/b/86146
+# css3-conditionals support is not yet enabled. http://webkit.org/b/86146 http://webkit.org/b/104822
css3/supports.html
+css3/supports-cssom.html
# https://bugs.webkit.org/show_bug.cgi?id=98169
http/tests/inspector/stacktraces
diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations
index 25dd8ae..0a79ab6 100644
--- a/LayoutTests/platform/wk2/TestExpectations
+++ b/LayoutTests/platform/wk2/TestExpectations
@@ -345,6 +345,7 @@
# css3-conditionals support is not yet enabled.
webkit.org/b/86146 css3/supports.html
+webkit.org/b/104822 css3/supports-cssom.html
# Text Autosizing is not yet enabled.
# https://bugs.webkit.org/show_bug.cgi?id=84186
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index 4da16e6..2ee51c9 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -321,6 +321,7 @@
css/CSSStyleDeclaration.idl
css/CSSStyleRule.idl
css/CSSStyleSheet.idl
+ css/CSSSupportsRule.idl
css/CSSValue.idl
css/CSSValueList.idl
css/MediaList.idl
@@ -1055,6 +1056,7 @@
css/CSSSelectorList.cpp
css/CSSStyleRule.cpp
css/CSSStyleSheet.cpp
+ css/CSSSupportsRule.cpp
css/CSSTimingFunctionValue.cpp
css/CSSToStyleMap.cpp
css/CSSUnicodeRangeValue.cpp
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 1c66efa..373b270 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,94 @@
+2013-01-16 Pablo Flouret <pablof@motorola.com>
+
+ Implement CSSSupportsRule
+ https://bugs.webkit.org/show_bug.cgi?id=104822
+
+ Reviewed by Allan Sandfeld Jensen.
+
+ http://dev.w3.org/csswg/css3-conditional/#the-csssupportsrule-interface
+
+ Right now, @supports is not implemented as a proper CSSRule. Apart from
+ the CSSOM implications it gives wrong results when, for instance, an
+ @supports rule is nested inside a @media rule.
+
+ Test: css3/supports-cssom.html
+
+ * CMakeLists.txt:
+ * DerivedSources.cpp:
+ * DerivedSources.make:
+ * DerivedSources.pri:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.exp.in:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add CSSSupportsRule.* and associated files.
+
+ * bindings/js/JSCSSRuleCustom.cpp:
+ (WebCore::toJS):
+ * bindings/objc/DOMCSS.mm:
+ (kitClass):
+ * bindings/v8/custom/V8CSSRuleCustom.cpp:
+ (WebCore::wrap):
+ Create the correct wrappers for the rule.
+
+ * css/CSSGrammar.y.in:
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::createSupportsRule):
+ (WebCore::CSSParser::markSupportsRuleHeaderStart):
+ (WebCore::CSSParser::markSupportsRuleHeaderEnd):
+ * css/CSSParser.h:
+ Create the supports rule when parsing and add it where it corresponds,
+ instead of directly adding the child rules to the stylesheet.
+
+ * css/CSSPropertySourceData.h:
+ * css/CSSRule.h:
+ * css/CSSRule.idl:
+ Add SUPPORTS_RULE type to enums.
+
+ * css/CSSSupportsRule.cpp: Added.
+ (WebCore::CSSSupportsRule::CSSSupportsRule):
+ (WebCore::CSSSupportsRule::~CSSSupportsRule):
+ (WebCore::CSSSupportsRule::cssText):
+ (WebCore::CSSSupportsRule::conditionText):
+ * css/CSSSupportsRule.h: Added.
+ (WebCore::CSSSupportsRule::create):
+ * css/CSSSupportsRule.idl: Added.
+ DOM interface.
+
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::addChildRules):
+ Add rules included in the @supports rule.
+
+ * css/StyleResolver.cpp:
+ (WebCore::collectCSSOMWrappers):
+ Collect CSSSupportsRule wrappers.
+
+ * css/StyleRule.cpp:
+ (WebCore::StyleRuleBase::reportMemoryUsage):
+ (WebCore::StyleRuleBase::destroy):
+ (WebCore::StyleRuleBase::copy):
+ (WebCore::StyleRuleBase::createCSSOMWrapper):
+ (WebCore::StyleRuleSupports::StyleRuleSupports):
+ * css/StyleRule.h:
+ (StyleRuleBase):
+ (WebCore::StyleRuleBase::isSupportsRule):
+ (StyleRuleSupports):
+ (WebCore::StyleRuleSupports::create):
+ (WebCore::StyleRuleSupports::conditionText):
+ (WebCore::StyleRuleSupports::conditionIsSupported):
+ (WebCore::StyleRuleSupports::copy):
+ (WebCore::toStyleRuleSupports):
+ New subclass of StyleRuleBlock: StyleRuleSupports.
+
+ * css/StyleSheetContents.cpp:
+ (WebCore::childRulesHaveFailedOrCanceledSubresources):
+ * inspector/InspectorStyleSheet.cpp:
+ (flattenSourceData):
+ (WebCore::asCSSRuleList):
+ Handle @supports rules where needed.
+
2013-01-16 Kent Tamura <tkent@chromium.org>
INPUT_MULTIPLE_FIELDS_UI: Unable to edit a time field with step=86400, and confusing appearance
diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp
index a3d7f29..0fc1444 100644
--- a/Source/WebCore/DerivedSources.cpp
+++ b/Source/WebCore/DerivedSources.cpp
@@ -64,6 +64,7 @@
#include "JSCSSStyleDeclaration.cpp"
#include "JSCSSStyleRule.cpp"
#include "JSCSSStyleSheet.cpp"
+#include "JSCSSSupportsRule.cpp"
#include "JSCSSValue.cpp"
#include "JSCSSValueList.cpp"
#include "JSCustomEvent.cpp"
diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make
index f3a2a1b..1b205db 100644
--- a/Source/WebCore/DerivedSources.make
+++ b/Source/WebCore/DerivedSources.make
@@ -178,6 +178,7 @@
$(WebCore)/css/CSSStyleDeclaration.idl \
$(WebCore)/css/CSSStyleRule.idl \
$(WebCore)/css/CSSStyleSheet.idl \
+ $(WebCore)/css/CSSSupportsRule.idl \
$(WebCore)/css/CSSUnknownRule.idl \
$(WebCore)/css/CSSValue.idl \
$(WebCore)/css/CSSValueList.idl \
diff --git a/Source/WebCore/DerivedSources.pri b/Source/WebCore/DerivedSources.pri
index 6dfbd4e..a8b6c2a 100644
--- a/Source/WebCore/DerivedSources.pri
+++ b/Source/WebCore/DerivedSources.pri
@@ -198,6 +198,7 @@
$$PWD/css/CSSStyleDeclaration.idl \
$$PWD/css/CSSStyleRule.idl \
$$PWD/css/CSSStyleSheet.idl \
+ $$PWD/css/CSSSupportsRule.idl \
$$PWD/css/CSSValue.idl \
$$PWD/css/CSSValueList.idl \
$$PWD/css/MediaList.idl \
diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am
index c125dd4..5cabfe2 100644
--- a/Source/WebCore/GNUmakefile.list.am
+++ b/Source/WebCore/GNUmakefile.list.am
@@ -133,6 +133,8 @@
DerivedSources/WebCore/JSCSSStyleRule.h \
DerivedSources/WebCore/JSCSSStyleSheet.cpp \
DerivedSources/WebCore/JSCSSStyleSheet.h \
+ DerivedSources/WebCore/JSCSSSupportsRule.cpp \
+ DerivedSources/WebCore/JSCSSSupportsRule.h \
DerivedSources/WebCore/JSCSSValue.cpp \
DerivedSources/WebCore/JSCSSValue.h \
DerivedSources/WebCore/JSCSSValueList.cpp \
@@ -1329,6 +1331,7 @@
$(WebCore)/css/CSSStyleDeclaration.idl \
$(WebCore)/css/CSSStyleRule.idl \
$(WebCore)/css/CSSStyleSheet.idl \
+ $(WebCore)/css/CSSSupportsRule.idl \
$(WebCore)/css/CSSValue.idl \
$(WebCore)/css/CSSValueList.idl \
$(WebCore)/css/Counter.idl \
@@ -2592,6 +2595,8 @@
Source/WebCore/css/CSSStyleRule.h \
Source/WebCore/css/CSSStyleSheet.cpp \
Source/WebCore/css/CSSStyleSheet.h \
+ Source/WebCore/css/CSSSupportsRule.cpp \
+ Source/WebCore/css/CSSSupportsRule.h \
Source/WebCore/css/CSSTimingFunctionValue.cpp \
Source/WebCore/css/CSSTimingFunctionValue.h \
Source/WebCore/css/CSSToStyleMap.cpp \
diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri
index bc16847..800f469 100644
--- a/Source/WebCore/Target.pri
+++ b/Source/WebCore/Target.pri
@@ -287,6 +287,7 @@
css/CSSSegmentedFontFace.cpp \
css/CSSStyleRule.cpp \
css/CSSStyleSheet.cpp \
+ css/CSSSupportsRule.cpp \
css/CSSTimingFunctionValue.cpp \
css/CSSToStyleMap.cpp \
css/CSSUnicodeRangeValue.cpp \
@@ -1498,6 +1499,7 @@
css/CSSStyleDeclaration.h \
css/CSSStyleRule.h \
css/CSSStyleSheet.h \
+ css/CSSSupportsRule.h \
css/CSSTimingFunctionValue.h \
css/CSSToStyleMap.h \
css/CSSUnicodeRangeValue.h \
diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in
index afcd216..166cbfd 100644
--- a/Source/WebCore/WebCore.exp.in
+++ b/Source/WebCore/WebCore.exp.in
@@ -1576,6 +1576,7 @@
.objc_class_name_DOMCSSRuleList
.objc_class_name_DOMCSSStyleRule
.objc_class_name_DOMCSSStyleSheet
+.objc_class_name_DOMCSSSupportsRule
.objc_class_name_DOMCSSUnknownRule
.objc_class_name_DOMCSSValue
.objc_class_name_DOMCSSValueList
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index 065754f..a1c3f99 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -169,6 +169,7 @@
'css/CSSStyleDeclaration.idl',
'css/CSSStyleRule.idl',
'css/CSSStyleSheet.idl',
+ 'css/CSSSupportsRule.idl',
'css/CSSUnknownRule.idl',
'css/CSSValue.idl',
'css/CSSValueList.idl',
@@ -1505,6 +1506,8 @@
'css/CSSStyleRule.h',
'css/CSSStyleSheet.cpp',
'css/CSSStyleSheet.h',
+ 'css/CSSSupportsRule.cpp',
+ 'css/CSSSupportsRule.h',
'css/CSSTimingFunctionValue.cpp',
'css/CSSTimingFunctionValue.h',
'css/CSSToStyleMap.cpp',
@@ -5584,6 +5587,8 @@
'<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSStyleRuleInternal.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSStyleSheet.mm',
'<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSStyleSheetInternal.h',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSSupportsRule.mm',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSSupportsRuleInternal.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSUnknownRule.mm',
'<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSUnknownRuleInternal.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/DOMCSSValue.mm',
@@ -6144,6 +6149,8 @@
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSStyleRule.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSStyleSheet.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSStyleSheet.h',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSSupportsRule.cpp',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSSupportsRule.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSUnknownRule.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSUnknownRule.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSValue.cpp',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index db56b59..1656e53 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -2362,6 +2362,62 @@
>
</File>
<File
+ RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCSSSupportsRule.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCSSSupportsRule.h"
+ >
+ </File>
+ <File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\JSCSSValue.cpp"
>
<FileConfiguration
@@ -37366,6 +37422,62 @@
>
</File>
<File
+ RelativePath="..\css\CSSSupportsRule.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\css\CSSSupportsRule.h"
+ >
+ </File>
+ <File
RelativePath="..\css\CSSTimingFunctionValue.cpp"
>
<FileConfiguration
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index c9a790a..20ee741 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -6445,6 +6445,14 @@
FBD6AF8C15EF2604008B7110 /* BasicShapes.h in Headers */ = {isa = PBXBuildFile; fileRef = FBD6AF8315EF21A3008B7110 /* BasicShapes.h */; settings = {ATTRIBUTES = (Private, ); }; };
FBD6AF8D15EF260A008B7110 /* BasicShapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBD6AF8215EF21A3008B7110 /* BasicShapes.cpp */; };
FBF89045169E9F1F0052D86E /* CSSGroupingRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBF89044169E9F1F0052D86E /* CSSGroupingRule.cpp */; };
+ FC63BDB3167AABAC00F9380F /* CSSSupportsRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC63BDB0167AABAC00F9380F /* CSSSupportsRule.cpp */; };
+ FC63BDB4167AABAC00F9380F /* CSSSupportsRule.h in Sources */ = {isa = PBXBuildFile; fileRef = FC63BDB1167AABAC00F9380F /* CSSSupportsRule.h */; };
+ FC7E66E91680EF1F00283716 /* JSCSSSupportsRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FC84802D167AB444008CD100 /* JSCSSSupportsRule.cpp */; };
+ FC7E66EA1680EF2200283716 /* JSCSSSupportsRule.h in Sources */ = {isa = PBXBuildFile; fileRef = FC84802E167AB444008CD100 /* JSCSSSupportsRule.h */; };
+ FCD8832A16A49F8200962227 /* DOMCSSSupportsRule.h in Headers */ = {isa = PBXBuildFile; fileRef = FCD8832816A49F8200962227 /* DOMCSSSupportsRule.h */; };
+ FCD8832B16A49F8200962227 /* DOMCSSSupportsRule.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCD8832916A49F8200962227 /* DOMCSSSupportsRule.mm */; };
+ FCD8832C16A49FB000962227 /* DOMCSSSupportsRule.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = FCD8832816A49F8200962227 /* DOMCSSSupportsRule.h */; };
+ FCEBBAAB16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = FCEBBAAA16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h */; };
FD00D7A414A3F61900734011 /* SincResampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD00D7A214A3F61900734011 /* SincResampler.cpp */; };
FD00D7A514A3F61900734011 /* SincResampler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD00D7A314A3F61900734011 /* SincResampler.h */; };
FD06DFA5134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */; };
@@ -6774,6 +6782,7 @@
1ACD1B630B029739007E5016 /* DOMCSSStyleDeclarationInternal.h in Copy Generated Headers */,
85F74E090AA8DF8C000DC284 /* DOMCSSStyleRule.h in Copy Generated Headers */,
858C39BD0AA905EF00B187A4 /* DOMCSSStyleSheet.h in Copy Generated Headers */,
+ FCD8832C16A49FB000962227 /* DOMCSSSupportsRule.h in Copy Generated Headers */,
85F74E0A0AA8DF8C000DC284 /* DOMCSSUnknownRule.h in Copy Generated Headers */,
858C39B80AA905EF00B187A4 /* DOMCSSValue.h in Copy Generated Headers */,
858C39BA0AA905EF00B187A4 /* DOMCSSValueList.h in Copy Generated Headers */,
@@ -14024,6 +14033,14 @@
FBD6AF8615EF21D4008B7110 /* CSSBasicShapes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSBasicShapes.cpp; sourceTree = "<group>"; };
FBD6AF8715EF21D4008B7110 /* CSSBasicShapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSBasicShapes.h; sourceTree = "<group>"; };
FBF89044169E9F1F0052D86E /* CSSGroupingRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSGroupingRule.cpp; sourceTree = "<group>"; };
+ FC63BDB0167AABAC00F9380F /* CSSSupportsRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSSupportsRule.cpp; sourceTree = "<group>"; };
+ FC63BDB1167AABAC00F9380F /* CSSSupportsRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSSupportsRule.h; sourceTree = "<group>"; };
+ FC63BDB2167AABAC00F9380F /* CSSSupportsRule.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CSSSupportsRule.idl; sourceTree = "<group>"; };
+ FC84802D167AB444008CD100 /* JSCSSSupportsRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSSupportsRule.cpp; sourceTree = "<group>"; };
+ FC84802E167AB444008CD100 /* JSCSSSupportsRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSSupportsRule.h; sourceTree = "<group>"; };
+ FCD8832816A49F8200962227 /* DOMCSSSupportsRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMCSSSupportsRule.h; path = DOMCSSSupportsRule.h; sourceTree = "<group>"; };
+ FCD8832916A49F8200962227 /* DOMCSSSupportsRule.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DOMCSSSupportsRule.mm; path = DOMCSSSupportsRule.mm; sourceTree = "<group>"; };
+ FCEBBAAA16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMCSSSupportsRuleInternal.h; path = DOMCSSSupportsRuleInternal.h; sourceTree = "<group>"; };
FCEBCD711623A7910029965E /* CSSGrammar.y.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = CSSGrammar.y.in; sourceTree = "<group>"; };
FCEBCD721623A7910029965E /* CSSGrammar.y.includes */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = CSSGrammar.y.includes; sourceTree = "<group>"; };
FD00D7A214A3F61900734011 /* SincResampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SincResampler.cpp; sourceTree = "<group>"; };
@@ -16423,6 +16440,8 @@
85032DD40AA8C9BE007D3B7D /* DOMCSSStyleRule.mm */,
858C39260AA8FF9D00B187A4 /* DOMCSSStyleSheet.h */,
858C39270AA8FF9D00B187A4 /* DOMCSSStyleSheet.mm */,
+ FCD8832816A49F8200962227 /* DOMCSSSupportsRule.h */,
+ FCD8832916A49F8200962227 /* DOMCSSSupportsRule.mm */,
85032DD50AA8C9BE007D3B7D /* DOMCSSUnknownRule.h */,
85032DD60AA8C9BE007D3B7D /* DOMCSSUnknownRule.mm */,
858C381A0AA8E29600B187A4 /* DOMCSSValue.h */,
@@ -17122,6 +17141,7 @@
85E711440AC5D5340053270F /* DOMCSSStyleDeclarationInternal.h */,
85909CD90ACC7A7E00DF01F1 /* DOMCSSStyleRuleInternal.h */,
85909CDA0ACC7A7E00DF01F1 /* DOMCSSStyleSheetInternal.h */,
+ FCEBBAAA16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h */,
85909CDB0ACC7A7E00DF01F1 /* DOMCSSUnknownRuleInternal.h */,
85B498F20ADB336A00925CBB /* DOMCSSValueInternal.h */,
85909D280ACC7D5500DF01F1 /* DOMCSSValueListInternal.h */,
@@ -19241,6 +19261,8 @@
BC46C2050C0DDCA10020CFC3 /* JSCSSStyleRule.h */,
BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */,
BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */,
+ FC84802D167AB444008CD100 /* JSCSSSupportsRule.cpp */,
+ FC84802E167AB444008CD100 /* JSCSSSupportsRule.h */,
14CF78A309F58CBF00EB3665 /* JSCSSValue.cpp */,
14CF78A509F58CD800EB3665 /* JSCSSValue.h */,
A8D05FA90A23B30F005E7203 /* JSCSSValueList.cpp */,
@@ -21596,6 +21618,9 @@
A8EA80000A19516E00A8EF5F /* CSSStyleSheet.cpp */,
A8EA7FFF0A19516E00A8EF5F /* CSSStyleSheet.h */,
858C39100AA8FF0000B187A4 /* CSSStyleSheet.idl */,
+ FC63BDB0167AABAC00F9380F /* CSSSupportsRule.cpp */,
+ FC63BDB1167AABAC00F9380F /* CSSSupportsRule.h */,
+ FC63BDB2167AABAC00F9380F /* CSSSupportsRule.idl */,
BC80C9850CD294EE00A0B7B3 /* CSSTimingFunctionValue.cpp */,
BC80C9860CD294EE00A0B7B3 /* CSSTimingFunctionValue.h */,
A882DA1F1593846A000115ED /* CSSToStyleMap.cpp */,
@@ -23218,6 +23243,8 @@
85909CE20ACC7A7E00DF01F1 /* DOMCSSStyleRuleInternal.h in Headers */,
858C39280AA8FF9D00B187A4 /* DOMCSSStyleSheet.h in Headers */,
85909CE30ACC7A7E00DF01F1 /* DOMCSSStyleSheetInternal.h in Headers */,
+ FCD8832A16A49F8200962227 /* DOMCSSSupportsRule.h in Headers */,
+ FCEBBAAB16A4967A00FA20A6 /* DOMCSSSupportsRuleInternal.h in Headers */,
85032DE90AA8C9BE007D3B7D /* DOMCSSUnknownRule.h in Headers */,
85909CE40ACC7A7E00DF01F1 /* DOMCSSUnknownRuleInternal.h in Headers */,
858C381C0AA8E29600B187A4 /* DOMCSSValue.h in Headers */,
@@ -26687,6 +26714,8 @@
E4C1789A0EE6903800824D69 /* CSSSelectorList.cpp in Sources */,
A80E6CEF0A1989CA007FB8C5 /* CSSStyleRule.cpp in Sources */,
A8EA80080A19516E00A8EF5F /* CSSStyleSheet.cpp in Sources */,
+ FC63BDB3167AABAC00F9380F /* CSSSupportsRule.cpp in Sources */,
+ FC63BDB4167AABAC00F9380F /* CSSSupportsRule.h in Sources */,
BC80C9870CD294EE00A0B7B3 /* CSSTimingFunctionValue.cpp in Sources */,
A882DA201593846A000115ED /* CSSToStyleMap.cpp in Sources */,
371F53EA0D2704F900ECE0D5 /* CSSUnicodeRangeValue.cpp in Sources */,
@@ -26807,6 +26836,7 @@
85032DE60AA8C9BE007D3B7D /* DOMCSSStyleDeclaration.mm in Sources */,
85032DE80AA8C9BE007D3B7D /* DOMCSSStyleRule.mm in Sources */,
858C39290AA8FF9D00B187A4 /* DOMCSSStyleSheet.mm in Sources */,
+ FCD8832B16A49F8200962227 /* DOMCSSSupportsRule.mm in Sources */,
85032DEA0AA8C9BE007D3B7D /* DOMCSSUnknownRule.mm in Sources */,
858C381D0AA8E29600B187A4 /* DOMCSSValue.mm in Sources */,
858C383D0AA8ED8200B187A4 /* DOMCSSValueList.mm in Sources */,
@@ -27623,6 +27653,8 @@
BC46C2060C0DDCA10020CFC3 /* JSCSSStyleRule.cpp in Sources */,
E1AD14E81297377400ACA989 /* JSCSSStyleRuleCustom.cpp in Sources */,
BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */,
+ FC7E66E91680EF1F00283716 /* JSCSSSupportsRule.cpp in Sources */,
+ FC7E66EA1680EF2200283716 /* JSCSSSupportsRule.h in Sources */,
14CF78A409F58CBF00EB3665 /* JSCSSValue.cpp in Sources */,
BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */,
A8D05FAB0A23B30F005E7203 /* JSCSSValueList.cpp in Sources */,
diff --git a/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp b/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp
index 2a465dc..0d67d12 100644
--- a/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp
+++ b/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp
@@ -32,12 +32,14 @@
#include "CSSMediaRule.h"
#include "CSSPageRule.h"
#include "CSSStyleRule.h"
+#include "CSSSupportsRule.h"
#include "JSCSSCharsetRule.h"
#include "JSCSSFontFaceRule.h"
#include "JSCSSImportRule.h"
#include "JSCSSMediaRule.h"
#include "JSCSSPageRule.h"
#include "JSCSSStyleRule.h"
+#include "JSCSSSupportsRule.h"
#include "JSNode.h"
#include "JSWebKitCSSKeyframeRule.h"
#include "JSWebKitCSSKeyframesRule.h"
@@ -96,6 +98,11 @@
case CSSRule::WEBKIT_KEYFRAMES_RULE:
wrapper = CREATE_DOM_WRAPPER(exec, globalObject, WebKitCSSKeyframesRule, rule);
break;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case CSSRule::SUPPORTS_RULE:
+ wrapper = CREATE_DOM_WRAPPER(exec, globalObject, CSSSupportsRule, rule);
+ break;
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
case CSSRule::WEBKIT_VIEWPORT_RULE:
wrapper = CREATE_DOM_WRAPPER(exec, globalObject, WebKitCSSViewportRule, rule);
diff --git a/Source/WebCore/bindings/objc/DOMCSS.mm b/Source/WebCore/bindings/objc/DOMCSS.mm
index 3c1da823..65914ba 100644
--- a/Source/WebCore/bindings/objc/DOMCSS.mm
+++ b/Source/WebCore/bindings/objc/DOMCSS.mm
@@ -40,6 +40,9 @@
#import "DOMCSSStyleDeclaration.h"
#import "DOMCSSStyleRule.h"
#import "DOMCSSStyleSheet.h"
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+#import "DOMCSSSupportsRule.h"
+#endif
#import "DOMCSSUnknownRule.h"
#import "DOMCSSValueInternal.h"
#import "DOMCSSValueList.h"
@@ -99,6 +102,10 @@
return [DOMWebKitCSSKeyframesRule class];
case DOM_WEBKIT_KEYFRAME_RULE:
return [DOMWebKitCSSKeyframeRule class];
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case DOM_SUPPORTS_RULE:
+ return [DOMCSSSupportsRule class];
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
case DOM_WEBKIT_VIEWPORT_RULE:
return [DOMWebKitCSSViewportRule class];
diff --git a/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp
index d151cd8..6bf6eec 100644
--- a/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp
+++ b/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp
@@ -37,6 +37,9 @@
#include "V8CSSMediaRule.h"
#include "V8CSSPageRule.h"
#include "V8CSSStyleRule.h"
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+#include "V8CSSSupportsRule.h"
+#endif
#include "V8WebKitCSSKeyframeRule.h"
#include "V8WebKitCSSKeyframesRule.h"
#include "V8WebKitCSSRegionRule.h"
@@ -72,6 +75,10 @@
return wrap(static_cast<WebKitCSSKeyframeRule*>(impl), creationContext, isolate);
case CSSRule::WEBKIT_KEYFRAMES_RULE:
return wrap(static_cast<WebKitCSSKeyframesRule*>(impl), creationContext, isolate);
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case CSSRule::SUPPORTS_RULE:
+ return wrap(static_cast<CSSSupportsRule*>(impl), creationContext, isolate);
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
case CSSRule::WEBKIT_VIEWPORT_RULE:
return wrap(static_cast<WebKitCSSViewportRule*>(impl), creationContext, isolate);
diff --git a/Source/WebCore/css/CSSGrammar.y.in b/Source/WebCore/css/CSSGrammar.y.in
index 56814cd..6187d6c 100644
--- a/Source/WebCore/css/CSSGrammar.y.in
+++ b/Source/WebCore/css/CSSGrammar.y.in
@@ -464,6 +464,9 @@
| font_face
| media
| keyframes
+#if ENABLE_CSS3_CONDITIONAL_RULES
+ | supports
+#endif
#if ENABLE_CSS_DEVICE_ADAPTATION
| viewport
#endif
@@ -476,9 +479,6 @@
| namespace
| import
| region
-#if ENABLE_CSS3_CONDITIONAL_RULES
- | supports
-#endif
;
at_import_header_end_maybe_space:
@@ -676,13 +676,22 @@
#if ENABLE_CSS3_CONDITIONAL_RULES
supports:
- SUPPORTS_SYM maybe_space supports_condition '{' maybe_space block_rule_list save_block {
- CSSParser* p = static_cast<CSSParser*>(parser);
- if ($3 && $6 && p->m_styleSheet) {
- for (unsigned i = 0; i < $6->size(); i++)
- p->m_styleSheet->parserAppendRule($6->at(i).release());
- }
- $$ = 0;
+ before_supports_rule SUPPORTS_SYM maybe_space supports_condition at_supports_rule_header_end '{' at_rule_body_start maybe_space block_rule_list save_block {
+ $$ = parser->createSupportsRule($4, $9);
+ }
+ ;
+
+before_supports_rule:
+ /* empty */ {
+ parser->markRuleHeaderStart(CSSRuleSourceData::SUPPORTS_RULE);
+ parser->markSupportsRuleHeaderStart();
+ }
+ ;
+
+at_supports_rule_header_end:
+ /* empty */ {
+ parser->markRuleHeaderEnd();
+ parser->markSupportsRuleHeaderEnd();
}
;
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 3834f04..8ec14b1 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -10703,6 +10703,62 @@
return result;
}
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+StyleRuleBase* CSSParser::createSupportsRule(bool conditionIsSupported, RuleList* rules)
+{
+ m_allowImportRules = m_allowNamespaceDeclarations = false;
+
+ ASSERT(!m_supportsRuleDataStack->isEmpty());
+ RefPtr<CSSRuleSourceData> data = m_supportsRuleDataStack->last();
+ m_supportsRuleDataStack->removeLast();
+ if (m_supportsRuleDataStack->isEmpty())
+ m_supportsRuleDataStack.clear();
+
+ RefPtr<StyleRuleSupports> rule;
+ String conditionText;
+ unsigned conditionOffset = data->ruleHeaderRange.start + 9;
+ unsigned conditionLength = data->ruleHeaderRange.length() - 9;
+
+ if (is8BitSource())
+ conditionText = String(m_dataStart8.get() + conditionOffset, conditionLength).stripWhiteSpace();
+ else
+ conditionText = String(m_dataStart16.get() + conditionOffset, conditionLength).stripWhiteSpace();
+
+ if (rules)
+ rule = StyleRuleSupports::create(conditionText, conditionIsSupported, *rules);
+ else {
+ RuleList emptyRules;
+ rule = StyleRuleSupports::create(conditionText, conditionIsSupported, emptyRules);
+ }
+
+ StyleRuleSupports* result = rule.get();
+ m_parsedRules.append(rule.release());
+ processAndAddNewRuleToSourceTreeIfNeeded();
+
+ return result;
+}
+
+void CSSParser::markSupportsRuleHeaderStart()
+{
+ if (!m_supportsRuleDataStack)
+ m_supportsRuleDataStack = adoptPtr(new RuleSourceDataList());
+
+ RefPtr<CSSRuleSourceData> data = CSSRuleSourceData::create(CSSRuleSourceData::SUPPORTS_RULE);
+ data->ruleHeaderRange.start = tokenStartOffset();
+ m_supportsRuleDataStack->append(data);
+}
+
+void CSSParser::markSupportsRuleHeaderEnd()
+{
+ ASSERT(!m_supportsRuleDataStack->isEmpty());
+
+ if (is8BitSource())
+ m_supportsRuleDataStack->last()->ruleHeaderRange.end = tokenStart<LChar>() - m_dataStart8.get();
+ else
+ m_supportsRuleDataStack->last()->ruleHeaderRange.end = tokenStart<UChar>() - m_dataStart16.get();
+}
+#endif
+
CSSParser::RuleList* CSSParser::createRuleList()
{
OwnPtr<RuleList> list = adoptPtr(new RuleList);
diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h
index 57e7cc4..17e3a7d 100644
--- a/Source/WebCore/css/CSSParser.h
+++ b/Source/WebCore/css/CSSParser.h
@@ -292,6 +292,11 @@
StyleRuleBase* createPageRule(PassOwnPtr<CSSParserSelector> pageSelector);
StyleRuleBase* createRegionRule(Vector<OwnPtr<CSSParserSelector> >* regionSelector, RuleList* rules);
StyleRuleBase* createMarginAtRule(CSSSelector::MarginBoxType);
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ StyleRuleBase* createSupportsRule(bool conditionIsSupported, RuleList*);
+ void markSupportsRuleHeaderStart();
+ void markSupportsRuleHeaderEnd();
+#endif
#if ENABLE(SHADOW_DOM)
StyleRuleBase* createHostRule(RuleList* rules);
#endif
@@ -566,6 +571,10 @@
RefPtr<CSSCalcValue> m_parsedCalculation;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ OwnPtr<RuleSourceDataList> m_supportsRuleDataStack;
+#endif
+
// defines units allowed for a certain property, used in parseUnit
enum Units {
FUnknown = 0x0000,
diff --git a/Source/WebCore/css/CSSPropertySourceData.h b/Source/WebCore/css/CSSPropertySourceData.h
index e12aaae..2c90f83 100644
--- a/Source/WebCore/css/CSSPropertySourceData.h
+++ b/Source/WebCore/css/CSSPropertySourceData.h
@@ -97,7 +97,8 @@
KEYFRAMES_RULE,
REGION_RULE,
HOST_RULE,
- VIEWPORT_RULE
+ VIEWPORT_RULE,
+ SUPPORTS_RULE
};
static PassRefPtr<CSSRuleSourceData> create(Type type)
diff --git a/Source/WebCore/css/CSSRule.h b/Source/WebCore/css/CSSRule.h
index 0758e74..4f01bdd 100644
--- a/Source/WebCore/css/CSSRule.h
+++ b/Source/WebCore/css/CSSRule.h
@@ -50,6 +50,9 @@
// <https://bugs.webkit.org/show_bug.cgi?id=71293>.
WEBKIT_KEYFRAMES_RULE,
WEBKIT_KEYFRAME_RULE,
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ SUPPORTS_RULE = 12,
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
WEBKIT_VIEWPORT_RULE = 15,
#endif
diff --git a/Source/WebCore/css/CSSRule.idl b/Source/WebCore/css/CSSRule.idl
index af118fe..30b1c21 100644
--- a/Source/WebCore/css/CSSRule.idl
+++ b/Source/WebCore/css/CSSRule.idl
@@ -37,6 +37,9 @@
const unsigned short PAGE_RULE = 6;
const unsigned short WEBKIT_KEYFRAMES_RULE = 7;
const unsigned short WEBKIT_KEYFRAME_RULE = 8;
+#if defined(ENABLE_CSS3_CONDITIONAL_RULES) && ENABLE_CSS3_CONDITIONAL_RULES
+ const unsigned short SUPPORTS_RULE = 12;
+#endif
#if defined(ENABLE_CSS_DEVICE_ADAPTATION) && ENABLE_CSS_DEVICE_ADAPTATION
const unsigned short WEBKIT_VIEWPORT_RULE = 15;
#endif
diff --git a/Source/WebCore/css/CSSSupportsRule.cpp b/Source/WebCore/css/CSSSupportsRule.cpp
new file mode 100644
index 0000000..2602ffc
--- /dev/null
+++ b/Source/WebCore/css/CSSSupportsRule.cpp
@@ -0,0 +1,71 @@
+/* Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Motorola Mobility Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSSupportsRule.h"
+
+#include "CSSParser.h"
+#include "CSSRule.h"
+#include "CSSRuleList.h"
+#include "CSSStyleSheet.h"
+#include "ExceptionCode.h"
+#include "StyleRule.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/MemoryInstrumentationVector.h>
+#include <wtf/text/StringBuilder.h>
+
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+
+namespace WebCore {
+
+CSSSupportsRule::CSSSupportsRule(StyleRuleSupports* supportsRule, CSSStyleSheet* parent)
+ : CSSGroupingRule(supportsRule, parent)
+{
+}
+
+String CSSSupportsRule::cssText() const
+{
+ StringBuilder result;
+
+ result.append("@supports ");
+ result.append(conditionText());
+ result.append(" {\n");
+ appendCssTextForItems(result);
+ result.append('}');
+
+ return result.toString();
+}
+
+String CSSSupportsRule::conditionText() const
+{
+ return toStyleRuleSupports(m_groupRule.get())->conditionText();
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/CSSSupportsRule.h b/Source/WebCore/css/CSSSupportsRule.h
new file mode 100644
index 0000000..7c5e244
--- /dev/null
+++ b/Source/WebCore/css/CSSSupportsRule.h
@@ -0,0 +1,63 @@
+/* Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Motorola Mobility Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSSupportsRule_h
+#define CSSSupportsRule_h
+
+#include "CSSGroupingRule.h"
+
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+
+namespace WebCore {
+
+class CSSRule;
+class StyleRuleSupports;
+
+class CSSSupportsRule : public CSSGroupingRule {
+public:
+ static PassRefPtr<CSSSupportsRule> create(StyleRuleSupports* rule, CSSStyleSheet* sheet)
+ {
+ return adoptRef(new CSSSupportsRule(rule, sheet));
+ }
+
+ virtual ~CSSSupportsRule() { }
+
+ virtual CSSRule::Type type() const OVERRIDE { return SUPPORTS_RULE; }
+ virtual String cssText() const OVERRIDE;
+
+ String conditionText() const;
+
+private:
+ CSSSupportsRule(StyleRuleSupports*, CSSStyleSheet*);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS3_CONDITIONAL_RULES)
+
+#endif // CSSSupportsRule_h
diff --git a/Source/WebCore/css/CSSSupportsRule.idl b/Source/WebCore/css/CSSSupportsRule.idl
new file mode 100644
index 0000000..c533882
--- /dev/null
+++ b/Source/WebCore/css/CSSSupportsRule.idl
@@ -0,0 +1,39 @@
+/* Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Motorola Mobility Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=CSS3_CONDITIONAL_RULES
+] interface CSSSupportsRule : CSSRule {
+ readonly attribute CSSRuleList cssRules;
+ readonly attribute DOMString conditionText;
+
+ unsigned long insertRule(in [Optional=DefaultIsUndefined] DOMString rule,
+ in [Optional=DefaultIsUndefined] unsigned long index) raises(DOMException);
+ void deleteRule(in [Optional=DefaultIsUndefined] unsigned long index) raises(DOMException);
+};
+
diff --git a/Source/WebCore/css/RuleSet.cpp b/Source/WebCore/css/RuleSet.cpp
index d7b520b..a7c32df 100644
--- a/Source/WebCore/css/RuleSet.cpp
+++ b/Source/WebCore/css/RuleSet.cpp
@@ -320,6 +320,10 @@
resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(rule));
}
#endif
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rule)->conditionIsSupported())
+ addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags);
+#endif
}
}
diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp
index 8d75a93..a3d17ec 100644
--- a/Source/WebCore/css/StyleResolver.cpp
+++ b/Source/WebCore/css/StyleResolver.cpp
@@ -48,6 +48,7 @@
#include "CSSSelectorList.h"
#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
+#include "CSSSupportsRule.h"
#include "CSSTimingFunctionValue.h"
#include "CSSValueList.h"
#if ENABLE(CSS_VARIABLES)
@@ -2638,6 +2639,11 @@
case CSSRule::MEDIA_RULE:
collectCSSOMWrappers(wrapperMap, static_cast<CSSMediaRule*>(cssRule));
break;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case CSSRule::SUPPORTS_RULE:
+ collectCSSOMWrappers(wrapperMap, static_cast<CSSSupportsRule*>(cssRule));
+ break;
+#endif
#if ENABLE(CSS_REGIONS)
case CSSRule::WEBKIT_REGION_RULE:
collectCSSOMWrappers(wrapperMap, static_cast<WebKitCSSRegionRule*>(cssRule));
diff --git a/Source/WebCore/css/StyleRule.cpp b/Source/WebCore/css/StyleRule.cpp
index 43e6a5e..b437933 100644
--- a/Source/WebCore/css/StyleRule.cpp
+++ b/Source/WebCore/css/StyleRule.cpp
@@ -28,6 +28,7 @@
#include "CSSMediaRule.h"
#include "CSSPageRule.h"
#include "CSSStyleRule.h"
+#include "CSSSupportsRule.h"
#include "CSSUnknownRule.h"
#include "StyleRuleImport.h"
#include "WebCoreMemoryInstrumentation.h"
@@ -81,6 +82,9 @@
case Keyframes:
static_cast<const StyleRuleKeyframes*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
return;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case Supports:
+#endif
#if ENABLE(SHADOW_DOM)
case Host:
static_cast<const StyleRuleBlock*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
@@ -118,6 +122,11 @@
case Media:
delete static_cast<StyleRuleMedia*>(this);
return;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case Supports:
+ delete static_cast<StyleRuleSupports*>(this);
+ return;
+#endif
#if ENABLE(CSS_REGIONS)
case Region:
delete static_cast<StyleRuleRegion*>(this);
@@ -162,6 +171,10 @@
return static_cast<const StyleRuleFontFace*>(this)->copy();
case Media:
return static_cast<const StyleRuleMedia*>(this)->copy();
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case Supports:
+ return static_cast<const StyleRuleSupports*>(this)->copy();
+#endif
#if ENABLE(CSS_REGIONS)
case Region:
return static_cast<const StyleRuleRegion*>(this)->copy();
@@ -210,6 +223,11 @@
case Media:
rule = CSSMediaRule::create(static_cast<StyleRuleMedia*>(self), parentSheet);
break;
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case Supports:
+ rule = CSSSupportsRule::create(static_cast<StyleRuleSupports*>(self), parentSheet);
+ break;
+#endif
#if ENABLE(CSS_REGIONS)
case Region:
rule = WebKitCSSRegionRule::create(static_cast<StyleRuleRegion*>(self), parentSheet);
@@ -404,6 +422,23 @@
info.addMember(m_mediaQueries);
}
+
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules)
+ : StyleRuleBlock(Supports, adoptRules)
+ , m_conditionText(conditionText)
+ , m_conditionIsSupported(conditionIsSupported)
+{
+}
+
+StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o)
+ : StyleRuleBlock(o)
+ , m_conditionText(o.m_conditionText)
+ , m_conditionIsSupported(o.m_conditionIsSupported)
+{
+}
+#endif
+
StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules)
: StyleRuleBlock(Region, adoptRules)
{
diff --git a/Source/WebCore/css/StyleRule.h b/Source/WebCore/css/StyleRule.h
index 7464b1f..9498233 100644
--- a/Source/WebCore/css/StyleRule.h
+++ b/Source/WebCore/css/StyleRule.h
@@ -49,6 +49,9 @@
#if ENABLE(SHADOW_DOM)
Host,
#endif
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ Supports = 12,
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
Viewport = 15,
#endif
@@ -63,6 +66,9 @@
bool isPageRule() const { return type() == Page; }
bool isStyleRule() const { return type() == Style; }
bool isRegionRule() const { return type() == Region; }
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ bool isSupportsRule() const { return type() == Supports; }
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
bool isViewportRule() const { return type() == Viewport; }
#endif
@@ -215,6 +221,27 @@
RefPtr<MediaQuerySet> m_mediaQueries;
};
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+class StyleRuleSupports : public StyleRuleBlock {
+public:
+ static PassRefPtr<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules)
+ {
+ return adoptRef(new StyleRuleSupports(conditionText, conditionIsSupported, adoptRules));
+ }
+
+ String conditionText() const { return m_conditionText; }
+ bool conditionIsSupported() const { return m_conditionIsSupported; }
+ PassRefPtr<StyleRuleSupports> copy() const { return adoptRef(new StyleRuleSupports(*this)); }
+
+private:
+ StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules);
+ StyleRuleSupports(const StyleRuleSupports&);
+
+ String m_conditionText;
+ bool m_conditionIsSupported;
+};
+#endif
+
class StyleRuleRegion : public StyleRuleBlock {
public:
static PassRefPtr<StyleRuleRegion> create(Vector<OwnPtr<CSSParserSelector> >* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules)
@@ -281,6 +308,14 @@
return static_cast<const StyleRuleMedia*>(rule);
}
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+inline const StyleRuleSupports* toStyleRuleSupports(const StyleRuleBlock* rule)
+{
+ ASSERT(!rule || rule->isSupportsRule());
+ return static_cast<const StyleRuleSupports*>(rule);
+}
+#endif
+
inline const StyleRuleRegion* toStyleRuleRegion(const StyleRuleBlock* rule)
{
ASSERT(!rule || rule->isRegionRule());
diff --git a/Source/WebCore/css/StyleSheetContents.cpp b/Source/WebCore/css/StyleSheetContents.cpp
index 6b7c0c5..67b0c1d 100644
--- a/Source/WebCore/css/StyleSheetContents.cpp
+++ b/Source/WebCore/css/StyleSheetContents.cpp
@@ -456,6 +456,9 @@
case StyleRuleBase::Unknown:
case StyleRuleBase::Charset:
case StyleRuleBase::Keyframe:
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ case StyleRuleBase::Supports:
+#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
case StyleRuleBase::Viewport:
#endif
diff --git a/Source/WebCore/inspector/InspectorStyleSheet.cpp b/Source/WebCore/inspector/InspectorStyleSheet.cpp
index c5283d5..ce98879 100644
--- a/Source/WebCore/inspector/InspectorStyleSheet.cpp
+++ b/Source/WebCore/inspector/InspectorStyleSheet.cpp
@@ -37,6 +37,7 @@
#include "CSSRuleList.h"
#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
+#include "CSSSupportsRule.h"
#include "ContentSecurityPolicy.h"
#include "Document.h"
#include "Element.h"
@@ -109,6 +110,10 @@
target->append(data);
else if (data->type == CSSRuleSourceData::MEDIA_RULE)
flattenSourceData(&data->childRules, target);
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ else if (data->type == CSSRuleSourceData::SUPPORTS_RULE)
+ flattenSourceData(&data->childRules, target);
+#endif
}
}
@@ -209,6 +214,11 @@
if (rule->type() == CSSRule::WEBKIT_KEYFRAMES_RULE)
return static_cast<WebKitCSSKeyframesRule*>(rule)->cssRules();
+#if ENABLE(CSS3_CONDITIONAL_RULES)
+ if (rule->type() == CSSRule::SUPPORTS_RULE)
+ return static_cast<CSSSupportsRule*>(rule)->cssRules();
+#endif
+
return 0;
}