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 11 matching lines...) Expand all Loading... |
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/exported/WebViewBase.h" | 30 #include "core/exported/WebViewBase.h" |
31 #include "core/frame/FrameView.h" | 31 #include "core/frame/FrameView.h" |
| 32 #include "core/frame/LocalFrame.h" |
32 #include "core/page/ChromeClient.h" | 33 #include "core/page/ChromeClient.h" |
33 #include "platform/PlatformChromeClient.h" | 34 #include "platform/PlatformChromeClient.h" |
34 #include "platform/wtf/CurrentTime.h" | 35 #include "platform/wtf/CurrentTime.h" |
35 #include "public/platform/WebRect.h" | 36 #include "public/platform/WebRect.h" |
36 #include "public/platform/WebString.h" | 37 #include "public/platform/WebString.h" |
37 #include "public/web/WebTextDirection.h" | 38 #include "public/web/WebTextDirection.h" |
38 #include "public/web/WebViewClient.h" | 39 #include "public/web/WebViewClient.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
(...skipping 25 matching lines...) Expand all Loading... |
67 return; | 68 return; |
68 } | 69 } |
69 if (!anchor.GetLayoutBox()) | 70 if (!anchor.GetLayoutBox()) |
70 return; | 71 return; |
71 if (current_anchor_) | 72 if (current_anchor_) |
72 HideValidationMessage(*current_anchor_); | 73 HideValidationMessage(*current_anchor_); |
73 current_anchor_ = &anchor; | 74 current_anchor_ = &anchor; |
74 IntRect anchor_in_viewport = | 75 IntRect anchor_in_viewport = |
75 CurrentView()->ContentsToViewport(anchor.PixelSnappedBoundingBox()); | 76 CurrentView()->ContentsToViewport(anchor.PixelSnappedBoundingBox()); |
76 last_anchor_rect_in_screen_ = | 77 last_anchor_rect_in_screen_ = |
77 CurrentView()->GetChromeClient()->ViewportToScreen(anchor_in_viewport, | 78 CurrentView()->GetChromeClient()->ViewportToScreen( |
78 CurrentView()); | 79 anchor_in_viewport, current_anchor_->GetDocument().GetFrame()); |
79 last_page_scale_factor_ = web_view_.PageScaleFactor(); | 80 last_page_scale_factor_ = web_view_.PageScaleFactor(); |
80 message_ = message; | 81 message_ = message; |
81 const double kMinimumSecondToShowValidationMessage = 5.0; | 82 const double kMinimumSecondToShowValidationMessage = 5.0; |
82 const double kSecondPerCharacter = 0.05; | 83 const double kSecondPerCharacter = 0.05; |
83 const double kStatusCheckInterval = 0.1; | 84 const double kStatusCheckInterval = 0.1; |
84 | 85 |
85 web_view_.Client()->ShowValidationMessage( | 86 web_view_.Client()->ShowValidationMessage( |
86 anchor_in_viewport, message_, ToWebTextDirection(message_dir), | 87 anchor_in_viewport, message_, ToWebTextDirection(message_dir), |
87 sub_message, ToWebTextDirection(sub_message_dir)); | 88 sub_message, ToWebTextDirection(sub_message_dir)); |
88 web_view_.ChromeClient().RegisterPopupOpeningObserver(this); | 89 web_view_.ChromeClient().RegisterPopupOpeningObserver(this); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 135 |
135 IntRect new_anchor_rect_in_viewport = | 136 IntRect new_anchor_rect_in_viewport = |
136 current_anchor_->VisibleBoundsInVisualViewport(); | 137 current_anchor_->VisibleBoundsInVisualViewport(); |
137 if (new_anchor_rect_in_viewport.IsEmpty()) { | 138 if (new_anchor_rect_in_viewport.IsEmpty()) { |
138 HideValidationMessage(*current_anchor_); | 139 HideValidationMessage(*current_anchor_); |
139 return; | 140 return; |
140 } | 141 } |
141 | 142 |
142 IntRect new_anchor_rect_in_viewport_in_screen = | 143 IntRect new_anchor_rect_in_viewport_in_screen = |
143 CurrentView()->GetChromeClient()->ViewportToScreen( | 144 CurrentView()->GetChromeClient()->ViewportToScreen( |
144 new_anchor_rect_in_viewport, CurrentView()); | 145 new_anchor_rect_in_viewport, |
| 146 current_anchor_->GetDocument().GetFrame()); |
145 if (new_anchor_rect_in_viewport_in_screen == last_anchor_rect_in_screen_ && | 147 if (new_anchor_rect_in_viewport_in_screen == last_anchor_rect_in_screen_ && |
146 web_view_.PageScaleFactor() == last_page_scale_factor_) | 148 web_view_.PageScaleFactor() == last_page_scale_factor_) |
147 return; | 149 return; |
148 last_anchor_rect_in_screen_ = new_anchor_rect_in_viewport_in_screen; | 150 last_anchor_rect_in_screen_ = new_anchor_rect_in_viewport_in_screen; |
149 last_page_scale_factor_ = web_view_.PageScaleFactor(); | 151 last_page_scale_factor_ = web_view_.PageScaleFactor(); |
150 web_view_.Client()->MoveValidationMessage(new_anchor_rect_in_viewport); | 152 web_view_.Client()->MoveValidationMessage(new_anchor_rect_in_viewport); |
151 } | 153 } |
152 | 154 |
153 void ValidationMessageClientImpl::WillBeDestroyed() { | 155 void ValidationMessageClientImpl::WillBeDestroyed() { |
154 if (current_anchor_) | 156 if (current_anchor_) |
155 HideValidationMessage(*current_anchor_); | 157 HideValidationMessage(*current_anchor_); |
156 } | 158 } |
157 | 159 |
158 void ValidationMessageClientImpl::WillOpenPopup() { | 160 void ValidationMessageClientImpl::WillOpenPopup() { |
159 if (current_anchor_) | 161 if (current_anchor_) |
160 HideValidationMessage(*current_anchor_); | 162 HideValidationMessage(*current_anchor_); |
161 } | 163 } |
162 | 164 |
163 DEFINE_TRACE(ValidationMessageClientImpl) { | 165 DEFINE_TRACE(ValidationMessageClientImpl) { |
164 visitor->Trace(current_anchor_); | 166 visitor->Trace(current_anchor_); |
165 ValidationMessageClient::Trace(visitor); | 167 ValidationMessageClient::Trace(visitor); |
166 } | 168 } |
167 | 169 |
168 } // namespace blink | 170 } // namespace blink |
OLD | NEW |