Index: Source/core/html/HTMLElement.cpp |
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp |
index f9dff426403e18215fdd92b3f3597386140f0978..a992d415331ca28cf87b15c93d63aa4948391f79 100644 |
--- a/Source/core/html/HTMLElement.cpp |
+++ b/Source/core/html/HTMLElement.cpp |
@@ -185,13 +185,15 @@ void HTMLElement::collectStyleForPresentationAttribute(const QualifiedName& name |
} else if (equalIgnoringCase(value, "false")) |
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, CSSValueNone); |
} else if (name == dirAttr) { |
- if (equalIgnoringCase(value, "auto")) |
+ if (equalIgnoringCase(value, "auto")) { |
addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this)); |
- else { |
- if (isValidDirAttribute(value)) |
+ } else { |
+ if (!isValidDirAttribute(value)) { |
+ const AtomicString& dirValue = determineDirection() == RTL ? "rtl" : "ltr"; |
tkent
2014/09/10 01:08:52
I realized that we didn't need to compute directio
Sunil Ratnu
2014/09/10 04:33:00
Done.
|
+ addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, dirValue); |
+ } else { |
addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value); |
tkent
2014/09/10 01:08:52
This can set "auto" to "direction" CSS property.
Sunil Ratnu
2014/09/10 04:33:00
We don't have this code part now since whenever we
|
- else |
- addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, "ltr"); |
+ } |
if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag)) |
addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueEmbed); |
} |
@@ -683,6 +685,33 @@ TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con |
return directionality(); |
} |
+// FIXME: Implement directionality for input type='tel' when it is supported |
+// [Currently it is not supported in any of the browsers]. |
+// Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#the-directionality |
+TextDirection HTMLElement::determineDirection() const |
+{ |
+ 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")) |
+ return RTL; |
+ |
+ if (equalIgnoringCase(dirAttributeValue, "ltr")) |
+ return LTR; |
+ |
+ if (equalIgnoringCase(dirAttributeValue, "auto")) { |
+ bool isAuto; |
+ return element->directionalityIfhasDirAutoAttribute(isAuto); |
+ } |
+ } |
+ |
+ return LTR; |
+} |
+ |
+// FIXME: This implementation deviates from the spec in case of 'textarea' having 'auto' attribute. |
+// Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#the-directionality |
TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const |
{ |
if (isHTMLInputElement(*this)) { |