Chromium Code Reviews| Index: Source/core/html/HTMLElement.cpp |
| diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp |
| index 2ae40944acbf5638ef602b02fe2ac16754ac0e08..cf8b85d1b0d2511603b50f59658554b97b3cf088 100644 |
| --- a/Source/core/html/HTMLElement.cpp |
| +++ b/Source/core/html/HTMLElement.cpp |
| @@ -38,6 +38,7 @@ |
| #include "core/dom/DocumentFragment.h" |
| #include "core/dom/ElementTraversal.h" |
| #include "core/dom/ExceptionCode.h" |
| +#include "core/dom/NodeRenderStyle.h" |
| #include "core/dom/NodeTraversal.h" |
| #include "core/dom/Text.h" |
| #include "core/dom/shadow/ElementShadow.h" |
| @@ -51,6 +52,7 @@ |
| #include "core/html/HTMLInputElement.h" |
| #include "core/html/HTMLMenuElement.h" |
| #include "core/html/HTMLTemplateElement.h" |
| +#include "core/html/HTMLTextAreaElement.h" |
| #include "core/html/HTMLTextFormControlElement.h" |
| #include "core/html/parser/HTMLParserIdioms.h" |
| #include "core/rendering/RenderObject.h" |
| @@ -189,10 +191,11 @@ 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, directionForFormData()); |
|
tkent
2014/09/09 01:42:28
|ForFormData| is an inappropriate name. FormData
Sunil Ratnu
2014/09/09 03:31:03
Done.
|
| + } else { |
| addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, value); |
| - else |
| - addPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, "ltr"); |
| + } |
| if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(outputTag)) |
| addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBidi, CSSValueEmbed); |
| } |
| @@ -684,14 +687,44 @@ TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con |
| return directionality(); |
| } |
| +String HTMLElement::directionForFormData() 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") || 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)) { |
| HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLElement*>(this)); |
| + if (inputElement->isTextField() || inputElement->isSearchField() |
| + || inputElement->isURLField() || inputElement->isEmailField()) { |
| + bool hasStrongDirectionality; |
| + TextDirection textDirection = determineDirectionality(inputElement->value(), hasStrongDirectionality); |
| + if (strongDirectionalityTextNode) |
| + *strongDirectionalityTextNode = hasStrongDirectionality ? inputElement : 0; |
| + return textDirection; |
| + } |
| + } else if (isHTMLTextAreaElement(*this)) { |
| + HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(const_cast<HTMLElement*>(this)); |
| bool hasStrongDirectionality; |
| - TextDirection textDirection = determineDirectionality(inputElement->value(), hasStrongDirectionality); |
| + TextDirection textDirection = determineDirectionality(textAreaElement->value(), hasStrongDirectionality); |
| if (strongDirectionalityTextNode) |
| - *strongDirectionalityTextNode = hasStrongDirectionality ? inputElement : 0; |
| + *strongDirectionalityTextNode = hasStrongDirectionality ? textAreaElement : 0; |
| return textDirection; |
| } |