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

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: Updated to latest master changes 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
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLFormControlElementTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLFormControlElement.cpp
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index a4e37a36cc362f9912230017706c1f74ee3793f4..d68646f6f6b1a0b3a611fd3f84280d2a3f4ef0d9 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 blink {
@@ -405,6 +406,18 @@ void HTMLFormControlElement::setNeedsWillValidateCheck()
hideVisibleValidationMessage();
}
+void HTMLFormControlElement::findCustomValidationMessageTextDirection(const String& message, TextDirection &messageDir, String& subMessage, TextDirection &subMessageDir)
+{
+ bool hasStrongDirection;
+ subMessage = fastGetAttribute(titleAttr);
+ messageDir = determineDirectionality(message, hasStrongDirection);
+ if (!subMessage.isEmpty())
+ subMessageDir = renderer()->style()->direction();
+ AtomicString dir = fastGetAttribute(dirAttr);
tkent 2014/08/08 01:41:14 Why do you refer to |dir| attribute though we alre
+ if (!dir.isEmpty())
+ subMessageDir = equalIgnoringCase(dir, "auto") ? determineDirectionality(message, hasStrongDirection): equalIgnoringCase(dir, "ltr") ? LTR: RTL;
+}
+
void HTMLFormControlElement::updateVisibleValidationMessage()
{
Page* page = document().page();
@@ -416,10 +429,14 @@ void HTMLFormControlElement::updateVisibleValidationMessage()
m_hasValidationMessage = true;
ValidationMessageClient* client = &page->validationMessageClient();
+ TextDirection messageDir = LTR;
+ TextDirection subMessageDir = LTR;
+ String subMessage = String();
if (message.isEmpty())
client->hideValidationMessage(*this);
else
- client->showValidationMessage(*this, message);
+ findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
+ client->showValidationMessage(*this, message, messageDir, subMessage, subMessageDir);
}
void HTMLFormControlElement::hideVisibleValidationMessage()
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLFormControlElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698