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

Method ScrollWithinOverflow

cpp/iedriver/Element.cpp:831–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829}
830
831bool Element::ScrollWithinOverflow(const LocationInfo element_location) {
832 RECT element_rect;
833 element_rect.left = element_location.x;
834 element_rect.top = element_location.y;
835 element_rect.right = element_location.x + element_location.width;
836 element_rect.bottom = element_location.y + element_location.height;
837
838 CComPtr<IHTMLElement> parent_element;
839 this->element_->get_parentElement(&parent_element);
840 while (parent_element != NULL) {
841 CComPtr<IHTMLElement2> el2;
842 parent_element->QueryInterface<IHTMLElement2>(&el2);
843 CComPtr<IHTMLRect> parent_bounding_rect;
844 el2->getBoundingClientRect(&parent_bounding_rect);
845 RECT parent_rect;
846 parent_bounding_rect->get_left(&parent_rect.left);
847 parent_bounding_rect->get_top(&parent_rect.top);
848 parent_bounding_rect->get_right(&parent_rect.right);
849 parent_bounding_rect->get_bottom(&parent_rect.bottom);
850 RECT intersection;
851 if (::IntersectRect(&intersection, &element_rect, &parent_rect)) {
852 if (::EqualRect(&intersection, &element_rect)) {
853 CComPtr<IHTMLElement> next_ancestor;
854 // The entire element is visible within this ancestor.
855 // Need to proceed to the next ancestor in the tree.
856 parent_element->get_parentElement(&next_ancestor);
857 parent_element.Release();
858 parent_element = next_ancestor;
859 } else {
860 // We have the intersecting rect, so adjust the location
861 long intersection_vert_center = intersection.top + ((intersection.bottom - intersection.top) / 2);
862 long intersection_horiz_center = intersection.left + ((intersection.right - intersection.left) / 2);
863
864 long offset_top = 0;
865 element_->get_offsetTop(&offset_top);
866 offset_top += element_location.height / 2;
867
868 long offset_left = 0;
869 element_->get_offsetLeft(&offset_left);
870 offset_left += element_location.width / 2;
871
872 el2->put_scrollTop(offset_top - intersection_vert_center);
873 el2->put_scrollLeft(offset_left - intersection_horiz_center);
874 return true;
875 }
876 } else {
877 // the rects don't intersect, so something went wrong.
878 break;
879 }
880 }
881 return false;
882}
883bool Element::IsLocationVisibleInFrames(const LocationInfo location,
884 const std::vector<LocationInfo> frame_locations) {
885 std::vector<LocationInfo>::const_iterator iterator = frame_locations.begin();

Callers

nothing calls this directly

Calls 1

ReleaseMethod · 0.80

Tested by

no test coverage detected