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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 CurrentView()); | 78 CurrentView()); |
79 last_page_scale_factor_ = web_view_.PageScaleFactor(); | 79 last_page_scale_factor_ = web_view_.PageScaleFactor(); |
80 message_ = message; | 80 message_ = message; |
81 const double kMinimumSecondToShowValidationMessage = 5.0; | 81 const double kMinimumSecondToShowValidationMessage = 5.0; |
82 const double kSecondPerCharacter = 0.05; | 82 const double kSecondPerCharacter = 0.05; |
83 const double kStatusCheckInterval = 0.1; | 83 const double kStatusCheckInterval = 0.1; |
84 | 84 |
85 web_view_.Client()->ShowValidationMessage( | 85 web_view_.Client()->ShowValidationMessage( |
86 anchor_in_viewport, message_, ToWebTextDirection(message_dir), | 86 anchor_in_viewport, message_, ToWebTextDirection(message_dir), |
87 sub_message, ToWebTextDirection(sub_message_dir)); | 87 sub_message, ToWebTextDirection(sub_message_dir)); |
88 web_view_.ChromeClient().RegisterPopupOpeningObserver(this); | 88 web_view_.GetChromeClient().RegisterPopupOpeningObserver(this); |
89 | 89 |
90 finish_time_ = | 90 finish_time_ = |
91 MonotonicallyIncreasingTime() + | 91 MonotonicallyIncreasingTime() + |
92 std::max(kMinimumSecondToShowValidationMessage, | 92 std::max(kMinimumSecondToShowValidationMessage, |
93 (message.length() + sub_message.length()) * kSecondPerCharacter); | 93 (message.length() + sub_message.length()) * kSecondPerCharacter); |
94 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll, | 94 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll, |
95 // or page scale change happen. | 95 // or page scale change happen. |
96 timer_ = WTF::MakeUnique<TaskRunnerTimer<ValidationMessageClientImpl>>( | 96 timer_ = WTF::MakeUnique<TaskRunnerTimer<ValidationMessageClientImpl>>( |
97 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &anchor.GetDocument()), | 97 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &anchor.GetDocument()), |
98 this, &ValidationMessageClientImpl::CheckAnchorStatus); | 98 this, &ValidationMessageClientImpl::CheckAnchorStatus); |
99 timer_->StartRepeating(kStatusCheckInterval, BLINK_FROM_HERE); | 99 timer_->StartRepeating(kStatusCheckInterval, BLINK_FROM_HERE); |
100 } | 100 } |
101 | 101 |
102 void ValidationMessageClientImpl::HideValidationMessage(const Element& anchor) { | 102 void ValidationMessageClientImpl::HideValidationMessage(const Element& anchor) { |
103 if (!current_anchor_ || !IsValidationMessageVisible(anchor)) | 103 if (!current_anchor_ || !IsValidationMessageVisible(anchor)) |
104 return; | 104 return; |
105 timer_ = nullptr; | 105 timer_ = nullptr; |
106 current_anchor_ = nullptr; | 106 current_anchor_ = nullptr; |
107 message_ = String(); | 107 message_ = String(); |
108 finish_time_ = 0; | 108 finish_time_ = 0; |
109 web_view_.Client()->HideValidationMessage(); | 109 web_view_.Client()->HideValidationMessage(); |
110 web_view_.ChromeClient().UnregisterPopupOpeningObserver(this); | 110 web_view_.GetChromeClient().UnregisterPopupOpeningObserver(this); |
111 } | 111 } |
112 | 112 |
113 bool ValidationMessageClientImpl::IsValidationMessageVisible( | 113 bool ValidationMessageClientImpl::IsValidationMessageVisible( |
114 const Element& anchor) { | 114 const Element& anchor) { |
115 return current_anchor_ == &anchor; | 115 return current_anchor_ == &anchor; |
116 } | 116 } |
117 | 117 |
118 void ValidationMessageClientImpl::WillUnloadDocument(const Document& document) { | 118 void ValidationMessageClientImpl::WillUnloadDocument(const Document& document) { |
119 if (current_anchor_ && current_anchor_->GetDocument() == document) | 119 if (current_anchor_ && current_anchor_->GetDocument() == document) |
120 HideValidationMessage(*current_anchor_); | 120 HideValidationMessage(*current_anchor_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (current_anchor_) | 159 if (current_anchor_) |
160 HideValidationMessage(*current_anchor_); | 160 HideValidationMessage(*current_anchor_); |
161 } | 161 } |
162 | 162 |
163 DEFINE_TRACE(ValidationMessageClientImpl) { | 163 DEFINE_TRACE(ValidationMessageClientImpl) { |
164 visitor->Trace(current_anchor_); | 164 visitor->Trace(current_anchor_); |
165 ValidationMessageClient::Trace(visitor); | 165 ValidationMessageClient::Trace(visitor); |
166 } | 166 } |
167 | 167 |
168 } // namespace blink | 168 } // namespace blink |
OLD | NEW |