Index: Source/web/ValidationMessageClientImpl.cpp |
diff --git a/Source/web/ValidationMessageClientImpl.cpp b/Source/web/ValidationMessageClientImpl.cpp |
index 54b7bda41d4839454acc377d4744d96858d83dc5..0f6b510b7d820a9d0444ccd499e130b018c539d4 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,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, bool customError) |
{ |
if (message.isEmpty()) { |
hideValidationMessage(anchor); |
@@ -79,15 +81,32 @@ 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); |
+ |
+ if (!customError) { |
+ m_webView.client()->showValidationMessage(anchorInRootView, m_message, m_currentAnchor->locale().isRTL() ? WebTextDirectionRightToLeft: WebTextDirectionLeftToRight, String(), WebTextDirectionLeftToRight); |
+ m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowValidationMessage, message.length() * secondPerCharacter); |
+ } else { |
+ AtomicString subMsg = m_currentAnchor->fastGetAttribute(HTMLNames::titleAttr); |
+ bool hasStrongDirection; |
+ WebTextDirection messageDir = determineDirectionality(message, hasStrongDirection) == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft; |
+ WebTextDirection subMsgDir = WebTextDirectionLeftToRight; |
+ if (!subMsg.isEmpty()) { |
+ // Sub Msg takes direction of the element direction |
+ AtomicString dir = m_currentAnchor->fastGetAttribute(HTMLNames::dirAttr); |
+ if (dir.isEmpty()) { |
+ subMsgDir = m_currentAnchor->renderer()->style()->direction() == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft; |
+ } else { |
+ subMsgDir = (equalIgnoringCase(dir, "auto") ? (determineDirectionality(message, hasStrongDirection) == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft) |
+ : (equalIgnoringCase(dir, "ltr") ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft)); |
+ } |
+ } |
leviw_travelin_and_unemployed
2014/07/16 04:26:22
Can you put all this code into a helper function?
Habib Virji
2014/07/16 13:32:02
Done.
|
+ m_webView.client()->showValidationMessage(anchorInRootView, m_message, messageDir, subMsg, subMsgDir); |
+ m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowValidationMessage, (message.length() + subMsg.length()) * secondPerCharacter); |
leviw_travelin_and_unemployed
2014/07/16 04:26:22
It seems like this code doesn't need to be duplica
Habib Virji
2014/07/16 13:32:02
It had subMsg.length which differed, changed to av
|
+ } |
+ |
// FIXME: We should invoke checkAnchorStatus actively when layout, scroll, |
// or page scale change happen. |
m_timer.startRepeating(statusCheckInterval, FROM_HERE); |