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

Method IsImageMap

cpp/iedriver/Element.cpp:923–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921}
922
923bool Element::IsImageMap(LocationInfo* location) {
924 CComPtr<IHTMLElement> map_element;
925 CComPtr<IHTMLAreaElement> area_element;
926 CComPtr<IHTMLMapElement> map_element_candidate;
927 this->element_->QueryInterface<IHTMLMapElement>(&map_element_candidate);
928 if (map_element_candidate == NULL) {
929 this->element_->QueryInterface<IHTMLAreaElement>(&area_element);
930 if (area_element) {
931 this->element_->get_parentElement(&map_element);
932 if (map_element) {
933 map_element->QueryInterface<IHTMLMapElement>(&map_element_candidate);
934 }
935 }
936 }
937
938 if (map_element_candidate && map_element) {
939 CComBSTR name_bstr;
940 map_element_candidate->get_name(&name_bstr);
941 CComBSTR img_selector = L"*[usemap='#";
942 img_selector.Append(name_bstr);
943 img_selector.Append(L"']");
944
945 CComPtr<IDispatch> doc_dispatch;
946 map_element->get_document(&doc_dispatch);
947
948 CComPtr<IDocumentSelector> doc;
949 doc_dispatch->QueryInterface<IDocumentSelector>(&doc);
950 if (doc) {
951 CComPtr<IHTMLElement> img_element;
952 doc->querySelector(img_selector, &img_element);
953 if (img_element) {
954 CComPtr<IHTMLElement2> rect_element;
955 img_element->QueryInterface<IHTMLElement2>(&rect_element);
956 if (rect_element) {
957 CComPtr<IHTMLRect> rect;
958 rect_element->getBoundingClientRect(&rect);
959 RECT img_rect;
960 rect->get_left(&img_rect.left);
961 rect->get_top(&img_rect.top);
962 rect->get_right(&img_rect.right);
963 rect->get_bottom(&img_rect.bottom);
964
965 CComBSTR shape;
966 area_element->get_shape(&shape);
967 shape.ToLower();
968 if (shape == L"default") {
969 location->x = img_rect.left;
970 location->y = img_rect.top;
971 location->width = img_rect.right - img_rect.left;
972 location->height = img_rect.bottom - img_rect.top;
973 return true;
974 }
975
976 CComBSTR coords_bstr;
977 area_element->get_coords(&coords_bstr);
978 std::wstring coords(coords_bstr);
979 std::vector<std::wstring> individual;
980 StringUtilities::Split(coords, L",", &individual);

Callers 1

GetLocationMethod · 0.95

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected