Index: Source/core/html/HTMLElement.cpp |
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp |
index 1c451cff4c3b76e7a0880e86a8f605642aaca74b..7fae6b26659288df365a9880d03686660af221b9 100644 |
--- a/Source/core/html/HTMLElement.cpp |
+++ b/Source/core/html/HTMLElement.cpp |
@@ -629,6 +629,35 @@ void HTMLElement::setTranslate(bool enable) |
setAttribute(translateAttr, enable ? "yes" : "no"); |
} |
+// Returns the conforming 'dir' value associated with the state the attribute is in (in its canonical case), if any, |
+// or the empty string if the attribute is in a state that has no associated keyword value or if the attribute is |
+// not in a defined state (e.g. the attribute is missing and there is no missing value default). |
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#limited-to-only-known-values |
+static inline const AtomicString& toValidDirValue(const AtomicString& value) |
+{ |
+ DEFINE_STATIC_LOCAL(const AtomicString, ltrValue, ("ltr", AtomicString::ConstructFromLiteral)); |
+ DEFINE_STATIC_LOCAL(const AtomicString, rtlValue, ("rtl", AtomicString::ConstructFromLiteral)); |
+ DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto", AtomicString::ConstructFromLiteral)); |
+ |
+ if (equalIgnoringCase(value, ltrValue)) |
+ return ltrValue; |
+ if (equalIgnoringCase(value, rtlValue)) |
+ return rtlValue; |
+ if (equalIgnoringCase(value, autoValue)) |
+ return autoValue; |
+ return nullAtom; |
+} |
+ |
+const AtomicString& HTMLElement::dir() |
+{ |
+ return toValidDirValue(fastGetAttribute(dirAttr)); |
+} |
+ |
+void HTMLElement::setDir(const AtomicString& value) |
+{ |
+ setAttribute(dirAttr, value); |
+} |
+ |
HTMLFormElement* HTMLElement::findFormAncestor() const |
{ |
return Traversal<HTMLFormElement>::firstAncestor(*this); |