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/element_util.h" | 5 #include "chrome/test/chromedriver/element_util.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 session, web_view, element_id, &is_selected); | 570 session, web_view, element_id, &is_selected); |
571 if (status.IsError()) | 571 if (status.IsError()) |
572 return status; | 572 return status; |
573 return SetOptionElementSelected(session, web_view, element_id, !is_selected); | 573 return SetOptionElementSelected(session, web_view, element_id, !is_selected); |
574 } | 574 } |
575 | 575 |
576 Status ScrollElementIntoView( | 576 Status ScrollElementIntoView( |
577 Session* session, | 577 Session* session, |
578 WebView* web_view, | 578 WebView* web_view, |
579 const std::string& id, | 579 const std::string& id, |
580 const WebPoint* offset, | |
580 WebPoint* location) { | 581 WebPoint* location) { |
581 WebSize size; | 582 WebRect region; |
582 Status status = GetElementSize(session, web_view, id, &size); | 583 Status status = GetElementRegion(session, web_view, id, ®ion); |
stgao
2015/01/14 01:47:20
Not sure if there will be side-effect on screensho
samuong
2015/01/14 04:35:05
GetElementRegion gets a WebRect (i.e. both a WebPo
| |
583 if (status.IsError()) | 584 if (status.IsError()) |
584 return status; | 585 return status; |
585 return ScrollElementRegionIntoView( | 586 status = ScrollElementRegionIntoView(session, web_view, id, region, |
586 session, web_view, id, WebRect(WebPoint(0, 0), size), | |
587 false /* center */, std::string(), location); | 587 false /* center */, std::string(), location); |
588 if (status.IsError()) | |
589 return status; | |
590 if (offset) | |
591 location->Offset(offset->x, offset->y); | |
592 else | |
593 location->Offset(region.size.width / 2, region.size.height / 2); | |
stgao
2015/01/14 01:47:20
It may worth a check if this change has unexpected
samuong
2015/01/14 04:35:05
I will be running some presubmits later to find as
| |
594 return Status(kOk); | |
588 } | 595 } |
589 | 596 |
590 Status ScrollElementRegionIntoView( | 597 Status ScrollElementRegionIntoView( |
591 Session* session, | 598 Session* session, |
592 WebView* web_view, | 599 WebView* web_view, |
593 const std::string& element_id, | 600 const std::string& element_id, |
594 const WebRect& region, | 601 const WebRect& region, |
595 bool center, | 602 bool center, |
596 const std::string& clickable_element_id, | 603 const std::string& clickable_element_id, |
597 WebPoint* location) { | 604 WebPoint* location) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 status = ScrollElementRegionIntoViewHelper( | 645 status = ScrollElementRegionIntoViewHelper( |
639 rit->parent_frame_id, web_view, frame_element_id, | 646 rit->parent_frame_id, web_view, frame_element_id, |
640 WebRect(region_offset, region_size), | 647 WebRect(region_offset, region_size), |
641 center, frame_element_id, ®ion_offset); | 648 center, frame_element_id, ®ion_offset); |
642 if (status.IsError()) | 649 if (status.IsError()) |
643 return status; | 650 return status; |
644 } | 651 } |
645 *location = region_offset; | 652 *location = region_offset; |
646 return Status(kOk); | 653 return Status(kOk); |
647 } | 654 } |
OLD | NEW |