Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Side by Side Diff: third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp

Issue 2834783002: window.print() should close form validation bubble. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/ValidationMessageClientImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 web_view_.ChromeClient().RegisterPopupOpeningObserver(this);
87 88
88 finish_time_ = 89 finish_time_ =
89 MonotonicallyIncreasingTime() + 90 MonotonicallyIncreasingTime() +
90 std::max(kMinimumSecondToShowValidationMessage, 91 std::max(kMinimumSecondToShowValidationMessage,
91 (message.length() + sub_message.length()) * kSecondPerCharacter); 92 (message.length() + sub_message.length()) * kSecondPerCharacter);
92 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll, 93 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll,
93 // or page scale change happen. 94 // or page scale change happen.
94 timer_ = WTF::MakeUnique<TaskRunnerTimer<ValidationMessageClientImpl>>( 95 timer_ = WTF::MakeUnique<TaskRunnerTimer<ValidationMessageClientImpl>>(
95 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &anchor.GetDocument()), 96 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &anchor.GetDocument()),
96 this, &ValidationMessageClientImpl::CheckAnchorStatus); 97 this, &ValidationMessageClientImpl::CheckAnchorStatus);
97 timer_->StartRepeating(kStatusCheckInterval, BLINK_FROM_HERE); 98 timer_->StartRepeating(kStatusCheckInterval, BLINK_FROM_HERE);
98 } 99 }
99 100
100 void ValidationMessageClientImpl::HideValidationMessage(const Element& anchor) { 101 void ValidationMessageClientImpl::HideValidationMessage(const Element& anchor) {
101 if (!current_anchor_ || !IsValidationMessageVisible(anchor)) 102 if (!current_anchor_ || !IsValidationMessageVisible(anchor))
102 return; 103 return;
103 timer_ = nullptr; 104 timer_ = nullptr;
104 current_anchor_ = nullptr; 105 current_anchor_ = nullptr;
105 message_ = String(); 106 message_ = String();
106 finish_time_ = 0; 107 finish_time_ = 0;
107 web_view_.Client()->HideValidationMessage(); 108 web_view_.Client()->HideValidationMessage();
109 web_view_.ChromeClient().UnregisterPopupOpeningObserver(this);
108 } 110 }
109 111
110 bool ValidationMessageClientImpl::IsValidationMessageVisible( 112 bool ValidationMessageClientImpl::IsValidationMessageVisible(
111 const Element& anchor) { 113 const Element& anchor) {
112 return current_anchor_ == &anchor; 114 return current_anchor_ == &anchor;
113 } 115 }
114 116
115 void ValidationMessageClientImpl::WillUnloadDocument(const Document& document) { 117 void ValidationMessageClientImpl::WillUnloadDocument(const Document& document) {
116 if (current_anchor_ && current_anchor_->GetDocument() == document) 118 if (current_anchor_ && current_anchor_->GetDocument() == document)
117 HideValidationMessage(*current_anchor_); 119 HideValidationMessage(*current_anchor_);
(...skipping 27 matching lines...) Expand all
145 last_anchor_rect_in_screen_ = new_anchor_rect_in_viewport_in_screen; 147 last_anchor_rect_in_screen_ = new_anchor_rect_in_viewport_in_screen;
146 last_page_scale_factor_ = web_view_.PageScaleFactor(); 148 last_page_scale_factor_ = web_view_.PageScaleFactor();
147 web_view_.Client()->MoveValidationMessage(new_anchor_rect_in_viewport); 149 web_view_.Client()->MoveValidationMessage(new_anchor_rect_in_viewport);
148 } 150 }
149 151
150 void ValidationMessageClientImpl::WillBeDestroyed() { 152 void ValidationMessageClientImpl::WillBeDestroyed() {
151 if (current_anchor_) 153 if (current_anchor_)
152 HideValidationMessage(*current_anchor_); 154 HideValidationMessage(*current_anchor_);
153 } 155 }
154 156
157 void ValidationMessageClientImpl::WillOpenPopup() {
158 if (current_anchor_)
159 HideValidationMessage(*current_anchor_);
160 }
161
155 DEFINE_TRACE(ValidationMessageClientImpl) { 162 DEFINE_TRACE(ValidationMessageClientImpl) {
156 visitor->Trace(current_anchor_); 163 visitor->Trace(current_anchor_);
157 ValidationMessageClient::Trace(visitor); 164 ValidationMessageClient::Trace(visitor);
158 } 165 }
159 166
160 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ValidationMessageClientImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698