Bug 631352. Changes to @lang need to restyle all descendants. r=dbaron, a=blocker
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Feb 2011 16:30:57 -0500
changeset 62171 b715a81bb7aaa2069838cf6a1bcaf5c7cf06e14c
parent 62170 0399ff8f614c598d722836b49ffcb56dfa6f6c59
child 62172 db3e06f7018efefdccd1bbddb12c97d2a96fda6f
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdbaron, blocker
bugs631352
milestone2.0b12pre
Bug 631352. Changes to @lang need to restyle all descendants. r=dbaron, a=blocker
layout/reftests/bugs/631352-1-ref.html
layout/reftests/bugs/631352-1.html
layout/reftests/bugs/reftest.list
layout/style/nsCSSRuleProcessor.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/631352-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <div>This text should be visible</div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/631352-1.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <style>
+      div:not(:lang(foo)) { display: none; }
+    </style>
+  </head>
+  <body onload="document.body.offsetWidth; document.body.lang = 'foo'">
+    <div>This text should be visible</div>
+  </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1604,8 +1604,9 @@ HTTP(..) == 621253-1-externalFilter.html
 == 621253-1-internalFilter.html 621253-1-ref.html # XXX update reference case after bug 541270 is fixed
 HTTP(..) == 621253-2-externalFilter.html 621253-2-ref.html
 == 621253-2-internalFilter.html 621253-2-ref.html
 HTTP(..) == 619511-1.html 619511-1-ref.html
 random-if(winWidget) == 621918-1.svg 621918-1-ref.svg # 1-pixel diacritic positioning discrepancy in rotated text (may depend on platform fonts)
 random-if(winWidget) HTTP(..) == 621918-2.svg 621918-2-ref.svg # same 1px issue as above, and HTTP(..) for filters.svg, used to mask antialiasing issues where glyphs touch
 == 625409-1.html 625409-1-ref.html
 == 627393-1.html about:blank
+== 631352-1.html 631352-1-ref.html
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2568,16 +2568,24 @@ nsCSSRuleProcessor::HasAttributeDependen
     // check for the lwtheme and lwthemetextcolor attribute on root XUL elements
     if ((aData->mAttribute == nsGkAtoms::lwtheme ||
          aData->mAttribute == nsGkAtoms::lwthemetextcolor) &&
         aData->mNameSpaceID == kNameSpaceID_XUL &&
         aData->mElement == aData->mElement->GetOwnerDoc()->GetRootElement())
       {
         data.change = nsRestyleHint(data.change | eRestyle_Subtree);
       }
+
+    // We don't know the namespace of the attribute, and xml:lang applies to
+    // all elements.  If the lang attribute changes, we need to restyle our
+    // whole subtree, since the :lang selector on our descendants can examine
+    // our lang attribute.
+    if (aData->mAttribute == nsGkAtoms::lang) {
+      data.change = nsRestyleHint(data.change | eRestyle_Subtree);
+    }
   }
 
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   // Since we get both before and after notifications for attributes, we
   // don't have to ignore aData->mAttribute while matching.  Just check
   // whether we have selectors relevant to aData->mAttribute that we
   // match.  If this is the before change notification, that will catch