WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
{
    ASSERT(m_inspectedPage);

#ifdef HAVE_ECORE_X
    const char* engine = "opengl_x11";
    m_inspectorWindow = ecore_evas_new(engine, 0, 0, initialWindowWidth, initialWindowHeight, 0);

    // Gracefully fall back to software if evas_gl engine is not available.
    if (!m_inspectorWindow)
#endif
    m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0);
    if (!m_inspectorWindow)
        return 0;

    WKContextRef wkContext = toAPI(&inspectorProcessPool());
    WKRetainPtr<WKStringRef> wkGroupIdentifier = adoptWK(WKStringCreateWithUTF8CString(inspectorPageGroupIdentifier().utf8().data()));
    WKPageGroupRef wkPageGroup = WKPageGroupCreateWithIdentifier(wkGroupIdentifier.get());

    WKRetainPtr<WKPageConfigurationRef> wkPageConfiguration = adoptWK(WKPageConfigurationCreate());
    WKPageConfigurationSetContext(wkPageConfiguration.get(), wkContext);
    WKPageConfigurationSetPageGroup(wkPageConfiguration.get(), wkPageGroup);

    m_inspectorView = EWKViewCreate(wkContext, wkPageConfiguration.get(), ecore_evas_get(m_inspectorWindow), /* smart */ 0);
    WKViewRef wkView = EWKViewGetWKView(m_inspectorView);

    WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(DEFAULT_THEME_DIR "/default.edj"));
    WKViewSetThemePath(wkView, wkTheme.get());

    WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup);
    WKPreferencesSetFileAccessFromFileURLsAllowed(wkPreferences, true);
    WKPreferencesSetJavaScriptRuntimeFlags(wkPreferences, 0);

    return toImpl(WKViewGetPage(wkView));
}
Пример #2
0
View::View(GLContext& glContext)
    : m_glContext(glContext)
{
    m_context = WKContextCreate();
    m_pageConfiguration = WKPageConfigurationCreate();
    {
        auto pageGroupIdentifier = adoptWK(WKStringCreateWithUTF8CString("WPEPageGroup"));
        auto pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(pageGroupIdentifier.get()));
        WKPageConfigurationSetContext(m_pageConfiguration, m_context);
        WKPageConfigurationSetPageGroup(m_pageConfiguration, pageGroup.get());
    }

    m_exportable = wpe_mesa_view_backend_exportable_create(&s_exportableClient, this);

    auto* backend = wpe_mesa_view_backend_exportable_get_view_backend(m_exportable);
    m_view = WKViewCreateWithViewBackend(backend, m_pageConfiguration);

    WKPageSetPageNavigationClient(WKViewGetPage(m_view), &s_pageNavigationClient.base);

    m_updateSource = g_timeout_source_new(m_frameRate / 1000);
    g_source_set_callback(m_updateSource,
        [](gpointer data) -> gboolean {
            auto& view = *static_cast<View*>(data);
            view.performUpdate();
            return TRUE;
        }, this, nullptr);
    g_source_attach(m_updateSource, g_main_context_default());
}