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

Unified Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 389343002: Custom validation message to take into account text direction (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved code from web to core Created 6 years, 5 months 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
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()
« no previous file with comments | « no previous file | Source/core/page/ValidationMessageClient.h » ('j') | Source/core/page/ValidationMessageClient.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698