[WPE] Use new view state API from libwpe
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2018 12:57:22 +0000 (12:57 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2018 12:57:22 +0000 (12:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191906

Reviewed by Žan Doberšek.

Source/WebKit:

Remove WKViewSetViewState from the C API.

* UIProcess/API/C/wpe/WKAPICastWPE.h:
* UIProcess/API/C/wpe/WKView.cpp:
* UIProcess/API/C/wpe/WKView.h:
* UIProcess/API/wpe/WPEView.cpp:
(WKWPE::View::View): Add implementation for activity_state_changed vfunc of the view backend client.):
(WKWPE::View::setViewState): Remove the default flags.
* UIProcess/API/wpe/WPEView.h:
(WKWPE::View::setViewState const): Make it private.

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(beforeAll): Enable /webkit/WebKitWebView/page-visibility in WPE.
* TestWebKitAPI/glib/WebKitGLib/TestMain.h:
(Test::createWebViewBackend): Make the view initially hidden for consistency with GTK+ tests.
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
* TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:
(WebViewTest::showInWindow): Add wpe_view_activity_state_visible, wpe_view_activity_state_in_window and
wpe_view_activity_state_focused state flags.
(WebViewTest::hideView): Remove wpe_view_activity_state_visible and wpe_view_activity_state_focused state flags.
* wpe/backends/HeadlessViewBackend.cpp:
(WPEToolingBackends::HeadlessViewBackend::HeadlessViewBackend): Assume view is always visible, focused and in window.
* wpe/backends/WindowViewBackend.cpp:
(WPEToolingBackends::WindowViewBackend::WindowViewBackend): Update the view state flags depending on state
received in configure callback.
* wpe/jhbuild.modules: Bump libwpe to 1.1.0

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239203 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/wpe/WKAPICastWPE.h
Source/WebKit/UIProcess/API/C/wpe/WKView.cpp
Source/WebKit/UIProcess/API/C/wpe/WKView.h
Source/WebKit/UIProcess/API/wpe/WPEView.cpp
Source/WebKit/UIProcess/API/wpe/WPEView.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp
Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h
Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h
Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp
Tools/wpe/backends/HeadlessViewBackend.cpp
Tools/wpe/backends/WindowViewBackend.cpp
Tools/wpe/jhbuild.modules

index 9fbabea..5b7507a 100644 (file)
@@ -1,3 +1,21 @@
+2018-12-14  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [WPE] Use new view state API from libwpe
+        https://bugs.webkit.org/show_bug.cgi?id=191906
+
+        Reviewed by Žan Doberšek.
+
+        Remove WKViewSetViewState from the C API.
+
+        * UIProcess/API/C/wpe/WKAPICastWPE.h:
+        * UIProcess/API/C/wpe/WKView.cpp:
+        * UIProcess/API/C/wpe/WKView.h:
+        * UIProcess/API/wpe/WPEView.cpp:
+        (WKWPE::View::View): Add implementation for activity_state_changed vfunc of the view backend client.):
+        (WKWPE::View::setViewState): Remove the default flags.
+        * UIProcess/API/wpe/WPEView.h:
+        (WKWPE::View::setViewState const): Make it private.
+
 2018-12-13  Joseph Pecoraro  <pecoraro@apple.com>
 
         [iOS] Web Inspector: Occasional UIProcess crashes under WebPageProxy::showInspectorIndication
index 4bfe6cc..1e67840 100644 (file)
@@ -32,7 +32,6 @@
 
 #include "WKView.h"
 #include "WebGrammarDetail.h"
-#include <WebCore/ActivityState.h>
 
 namespace WKWPE {
 class View;
@@ -48,18 +47,6 @@ inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& gram
     return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));
 }
 
-inline OptionSet<WebCore::ActivityState::Flag> toViewStateFlags(WKViewState wkViewState)
-{
-    OptionSet<WebCore::ActivityState::Flag> viewStateFlags;
-
-    if (wkViewState & kWKViewStateIsInWindow)
-        viewStateFlags.add(WebCore::ActivityState::IsInWindow);
-    if (wkViewState & kWKViewStateIsVisible)
-        viewStateFlags.add(WebCore::ActivityState::IsVisible);
-
-    return viewStateFlags;
-}
-
 }
 
 #endif // WKAPICastWPE_h
index 50149ff..78bba39 100644 (file)
@@ -50,11 +50,6 @@ WKPageRef WKViewGetPage(WKViewRef view)
     return toAPI(&toImpl(view)->page());
 }
 
-void WKViewSetViewState(WKViewRef view, WKViewState viewState)
-{
-    toImpl(view)->setViewState(toViewStateFlags(viewState));
-}
-
 void WKViewSetViewClient(WKViewRef view, const WKViewClientBase* client)
 {
     class ViewClient final : public API::Client<WKViewClientBase>, public API::ViewClient {
index 1115a0e..8fb9839 100644 (file)
@@ -39,14 +39,6 @@ WK_EXPORT WKViewRef WKViewCreate(struct wpe_view_backend*, WKPageConfigurationRe
 
 WK_EXPORT WKPageRef WKViewGetPage(WKViewRef);
 
-enum {
-    kWKViewStateIsInWindow = 1 << 0,
-    kWKViewStateIsVisible = 1 << 1,
-};
-typedef uint32_t WKViewState;
-
-WK_EXPORT void WKViewSetViewState(WKViewRef, WKViewState);
-
 typedef void (*WKViewFrameDisplayed)(WKViewRef view, const void* clientInfo);
 
 typedef struct WKViewClientBase {
index fffcb11..afdbd07 100644 (file)
@@ -45,7 +45,9 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC
     : m_client(std::make_unique<API::ViewClient>())
     , m_pageClient(std::make_unique<PageClientImpl>(*this))
     , m_size { 800, 600 }
+#if !defined(WPE_BACKEND_CHECK_VERSION) || !WPE_BACKEND_CHECK_VERSION(1, 1, 0)
     , m_viewStateFlags { WebCore::ActivityState::WindowIsActive, WebCore::ActivityState::IsFocused, WebCore::ActivityState::IsVisible, WebCore::ActivityState::IsInWindow }
+#endif
     , m_compositingManagerProxy(*this)
     , m_backend(backend)
 {
@@ -88,8 +90,26 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC
             auto& view = *reinterpret_cast<View*>(data);
             view.frameDisplayed();
         },
-        // padding
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+        // activity_state_changed
+        [](void* data, uint32_t state)
+        {
+            auto& view = *reinterpret_cast<View*>(data);
+            OptionSet<WebCore::ActivityState::Flag> flags;
+            if (state & wpe_view_activity_state_visible)
+                flags.add(WebCore::ActivityState::IsVisible);
+            if (state & wpe_view_activity_state_focused) {
+                flags.add(WebCore::ActivityState::IsFocused);
+                flags.add(WebCore::ActivityState::WindowIsActive);
+            }
+            if (state & wpe_view_activity_state_in_window)
+                flags.add(WebCore::ActivityState::IsInWindow);
+            view.setViewState(flags);
+        },
+#else
         nullptr,
+#endif
+        // padding
         nullptr,
         nullptr,
         nullptr
@@ -174,10 +194,8 @@ void View::setSize(const WebCore::IntSize& size)
 
 void View::setViewState(OptionSet<WebCore::ActivityState::Flag> flags)
 {
-    static const OptionSet<WebCore::ActivityState::Flag> defaultFlags { WebCore::ActivityState::WindowIsActive, WebCore::ActivityState::IsFocused };
-
-    auto changedFlags = m_viewStateFlags ^ (defaultFlags | flags);
-    m_viewStateFlags = defaultFlags | flags;
+    auto changedFlags = m_viewStateFlags ^ flags;
+    m_viewStateFlags = flags;
 
     if (changedFlags)
         m_pageProxy->activityStateDidChange(changedFlags);
index 2ab4853..99bf278 100644 (file)
@@ -69,7 +69,6 @@ public:
     const WebCore::IntSize& size() const { return m_size; }
 
     OptionSet<WebCore::ActivityState::Flag> viewState() const { return m_viewStateFlags; }
-    void setViewState(OptionSet<WebCore::ActivityState::Flag>);
 
     void close();
 
@@ -82,6 +81,7 @@ private:
     View(struct wpe_view_backend*, const API::PageConfiguration&);
 
     void setSize(const WebCore::IntSize&);
+    void setViewState(OptionSet<WebCore::ActivityState::Flag>);
 
     std::unique_ptr<API::ViewClient> m_client;
 
index 53567cd..801ed44 100644 (file)
@@ -1,3 +1,26 @@
+2018-12-14  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [WPE] Use new view state API from libwpe
+        https://bugs.webkit.org/show_bug.cgi?id=191906
+
+        Reviewed by Žan Doberšek.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
+        (beforeAll): Enable /webkit/WebKitWebView/page-visibility in WPE.
+        * TestWebKitAPI/glib/WebKitGLib/TestMain.h:
+        (Test::createWebViewBackend): Make the view initially hidden for consistency with GTK+ tests.
+        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
+        * TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp:
+        (WebViewTest::showInWindow): Add wpe_view_activity_state_visible, wpe_view_activity_state_in_window and
+        wpe_view_activity_state_focused state flags.
+        (WebViewTest::hideView): Remove wpe_view_activity_state_visible and wpe_view_activity_state_focused state flags.
+        * wpe/backends/HeadlessViewBackend.cpp:
+        (WPEToolingBackends::HeadlessViewBackend::HeadlessViewBackend): Assume view is always visible, focused and in window.
+        * wpe/backends/WindowViewBackend.cpp:
+        (WPEToolingBackends::WindowViewBackend::WindowViewBackend): Update the view state flags depending on state
+        received in configure callback.
+        * wpe/jhbuild.modules: Bump libwpe to 1.1.0
+
 2018-12-13  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [WinCairo][Clang] DLLLauncherMain.cpp: warning: unused function 'prependPath' and 'appleApplicationSupportDirectory'
index ba91024..45ec1e5 100644 (file)
@@ -714,7 +714,6 @@ static void testWebViewSave(SaveWebViewTest* test, gconstpointer)
     g_assert_cmpint(g_file_info_get_size(fileInfo.get()), ==, totalBytesFromStream);
 }
 
-#if PLATFORM(GTK)
 // To test page visibility API. Currently only 'visible', 'hidden' and 'prerender' states are implemented fully in WebCore.
 // See also http://www.w3.org/TR/2011/WD-page-visibility-20110602/ and https://developers.google.com/chrome/whitepapers/pagevisibility
 static void testWebViewPageVisibility(WebViewTest* test, gconstpointer)
@@ -776,6 +775,7 @@ static void testWebViewPageVisibility(WebViewTest* test, gconstpointer)
     g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult));
 }
 
+#if PLATFORM(GTK)
 class SnapshotWebViewTest: public WebViewTest {
 public:
     MAKE_GLIB_TEST_FIXTURE(SnapshotWebViewTest);
@@ -1261,8 +1261,8 @@ void beforeAll()
     // FIXME: View is initially visible in WPE and has a fixed hardcoded size.
 #if PLATFORM(GTK)
     SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
-    WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
 #endif
+    WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
 #if ENABLE(NOTIFICATIONS)
     NotificationWebViewTest::add("WebKitWebView", "notification", testWebViewNotification);
     NotificationWebViewTest::add("WebKitWebView", "notification-initial-permission-allowed", testWebViewNotificationInitialPermissionAllowed);
index 57a2d20..313f217 100644 (file)
@@ -143,6 +143,10 @@ public:
     static WebKitWebViewBackend* createWebViewBackend()
     {
         auto* headlessBackend = new WPEToolingBackends::HeadlessViewBackend(800, 600);
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+        // Make the view initially hidden for consistency with GTK+ tests.
+        wpe_view_backend_remove_activity_state(headlessBackend->backend(), wpe_view_activity_state_visible | wpe_view_activity_state_focused);
+#endif
         return webkit_web_view_backend_new(headlessBackend->backend(), [](gpointer userData) {
             delete static_cast<WPEToolingBackends::HeadlessViewBackend*>(userData);
         }, headlessBackend);
index 2d2b31f..3d4d511 100644 (file)
@@ -69,6 +69,10 @@ public:
     void emitPopupMenuSignal();
 #endif
 
+#if PLATFORM(WPE)
+    void showInWindow();
+#endif
+
     WebKitJavascriptResult* runJavaScriptAndWaitUntilFinished(const char* javascript, GError**);
     WebKitJavascriptResult* runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError**);
     WebKitJavascriptResult* runJavaScriptInWorldAndWaitUntilFinished(const char* javascript, const char* world, GError**);
index ccf15c2..6494186 100644 (file)
@@ -20,6 +20,8 @@
 #include "config.h"
 #include "WebViewTest.h"
 
+#include <wpe/wpe.h>
+
 void WebViewTest::platformDestroy()
 {
 }
@@ -39,9 +41,20 @@ void WebViewTest::resizeView(int width, int height)
     // FIXME: implement.
 }
 
+void WebViewTest::showInWindow()
+{
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+    auto* backend = webkit_web_view_backend_get_wpe_backend(webkit_web_view_get_backend(m_webView));
+    wpe_view_backend_add_activity_state(backend, wpe_view_activity_state_visible | wpe_view_activity_state_in_window | wpe_view_activity_state_focused);
+#endif
+}
+
 void WebViewTest::hideView()
 {
-    // FIXME: implement.
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+    auto* backend = webkit_web_view_backend_get_wpe_backend(webkit_web_view_get_backend(m_webView));
+    wpe_view_backend_remove_activity_state(backend, wpe_view_activity_state_visible | wpe_view_activity_state_focused);
+#endif
 }
 
 void WebViewTest::mouseMoveTo(int x, int y, unsigned mouseModifiers)
index ed1ada4..8e12ee6 100644 (file)
@@ -72,6 +72,10 @@ HeadlessViewBackend::HeadlessViewBackend(uint32_t width, uint32_t height)
     if (!initialize())
         return;
 
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+    wpe_view_backend_add_activity_state(backend(), wpe_view_activity_state_visible | wpe_view_activity_state_focused | wpe_view_activity_state_in_window);
+#endif
+
     if (!eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, m_eglContext))
         return;
 
index 65221e1..20f03b8 100644 (file)
@@ -434,12 +434,48 @@ const struct zxdg_surface_v6_listener WindowViewBackend::s_xdgSurfaceListener =
 
 const struct zxdg_toplevel_v6_listener WindowViewBackend::s_xdgToplevelListener = {
     // configure
-    [](void*, struct zxdg_toplevel_v6*, int32_t /*width*/, int32_t /*height*/, struct wl_array*)
+    [](void* data, struct zxdg_toplevel_v6*, int32_t width, int32_t height, struct wl_array* states)
     {
-        // FIXME: dispatch the size against wpe_view_backend.
+        auto& window = *static_cast<WindowViewBackend*>(data);
+        wpe_view_backend_dispatch_set_size(window.backend(), width, height);
+
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+        bool isFocused = false;
+        void* p;
+        wl_array_for_each(p, states)
+        {
+            uint32_t state = *static_cast<uint32_t*>(p);
+
+            switch (state) {
+            case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
+                isFocused = true;
+                break;
+            case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
+            case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
+            case ZXDG_TOPLEVEL_V6_STATE_RESIZING:
+            default:
+                break;
+            }
+        }
+
+        if (isFocused)
+            wpe_view_backend_add_activity_state(window.backend(), wpe_view_activity_state_focused);
+        else
+            wpe_view_backend_remove_activity_state(window.backend(), wpe_view_activity_state_focused);
+#else
+        (void)states;
+#endif
     },
     // close
-    [](void*, struct zxdg_toplevel_v6*) { },
+    [](void* data, struct zxdg_toplevel_v6*)
+    {
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+        auto& window = *static_cast<WindowViewBackend*>(data);
+        wpe_view_backend_remove_activity_state(window.backend(), wpe_view_activity_state_visible | wpe_view_activity_state_focused | wpe_view_activity_state_in_window);
+#else
+        (void)data;
+#endif
+    },
 };
 
 WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height)
@@ -486,9 +522,12 @@ WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height)
         zxdg_surface_v6_add_listener(m_xdgSurface, &s_xdgSurfaceListener, nullptr);
         m_xdgToplevel = zxdg_surface_v6_get_toplevel(m_xdgSurface);
         if (m_xdgToplevel) {
-            zxdg_toplevel_v6_add_listener(m_xdgToplevel, &s_xdgToplevelListener, nullptr);
+            zxdg_toplevel_v6_add_listener(m_xdgToplevel, &s_xdgToplevelListener, this);
             zxdg_toplevel_v6_set_title(m_xdgToplevel, "WPE");
             wl_surface_commit(m_surface);
+#if defined(WPE_BACKEND_CHECK_VERSION) && WPE_BACKEND_CHECK_VERSION(1, 1, 0)
+            wpe_view_backend_add_activity_state(backend(), wpe_view_activity_state_visible | wpe_view_activity_state_in_window);
+#endif
         }
     }
 
index edc26cd..85b6328 100644 (file)
   </autotools>
 
   <cmake id="libwpe">
-      <branch repo="wpewebkit" module="libwpe-1.0.0.tar.xz" version="1.0.0"
-              hash="sha256:aff11612123f9ab85a8b9a4bcdfb3a7503eba0a0d2d96f2cdecd30e911091719" />
+      <branch repo="wpewebkit" module="libwpe-1.1.0.tar.xz" version="1.1.0"
+              hash="sha256:72e34ad754be11abd1a438cfe195d8d644c52105ab2b1c3b39dec6228bc776ce"/>
   </cmake>
 
   <cmake id="wpebackend-fdo">