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

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: Addressed code review comments 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 | « no previous file | Source/core/page/ValidationMessageClient.h » ('j') | Source/web/ValidationMessageClientImpl.h » ('J')
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..cf2d0522bb3865b62bbbd9f9f104d2d190d21ffc 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,20 @@ void HTMLFormControlElement::setNeedsWillValidateCheck()
hideVisibleValidationMessage();
}
+static void findCustomMessageTextDirection(const Element& anchor, const String& message, TextDirection& messageDir, String& subMessage, TextDirection& subMessageDir)
+{
+ bool hasStrongDirection;
+ subMessage = anchor.fastGetAttribute(titleAttr);
+ messageDir = determineDirectionality(message, hasStrongDirection);
+ if (!subMessage.isEmpty()) {
+ // Sub Msg takes direction of the element direction
tkent 2014/07/22 23:56:48 Msg -> message
Habib Virji 2014/07/23 13:32:03 Done.
+ subMessageDir = anchor.renderer()->style()->direction();
+ AtomicString dir = anchor.fastGetAttribute(dirAttr);
tkent 2014/07/22 23:56:49 Line 417-419 has no effect. It is unnecessary.
Habib Virji 2014/07/23 13:32:03 Done. Removed but it did work correctly if <input
+ if (!dir.isEmpty() && equalIgnoringCase(dir, "auto"))
+ determineDirectionality(message, hasStrongDirection);
+ }
+}
+
void HTMLFormControlElement::updateVisibleValidationMessage()
{
Page* page = document().page();
@@ -416,10 +431,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;
tkent 2014/07/22 23:56:49 We don't declare multiple variables at once.
Habib Virji 2014/07/23 13:32:03 Done.
+ 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/web/ValidationMessageClientImpl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698