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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (message.isEmpty()) { | 66 if (message.isEmpty()) { |
67 hideValidationMessage(anchor); | 67 hideValidationMessage(anchor); |
68 return; | 68 return; |
69 } | 69 } |
70 if (!anchor.layoutBox()) | 70 if (!anchor.layoutBox()) |
71 return; | 71 return; |
72 if (m_currentAnchor) | 72 if (m_currentAnchor) |
73 hideValidationMessage(*m_currentAnchor); | 73 hideValidationMessage(*m_currentAnchor); |
74 m_currentAnchor = &anchor; | 74 m_currentAnchor = &anchor; |
75 IntRect anchorInViewport = currentView()->contentsToViewport(anchor.pixelSna
ppedBoundingBox()); | 75 IntRect anchorInViewport = currentView()->contentsToViewport(anchor.pixelSna
ppedBoundingBox()); |
76 m_lastAnchorRectInScreen = currentView()->hostWindow()->viewportToScreen(anc
horInViewport); | 76 m_lastAnchorRectInScreen = currentView()->getHostWindow()->viewportToScreen(
anchorInViewport); |
77 m_lastPageScaleFactor = m_webView.pageScaleFactor(); | 77 m_lastPageScaleFactor = m_webView.pageScaleFactor(); |
78 m_message = message; | 78 m_message = message; |
79 const double minimumSecondToShowValidationMessage = 5.0; | 79 const double minimumSecondToShowValidationMessage = 5.0; |
80 const double secondPerCharacter = 0.05; | 80 const double secondPerCharacter = 0.05; |
81 const double statusCheckInterval = 0.1; | 81 const double statusCheckInterval = 0.1; |
82 | 82 |
83 m_webView.client()->showValidationMessage(anchorInViewport, m_message, toWeb
TextDirection(messageDir), | 83 m_webView.client()->showValidationMessage(anchorInViewport, m_message, toWeb
TextDirection(messageDir), |
84 subMessage, toWebTextDirection(subMessageDir)); | 84 subMessage, toWebTextDirection(subMessageDir)); |
85 | 85 |
86 m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowV
alidationMessage, (message.length() + subMessage.length()) * secondPerCharacter)
; | 86 m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowV
alidationMessage, (message.length() + subMessage.length()) * secondPerCharacter)
; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 // FIXME: This intersection eliminates the part of the rect outside the root
view. | 126 // FIXME: This intersection eliminates the part of the rect outside the root
view. |
127 // If this is meant as a visiblity test, intersecting it against the viewpor
t rect | 127 // If this is meant as a visiblity test, intersecting it against the viewpor
t rect |
128 // likely makes more sense. | 128 // likely makes more sense. |
129 newAnchorRectInViewport = intersection(currentView()->convertToRootFrame(cur
rentView()->boundsRect()), newAnchorRectInViewport); | 129 newAnchorRectInViewport = intersection(currentView()->convertToRootFrame(cur
rentView()->boundsRect()), newAnchorRectInViewport); |
130 if (newAnchorRectInViewport.isEmpty()) { | 130 if (newAnchorRectInViewport.isEmpty()) { |
131 hideValidationMessage(*m_currentAnchor); | 131 hideValidationMessage(*m_currentAnchor); |
132 return; | 132 return; |
133 } | 133 } |
134 | 134 |
135 IntRect newAnchorRectInViewportInScreen = currentView()->hostWindow()->viewp
ortToScreen(newAnchorRectInViewport); | 135 IntRect newAnchorRectInViewportInScreen = currentView()->getHostWindow()->vi
ewportToScreen(newAnchorRectInViewport); |
136 if (newAnchorRectInViewportInScreen == m_lastAnchorRectInScreen && m_webView
.pageScaleFactor() == m_lastPageScaleFactor) | 136 if (newAnchorRectInViewportInScreen == m_lastAnchorRectInScreen && m_webView
.pageScaleFactor() == m_lastPageScaleFactor) |
137 return; | 137 return; |
138 m_lastAnchorRectInScreen = newAnchorRectInViewportInScreen; | 138 m_lastAnchorRectInScreen = newAnchorRectInViewportInScreen; |
139 m_lastPageScaleFactor = m_webView.pageScaleFactor(); | 139 m_lastPageScaleFactor = m_webView.pageScaleFactor(); |
140 m_webView.client()->moveValidationMessage(newAnchorRectInViewport); | 140 m_webView.client()->moveValidationMessage(newAnchorRectInViewport); |
141 } | 141 } |
142 | 142 |
143 void ValidationMessageClientImpl::willBeDestroyed() | 143 void ValidationMessageClientImpl::willBeDestroyed() |
144 { | 144 { |
145 if (m_currentAnchor) | 145 if (m_currentAnchor) |
146 hideValidationMessage(*m_currentAnchor); | 146 hideValidationMessage(*m_currentAnchor); |
147 } | 147 } |
148 | 148 |
149 DEFINE_TRACE(ValidationMessageClientImpl) | 149 DEFINE_TRACE(ValidationMessageClientImpl) |
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 } // namespace blink | 155 } // namespace blink |
OLD | NEW |