Set the AncestorHasDirAuto flag for all new text nodes that need it. Bug 847127, r=ehsan
authorSimon Montagu <smontagu@smontagu.org>
Thu, 07 Mar 2013 22:53:07 +0200
changeset 124150 e81b56f0c6897785916db0f2e69a1c1aa18fe04b
parent 124149 916cfe5fa71149bca9828840a3fc22a5be00d96c
child 124151 ac291d349daaaa6dfd6eca8a2e099c3fdc380e3f
push id24408
push userryanvm@gmail.com
push dateFri, 08 Mar 2013 04:58:11 +0000
treeherdermozilla-central@cb432984d5ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs847127
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Set the AncestorHasDirAuto flag for all new text nodes that need it. Bug 847127, r=ehsan
content/base/public/DirectionalityUtils.h
content/base/src/DirectionalityUtils.cpp
--- a/content/base/public/DirectionalityUtils.h
+++ b/content/base/public/DirectionalityUtils.h
@@ -85,17 +85,17 @@ void WalkDescendantsClearAncestorDirAuto
 void SetDirectionFromChangedTextNode(nsIContent* aTextNode, uint32_t aOffset,
                                      const PRUnichar* aBuffer, uint32_t aLength,
                                      bool aNotify);
 
 /**
  * When a text node is appended to an element, find any ancestors with dir=auto
  * whose directionality will be determined by the text node
  */
-void SetDirectionFromNewTextNode(nsTextNode* aTextNode);
+void SetDirectionFromNewTextNode(nsIContent* aTextNode);
 
 /**
  * When a text node is removed from a document, find any ancestors whose
  * directionality it determined and redetermine their directionality
  */
 void ResetDirectionSetByTextNode(nsTextNode* aTextNode);
 
 /**
--- a/content/base/src/DirectionalityUtils.cpp
+++ b/content/base/src/DirectionalityUtils.cpp
@@ -709,18 +709,16 @@ void SetAncestorDirectionIfAuto(nsINode*
              "Must be a text node");
 
   Element* parent = aTextNode->GetParentElement();
   while (parent && parent->NodeOrAncestorHasDirAuto()) {
     if (DoesNotParticipateInAutoDirection(parent) || parent->HasFixedDir()) {
       break;
     }
 
-    aTextNode->SetAncestorHasDirAuto();
-
     if (parent->HasDirAuto()) {
       bool resetDirection = false;
 
       if (!parent->HasDirAutoSet()) {
         // Fast path if parent's direction is not yet set by any descendant
         resetDirection = true;
       } else {
         // If parent's direction is already set, we need to know if
@@ -807,22 +805,27 @@ SetDirectionFromChangedTextNode(nsIConte
       nsTextNodeDirectionalityMap::UpdateTextNodeDirection(aTextNode, newDir);
     } else {
       SetAncestorDirectionIfAuto(aTextNode, newDir, aNotify);
     }
   }
 }
 
 void
-SetDirectionFromNewTextNode(nsTextNode* aTextNode)
+SetDirectionFromNewTextNode(nsIContent* aTextNode)
 {
   if (!NodeAffectsDirAutoAncestor(aTextNode)) {
     return;
   }
 
+  Element* parent = aTextNode->GetParentElement();
+  if (parent && parent->NodeOrAncestorHasDirAuto()) {
+    aTextNode->SetAncestorHasDirAuto();
+  }
+
   Directionality dir = GetDirectionFromText(aTextNode->GetText());
   if (dir != eDir_NotSet) {
     SetAncestorDirectionIfAuto(aTextNode, dir);
   }
 }
 
 void
 ResetDirectionSetByTextNode(nsTextNode* aTextNode)