Distinguish between bdi with default auto direction and with explicit auto-direction. Bug 832644, r=ehsan, a=bajaj
authorSimon Montagu <smontagu@smontagu.org>
Sat, 26 Jan 2013 23:14:14 -0800
changeset 127432 8516612e2d80856e809f8e554f4f6566593dea77
parent 127431 e368c539e1a82dbe43238c30731c52f6240461b6
child 127433 0b46a4903d4c137960e092dfaac6ef895ad10329
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, bajaj
bugs832644
milestone20.0a2
Distinguish between bdi with default auto direction and with explicit auto-direction. Bug 832644, r=ehsan, a=bajaj
content/base/src/DirectionalityUtils.cpp
--- a/content/base/src/DirectionalityUtils.cpp
+++ b/content/base/src/DirectionalityUtils.cpp
@@ -236,16 +236,22 @@ DoesNotParticipateInAutoDirection(const 
 {
   nsINodeInfo* nodeInfo = aElement->NodeInfo();
   return (!aElement->IsHTML() ||
           nodeInfo->Equals(nsGkAtoms::script) ||
           nodeInfo->Equals(nsGkAtoms::style) ||
           nodeInfo->Equals(nsGkAtoms::textarea));
 }
 
+static inline bool
+IsBdiWithoutDirAuto(const Element* aElement)
+{
+  return aElement->IsHTML(nsGkAtoms::bdi) && !aElement->HasDirAuto();
+}
+
 /**
  * Returns the directionality of a Unicode character
  */
 static Directionality
 GetDirectionFromChar(uint32_t ch)
 {
   switch(mozilla::unicode::GetBidiCat(ch)) {
     case eCharType_RightToLeft:
@@ -627,31 +633,31 @@ WalkDescendantsResetAutoDirection(Elemen
     child = child->GetNextNode(aElement);
   }
 }
 
 void
 WalkDescendantsSetDirAuto(Element* aElement, bool aNotify)
 {
   if (!DoesNotParticipateInAutoDirection(aElement) &&
-      !aElement->IsHTML(nsGkAtoms::bdi)) {
+      !IsBdiWithoutDirAuto(aElement)) {
 
     bool setAncestorDirAutoFlag =
 #ifdef DEBUG
       true;
 #else
       !aElement->AncestorHasDirAuto();
 #endif
 
     if (setAncestorDirAutoFlag) {
       nsIContent* child = aElement->GetFirstChild();
       while (child) {
         if (child->IsElement() &&
             (DoesNotParticipateInAutoDirection(child->AsElement()) ||
-             child->NodeInfo()->Equals(nsGkAtoms::bdi) ||
+             IsBdiWithoutDirAuto(child->AsElement()) ||
              child->HasFixedDir())) {
           child = child->GetNextNonChildNode(aElement);
           continue;
         }
 
         MOZ_ASSERT(!aElement->AncestorHasDirAuto() ||
                    child->AncestorHasDirAuto(),
                    "AncestorHasDirAuto set on node but not its children");
@@ -710,17 +716,17 @@ void SetAncestorDirectionIfAuto(nsINode*
           static_cast<nsINode*>(parent->GetProperty(nsGkAtoms::dirAutoSetBy));
         if (!directionWasSetByTextNode) {
           resetDirection = true;
         } else if (directionWasSetByTextNode != aTextNode) {
           nsIContent* child = aTextNode->GetNextNode(parent);
           while (child) {
             if (child->IsElement() &&
                 (DoesNotParticipateInAutoDirection(child->AsElement()) ||
-                 child->NodeInfo()->Equals(nsGkAtoms::bdi) ||
+                 IsBdiWithoutDirAuto(child->AsElement()) ||
                  child->HasFixedDir())) {
               child = child->GetNextNonChildNode(parent);
               continue;
             }
 
             if (child == directionWasSetByTextNode) {
               // we found the node that set the element's direction after our
               // text node, so we need to reset the direction
@@ -878,17 +884,17 @@ SetDirOnBind(mozilla::dom::Element* aEle
     if (child) {
       // If we are binding an element to the tree that already has descendants,
       // and the parent has NodeHasDirAuto or NodeAncestorHasDirAuto, we need
       // to set NodeAncestorHasDirAuto on all the element's descendants, except
       // for nodes that don't affect the direction of their ancestors.
       do {
         if (child->IsElement() &&
             (DoesNotParticipateInAutoDirection(child->AsElement()) ||
-             child->NodeInfo()->Equals(nsGkAtoms::bdi) ||
+             IsBdiWithoutDirAuto(child->AsElement()) ||
              child->HasFixedDir())) {
           child = child->GetNextNonChildNode(aElement);
           continue;
         }
 
         child->SetAncestorHasDirAuto();
         child = child->GetNextNode(aElement);
       } while (child);