Ejemplo n.º 1
0
bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event)
{
    if (!shouldSearchForNode())
        return false;

    LocalFrame* frame = m_webViewImpl->mainFrameImpl()->frame();
    if (!frame->view() || !frame->contentLayoutObject())
        return false;
    Node* node = hoveredNodeForEvent(frame, event, event.shiftKey());

    // Do not highlight within user agent shadow root unless requested.
    if (m_inspectMode != InspectorDOMAgent::SearchingForUAShadow) {
        ShadowRoot* shadowRoot = InspectorDOMAgent::userAgentShadowRoot(node);
        if (shadowRoot)
            node = shadowRoot->host();
    }

    // Shadow roots don't have boxes - use host element instead.
    if (node && node->isShadowRoot())
        node = node->parentOrShadowHostNode();

    if (!node)
        return true;

    Node* eventTarget = event.shiftKey() ? hoveredNodeForEvent(m_webViewImpl->mainFrameImpl()->frame(), event, false) : nullptr;
    if (eventTarget == node)
        eventTarget = nullptr;

    if (node && m_inspectModeHighlightConfig) {
        m_hoveredNodeForInspectMode = node;
        m_domAgent->nodeHighlightedInOverlay(node);
        highlightNode(node, eventTarget, *m_inspectModeHighlightConfig, event.ctrlKey() || event.metaKey());
    }
    return true;
}
Ejemplo n.º 2
0
bool InspectorOverlay::handleTouchEvent(const PlatformTouchEvent& event) {
  if (!shouldSearchForNode())
    return false;
  Node* node = hoveredNodeForEvent(m_frameImpl->frame(), event, false);
  if (node && m_inspectModeHighlightConfig) {
    highlightNode(node, *m_inspectModeHighlightConfig, false);
    inspect(node);
    return true;
  }
  return false;
}
Ejemplo n.º 3
0
bool InspectorOverlay::handleGestureEvent(const PlatformGestureEvent& event)
{
    if (!shouldSearchForNode() || event.type() != PlatformEvent::GestureTap)
        return false;
    Node* node = hoveredNodeForEvent(m_webViewImpl->mainFrameImpl()->frame(), event, false);
    if (node && m_inspectModeHighlightConfig) {
        highlightNode(node, *m_inspectModeHighlightConfig, false);
        inspect(node);
        return true;
    }
    return false;
}
Ejemplo n.º 4
0
void InspectorOverlay::overlayClearSelection(bool commitChanges)
{
    ASSERT(m_layoutEditor);
    m_hoveredNodeForInspectMode = m_layoutEditor->element();

    if (commitChanges)
        m_layoutEditor->commitChanges();

    if (m_layoutEditor) {
        m_layoutEditor->dispose();
        m_layoutEditor.clear();
    }

    if (m_inspectModeHighlightConfig)
        highlightNode(m_hoveredNodeForInspectMode.get(), *m_inspectModeHighlightConfig, false);

    toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridden(false);
    toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursor(pointerCursor(), overlayMainFrame());
}
Ejemplo n.º 5
0
void InspectorOverlay::highlightNode(
    Node* node,
    const InspectorHighlightConfig& highlightConfig,
    bool omitTooltip) {
  highlightNode(node, nullptr, highlightConfig, omitTooltip);
}