Bug 1228882 - Don't assume that the textnode has changed when checking whether any textnode descendants determine the directionality of a dir=auto ancestor; r=peterv, a=lizzard
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 08 Mar 2016 15:54:01 -0500
changeset 325524 54836a65a622ddbefa6dd19b1a33168f392dab72
parent 325523 0371dd431b20709b0111b8dab2719f40ce066ffe
child 325525 30de9ac21a783228a1bb6b3d5920050824cbc58f
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, lizzard
bugs1228882
milestone47.0a2
Bug 1228882 - Don't assume that the textnode has changed when checking whether any textnode descendants determine the directionality of a dir=auto ancestor; r=peterv, a=lizzard
dom/base/DirectionalityUtils.cpp
--- a/dom/base/DirectionalityUtils.cpp
+++ b/dom/base/DirectionalityUtils.cpp
@@ -565,21 +565,22 @@ public:
   static uint32_t UpdateTextNodeDirection(nsINode* aTextNode,
                                           Directionality aDir)
   {
     MOZ_ASSERT(aTextNode->HasTextNodeDirectionalityMap(),
                "Map missing in UpdateTextNodeDirection");
     return GetDirectionalityMap(aTextNode)->UpdateAutoDirection(aDir);
   }
 
-  static void ResetTextNodeDirection(nsINode* aTextNode)
+  static void ResetTextNodeDirection(nsINode* aTextNode,
+                                     nsINode* aChangedTextNode)
   {
     MOZ_ASSERT(aTextNode->HasTextNodeDirectionalityMap(),
                "Map missing in ResetTextNodeDirection");
-    GetDirectionalityMap(aTextNode)->ResetAutoDirection(aTextNode);
+    GetDirectionalityMap(aTextNode)->ResetAutoDirection(aChangedTextNode);
   }
 
   static void EnsureMapIsClearFor(nsINode* aTextNode)
   {
     if (aTextNode->HasTextNodeDirectionalityMap()) {
       GetDirectionalityMap(aTextNode)->EnsureMapIsClear(aTextNode);
     }
   }
@@ -676,17 +677,17 @@ WalkDescendantsResetAutoDirection(Elemen
   nsIContent* child = aElement->GetFirstChild();
   while (child) {
     if (child->HasDirAuto()) {
       child = child->GetNextNonChildNode(aElement);
       continue;
     }
 
     if (child->HasTextNodeDirectionalityMap()) {
-      nsTextNodeDirectionalityMap::ResetTextNodeDirection(child);
+      nsTextNodeDirectionalityMap::ResetTextNodeDirection(child, nullptr);
       nsTextNodeDirectionalityMap::EnsureMapIsClearFor(child);
     }
     child = child->GetNextNode(aElement);
   }
 }
 
 void
 WalkDescendantsSetDirAuto(Element* aElement, bool aNotify)
@@ -836,17 +837,17 @@ TextNodeChangedDirection(nsIContent* aTe
 {
   Directionality newDir = GetDirectionFromText(aTextNode->GetText());
   if (newDir == eDir_NotSet) {
     if (aOldDir != eDir_NotSet && aTextNode->HasTextNodeDirectionalityMap()) {
       // This node used to have a strong directional character but no
       // longer does. ResetTextNodeDirection() will re-resolve the
       // directionality of any elements whose directionality was
       // determined by this node.
-      nsTextNodeDirectionalityMap::ResetTextNodeDirection(aTextNode);
+      nsTextNodeDirectionalityMap::ResetTextNodeDirection(aTextNode, aTextNode);
     }
   } else {
     // This node has a strong directional character. If it has a
     // TextNodeDirectionalityMap property, it already determines the
     // directionality of some element(s), so call UpdateTextNodeDirection to
     // reresolve their directionality. If it has no map, or if
     // UpdateTextNodeDirection returns zero, indicating that the map is
     // empty, call SetAncestorDirectionIfAuto to find ancestor elements
@@ -883,17 +884,17 @@ ResetDirectionSetByTextNode(nsTextNode* 
 {
   if (!NodeAffectsDirAutoAncestor(aTextNode)) {
     nsTextNodeDirectionalityMap::EnsureMapIsClearFor(aTextNode);
     return;
   }
 
   Directionality dir = GetDirectionFromText(aTextNode->GetText());
   if (dir != eDir_NotSet && aTextNode->HasTextNodeDirectionalityMap()) {
-    nsTextNodeDirectionalityMap::ResetTextNodeDirection(aTextNode);
+    nsTextNodeDirectionalityMap::ResetTextNodeDirection(aTextNode, aTextNode);
   }
 }
 
 void
 SetDirectionalityFromValue(Element* aElement, const nsAString& value,
                            bool aNotify)
 {
   Directionality dir = GetDirectionFromText(PromiseFlatString(value).get(),