MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / Reset

Method Reset

cpp/iedriver/InputManager.cpp:268–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268void InputManager::Reset(BrowserHandle browser_wrapper) {
269 LOG(TRACE) << "Entering InputManager::Reset";
270
271 LOG(DEBUG) << "Releasing " << this->pressed_keys_.size() << " keys";
272 std::vector<wchar_t> local_pressed_keys(this->pressed_keys_);
273
274 HWND browser_window_handle = browser_wrapper->GetContentWindowHandle();
275 InputState current_input_state = this->CloneCurrentInputState();
276 this->inputs_.clear();
277 std::vector<wchar_t>::const_reverse_iterator it = local_pressed_keys.rbegin();
278 for (; it != local_pressed_keys.rend(); ++it) {
279 std::wstring key_value = L"";
280 key_value.append(1, *it);
281 std::wstring key_description = this->GetKeyDescription(*it);
282 LOG(DEBUG) << "Key: " << LOGWSTRING(key_description);
283 if (*it == WD_MOUSE_LBUTTON) {
284 this->AddMouseInput(browser_window_handle, MOUSEEVENTF_LEFTUP, 0, 0);
285 } else if (*it == WD_MOUSE_RBUTTON) {
286 this->AddMouseInput(browser_window_handle, MOUSEEVENTF_RIGHTUP, 0, 0);
287 } else {
288 this->AddKeyboardInput(browser_window_handle,
289 key_value,
290 true,
291 &current_input_state);
292 }
293 }
294
295 // If there are inputs in the array, then we've queued up input actions
296 // to be played back. So play them back.
297 if (this->inputs_.size() > 0) {
298 LOG(DEBUG) << "Processing a total of " << this->inputs_.size() << " input events";
299 this->action_simulator_->SimulateActions(browser_wrapper,
300 this->inputs_,
301 &this->current_input_state_);
302 }
303
304 ::Sleep(50);
305
306 if (this->current_input_state_.mouse_x > 0 ||
307 this->current_input_state_.mouse_y > 0) {
308 LOG(DEBUG) << "Resetting mouse position";
309 this->current_input_state_.mouse_x = 0;
310 this->current_input_state_.mouse_y = 0;
311 }
312
313 if (this->pressed_keys_.size() > 0) {
314 LOG(WARN) << "Pressed keys should have been empty, but had " << this->pressed_keys_.size() << " values.";
315 this->pressed_keys_.clear();
316 }
317}
318
319int InputManager::PointerMoveTo(BrowserHandle browser_wrapper,
320 const Json::Value& move_to_action,

Callers 3

OnGetResponseMethod · 0.45
ExecuteInternalMethod · 0.45

Calls 10

GetKeyDescriptionMethod · 0.95
AddMouseInputMethod · 0.95
AddKeyboardInputMethod · 0.95
clearMethod · 0.65
LOGClass · 0.50
sizeMethod · 0.45
appendMethod · 0.45
SimulateActionsMethod · 0.45

Tested by

no test coverage detected