Diff
Modified: trunk/LayoutTests/ChangeLog (139593 => 139594)
--- trunk/LayoutTests/ChangeLog 2013-01-14 09:44:20 UTC (rev 139593)
+++ trunk/LayoutTests/ChangeLog 2013-01-14 09:49:56 UTC (rev 139594)
@@ -1,3 +1,13 @@
+2013-01-14 Pablo Flouret <pab...@motorola.com>
+
+ Allow nesting of at-rules
+ https://bugs.webkit.org/show_bug.cgi?id=106696
+
+ Reviewed by Allan Sandfeld Jensen.
+
+ * fast/css/nested-at-rules-expected.txt: Added.
+ * fast/css/nested-at-rules.html: Added.
+
2013-01-13 Noel Gordon <noel.gor...@gmail.com>
[chromium] Optimize svg/W3C-SVG-1.1/animate-elem-80-t.svg everywhere
Added: trunk/LayoutTests/fast/css/nested-at-rules-expected.txt (0 => 139594)
--- trunk/LayoutTests/fast/css/nested-at-rules-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/nested-at-rules-expected.txt 2013-01-14 09:49:56 UTC (rev 139594)
@@ -0,0 +1,31 @@
+Test nested at-rules.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+rules = document.styleSheets[1].cssRules
+PASS rules.length is 2
+PASS rules[0].type is CSSRule.STYLE_RULE
+PASS rules[1].type is CSSRule.MEDIA_RULE
+PASS rules[1].cssRules.length is 2
+PASS rules[1].cssRules[0].type is CSSRule.MEDIA_RULE
+PASS rules[1].cssRules[0].cssRules.length is 3
+PASS rules[1].cssRules[0].cssRules[0].type is CSSRule.FONT_FACE_RULE
+PASS rules[1].cssRules[0].cssRules[1].type is CSSRule.PAGE_RULE
+PASS rules[1].cssRules[0].cssRules[2].type is CSSRule.STYLE_RULE
+PASS rules[1].cssRules[0].cssRules[0].parentStyleSheet is document.styleSheets[1]
+PASS rules[1].cssRules[0].cssRules[1].parentStyleSheet is document.styleSheets[1]
+PASS rules[1].cssRules[0].cssRules[2].parentStyleSheet is document.styleSheets[1]
+PASS rules[1].cssRules[1].type is CSSRule.MEDIA_RULE
+PASS rules[1].cssRules[1].cssRules.length is 1
+PASS rules[1].cssRules[1].cssRules[0].type is CSSRule.MEDIA_RULE
+rules[1].cssRules[1].insertRule('@media all { @page :left { top: 0; } }', 1)
+PASS rules[1].cssRules[1].cssRules.length is 2
+PASS rules[1].cssRules[1].cssRules[1].type is CSSRule.MEDIA_RULE
+PASS rules[1].cssRules[1].cssRules[1].cssRules[0].type is CSSRule.PAGE_RULE
+PASS getComputedStyle(document.getElementById('t0')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t1')).content is "UNTOUCHED"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/nested-at-rules.html (0 => 139594)
--- trunk/LayoutTests/fast/css/nested-at-rules.html (rev 0)
+++ trunk/LayoutTests/fast/css/nested-at-rules.html 2013-01-14 09:49:56 UTC (rev 139594)
@@ -0,0 +1,63 @@
+<html>
+<head>
+<script src=""
+<style>
+.test {
+ content: "UNTOUCHED";
+}
+
+@media all {
+ @media all {
+ @font-face {
+ src: local('Courier');
+ font-family: Courier;
+ }
+
+ @page :left { top: 0 }
+
+ #t0 { content: "APPLIED" }
+
+ @import url("../../cssom/resources/import.css");
+ @charset "UTF-8";
+ @namespace "";
+ }
+ @media all {
+ @media none {
+ #t1 { content: "APPLIED" }
+ }
+ }
+}
+</style>
+<body>
+<span id=t0 class=test></span>
+<span id=t1 class=test></span>
+<script>
+description("Test nested at-rules.");
+
+evalAndLog("rules = document.styleSheets[1].cssRules");
+shouldEvaluateTo("rules.length", 2);
+
+shouldBe("rules[0].type", "CSSRule.STYLE_RULE");
+shouldBe("rules[1].type", "CSSRule.MEDIA_RULE");
+shouldEvaluateTo("rules[1].cssRules.length", 2);
+shouldBe("rules[1].cssRules[0].type", "CSSRule.MEDIA_RULE");
+shouldEvaluateTo("rules[1].cssRules[0].cssRules.length", 3);
+shouldBe("rules[1].cssRules[0].cssRules[0].type", "CSSRule.FONT_FACE_RULE");
+shouldBe("rules[1].cssRules[0].cssRules[1].type", "CSSRule.PAGE_RULE");
+shouldBe("rules[1].cssRules[0].cssRules[2].type", "CSSRule.STYLE_RULE");
+shouldBe("rules[1].cssRules[0].cssRules[0].parentStyleSheet", "document.styleSheets[1]");
+shouldBe("rules[1].cssRules[0].cssRules[1].parentStyleSheet", "document.styleSheets[1]");
+shouldBe("rules[1].cssRules[0].cssRules[2].parentStyleSheet", "document.styleSheets[1]");
+
+shouldBe("rules[1].cssRules[1].type", "CSSRule.MEDIA_RULE");
+shouldEvaluateTo("rules[1].cssRules[1].cssRules.length", 1);
+shouldBe("rules[1].cssRules[1].cssRules[0].type", "CSSRule.MEDIA_RULE");
+evalAndLog("rules[1].cssRules[1].insertRule('@media all { @page :left { top: 0; } }', 1)");
+shouldEvaluateTo("rules[1].cssRules[1].cssRules.length", 2);
+shouldBe("rules[1].cssRules[1].cssRules[1].type", "CSSRule.MEDIA_RULE");
+shouldBe("rules[1].cssRules[1].cssRules[1].cssRules[0].type", "CSSRule.PAGE_RULE");
+
+shouldBeEqualToString("getComputedStyle(document.getElementById('t0')).content", "APPLIED");
+shouldBeEqualToString("getComputedStyle(document.getElementById('t1')).content", "UNTOUCHED");
+</script>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (139593 => 139594)
--- trunk/Source/WebCore/ChangeLog 2013-01-14 09:44:20 UTC (rev 139593)
+++ trunk/Source/WebCore/ChangeLog 2013-01-14 09:49:56 UTC (rev 139594)
@@ -1,3 +1,28 @@
+2013-01-14 Pablo Flouret <pab...@motorola.com>
+
+ Allow nesting of at-rules
+ https://bugs.webkit.org/show_bug.cgi?id=106696
+
+ Reviewed by Allan Sandfeld Jensen.
+
+ http://dev.w3.org/csswg/css3-conditional/ introduces the
+ concept of grouping rules, and allows for them to be nested. In
+ particular, this change affects @media (and is needed for @supports as
+ well).
+
+ Test: fast/css/nested-at-rules.html
+
+ * css/CSSGrammar.y.in:
+ Move media to the block_valid_rule list.
+
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::addRegionRule):
+ (WebCore::RuleSet::addChildRules):
+ (WebCore::RuleSet::addRulesFromSheet):
+ * css/RuleSet.h:
+ Rip out the rule-adding loop into a new method, for added
+ cleanliness and recursing.
+
2013-01-14 Eugene Klyuchnikov <eus...@chromium.org>
Web Inspector: [Network] Add domain column
Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (139593 => 139594)
--- trunk/Source/WebCore/css/CSSGrammar.y.in 2013-01-14 09:44:20 UTC (rev 139593)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in 2013-01-14 09:49:56 UTC (rev 139594)
@@ -462,6 +462,7 @@
ruleset
| page
| font_face
+ | media
| keyframes
#if ENABLE_CSS_DEVICE_ADAPTATION
| viewport
@@ -474,7 +475,6 @@
| invalid_at
| namespace
| import
- | media
| region
#if ENABLE_CSS3_CONDITIONAL_RULES
| supports
Modified: trunk/Source/WebCore/css/RuleSet.cpp (139593 => 139594)
--- trunk/Source/WebCore/css/RuleSet.cpp 2013-01-14 09:44:20 UTC (rev 139593)
+++ trunk/Source/WebCore/css/RuleSet.cpp 2013-01-14 09:49:56 UTC (rev 139594)
@@ -258,6 +258,7 @@
regionRuleSet->m_ruleCount = m_ruleCount;
// Collect the region rules into a rule set
+ // FIXME: Should this add other types of rules? (i.e. use addChildRules() directly?)
const Vector<RefPtr<StyleRuleBase> >& childRules = regionRule->childRules();
AddRuleFlags addRuleFlags = hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleCanUseFastCheckSelector | RuleIsInRegionRule);
@@ -272,70 +273,19 @@
m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet.release()));
}
-void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope)
+void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope, bool hasDocumentSecurityOrigin, AddRuleFlags addRuleFlags)
{
- ASSERT(sheet);
-
- const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules();
- for (unsigned i = 0; i < importRules.size(); ++i) {
- StyleRuleImport* importRule = importRules[i].get();
- if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.eval(importRule->mediaQueries(), resolver)))
- addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope);
- }
- bool hasDocumentSecurityOrigin = resolver && resolver->document()->securityOrigin()->canRequest(sheet->baseURL());
- AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelector : 0));
-
- const Vector<RefPtr<StyleRuleBase> >& rules = sheet->childRules();
for (unsigned i = 0; i < rules.size(); ++i) {
StyleRuleBase* rule = rules[i].get();
- ASSERT(!rule->isImportRule());
if (rule->isStyleRule())
addStyleRule(static_cast<StyleRule*>(rule), addRuleFlags);
else if (rule->isPageRule())
addPageRule(static_cast<StyleRulePage*>(rule));
else if (rule->isMediaRule()) {
StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule);
-
- if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), resolver))) {
- // Traverse child elements of the @media rule.
- const Vector<RefPtr<StyleRuleBase> >& childRules = mediaRule->childRules();
- for (unsigned j = 0; j < childRules.size(); ++j) {
- StyleRuleBase* childRule = childRules[j].get();
- if (childRule->isStyleRule())
- addStyleRule(static_cast<StyleRule*>(childRule), addRuleFlags);
- else if (childRule->isPageRule())
- addPageRule(static_cast<StyleRulePage*>(childRule));
- else if (childRule->isFontFaceRule() && resolver) {
- // Add this font face to our set.
- // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for the moment.
- if (scope)
- continue;
- const StyleRuleFontFace* fontFaceRule = static_cast<StyleRuleFontFace*>(childRule);
- resolver->fontSelector()->addFontFaceRule(fontFaceRule);
- resolver->invalidateMatchedPropertiesCache();
- } else if (childRule->isKeyframesRule() && resolver) {
- // Add this keyframe rule to our set.
- // FIXME(BUG 72462): We don't add @keyframe rules of scoped style sheets for the moment.
- if (scope)
- continue;
- resolver->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(childRule));
- } else if (childRule->isRegionRule() && resolver) {
- // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style sheets for the moment.
- if (scope)
- continue;
- addRegionRule(static_cast<StyleRuleRegion*>(childRule), hasDocumentSecurityOrigin);
- }
-#if ENABLE(CSS_DEVICE_ADAPTATION)
- else if (childRule->isViewportRule() && resolver && !resolver->affectedByViewportChange()) {
- // @viewport should not be scoped.
- if (scope)
- continue;
- resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(childRule));
- }
-#endif
- } // for rules
- } // if rules
+ if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), resolver)))
+ addChildRules(mediaRule->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags);
} else if (rule->isFontFaceRule() && resolver) {
// Add this font face to our set.
// FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for the moment.
@@ -371,6 +321,24 @@
}
#endif
}
+}
+
+void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope)
+{
+ ASSERT(sheet);
+
+ const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules();
+ for (unsigned i = 0; i < importRules.size(); ++i) {
+ StyleRuleImport* importRule = importRules[i].get();
+ if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.eval(importRule->mediaQueries(), resolver)))
+ addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope);
+ }
+
+ bool hasDocumentSecurityOrigin = resolver && resolver->document()->securityOrigin()->canRequest(sheet->baseURL());
+ AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelector : 0));
+
+ addChildRules(sheet->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags);
+
if (m_autoShrinkToFitEnabled)
shrinkToFit();
}
Modified: trunk/Source/WebCore/css/RuleSet.h (139593 => 139594)
--- trunk/Source/WebCore/css/RuleSet.h 2013-01-14 09:44:20 UTC (rev 139593)
+++ trunk/Source/WebCore/css/RuleSet.h 2013-01-14 09:49:56 UTC (rev 139594)
@@ -129,6 +129,9 @@
void reportMemoryUsage(MemoryObjectInfo*) const;
+private:
+ void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEvaluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSecurityOrigin, AddRuleFlags);
+
public:
RuleSet();