virtual void run(Page* page) { if (m_running) return; m_running = true; // 0. Flush pending frontend messages. WebViewImpl* viewImpl = WebViewImpl::fromPage(page); WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(viewImpl->devToolsAgent()); agent->flushPendingFrontendMessages(); Vector<WebViewImpl*> views; // 1. Disable input events. const HashSet<Page*>& pages = Page::ordinaryPages(); HashSet<Page*>::const_iterator end = pages.end(); for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { WebViewImpl* view = WebViewImpl::fromPage(*it); if (!view) continue; m_frozenViews.add(view); views.append(view); view->setIgnoreInputEvents(true); } // Notify embedder about pausing. agent->client()->willEnterDebugLoop(); // 2. Disable active objects WebView::willEnterModalLoop(); // 3. Process messages until quitNow is called. m_messageLoop->run(); // 4. Resume active objects WebView::didExitModalLoop(); // 5. Resume input events. for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) { if (m_frozenViews.contains(*it)) { // The view was not closed during the dispatch. (*it)->setIgnoreInputEvents(false); } } agent->client()->didExitDebugLoop(); // 6. All views have been resumed, clear the set. m_frozenViews.clear(); m_running = false; }
void run(LocalFrame* frame) override { if (m_running) return; m_running = true; // 0. Flush pending frontend messages. WebLocalFrameImpl* frameImpl = WebLocalFrameImpl::fromFrame(frame); WebDevToolsAgentImpl* agent = frameImpl->devToolsAgentImpl(); agent->flushPendingProtocolNotifications(); Vector<WebViewImpl*> views; Vector<WebFrameWidgetImpl*> widgets; // 1. Disable input events. const HashSet<WebViewImpl*>& viewImpls = WebViewImpl::allInstances(); HashSet<WebViewImpl*>::const_iterator viewImplsEnd = viewImpls.end(); for (HashSet<WebViewImpl*>::const_iterator it = viewImpls.begin(); it != viewImplsEnd; ++it) { WebViewImpl* view = *it; m_frozenViews.add(view); views.append(view); view->setIgnoreInputEvents(true); } const HashSet<WebFrameWidgetImpl*>& widgetImpls = WebFrameWidgetImpl::allInstances(); HashSet<WebFrameWidgetImpl*>::const_iterator widgetImplsEnd = widgetImpls.end(); for (HashSet<WebFrameWidgetImpl*>::const_iterator it = widgetImpls.begin(); it != widgetImplsEnd; ++it) { WebFrameWidgetImpl* widget = *it; m_frozenWidgets.add(widget); widgets.append(widget); widget->setIgnoreInputEvents(true); } // 2. Notify embedder about pausing. agent->client()->willEnterDebugLoop(); // 3. Disable active objects WebView::willEnterModalLoop(); // 4. Process messages until quitNow is called. m_messageLoop->run(); // 5. Resume active objects WebView::didExitModalLoop(); // 6. Resume input events. for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) { if (m_frozenViews.contains(*it)) { // The view was not closed during the dispatch. (*it)->setIgnoreInputEvents(false); } } for (Vector<WebFrameWidgetImpl*>::iterator it = widgets.begin(); it != widgets.end(); ++it) { if (m_frozenWidgets.contains(*it)) { // The widget was not closed during the dispatch. (*it)->setIgnoreInputEvents(false); } } // 7. Notify embedder about resuming. agent->client()->didExitDebugLoop(); // 8. All views have been resumed, clear the set. m_frozenViews.clear(); m_frozenWidgets.clear(); m_running = false; }