void ChromeClientImpl::setCursor(const WebCursorInfo& cursor, LocalFrame* localRoot)
{
    if (m_cursorOverridden)
        return;

#if OS(MACOSX)
    // On Mac the mousemove event propagates to both the popup and main window.
    // If a popup is open we don't want the main window to change the cursor.
    if (m_webView->hasOpenedPopup())
        return;
#endif
    if (!m_webView->client())
        return;
    // TODO(kenrb, dcheng): For top-level frames we still use the WebView as
    // a WebWidget. This special case will be removed when top-level frames
    // get WebFrameWidgets.
    if (localRoot->isMainFrame()) {
        m_webView->client()->didChangeCursor(cursor);
    } else {
        WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(localRoot);
        ASSERT(webFrame);
        ASSERT(webFrame->frameWidget());
        if (toWebFrameWidgetImpl(webFrame->frameWidget())->client())
            toWebFrameWidgetImpl(webFrame->frameWidget())->client()->didChangeCursor(cursor);
    }
}
Example #2
0
void PageOverlay::update() {
  if (!m_frameImpl->frameWidget()->isAcceleratedCompositingActive())
    return;

  LocalFrame* frame = m_frameImpl->frame();
  if (!frame)
    return;

  if (!m_layer) {
    m_layer = GraphicsLayer::create(this);
    m_layer->setDrawsContent(true);

    if (WebDevToolsAgentImpl* devTools = m_frameImpl->devToolsAgentImpl())
      devTools->willAddPageOverlay(m_layer.get());

    // This is required for contents of overlay to stay in sync with the page
    // while scrolling.
    WebLayer* platformLayer = m_layer->platformLayer();
    platformLayer->addMainThreadScrollingReasons(
        MainThreadScrollingReason::kPageOverlay);
    if (frame->isMainFrame()) {
      frame->host()->visualViewport().containerLayer()->addChild(m_layer.get());
    } else {
      toWebFrameWidgetImpl(m_frameImpl->frameWidget())
          ->rootGraphicsLayer()
          ->addChild(m_layer.get());
    }
  }

  FloatSize size(frame->host()->visualViewport().size());
  if (size != m_layer->size())
    m_layer->setSize(size);

  m_layer->setNeedsDisplay();
}
// static
PassOwnPtrWillBeRawPtr<WebDevToolsAgentImpl> WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, WebDevToolsAgentClient* client)
{
    WebViewImpl* view = frame->viewImpl();
    // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even though |frame| is meant to be main frame.
    // See http://crbug.com/526162.
    bool isMainFrame = view && !frame->parent();
    if (!isMainFrame) {
        WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, nullptr);
        if (frame->frameWidget())
            agent->layerTreeViewChanged(toWebFrameWidgetImpl(frame->frameWidget())->layerTreeView());
        return adoptPtrWillBeNoop(agent);
    }

    WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, InspectorOverlay::create(view));
    // TODO(dgozman): we should actually pass the view instead of frame, but during
    // remote->local transition we cannot access mainFrameImpl() yet, so we have to store the
    // frame which will become the main frame later.
    agent->registerAgent(InspectorRenderingAgent::create(frame));
    agent->registerAgent(InspectorEmulationAgent::create(frame, agent));
    // TODO(dgozman): migrate each of the following agents to frame once module is ready.
    agent->registerAgent(InspectorDatabaseAgent::create(view->page()));
    agent->registerAgent(DeviceOrientationInspectorAgent::create(view->page()));
    agent->registerAgent(InspectorAccessibilityAgent::create(view->page()));
    agent->registerAgent(InspectorDOMStorageAgent::create(view->page()));
    agent->registerAgent(InspectorCacheStorageAgent::create());
    agent->layerTreeViewChanged(view->layerTreeView());
    return adoptPtrWillBeNoop(agent);
}
void ChromeClientImpl::detachCompositorAnimationTimeline(WebCompositorAnimationTimeline* compositorTimeline, LocalFrame* localRoot)
{
    // FIXME: For top-level frames we still use the WebView as a WebWidget. This
    // special case will be removed when top-level frames get WebFrameWidgets.
    if (localRoot->isMainFrame()) {
        m_webView->detachCompositorAnimationTimeline(compositorTimeline);
    } else {
        WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(localRoot);
        // FIXME: The following conditional is only needed for staging until the
        // Chromium patch lands that instantiates a WebFrameWidget.
        if (!webFrame->frameWidget()) {
            m_webView->detachCompositorAnimationTimeline(compositorTimeline);
            return;
        }
        ASSERT(webFrame);
        ASSERT(webFrame->frameWidget());
        toWebFrameWidgetImpl(webFrame->frameWidget())->detachCompositorAnimationTimeline(compositorTimeline);
    }
}
void ChromeClientImpl::attachRootGraphicsLayer(GraphicsLayer* rootLayer, LocalFrame* localRoot)
{
    // FIXME: For top-level frames we still use the WebView as a WebWidget. This
    // special case will be removed when top-level frames get WebFrameWidgets.
    if (localRoot->isMainFrame()) {
        m_webView->setRootGraphicsLayer(rootLayer);
    } else {
        WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(localRoot);
        // FIXME: The following conditional is only needed for staging until the
        // Chromium patch lands that instantiates a WebFrameWidget.
        if (!webFrame->frameWidget()) {
            m_webView->setRootGraphicsLayer(rootLayer);
            return;
        }
        ASSERT(webFrame);
        ASSERT(webFrame->frameWidget());
        toWebFrameWidgetImpl(webFrame->frameWidget())->setRootGraphicsLayer(rootLayer);
    }
}