| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 ValidationMessageClientImpl::~ValidationMessageClientImpl() | 58 ValidationMessageClientImpl::~ValidationMessageClientImpl() |
| 59 { | 59 { |
| 60 } | 60 } |
| 61 | 61 |
| 62 FrameView* ValidationMessageClientImpl::currentView() | 62 FrameView* ValidationMessageClientImpl::currentView() |
| 63 { | 63 { |
| 64 return m_currentAnchor->document().view(); | 64 return m_currentAnchor->document().view(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, c
onst String& message) | 67 void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, c
onst String& message, TextDirection messageDir, const String& subMessage, TextDi
rection subMessageDir) |
| 68 { | 68 { |
| 69 if (message.isEmpty()) { | 69 if (message.isEmpty()) { |
| 70 hideValidationMessage(anchor); | 70 hideValidationMessage(anchor); |
| 71 return; | 71 return; |
| 72 } | 72 } |
| 73 if (!anchor.renderBox()) | 73 if (!anchor.renderBox()) |
| 74 return; | 74 return; |
| 75 if (m_currentAnchor) | 75 if (m_currentAnchor) |
| 76 hideValidationMessage(*m_currentAnchor); | 76 hideValidationMessage(*m_currentAnchor); |
| 77 m_currentAnchor = &anchor; | 77 m_currentAnchor = &anchor; |
| 78 IntRect anchorInRootView = currentView()->contentsToRootView(anchor.pixelSna
ppedBoundingBox()); | 78 IntRect anchorInRootView = currentView()->contentsToRootView(anchor.pixelSna
ppedBoundingBox()); |
| 79 m_lastAnchorRectInScreen = currentView()->hostWindow()->rootViewToScreen(anc
horInRootView); | 79 m_lastAnchorRectInScreen = currentView()->hostWindow()->rootViewToScreen(anc
horInRootView); |
| 80 m_lastPageScaleFactor = m_webView.pageScaleFactor(); | 80 m_lastPageScaleFactor = m_webView.pageScaleFactor(); |
| 81 m_message = message; | 81 m_message = message; |
| 82 | |
| 83 WebTextDirection dir = m_currentAnchor->renderer()->style()->direction() ==
RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight; | |
| 84 AtomicString title = m_currentAnchor->fastGetAttribute(HTMLNames::titleAttr)
; | |
| 85 m_webView.client()->showValidationMessage(anchorInRootView, m_message, title
, dir); | |
| 86 | |
| 87 const double minimumSecondToShowValidationMessage = 5.0; | 82 const double minimumSecondToShowValidationMessage = 5.0; |
| 88 const double secondPerCharacter = 0.05; | 83 const double secondPerCharacter = 0.05; |
| 89 const double statusCheckInterval = 0.1; | 84 const double statusCheckInterval = 0.1; |
| 90 m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowV
alidationMessage, (message.length() + title.length()) * secondPerCharacter); | 85 |
| 86 m_webView.client()->showValidationMessage(anchorInRootView, m_message, messa
geDir == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToLeft, |
| 87 subMessage, subMessageDir == LTR ? WebTextDirectionLeftToRight: WebTextD
irectionRightToLeft); |
| 88 m_webView.client()->showValidationMessage(anchorInRootView, m_message, subMe
ssage, messageDir == LTR ? WebTextDirectionLeftToRight: WebTextDirectionRightToL
eft); |
| 89 |
| 90 m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowV
alidationMessage, (message.length() + subMessage.length()) * secondPerCharacter)
; |
| 91 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll, | 91 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll, |
| 92 // or page scale change happen. | 92 // or page scale change happen. |
| 93 m_timer.startRepeating(statusCheckInterval, FROM_HERE); | 93 m_timer.startRepeating(statusCheckInterval, FROM_HERE); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ValidationMessageClientImpl::hideValidationMessage(const Element& anchor) | 96 void ValidationMessageClientImpl::hideValidationMessage(const Element& anchor) |
| 97 { | 97 { |
| 98 if (!m_currentAnchor || !isValidationMessageVisible(anchor)) | 98 if (!m_currentAnchor || !isValidationMessageVisible(anchor)) |
| 99 return; | 99 return; |
| 100 m_timer.stop(); | 100 m_timer.stop(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 hideValidationMessage(*m_currentAnchor); | 146 hideValidationMessage(*m_currentAnchor); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ValidationMessageClientImpl::trace(Visitor* visitor) | 149 void ValidationMessageClientImpl::trace(Visitor* visitor) |
| 150 { | 150 { |
| 151 visitor->trace(m_currentAnchor); | 151 visitor->trace(m_currentAnchor); |
| 152 ValidationMessageClient::trace(visitor); | 152 ValidationMessageClient::trace(visitor); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } | 155 } |
| OLD | NEW |