Bug 1377826 - Don't allow anonymous text node to affect ancestor direction. r?ehsan draft
authorXidorn Quan <me@upsuper.org>
Fri, 07 Jul 2017 11:49:42 +1000
changeset 605075 6bf4622cca48dd1db630eee4b734483067577284
parent 605073 49d16ad3e2cf34cc787526206dca2255a37a933e
child 636389 42820b51a5bf359598b112a23bbf11f64906e09a
push id67293
push userxquan@mozilla.com
push dateFri, 07 Jul 2017 02:00:42 +0000
reviewersehsan
bugs1377826
milestone56.0a1
Bug 1377826 - Don't allow anonymous text node to affect ancestor direction. r?ehsan Given that elements in anonymous subtree have already been excluded from participating in auto direction, it shouldn't make anything worse to also exclude anonymous text node from that. MozReview-Commit-ID: DJKiHqkvVvJ
dom/base/DirectionalityUtils.cpp
dom/base/crashtests/1377826.html
dom/base/crashtests/crashtests.list
--- a/dom/base/DirectionalityUtils.cpp
+++ b/dom/base/DirectionalityUtils.cpp
@@ -281,22 +281,24 @@ GetDirectionFromChar(uint32_t ch)
     case eCharType_LeftToRight:
       return eDir_LTR;
 
     default:
       return eDir_NotSet;
   }
 }
 
-inline static bool NodeAffectsDirAutoAncestor(nsINode* aTextNode)
+inline static bool
+NodeAffectsDirAutoAncestor(nsINode* aTextNode)
 {
   Element* parent = aTextNode->GetParentElement();
   return (parent &&
           !DoesNotParticipateInAutoDirection(parent) &&
-          parent->NodeOrAncestorHasDirAuto());
+          parent->NodeOrAncestorHasDirAuto() &&
+          !aTextNode->IsInAnonymousSubtree());
 }
 
 Directionality
 GetDirectionFromText(const char16_t* aText, const uint32_t aLength,
                      uint32_t* aFirstStrong)
 {
   const char16_t* start = aText;
   const char16_t* end = aText + aLength;
new file mode 100644
--- /dev/null
+++ b/dom/base/crashtests/1377826.html
@@ -0,0 +1,5 @@
+<li id='a' dir='auto'>
+<select>
+<option dir='rtl'>
+&#x8C3;
+</html>
--- a/dom/base/crashtests/crashtests.list
+++ b/dom/base/crashtests/crashtests.list
@@ -209,12 +209,13 @@ pref(dom.IntersectionObserver.enabled,tr
 pref(dom.IntersectionObserver.enabled,true) load 1326194-2.html
 pref(dom.IntersectionObserver.enabled,true) load 1332939.html
 pref(dom.webcomponents.enabled,true) load 1341693.html
 pref(dom.IntersectionObserver.enabled,true) load 1353529.xul
 pref(dom.IntersectionObserver.enabled,true) load 1369363.xul
 load 1370072.html
 pref(clipboard.autocopy,true) load 1370737.html
 pref(dom.IntersectionObserver.enabled,true) load 1370968.html
+load 1377826.html
 load structured_clone_container_throws.html
 HTTP(..) load xhr_abortinprogress.html
 load xhr_empty_datauri.html
 load xhr_html_nullresponse.html