Diff
Modified: trunk/Source/WebCore/ChangeLog (153427 => 153428)
--- trunk/Source/WebCore/ChangeLog 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebCore/ChangeLog 2013-07-29 16:25:08 UTC (rev 153428)
@@ -1,3 +1,18 @@
+2013-07-29 Sergio Correia <[email protected]>
+
+ CoordinatedGraphics: Add API to get and set the active state of a WebView
+ https://bugs.webkit.org/show_bug.cgi?id=119067
+
+ Reviewed by Noam Rosenthal.
+
+ Added a method to return whether a scene is active or not.
+
+ No new tests, no behavior change.
+
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
+ (WebCore::CoordinatedGraphicsScene::isActive): Added method to return the
+ active state of the scene.
+
2013-07-29 Mario Sanchez Prada <[email protected]>
[ATK] Issues with edge cases when getting offsets for a text range in AtkText
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h (153427 => 153428)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h 2013-07-29 16:25:08 UTC (rev 153428)
@@ -77,6 +77,8 @@
// The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_client.
// Currently, QQuickWebPage::updatePaintNode() locks the main thread before calling both methods.
void purgeGLResources();
+
+ bool isActive() const { return m_isActive; }
void setActive(bool);
void commitSceneState(const CoordinatedGraphicsState&);
Modified: trunk/Source/WebKit2/ChangeLog (153427 => 153428)
--- trunk/Source/WebKit2/ChangeLog 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebKit2/ChangeLog 2013-07-29 16:25:08 UTC (rev 153428)
@@ -1,3 +1,39 @@
+2013-07-29 Sergio Correia <[email protected]>
+
+ CoordinatedGraphics: Add API to get and set the active state of a WebView
+ https://bugs.webkit.org/show_bug.cgi?id=119067
+
+ Reviewed by Noam Rosenthal.
+
+ A view being in the "active" state generally means that it is not in the
+ "background", although this definition can vary depending on the platform
+ under consideration.
+
+ This patch adds the following APIs to WKView:
+ - bool WKViewIsActive(WKViewRef)
+ This API accepts a WKViewRef as parameter and returns a boolean indicating
+ whether the given view is active.
+
+ - void WKViewSetIsActive(WKViewRef, bool)
+ This API accepts a WKViewRef and a boolean as parameteres, and it sets the
+ active state of the given view to the given boolean argument.
+
+ * UIProcess/API/C/CoordinatedGraphics/WKView.cpp:
+ (WKViewIsActive): API added.
+ (WKViewSetIsActive): Ditto.
+ * UIProcess/API/C/CoordinatedGraphics/WKView.h: Export aforementioned API.
+ * UIProcess/CoordinatedGraphics/WebView.cpp:
+ (WebKit::WebView::initialize): Use new setActive method.
+ (WebKit::WebView::setActive): Added method to set the active state of the
+ view.
+ (WebKit::WebView::isActive): Added method to return the active state of
+ view.
+ (WebKit::WebView::enterAcceleratedCompositingMode): Use new setActive
+ method.
+ (WebKit::WebView::exitAcceleratedCompositingMode): Ditto.
+ * UIProcess/CoordinatedGraphics/WebView.h: Added declarations of isActive
+ and setActive.
+
2013-07-29 Jae Hyun Park <[email protected]>
Remove duplicated LayerTreeHost::supportsAcceleratedCompositing
Modified: trunk/Source/WebKit2/UIProcess/API/C/CoordinatedGraphics/WKView.cpp (153427 => 153428)
--- trunk/Source/WebKit2/UIProcess/API/C/CoordinatedGraphics/WKView.cpp 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebKit2/UIProcess/API/C/CoordinatedGraphics/WKView.cpp 2013-07-29 16:25:08 UTC (rev 153428)
@@ -55,6 +55,16 @@
toImpl(viewRef)->initializeClient(client);
}
+bool WKViewIsActive(WKViewRef viewRef)
+{
+ return toImpl(viewRef)->isActive();
+}
+
+void WKViewSetIsActive(WKViewRef viewRef, bool isActive)
+{
+ toImpl(viewRef)->setActive(isActive);
+}
+
bool WKViewIsFocused(WKViewRef viewRef)
{
return toImpl(viewRef)->isFocused();
Modified: trunk/Source/WebKit2/UIProcess/API/C/CoordinatedGraphics/WKView.h (153427 => 153428)
--- trunk/Source/WebKit2/UIProcess/API/C/CoordinatedGraphics/WKView.h 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebKit2/UIProcess/API/C/CoordinatedGraphics/WKView.h 2013-07-29 16:25:08 UTC (rev 153428)
@@ -73,6 +73,9 @@
WK_EXPORT void WKViewSetViewClient(WKViewRef, const WKViewClient*);
+WK_EXPORT bool WKViewIsActive(WKViewRef);
+WK_EXPORT void WKViewSetIsActive(WKViewRef, bool);
+
WK_EXPORT bool WKViewIsFocused(WKViewRef);
WK_EXPORT void WKViewSetIsFocused(WKViewRef, bool);
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp (153427 => 153428)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp 2013-07-29 16:25:08 UTC (rev 153428)
@@ -73,10 +73,19 @@
void WebView::initialize()
{
m_page->initializeWebPage();
- if (CoordinatedGraphicsScene* scene = coordinatedGraphicsScene())
- scene->setActive(true);
+ setActive(true);
}
+void WebView::setActive(bool active)
+{
+ CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
+ if (!scene || scene->isActive() == active)
+ return;
+
+ scene->setActive(active);
+ m_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+}
+
void WebView::setSize(const WebCore::IntSize& size)
{
if (m_size == size)
@@ -298,6 +307,15 @@
return roundedIntSize(dipSize());
}
+bool WebView::isActive() const
+{
+ const CoordinatedGraphicsScene* scene = const_cast<WebView*>(this)->coordinatedGraphicsScene();
+ if (!scene)
+ return false;
+
+ return scene->isActive();
+}
+
bool WebView::isViewWindowActive()
{
notImplemented();
@@ -426,14 +444,12 @@
void WebView::enterAcceleratedCompositingMode(const LayerTreeContext&)
{
- if (CoordinatedGraphicsScene* scene = coordinatedGraphicsScene())
- scene->setActive(true);
+ setActive(true);
}
void WebView::exitAcceleratedCompositingMode()
{
- if (CoordinatedGraphicsScene* scene = coordinatedGraphicsScene())
- scene->setActive(false);
+ setActive(false);
}
void WebView::updateAcceleratedCompositingMode(const LayerTreeContext&)
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h (153427 => 153428)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h 2013-07-29 16:25:08 UTC (rev 153428)
@@ -57,6 +57,9 @@
void setSize(const WebCore::IntSize&);
const WebCore::IntSize& size() const { return m_size; }
+ bool isActive() const;
+ void setActive(bool);
+
bool isFocused() const { return m_focused; }
void setFocused(bool);
Modified: trunk/Tools/ChangeLog (153427 => 153428)
--- trunk/Tools/ChangeLog 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Tools/ChangeLog 2013-07-29 16:25:08 UTC (rev 153428)
@@ -1,3 +1,24 @@
+2013-07-29 Sergio Correia <[email protected]>
+
+ CoordinatedGraphics: Add API to get and set the active state of a WebView
+ https://bugs.webkit.org/show_bug.cgi?id=119067
+
+ Reviewed by Noam Rosenthal.
+
+ Added API tests for WKViewIsActive and WKViewSetIsActive.
+
+ * TestWebKitAPI/PlatformEfl.cmake:
+ * TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive.cpp: Added.
+ (TestWebKitAPI::didFinishLoadForFrame):
+ (TestWebKitAPI::webProcessCrashed):
+ (TestWebKitAPI::webProcessRelaunched):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp:
+ Bundle added to allow crashing the WebProcess and testing the active state of a view
+ under such condition.
+ (TestWebKitAPI::WKViewIsActiveSetIsActiveTest::WKViewIsActiveSetIsActiveTest):
+ (TestWebKitAPI::WKViewIsActiveSetIsActiveTest::didReceiveMessage):
+
2013-07-29 Zan Dobersek <[email protected]>
[Automake] Remove references to non-existent *_CFLAGS and *_LIBS variables
Modified: trunk/Tools/TestWebKitAPI/PlatformEfl.cmake (153427 => 153428)
--- trunk/Tools/TestWebKitAPI/PlatformEfl.cmake 2013-07-29 15:46:35 UTC (rev 153427)
+++ trunk/Tools/TestWebKitAPI/PlatformEfl.cmake 2013-07-29 16:25:08 UTC (rev 153428)
@@ -54,6 +54,7 @@
# In here we list the bundles that are used by our specific WK2 API Tests
list(APPEND bundle_harness_SOURCES
+ ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp
${TESTWEBKITAPI_DIR}/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks_Bundle.cpp
)
@@ -100,6 +101,7 @@
WKURL
WillLoad
WillSendSubmitEvent
+ CoordinatedGraphics/WKViewIsActiveSetIsActive
CoordinatedGraphics/WKViewUserViewportToContents
efl/WKViewClientWebProcessCallbacks
)
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive.cpp (0 => 153428)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive.cpp 2013-07-29 16:25:08 UTC (rev 153428)
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformUtilities.h"
+#include "Test.h"
+
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKPage.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKView.h>
+
+namespace TestWebKitAPI {
+
+static bool didWebProcessCrash = false;
+static bool didWebProcessRelaunch = false;
+static bool didFinishLoad = false;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+ didFinishLoad = true;
+}
+
+static void webProcessCrashed(WKViewRef view, WKURLRef, const void*)
+{
+ // WebProcess crashed, so at this point the view should not be active.
+ ASSERT_FALSE(WKViewIsActive(view));
+ didWebProcessCrash = true;
+}
+
+static void webProcessRelaunched(WKViewRef view, const void*)
+{
+ // WebProcess just relaunched, so at this point the view should not be active.
+ ASSERT_FALSE(WKViewIsActive(view));
+
+ didWebProcessRelaunch = true;
+}
+
+TEST(WebKit2, WKViewIsActiveSetIsActive)
+{
+ WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
+ WKRetainPtr<WKViewRef> view = adoptWK(WKViewCreate(context.get(), 0));
+
+ WKViewInitialize(view.get());
+
+ // At this point we should have an active view.
+ ASSERT_TRUE(WKViewIsActive(view.get()));
+
+ // Now we are going to play with its active state a few times.
+ WKViewSetIsActive(view.get(), true);
+ ASSERT_TRUE(WKViewIsActive(view.get()));
+
+ WKViewSetIsActive(view.get(), false);
+ ASSERT_FALSE(WKViewIsActive(view.get()));
+
+ WKViewSetIsActive(view.get(), false);
+ ASSERT_FALSE(WKViewIsActive(view.get()));
+
+ WKViewSetIsActive(view.get(), true);
+ ASSERT_TRUE(WKViewIsActive(view.get()));
+}
+
+TEST(WebKit2, WKViewIsActive)
+{
+ WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("WKViewIsActiveSetIsActiveTest"));
+ WKRetainPtr<WKViewRef> view = adoptWK(WKViewCreate(context.get(), 0));
+
+ WKViewClient viewClient;
+ memset(&viewClient, 0, sizeof(WKViewClient));
+ viewClient.version = kWKViewClientCurrentVersion;
+ viewClient.webProcessCrashed = webProcessCrashed;
+ viewClient.webProcessDidRelaunch = webProcessRelaunched;
+ WKViewSetViewClient(view.get(), &viewClient);
+
+ WKViewInitialize(view.get());
+
+ // At this point we should have an active view.
+ ASSERT_TRUE(WKViewIsActive(view.get()));
+
+ WKPageLoaderClient pageLoaderClient;
+ memset(&pageLoaderClient, 0, sizeof(WKPageLoaderClient));
+ pageLoaderClient.version = kWKPageLoaderClientCurrentVersion;
+ pageLoaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ WKPageSetPageLoaderClient(WKViewGetPage(view.get()), &pageLoaderClient);
+
+ const WKSize size = WKSizeMake(100, 100);
+ WKViewSetSize(view.get(), size);
+
+ didFinishLoad = false;
+ didWebProcessCrash = false;
+ didWebProcessRelaunch = false;
+
+ WKRetainPtr<WKURLRef> simpleUrl = adoptWK(Util::createURLForResource("../WebKit2/simple", "html"));
+ WKPageLoadURL(WKViewGetPage(view.get()), simpleUrl.get());
+ Util::run(&didFinishLoad);
+ didFinishLoad = false;
+
+ WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("Crash").get(), 0);
+ Util::run(&didWebProcessCrash);
+ ASSERT_TRUE(didWebProcessCrash);
+
+ WKPageLoadURL(WKViewGetPage(view.get()), simpleUrl.get());
+ Util::run(&didFinishLoad);
+
+ ASSERT_TRUE(didWebProcessRelaunch);
+ ASSERT_TRUE(didFinishLoad);
+}
+
+} // TestWebKitAPI
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp (0 => 153428)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/CoordinatedGraphics/WKViewIsActiveSetIsActive_Bundle.cpp 2013-07-29 16:25:08 UTC (rev 153428)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InjectedBundleTest.h"
+#include <WebKit2/WKRetainPtr.h>
+
+#include <cstdlib>
+
+namespace TestWebKitAPI {
+
+class WKViewIsActiveSetIsActiveTest : public InjectedBundleTest {
+public:
+ WKViewIsActiveSetIsActiveTest(const std::string& identifier)
+ : InjectedBundleTest(identifier)
+ {
+ }
+
+ virtual void didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody)
+ {
+ if (!WKStringIsEqualToUTF8CString(messageName, "Crash"))
+ return;
+ abort();
+ }
+};
+
+static InjectedBundleTest::Register<WKViewIsActiveSetIsActiveTest> registrar("WKViewIsActiveSetIsActiveTest");
+
+} // namespace TestWebKitAPI
+