Index: Source/web/ValidationMessageClientImpl.cpp |
diff --git a/Source/web/ValidationMessageClientImpl.cpp b/Source/web/ValidationMessageClientImpl.cpp |
index 54b7bda41d4839454acc377d4744d96858d83dc5..5d10e3cf86cbd5cff9c2867b4d3244ec8faea1e7 100644 |
--- a/Source/web/ValidationMessageClientImpl.cpp |
+++ b/Source/web/ValidationMessageClientImpl.cpp |
@@ -30,6 +30,8 @@ |
#include "core/frame/FrameView.h" |
#include "core/rendering/RenderObject.h" |
#include "platform/HostWindow.h" |
+#include "platform/text/BidiTextRun.h" |
+#include "platform/text/PlatformLocale.h" |
#include "public/platform/WebRect.h" |
#include "public/platform/WebString.h" |
#include "public/web/WebTextDirection.h" |
@@ -64,7 +66,24 @@ FrameView* ValidationMessageClientImpl::currentView() |
return m_currentAnchor->document().view(); |
} |
-void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, const String& message) |
+static void findCustomMessageTextDirection(const Element& anchor, const String& message, WebTextDirection& messageDir, String& subMessage, WebTextDirection& subMessageDir) |
+{ |
+ bool hasStrongDirection; |
+ subMessage = anchor.fastGetAttribute(HTMLNames::titleAttr); |
+ messageDir = determineDirectionality(message, hasStrongDirection) == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft; |
+ if (!subMessage.isEmpty()) { |
+ // Sub Msg takes direction of the element direction |
+ AtomicString dir = anchor.fastGetAttribute(HTMLNames::dirAttr); |
+ if (dir.isEmpty()) { |
+ subMessageDir = anchor.renderer()->style()->direction() == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft; |
+ } else { |
+ subMessageDir = (equalIgnoringCase(dir, "auto") ? (determineDirectionality(message, hasStrongDirection) == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft) |
+ : (equalIgnoringCase(dir, "ltr") ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft)); |
+ } |
+ } |
+} |
+ |
+void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, const String& message, MessageType type) |
{ |
if (message.isEmpty()) { |
hideValidationMessage(anchor); |
@@ -79,15 +98,24 @@ 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; |
+ String subMsg = String(); |
+ WebTextDirection messageDir, subMsgDir = WebTextDirectionLeftToRight; |
+ |
+ if (type == CannedMessage) |
+ messageDir = m_currentAnchor->locale().isRTL() ? WebTextDirectionRightToLeft: WebTextDirectionLeftToRight; |
tkent
2014/07/18 13:57:49
Looking at the element locale is wrong at this mom
Habib Virji
2014/07/18 15:37:45
Okay, I was more looking for browser UI locale. As
tkent
2014/07/22 01:29:56
There is. But using determineDirectionality for c
|
+ else |
+ findCustomMessageTextDirection(anchor, message, messageDir, subMsg, subMsgDir); |
+ |
+ length = message.length() + (!subMsg.isNull() ? subMsg.length() : 0); |
+ m_webView.client()->showValidationMessage(anchorInRootView, m_message, messageDir, subMsg, subMsgDir); |
+ m_webView.client()->showValidationMessage(anchorInRootView, m_message, subMsg, subMsgDir); |
+ |
+ 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); |