| 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 10 matching lines...) Expand all Loading... |
| 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 23 * SUCH DAMAGE. | 23 * SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "web/ValidationMessageClientImpl.h" | 26 #include "web/ValidationMessageClientImpl.h" |
| 27 | 27 |
| 28 #include "core/dom/Element.h" | 28 #include "core/dom/Element.h" |
| 29 #include "core/dom/TaskRunnerHelper.h" | 29 #include "core/dom/TaskRunnerHelper.h" |
| 30 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
| 31 #include "platform/HostWindow.h" | 31 #include "platform/PlatformChromeClient.h" |
| 32 #include "platform/wtf/CurrentTime.h" | 32 #include "platform/wtf/CurrentTime.h" |
| 33 #include "public/platform/WebRect.h" | 33 #include "public/platform/WebRect.h" |
| 34 #include "public/platform/WebString.h" | 34 #include "public/platform/WebString.h" |
| 35 #include "public/web/WebTextDirection.h" | 35 #include "public/web/WebTextDirection.h" |
| 36 #include "public/web/WebViewClient.h" | 36 #include "public/web/WebViewClient.h" |
| 37 #include "web/WebViewImpl.h" | 37 #include "web/WebViewImpl.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 ValidationMessageClientImpl::ValidationMessageClientImpl(WebViewImpl& web_view) | 41 ValidationMessageClientImpl::ValidationMessageClientImpl(WebViewImpl& web_view) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 if (!anchor.GetLayoutBox()) | 68 if (!anchor.GetLayoutBox()) |
| 69 return; | 69 return; |
| 70 if (current_anchor_) | 70 if (current_anchor_) |
| 71 HideValidationMessage(*current_anchor_); | 71 HideValidationMessage(*current_anchor_); |
| 72 current_anchor_ = &anchor; | 72 current_anchor_ = &anchor; |
| 73 IntRect anchor_in_viewport = | 73 IntRect anchor_in_viewport = |
| 74 CurrentView()->ContentsToViewport(anchor.PixelSnappedBoundingBox()); | 74 CurrentView()->ContentsToViewport(anchor.PixelSnappedBoundingBox()); |
| 75 last_anchor_rect_in_screen_ = | 75 last_anchor_rect_in_screen_ = |
| 76 CurrentView()->GetHostWindow()->ViewportToScreen(anchor_in_viewport, | 76 CurrentView()->GetChromeClient()->ViewportToScreen(anchor_in_viewport, |
| 77 CurrentView()); | 77 CurrentView()); |
| 78 last_page_scale_factor_ = web_view_.PageScaleFactor(); | 78 last_page_scale_factor_ = web_view_.PageScaleFactor(); |
| 79 message_ = message; | 79 message_ = message; |
| 80 const double kMinimumSecondToShowValidationMessage = 5.0; | 80 const double kMinimumSecondToShowValidationMessage = 5.0; |
| 81 const double kSecondPerCharacter = 0.05; | 81 const double kSecondPerCharacter = 0.05; |
| 82 const double kStatusCheckInterval = 0.1; | 82 const double kStatusCheckInterval = 0.1; |
| 83 | 83 |
| 84 web_view_.Client()->ShowValidationMessage( | 84 web_view_.Client()->ShowValidationMessage( |
| 85 anchor_in_viewport, message_, ToWebTextDirection(message_dir), | 85 anchor_in_viewport, message_, ToWebTextDirection(message_dir), |
| 86 sub_message, ToWebTextDirection(sub_message_dir)); | 86 sub_message, ToWebTextDirection(sub_message_dir)); |
| 87 | 87 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 | 131 |
| 132 IntRect new_anchor_rect_in_viewport = | 132 IntRect new_anchor_rect_in_viewport = |
| 133 current_anchor_->VisibleBoundsInVisualViewport(); | 133 current_anchor_->VisibleBoundsInVisualViewport(); |
| 134 if (new_anchor_rect_in_viewport.IsEmpty()) { | 134 if (new_anchor_rect_in_viewport.IsEmpty()) { |
| 135 HideValidationMessage(*current_anchor_); | 135 HideValidationMessage(*current_anchor_); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 IntRect new_anchor_rect_in_viewport_in_screen = | 139 IntRect new_anchor_rect_in_viewport_in_screen = |
| 140 CurrentView()->GetHostWindow()->ViewportToScreen( | 140 CurrentView()->GetChromeClient()->ViewportToScreen( |
| 141 new_anchor_rect_in_viewport, CurrentView()); | 141 new_anchor_rect_in_viewport, CurrentView()); |
| 142 if (new_anchor_rect_in_viewport_in_screen == last_anchor_rect_in_screen_ && | 142 if (new_anchor_rect_in_viewport_in_screen == last_anchor_rect_in_screen_ && |
| 143 web_view_.PageScaleFactor() == last_page_scale_factor_) | 143 web_view_.PageScaleFactor() == last_page_scale_factor_) |
| 144 return; | 144 return; |
| 145 last_anchor_rect_in_screen_ = new_anchor_rect_in_viewport_in_screen; | 145 last_anchor_rect_in_screen_ = new_anchor_rect_in_viewport_in_screen; |
| 146 last_page_scale_factor_ = web_view_.PageScaleFactor(); | 146 last_page_scale_factor_ = web_view_.PageScaleFactor(); |
| 147 web_view_.Client()->MoveValidationMessage(new_anchor_rect_in_viewport); | 147 web_view_.Client()->MoveValidationMessage(new_anchor_rect_in_viewport); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ValidationMessageClientImpl::WillBeDestroyed() { | 150 void ValidationMessageClientImpl::WillBeDestroyed() { |
| 151 if (current_anchor_) | 151 if (current_anchor_) |
| 152 HideValidationMessage(*current_anchor_); | 152 HideValidationMessage(*current_anchor_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 DEFINE_TRACE(ValidationMessageClientImpl) { | 155 DEFINE_TRACE(ValidationMessageClientImpl) { |
| 156 visitor->Trace(current_anchor_); | 156 visitor->Trace(current_anchor_); |
| 157 ValidationMessageClient::Trace(visitor); | 157 ValidationMessageClient::Trace(visitor); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace blink | 160 } // namespace blink |
| OLD | NEW |