Bug 1467964: Make NodeAffectsDirAutoAncestor do what it claims re. anonymous nodes. r?smaug
nsComboboxControlFrame creates an anonymous text-node, which isn't supposed to
change the directionality of the parent.
MozReview-Commit-ID: LgL5APThZiK
--- a/dom/base/DirectionalityUtils.cpp
+++ b/dom/base/DirectionalityUtils.cpp
@@ -273,27 +273,36 @@ GetDirectionFromChar(uint32_t ch)
return eDir_LTR;
default:
return eDir_NotSet;
}
}
inline static bool
-NodeAffectsDirAutoAncestor(nsINode* aTextNode)
+NodeAffectsDirAutoAncestor(nsIContent* aTextNode)
{
Element* parent = aTextNode->GetParentElement();
+ if (!parent ||
+ DoesNotParticipateInAutoDirection(parent) ||
+ !parent->NodeOrAncestorHasDirAuto()) {
+ return false;
+ }
+
+ if (!aTextNode->IsInAnonymousSubtree()) {
+ return true;
+ }
+
// In the anonymous content, we limit our implementation to only
// allow the children text node of the direct dir=auto parent in
- // the same anonymous subtree to affact the direction.
- return (parent &&
- !DoesNotParticipateInAutoDirection(parent) &&
- parent->NodeOrAncestorHasDirAuto() &&
- (!aTextNode->IsInAnonymousSubtree() ||
- parent->HasDirAuto()));
+ // the same anonymous subtree to affect the direction.
+ //
+ // FIXME(emilio): Probably we should disallow native anonymous content
+ // entirely from this condition.
+ return parent->HasDirAuto() && !aTextNode->IsRootOfAnonymousSubtree();
}
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/layout/base/crashtests/1467964.html
@@ -0,0 +1,2 @@
+<select dir='auto'>
+<option dir='auto'>ࡦ
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -536,8 +536,9 @@ load 1453196.html
load 1453342.html
load 1453702.html
pref(dom.webcomponents.shadowdom.enabled,true) load 1461749.html
load 1461812.html
load 1462412.html
load 1463940.html
pref(dom.webcomponents.shadowdom.enabled,true) HTTP load 1464641.html
load 1464737.html
+load 1467964.html