예제 #1
0
static bool shouldConvertTouchToMouse(Element* element)
{
    if (!element)
        return false;

    if ((element->hasTagName(HTMLNames::objectTag) || element->hasTagName(HTMLNames::embedTag)) && static_cast<HTMLPlugInElement*>(element))
        return true;

    // Input Range element is a special case that requires natural mouse events
    // in order to allow dragging of the slider handle.
    // Input Range element might appear in the webpage, or it might appear in the shadow tree,
    // like the timeline and volume media controls all use Input Range.
    // won't operate on the shadow node of other element type, because the webpages
    // aren't able to attach listeners to shadow content.
    do {
        element = toElement(element->shadowAncestorNode()); // If an element is not in shadow tree, shadowAncestorNode returns itself.
        if (isRangeControlElement(element))
            return true;
    } while (element->isInShadowTree());

    // Check if the element has a mouse listener and no touch listener. If so,
    // the field will require touch events be converted to mouse events to function properly.
    return hasMouseMoveListener(element) && !hasTouchListener(element);

}
예제 #2
0
static bool elementExpectsMouseEvents(Element* element)
{
    // Make sure we are not operating a shadow node here, since the webpages
    // aren't able to attach event listeners to shadow content.
    ASSERT(element);
    while (element->isInShadowTree())
        element = toElement(element->shadowAncestorNode());

    return hasMouseMoveListener(element) && !hasTouchListener(element);
}