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

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: Corrected addition in core.gypi Created 6 years, 4 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..dfa01d1eb7d5f48cade31141ed54633ebfb856d3 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,15 @@ 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();
+}
+
void HTMLFormControlElement::updateVisibleValidationMessage()
{
Page* page = document().page();
@@ -416,10 +426,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