Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1131)

Unified Diff: Source/core/html/HTMLElement.cpp

Issue 524593003: Resolve direction correctly when dir attribute is not in a defined state Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Splitting CL into 2 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index f9dff426403e18215fdd92b3f3597386140f0978..d50a2cc97fbfbb428865b40f3bbaa26984b3e912 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -188,10 +188,11 @@ void HTMLElement::collectStyleForPresentationAttribute(const QualifiedName& name
if (equalIgnoringCase(value, "auto"))
addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
else {
- if (isValidDirAttribute(value))
+ if (!isValidDirAttribute(value)) {
tkent 2014/09/09 06:37:00 Looks incorrect. If the value is "auto", we need t
esprehn 2014/09/09 10:20:13 Doesn't that happen inside the direction() method?
Sunil Ratnu 2014/09/09 10:41:57 This check is for the case when the dir attribute
+ addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, direction());
+ } else {
addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value);
- else
- addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, "ltr");
+ }
if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueEmbed);
}
@@ -683,6 +684,26 @@ TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con
return directionality();
}
+String HTMLElement::direction() const
tkent 2014/09/09 06:37:00 This function should return TextDirection because
Sunil Ratnu 2014/09/09 10:41:57 Done.
+{
+ for (const HTMLElement* element = this; element; element = Traversal<HTMLElement>::firstAncestor(*element)) {
+ const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAttr);
+ if (dirAttributeValue.isNull())
+ continue;
+
+ if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dirAttributeValue, "ltr"))
+ return dirAttributeValue;
+
+ if (equalIgnoringCase(dirAttributeValue, "auto")) {
+ bool isAuto;
+ TextDirection textDirection = element->directionalityIfhasDirAutoAttribute(isAuto);
+ return textDirection == RTL ? "rtl" : "ltr";
+ }
+ }
+
+ return "ltr";
+}
+
TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const
{
if (isHTMLInputElement(*this)) {

Powered by Google App Engine
This is Rietveld 408576698