Chromium Code Reviews| Index: Source/core/html/HTMLFormControlElement.cpp |
| diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp |
| index 546f51e2ab5fa829b3f40acf6ca10ebe8e9d4516..1628304ca71a552bad954c0152826563c3562531 100644 |
| --- a/Source/core/html/HTMLFormControlElement.cpp |
| +++ b/Source/core/html/HTMLFormControlElement.cpp |
| @@ -37,6 +37,7 @@ |
| #include "core/page/ValidationMessageClient.h" |
| #include "core/rendering/RenderBox.h" |
| #include "core/rendering/RenderTheme.h" |
| +#include "platform/text/BidiTextRun.h" |
| #include "wtf/Vector.h" |
| namespace WebCore { |
| @@ -405,6 +406,21 @@ void HTMLFormControlElement::setNeedsWillValidateCheck() |
| hideVisibleValidationMessage(); |
| } |
| +static void findCustomMessageTextDirection(const Element* anchor, const String& message, TextDirection& messageDir, String& subMessage, TextDirection& subMessageDir) |
|
tkent
2014/07/22 01:29:56
|anchor| should be |const Element&|, or this funct
Habib Virji
2014/07/22 16:10:00
Done.
|
| +{ |
| + bool hasStrongDirection; |
| + subMessage = anchor->fastGetAttribute(HTMLNames::titleAttr); |
|
tkent
2014/07/22 01:29:56
You can omit HTMLNames::.
Habib Virji
2014/07/22 16:10:00
Done.
|
| + messageDir = determineDirectionality(message, hasStrongDirection); |
| + if (!subMessage.isEmpty()) { |
| + // Sub Msg takes direction of the element direction |
| + AtomicString dir = anchor->fastGetAttribute(HTMLNames::dirAttr); |
|
tkent
2014/07/22 01:29:56
Don't refer to |dir| attribute of the element to d
Habib Virji
2014/07/22 16:10:00
Done.
|
| + if (dir.isEmpty()) |
| + subMessageDir = anchor->renderer()->style()->direction(); |
| + else |
| + subMessageDir = equalIgnoringCase(dir, "auto") ? determineDirectionality(message, hasStrongDirection) : (equalIgnoringCase(dir, "ltr") ? LTR: RTL); |
| + } |
| +} |
| + |
| void HTMLFormControlElement::updateVisibleValidationMessage() |
| { |
| Page* page = document().page(); |
| @@ -416,10 +432,14 @@ void HTMLFormControlElement::updateVisibleValidationMessage() |
| m_hasValidationMessage = true; |
| ValidationMessageClient* client = &page->validationMessageClient(); |
| - if (message.isEmpty()) |
| + if (message.isEmpty()) { |
| client->hideValidationMessage(*this); |
| - else |
| - client->showValidationMessage(*this, message); |
| + } else { |
| + TextDirection messageDir, subMessageDir = LTR; |
| + String subMessage = String(); |
| + findCustomMessageTextDirection(this, message, messageDir, subMessage, subMessageDir); |
| + client->showValidationMessage(*this, message, messageDir, subMessage, subMessageDir); |
| + } |
| } |
| void HTMLFormControlElement::hideVisibleValidationMessage() |