Set AncestorHasDirAuto on the descendants of a <bdi> having its dir attribute removed or set to an invalid value. Bug 849732, r=ehsan, a=bajaj
authorSimon Montagu <smontagu@smontagu.org>
Sun, 24 Mar 2013 11:27:03 +0200
changeset 132550 ed84088d095a5e3caa9b202378a10877651287ec
parent 132549 681bd5e6a343686164e77e8e49f487ed0c49200c
child 132551 233cb89fe45ec5bfe47e008d988ffb27e2f99ebe
push id2336
push usersmontagu@mozilla.com
push dateThu, 04 Apr 2013 07:13:00 +0000
treeherdermozilla-beta@ed84088d095a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, bajaj
bugs849732
milestone21.0
Set AncestorHasDirAuto on the descendants of a <bdi> having its dir attribute removed or set to an invalid value. Bug 849732, r=ehsan, a=bajaj
content/base/src/DirectionalityUtils.cpp
--- a/content/base/src/DirectionalityUtils.cpp
+++ b/content/base/src/DirectionalityUtils.cpp
@@ -657,18 +657,23 @@ WalkDescendantsResetAutoDirection(Elemen
     }
     child = child->GetNextNode(aElement);
   }
 }
 
 void
 WalkDescendantsSetDirAuto(Element* aElement, bool aNotify)
 {
-  if (!DoesNotParticipateInAutoDirection(aElement) &&
-      !IsBdiWithoutDirAuto(aElement)) {
+  // Only test for DoesNotParticipateInAutoDirection -- in other words, if
+  // aElement is a <bdi> which is having its dir attribute set to auto (or
+  // removed or set to an invalid value, which are equivalent to dir=auto for
+  // <bdi>, we *do* want to set AncestorHasDirAuto on its descendants, unlike
+  // in SetDirOnBind where we don't propagate AncestorHasDirAuto to a <bdi>
+  // being bound to an existing node with dir=auto.
+  if (!DoesNotParticipateInAutoDirection(aElement)) {
 
     bool setAncestorDirAutoFlag =
 #ifdef DEBUG
       true;
 #else
       !aElement->AncestorHasDirAuto();
 #endif
 
@@ -679,17 +684,17 @@ WalkDescendantsSetDirAuto(Element* aElem
             DoesNotAffectDirectionOfAncestors(child->AsElement())) {
           child = child->GetNextNonChildNode(aElement);
           continue;
         }
 
         MOZ_ASSERT(!aElement->AncestorHasDirAuto() ||
                    child->AncestorHasDirAuto(),
                    "AncestorHasDirAuto set on node but not its children");
-        child->SetHasDirAuto();
+        child->SetAncestorHasDirAuto();
         child = child->GetNextNode(aElement);
       }
     }
   }
 
   nsINode* textNode = WalkDescendantsSetDirectionFromText(aElement, aNotify);
   if (textNode) {
     nsTextNodeDirectionalityMap::AddEntryToMap(textNode, aElement);