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

Unified Diff: Source/web/ValidationMessageClientImpl.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/web/ValidationMessageClientImpl.cpp
diff --git a/Source/web/ValidationMessageClientImpl.cpp b/Source/web/ValidationMessageClientImpl.cpp
index 54b7bda41d4839454acc377d4744d96858d83dc5..8b354c722dd7a87a64c1f17c769164a1c43f8112 100644
--- a/Source/web/ValidationMessageClientImpl.cpp
+++ b/Source/web/ValidationMessageClientImpl.cpp
@@ -64,7 +64,7 @@ FrameView* ValidationMessageClientImpl::currentView()
return m_currentAnchor->document().view();
}
-void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, const String& message)
+void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, const String& message, TextDirection messageDir, const String& subMessage, TextDirection subMessageDir)
{
if (message.isEmpty()) {
hideValidationMessage(anchor);
@@ -79,15 +79,16 @@ void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, c
m_lastAnchorRectInScreen = currentView()->hostWindow()->rootViewToScreen(anchorInRootView);
m_lastPageScaleFactor = m_webView.pageScaleFactor();
m_message = message;
-
- WebTextDirection dir = m_currentAnchor->renderer()->style()->direction() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight;
- AtomicString title = m_currentAnchor->fastGetAttribute(HTMLNames::titleAttr);
- m_webView.client()->showValidationMessage(anchorInRootView, m_message, title, dir);
-
const double minimumSecondToShowValidationMessage = 5.0;
const double secondPerCharacter = 0.05;
const double statusCheckInterval = 0.1;
- m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowValidationMessage, (message.length() + title.length()) * secondPerCharacter);
+
+ unsigned length = message.length() + (!subMessage.isNull() ? subMessage.length() : 0);
tkent 2014/07/22 01:29:56 Checking isNull is unnecessary. subMessage.length
Habib Virji 2014/07/22 16:10:00 Done.
+ m_webView.client()->showValidationMessage(anchorInRootView, m_message, messageDir == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft,
+ subMessage, subMessageDir == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft);
+ m_webView.client()->showValidationMessage(anchorInRootView, m_message, subMessage, messageDir == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft);
+
+ m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowValidationMessage, length * secondPerCharacter);
// FIXME: We should invoke checkAnchorStatus actively when layout, scroll,
// or page scale change happen.
m_timer.startRepeating(statusCheckInterval, FROM_HERE);

Powered by Google App Engine
This is Rietveld 408576698