bool FatFingers::isElementClickable(Element* element) const { ASSERT(element); ASSERT(m_matchingApproach != Done); ASSERT(m_targetType == ClickableElement); switch (m_matchingApproach) { case ClickableByDefault: { ExceptionCode ec = 0; return element->webkitMatchesSelector("a[href],*:link,*:visited,*[role=button],button,input,select,label[for],area[href],textarea,embed,object", ec) || element->isMediaControlElement() || element->isContentEditable(); } case MadeClickableByTheWebpage: // Elements within a shadow DOM can not be 'made clickable by the webpage', since // they are not accessible. if (element->isInShadowTree()) return false; // FIXME: We fall back to checking for the presence of CSS style "cursor: pointer" to indicate whether the element A // can be clicked when A neither registers mouse events handlers nor is a hyperlink or form control. This workaround // ensures that we don't break various Google web apps, including <http://maps.google.com>. Ideally, we should walk // up the DOM hierarchy to determine the first parent element that accepts mouse events. // Consider the HTML snippet: <div id="A" onclick="..."><div id="B">Example</div></div> // Notice, B is not a hyperlink, or form control, and does not register any mouse event handler. Then B cannot // be clicked. Suppose B specified the CSS property "cursor: pointer". Then, B will be considered as clickable. return hasMousePressListener(element) || CSSComputedStyleDeclaration::create(element)->getPropertyValue(cssPropertyID("cursor")) == "pointer"; default: ASSERT_NOT_REACHED(); } return false; }
bool FatFingers::isElementClickable(Element* element) const { ASSERT(element); ASSERT(m_targetType == ClickableElement); ExceptionCode ec = 0; if (element->webkitMatchesSelector("a[href],*:link,*:visited,*[role=button],button,input,select,label[for],area[href],textarea,embed,object", ec) || element->isMediaControlElement() || element->isContentEditable()) return true; return hasMousePressListener(element) || CSSComputedStyleDeclaration::create(element)->getPropertyValue(cssPropertyID("cursor")) == "pointer"; }