Changeset 285000 in webkit


Ignore:
Timestamp:
Oct 28, 2021, 1:57:59 PM (4 years ago)
Author:
Adrian Perez de Castro
Message:

[WPE][Qt] Do not use WebKit internals in the implementation
https://bugs.webkit.org/show_bug.cgi?id=232228

Reviewed by Philippe Normand.

Remove usage of GRefPtr, GUniquePtr, WTF macros, and usage of the config.h header from
the WPE Qt API implementation, as all the funcionality can be achieved on top of the
public API. This allows building the Qt plug-in in a standalone fashion, without involving
any of the WebKit machinery, and a sample CMakeLists.txt which does that is provided as
well. Distributors may prefer to build using this approach instead of as part of the whole
WebKit compilation process, specially if when providing split packages on top of their
base WPE WebKit ones.

No new tests needed.

  • UIProcess/API/wpe/qt/CMakeLists.txt: Added.
  • UIProcess/API/wpe/qt/WPEQmlExtensionPlugin.cpp:
  • UIProcess/API/wpe/qt/WPEQtView.cpp:

(WPEQtView::createWebView):
(jsAsyncReadyCallback):

  • UIProcess/API/wpe/qt/WPEQtView.h:
  • UIProcess/API/wpe/qt/WPEQtViewBackend.cpp:

(WPEQtViewBackend::displayImage):

  • UIProcess/API/wpe/qt/WPEQtViewLoadRequest.cpp:
Location:
trunk/Source/WebKit
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r284997 r285000  
     12021-10-28  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [WPE][Qt] Do not use WebKit internals in the implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=232228
     5
     6        Reviewed by Philippe Normand.
     7
     8        Remove usage of GRefPtr, GUniquePtr, WTF macros, and usage of the config.h header from
     9        the WPE Qt API implementation, as all the funcionality can be achieved on top of the
     10        public API. This allows building the Qt plug-in in a standalone fashion, without involving
     11        any of the WebKit machinery, and a sample CMakeLists.txt which does that is provided as
     12        well. Distributors may prefer to build using this approach instead of as part of the whole
     13        WebKit compilation process, specially if when providing split packages on top of their
     14        base WPE WebKit ones.
     15
     16        No new tests needed.
     17
     18        * UIProcess/API/wpe/qt/CMakeLists.txt: Added.
     19        * UIProcess/API/wpe/qt/WPEQmlExtensionPlugin.cpp:
     20        * UIProcess/API/wpe/qt/WPEQtView.cpp:
     21        (WPEQtView::createWebView):
     22        (jsAsyncReadyCallback):
     23        * UIProcess/API/wpe/qt/WPEQtView.h:
     24        * UIProcess/API/wpe/qt/WPEQtViewBackend.cpp:
     25        (WPEQtViewBackend::displayImage):
     26        * UIProcess/API/wpe/qt/WPEQtViewLoadRequest.cpp:
     27
    1282021-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
    229
  • trunk/Source/WebKit/UIProcess/API/wpe/qt/WPEQmlExtensionPlugin.cpp

    r240141 r285000  
    11/*
    2  * Copyright (C) 2018, 2019 Igalia S.L
     2 * Copyright (C) 2018, 2019, 2021 Igalia S.L
    33 * Copyright (C) 2018, 2019 Zodiac Inflight Innovations
    44 *
     
    1919 */
    2020
    21 #include "config.h"
    2221#include "WPEQmlExtensionPlugin.h"
    2322
  • trunk/Source/WebKit/UIProcess/API/wpe/qt/WPEQtView.cpp

    r284983 r285000  
    11/*
    2  * Copyright (C) 2018, 2019 Igalia S.L
     2 * Copyright (C) 2018, 2019, 2021 Igalia S.L
    33 * Copyright (C) 2018, 2019 Zodiac Inflight Innovations
    44 *
     
    1919 */
    2020
    21 #include "config.h"
    2221#include "WPEQtView.h"
    2322
     
    3231#include <QtPlatformHeaders/QEGLNativeContext>
    3332#include <qpa/qplatformnativeinterface.h>
    34 #include <wtf/glib/GUniquePtr.h>
    3533
    3634/*!
     
    9896    auto* context = window()->openglContext();
    9997    std::unique_ptr<WPEQtViewBackend> backend = WPEQtViewBackend::create(m_size, context, display, QPointer<WPEQtView>(this));
    100     RELEASE_ASSERT_WITH_MESSAGE(backend, "EGL initialization failed");
    101     if (!backend)
     98    if (!backend) {
     99        qFatal("WPEQtView::createWebView(): EGL initialization failed");
    102100        return;
     101    }
    103102
    104103    m_backend = backend.get();
    105     auto settings = adoptGRef(webkit_settings_new_with_settings("enable-developer-extras", TRUE,
    106         "enable-webgl", TRUE, "enable-mediasource", TRUE, nullptr));
     104    auto* settings = webkit_settings_new_with_settings("enable-developer-extras", TRUE,
     105        "enable-webgl", TRUE, "enable-mediasource", TRUE, nullptr);
    107106    m_webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
    108107        "backend", webkit_web_view_backend_new(m_backend->backend(), [](gpointer data) {
    109108            delete static_cast<WPEQtViewBackend*>(data);
    110109        }, backend.release()),
    111         "settings", settings.get(), nullptr));
     110        "settings", settings, nullptr));
     111    g_clear_object(&settings);
    112112
    113113    g_signal_connect_swapped(m_webView, "notify::uri", G_CALLBACK(notifyUrlChangedCallback), this);
     
    405405static void jsAsyncReadyCallback(GObject* object, GAsyncResult* result, gpointer userData)
    406406{
    407     GUniqueOutPtr<GError> error;
     407    GError* error { nullptr };
    408408    std::unique_ptr<JavascriptCallbackData> data(reinterpret_cast<JavascriptCallbackData*>(userData));
    409     WebKitJavascriptResult* jsResult = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error.outPtr());
     409    WebKitJavascriptResult* jsResult = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error);
    410410    if (!jsResult) {
    411411        qWarning("Error running javascript: %s", error->message);
     412        g_error_free(error);
    412413        return;
    413414    }
     
    426427        // FIXME: Handle more value types?
    427428        if (jsc_value_is_string(value)) {
    428             GUniquePtr<gchar> strValue(jsc_value_to_string(value));
     429            auto* strValue = jsc_value_to_string(value);
    429430            JSCContext* context = jsc_value_get_context(value);
    430431            JSCException* exception = jsc_context_get_exception(context);
     
    433434                jsc_context_clear_exception(context);
    434435            } else
    435                 variant.setValue(QString::fromUtf8(strValue.get()));
     436                variant.setValue(QString::fromUtf8(strValue));
     437            g_free(strValue);
    436438        }
    437439        args.append(engine->toScriptValue(variant));
  • trunk/Source/WebKit/UIProcess/API/wpe/qt/WPEQtView.h

    r283802 r285000  
    11/*
    2  * Copyright (C) 2018, 2019 Igalia S.L
     2 * Copyright (C) 2018, 2019, 2021 Igalia S.L
    33 * Copyright (C) 2018, 2019 Zodiac Inflight Innovations
    44 *
     
    2121#pragma once
    2222
    23 #include "config.h"
    24 
    2523#include <QQmlEngine>
    2624#include <QQuickItem>
     
    2826#include <memory>
    2927#include <wpe/webkit.h>
    30 #include <wtf/glib/GRefPtr.h>
    3128
    3229class WPEQtViewBackend;
  • trunk/Source/WebKit/UIProcess/API/wpe/qt/WPEQtViewBackend.cpp

    r276308 r285000  
    11/*
    2  * Copyright (C) 2018, 2019 Igalia S.L
     2 * Copyright (C) 2018, 2019, 2021 Igalia S.L
    33 * Copyright (C) 2018, 2019 Zodiac Inflight Innovations
    44 *
     
    1919 */
    2020
    21 #include "config.h"
    2221#include "WPEQtViewBackend.h"
    2322
     
    211210void WPEQtViewBackend::displayImage(struct wpe_fdo_egl_exported_image* image)
    212211{
    213     RELEASE_ASSERT(!m_lockedImage);
     212    Q_ASSUME(!m_lockedImage);
    214213    m_lockedImage = image;
    215214    if (m_view)
  • trunk/Source/WebKit/UIProcess/API/wpe/qt/WPEQtViewLoadRequest.cpp

    r240141 r285000  
    11/*
    2  * Copyright (C) 2018, 2019 Igalia S.L
     2 * Copyright (C) 2018, 2019, 2021 Igalia S.L
    33 * Copyright (C) 2018, 2019 Zodiac Inflight Innovations
    44 *
     
    1919 */
    2020
    21 #include "config.h"
    2221#include "WPEQtViewLoadRequest.h"
    2322
Note: See TracChangeset for help on using the changeset viewer.