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

Method IsObscured

cpp/iedriver/Element.cpp:264–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264bool Element::IsObscured(LocationInfo* click_location,
265 long* obscuring_element_index,
266 std::string* obscuring_element_description) {
267 CComPtr<ISVGElement> svg_element;
268 HRESULT hr = this->element_->QueryInterface<ISVGElement>(&svg_element);
269 if (SUCCEEDED(hr) && svg_element != NULL) {
270 // SVG elements can have complex paths making them non-hierarchical
271 // when drawn. We'll just assume the user knows what they're doing
272 // and bail on this test here.
273 return false;
274 }
275
276 // If an element has a style value where pointer-events is set to 'none',
277 // the element is "obscured" by definition, since any mouse interaction
278 // will not be handled by the element.
279 CComPtr<IHTMLCSSStyleDeclaration> computed_style;
280 if (this->GetComputedStyle(&computed_style)) {
281 CComBSTR pointer_events_value = L"";
282 hr = computed_style->get_pointerEvents(&pointer_events_value);
283 if (SUCCEEDED(hr) && pointer_events_value == L"none") {
284 return true;
285 }
286 }
287
288 // The element being obscured only makes sense within the context
289 // of its own document, even if it's not in the top-level document.
290 LocationInfo element_location = {};
291 int status_code = this->GetLocation(&element_location, nullptr);
292 *click_location = this->CalculateClickPoint(element_location, false);
293 long x = click_location->x;
294 long y = click_location->y;
295
296 bool is_inline = this->IsInline();
297
298 CComPtr<IHTMLDocument2> doc;
299 this->GetContainingDocument(false, &doc);
300 CComPtr<IHTMLElement> element_hit;
301 hr = doc->elementFromPoint(x, y, &element_hit);
302 if (SUCCEEDED(hr) && element_hit) {
303 if (element_.IsEqualObject(element_hit)) {
304 // Short circuit the use of elementsFromPoint if we don't
305 // have to use it.
306 return false;
307 } else {
308 // Short circuit in the case where this element is specifically
309 // an "inline" element (<label>, <span>, <a>, at present),
310 // and the top-most element as determined by elementFromPoint is
311 // a direct child of this element. This is to work around IE's bug
312 // in elementsFromPoint that does not return inline elements in the
313 // list of elements hit.
314 // N.B., this is a hack of the highest order, and there's every
315 // likelihood that some page somewhere will fail this check.
316 if (is_inline) {
317 CComPtr<IHTMLElement> element_hit_parent;
318 hr = element_hit->get_parentElement(&element_hit_parent);
319 CComBSTR element_hit_parent_tag;
320 element_hit_parent->get_tagName(&element_hit_parent_tag);
321 if (SUCCEEDED(hr) && element_hit_parent) {

Callers 1

ExecuteInternalMethod · 0.80

Calls 9

GetComputedStyleMethod · 0.95
GetLocationMethod · 0.95
CalculateClickPointMethod · 0.95
IsInlineMethod · 0.95
GetContainingDocumentMethod · 0.95
HasShadowRootMethod · 0.95
elementMethod · 0.95
IsDisplayedMethod · 0.80

Tested by

no test coverage detected