| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/chromedriver/window_commands.h" | 5 #include "chrome/test/chromedriver/window_commands.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 bool has_element = params.GetString("element", &element_id); | 463 bool has_element = params.GetString("element", &element_id); |
| 464 int x_offset = 0; | 464 int x_offset = 0; |
| 465 int y_offset = 0; | 465 int y_offset = 0; |
| 466 bool has_offset = params.GetInteger("xoffset", &x_offset) && | 466 bool has_offset = params.GetInteger("xoffset", &x_offset) && |
| 467 params.GetInteger("yoffset", &y_offset); | 467 params.GetInteger("yoffset", &y_offset); |
| 468 if (!has_element && !has_offset) | 468 if (!has_element && !has_offset) |
| 469 return Status(kUnknownError, "at least an element or offset should be set"); | 469 return Status(kUnknownError, "at least an element or offset should be set"); |
| 470 | 470 |
| 471 WebPoint location; | 471 WebPoint location; |
| 472 if (has_element) { | 472 if (has_element) { |
| 473 Status status = ScrollElementIntoView( | 473 WebPoint offset(x_offset, y_offset); |
| 474 session, web_view, element_id, &location); | 474 Status status = ScrollElementIntoView(session, web_view, element_id, |
| 475 has_offset ? &offset : nullptr, &location); |
| 475 if (status.IsError()) | 476 if (status.IsError()) |
| 476 return status; | 477 return status; |
| 477 } else { | 478 } else { |
| 478 location = session->mouse_position; | 479 location = session->mouse_position; |
| 479 } | 480 if (has_offset) |
| 480 | 481 location.Offset(x_offset, y_offset); |
| 481 if (has_offset) { | |
| 482 location.Offset(x_offset, y_offset); | |
| 483 } else { | |
| 484 WebSize size; | |
| 485 Status status = GetElementSize(session, web_view, element_id, &size); | |
| 486 if (status.IsError()) | |
| 487 return status; | |
| 488 location.Offset(size.width / 2, size.height / 2); | |
| 489 } | 482 } |
| 490 | 483 |
| 491 std::list<MouseEvent> events; | 484 std::list<MouseEvent> events; |
| 492 events.push_back( | 485 events.push_back( |
| 493 MouseEvent(kMovedMouseEventType, kNoneMouseButton, | 486 MouseEvent(kMovedMouseEventType, kNoneMouseButton, |
| 494 location.x, location.y, session->sticky_modifiers, 0)); | 487 location.x, location.y, session->sticky_modifiers, 0)); |
| 495 Status status = | 488 Status status = |
| 496 web_view->DispatchMouseEvents(events, session->GetCurrentFrameId()); | 489 web_view->DispatchMouseEvents(events, session->GetCurrentFrameId()); |
| 497 if (status.IsOk()) | 490 if (status.IsOk()) |
| 498 session->mouse_position = location; | 491 session->mouse_position = location; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 return status; | 869 return status; |
| 877 } | 870 } |
| 878 | 871 |
| 879 Status ExecuteTakeHeapSnapshot( | 872 Status ExecuteTakeHeapSnapshot( |
| 880 Session* session, | 873 Session* session, |
| 881 WebView* web_view, | 874 WebView* web_view, |
| 882 const base::DictionaryValue& params, | 875 const base::DictionaryValue& params, |
| 883 scoped_ptr<base::Value>* value) { | 876 scoped_ptr<base::Value>* value) { |
| 884 return web_view->TakeHeapSnapshot(value); | 877 return web_view->TakeHeapSnapshot(value); |
| 885 } | 878 } |
| OLD | NEW |