Chromium Code Reviews| Index: Source/core/html/HTMLElement.cpp |
| diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp |
| index 1c451cff4c3b76e7a0880e86a8f605642aaca74b..7a27a758157af569d7d2020b3db0ac46136cc7c2 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(getAttribute(dirAttr)); |
|
tkent
2014/04/17 07:28:21
nit: I think we can use fastGetAttribute.
Inactive
2014/04/17 12:54:54
That's right, done.
|
| +} |
| + |
| +void HTMLElement::setDir(const AtomicString& value) |
| +{ |
| + setAttribute(dirAttr, value); |
| +} |
| + |
| HTMLFormElement* HTMLElement::findFormAncestor() const |
| { |
| return Traversal<HTMLFormElement>::firstAncestor(*this); |