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

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: Fix failing test Created 6 years, 1 month 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
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLTextAreaElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index 8eb8c19b2410213c17b090ca9e38f3d5d6fed2ce..efb44044516f3b1dacd2a72a29e508c4f0787018 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -211,10 +211,12 @@ void HTMLElement::collectStyleForPresentationAttribute(const QualifiedName& name
if (equalIgnoringCase(value, "auto"))
addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
else {
- if (isValidDirAttribute(value))
+ if (isValidDirAttribute(value)) {
addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value);
- else
- addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, "ltr");
Sunil Ratnu 2014/11/21 12:21:08 Hi tkent, We need to keep this else check here bec
tkent 2014/11/25 01:27:24 I don't think parent lookup is a right solution. H
Sunil Ratnu 2014/11/25 05:43:25 The above approach does not work here. The above m
tkent 2014/11/25 05:56:09 Please investigate why it didn't work, and find an
+ } else {
+ const AtomicString& dirValue = determineDirection() == RTL ? "rtl" : "ltr";
+ addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, dirValue);
+ }
if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag))
addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueEmbed);
}
@@ -715,6 +717,30 @@ TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con
return directionality();
}
+// FIXME: Implement directionality for input type='tel'.
+// Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#the-directionality.
+TextDirection HTMLElement::determineDirection() const
Sunil Ratnu 2014/11/21 12:21:08 Instead of moving it here, we can also define a ne
+{
+ 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;
+}
+
TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const
{
if (isHTMLInputElement(*this)) {
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLTextAreaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698