void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node)
{
    if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node->isElementNode() || !node->ownerDocument()->isActive())
        return;
    m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgent, &overlayMainFrame()->script());
    toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridden(true);
}
String InspectorOverlay::evaluateInOverlayForTest(const String& script)
{
    ScriptForbiddenScope::AllowUserAgentScript allowScript;
    v8::HandleScope handleScope(toIsolate(overlayMainFrame()));
    v8::Local<v8::Value> string = toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script), ScriptController::ExecuteScriptWhenScriptsDisabled);
    return toCoreStringWithUndefinedOrNullCheck(string);
}
Beispiel #3
0
void InspectorOverlay::updateAllLifecyclePhases() {
  if (isEmpty())
    return;

  AutoReset<bool> scoped(&m_inLayout, true);
  if (m_needsUpdate) {
    m_needsUpdate = false;
    rebuildOverlayPage();
  }
  overlayMainFrame()->view()->updateAllLifecyclePhases();
}
bool InspectorOverlay::handleInputEvent(const WebInputEvent& inputEvent)
{
    bool handled = false;

    if (isEmpty())
        return false;

    if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) {
        // Only let GestureTab in (we only need it and we know PlatformGestureEventBuilder supports it).
        PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEvent));
        handled = handleGestureEvent(gestureEvent);
        if (handled)
            return true;

        overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent);
    }
    if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != WebInputEvent::MouseEnter) {
        // PlatformMouseEventBuilder does not work with MouseEnter type, so we filter it out manually.
        PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent));

        if (mouseEvent.type() == PlatformEvent::MouseMoved)
            handled = handleMouseMove(mouseEvent);
        else if (mouseEvent.type() == PlatformEvent::MousePressed)
            handled = handleMousePress();

        if (handled)
            return true;

        if (mouseEvent.type() == PlatformEvent::MouseMoved)
            handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mouseEvent) != WebInputEventResult::NotHandled;
        if (mouseEvent.type() == PlatformEvent::MousePressed)
            handled = overlayMainFrame()->eventHandler().handleMousePressEvent(mouseEvent) != WebInputEventResult::NotHandled;
        if (mouseEvent.type() == PlatformEvent::MouseReleased)
            handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent(mouseEvent) != WebInputEventResult::NotHandled;
    }

    if (WebInputEvent::isTouchEventType(inputEvent.type)) {
        PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent));
        handled = handleTouchEvent(touchEvent);
        if (handled)
            return true;
        overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent);
    }
    if (WebInputEvent::isKeyboardEventType(inputEvent.type)) {
        PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(static_cast<const WebKeyboardEvent&>(inputEvent));
        overlayMainFrame()->eventHandler().keyEvent(keyboardEvent);
    }

    if (inputEvent.type == WebInputEvent::MouseWheel) {
        PlatformWheelEvent wheelEvent = PlatformWheelEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebMouseWheelEvent&>(inputEvent));
        handled = overlayMainFrame()->eventHandler().handleWheelEvent(wheelEvent) != WebInputEventResult::NotHandled;
    }

    return handled;
}
Beispiel #5
0
void InspectorOverlay::rebuildOverlayPage() {
  FrameView* view = m_frameImpl->frameView();
  LocalFrame* frame = m_frameImpl->frame();
  if (!view || !frame)
    return;

  IntRect visibleRectInDocument =
      view->getScrollableArea()->visibleContentRect();
  IntSize viewportSize = frame->host()->visualViewport().size();
  overlayMainFrame()->view()->resize(viewportSize);
  overlayPage()->frameHost().visualViewport().setSize(viewportSize);
  overlayMainFrame()->setPageZoomFactor(windowToViewportScale());

  reset(viewportSize, visibleRectInDocument.location());

  if (m_showReloadingBlanket) {
    evaluateInOverlay("showReloadingBlanket", "");
    return;
  }
  drawNodeHighlight();
  drawQuadHighlight();
  drawPausedInDebuggerMessage();
  drawViewSize();
}
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());
}