[CSS Regions] In region styling (@-webkit-region) the position for CSS rules is incor...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2012 15:16:38 +0000 (15:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2012 15:16:38 +0000 (15:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81901

Patch by Mihai Balan <mibalan@adobe.com> on 2012-03-26
Reviewed by Antti Koivisto.

Source/WebCore:

Right now CSS rules position does not take into account rules that are inside a @-webkit-region
declaration, leading to buggy behavior where rules that appear later in the document are superseded
by rules that appear earlier in the document (opposite as how things should be). The fix updates
the "global" rules counter once the rules in a @-webkit-region declaration have been added.

Tests: fast/regions/region-style-rule-position-expected.html
       fast/regions/region-style-rule-position.html

* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::collectMatchingRulesForList):

LayoutTests:

Ref tests for bug #81901. Testing that CSS rules position is properly computed when having multiple
@-webkit-region declarations.

* fast/regions/region-style-rule-position-expected.html: Added.
* fast/regions/region-style-rule-position.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112099 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/regions/region-style-rule-position-expected.html [new file with mode: 0644]
LayoutTests/fast/regions/region-style-rule-position.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleSelector.cpp

index 7100f35efe6153c3996e2676675b5e9b7c7dc57d..d18e5f91f1f7dd4eda920073748a548e7abc1742 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-26  Mihai Balan  <mibalan@adobe.com>
+
+        [CSS Regions] In region styling (@-webkit-region) the position for CSS rules is incorrectly computed
+        https://bugs.webkit.org/show_bug.cgi?id=81901
+
+        Reviewed by Antti Koivisto.
+
+        Ref tests for bug #81901. Testing that CSS rules position is properly computed when having multiple
+        @-webkit-region declarations.
+
+        * fast/regions/region-style-rule-position-expected.html: Added.
+        * fast/regions/region-style-rule-position.html: Added.
+
 2012-03-26  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] Unreviewed gardening. Remove tests, because the original change was rolled out.
 2012-03-26  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] Unreviewed gardening. Remove tests, because the original change was rolled out.
diff --git a/LayoutTests/fast/regions/region-style-rule-position-expected.html b/LayoutTests/fast/regions/region-style-rule-position-expected.html
new file mode 100644 (file)
index 0000000..2651f5b
--- /dev/null
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+       <head>
+               <style>
+               p {
+                       margin: 0;
+               }
+               .lime {
+                       background-color: lime;
+               }
+               .content {
+                       margin-top: 1em;
+                       width: 10em;
+                       height: 10em;
+                       background-color: lightgray;
+               }
+               </style>
+       </head>
+       <body>
+               <p class='lime'>Text that is not flowed - should be green</p>
+               <div class='content'>
+                       <p class='lime'>Paragraph that *is* flowed - should be green, too</p>
+                       <p class='lime'>Paragraph that *is* flowed - should be green, too</p>
+               </div>
+       </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/regions/region-style-rule-position.html b/LayoutTests/fast/regions/region-style-rule-position.html
new file mode 100644 (file)
index 0000000..f8d287c
--- /dev/null
@@ -0,0 +1,53 @@
+<!doctype html>
+<html>
+       <head>
+               <style>
+               p {
+                       margin: 0;
+               }
+               p.body {
+                       background-color: red;
+               }
+               p.body {
+                       background-color: lime;
+               }
+
+               .content {
+                       -webkit-flow-into: f;
+               }
+               #r {
+                       -webkit-flow-from: f;
+                       margin-top: 1em;
+                       width: 10em;
+                       height: 10em;
+                       background-color: lightgray;
+               }
+
+               @-webkit-region #r {
+                       * {
+                               background-color: blue;
+                       }
+                       p.region, #para {
+                               background-color: red;
+                       }
+                       #para {
+                               background-color: red;
+                       }
+               }
+               @-webkit-region #r {
+                       p.region, #para {
+                               background-color: lime;
+                       }
+               }
+               </style>
+       </head>
+       <body>
+               <p class='body'>Text that is not flowed - should be green</p>
+               <div class='content'>
+                       <p class='region'>Paragraph that *is* flowed - should be green, too</p>
+                       <p id='para'>Paragraph that *is* flowed - should be green, too</p>
+               </div>
+
+               <div id='r'/></div>
+       </body>
+</html>
\ No newline at end of file
index 58bb8cf6dd201734eb3913d063539e155d8be436..b8a6d1bbbfd4081246e9a8dc64e9509b59d52d5a 100644 (file)
@@ -1,3 +1,21 @@
+2012-03-26  Mihai Balan  <mibalan@adobe.com>
+
+        [CSS Regions] In region styling (@-webkit-region) the position for CSS rules is incorrectly computed
+        https://bugs.webkit.org/show_bug.cgi?id=81901
+
+        Reviewed by Antti Koivisto.
+
+        Right now CSS rules position does not take into account rules that are inside a @-webkit-region
+        declaration, leading to buggy behavior where rules that appear later in the document are superseded
+        by rules that appear earlier in the document (opposite as how things should be). The fix updates
+        the "global" rules counter once the rules in a @-webkit-region declaration have been added.
+
+        Tests: fast/regions/region-style-rule-position-expected.html
+               fast/regions/region-style-rule-position.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+
 2012-03-26  Pierre Rossi  <pierre.rossi@nokia.com>
 
         [Qt] Disable focus ring in the mobile theme.
 2012-03-26  Pierre Rossi  <pierre.rossi@nokia.com>
 
         [Qt] Disable focus ring in the mobile theme.
index 5cf0830f1ba299310ca0222169497f41127936a3..62ca7e0e735708649dec93bc3c9c5d8a0697152d 100644 (file)
@@ -2437,6 +2437,8 @@ void RuleSet::addRegionRule(WebKitCSSRegionRule* regionRule)
         if (regionStylingRule->isStyleRule())
             regionRuleSet->addStyleRule(static_cast<CSSStyleRule*>(regionStylingRule)->styleRule(), true, true);
     }
         if (regionStylingRule->isStyleRule())
             regionRuleSet->addStyleRule(static_cast<CSSStyleRule*>(regionStylingRule)->styleRule(), true, true);
     }
+    // Update the "global" rule count so that proper order is maintained
+    m_ruleCount = regionRuleSet->m_ruleCount;
 
     m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet));
 }
 
     m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet));
 }