Title: [165148] trunk
Revision
165148
Author
[email protected]
Date
2014-03-05 17:21:38 -0800 (Wed, 05 Mar 2014)

Log Message

[WebGL] Use WKSI to see what the system policy for WebGL is
https://bugs.webkit.org/show_bug.cgi?id=129722
<rdar://problem/15790542>

Reviewed by Tim Horton.

Source/WebKit2:

Use the WebKitSystemInterface methods WKShouldBlockWebGL
and WKShouldSuggestBlockingWebGL to query what the host
system thinks about the hardware. Tell the client about
the result in a new WebPage method setSystemWebGLPolicy.

* UIProcess/API/APILoaderClient.h:
(API::LoaderClient::setSystemWebGLLoadPolicy): New empty definition.
* UIProcess/API/C/WKAPICast.h:
(WebKit::toAPI): Convert a WebGLLoadPolicy into a WKWebGLLoadPolicy.
* UIProcess/API/C/WKPage.cpp: Call setSystemWebGLLoadPolicy.
(WKPageSetPageLoaderClient):
* UIProcess/API/C/WKPageLoaderClient.h: New typedef and entry in client structure.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setSystemWebGLPolicy):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in: Add SetSystemWebGLPolicy.
* Source/WebKit2/Configurations/WebKit2.xcconfig: We have to link against OpenGL now, because WKSI
uses it for hardware detection.
* WebProcess/WebPage/WebPage.cpp: Remove the implementation here, but leave
empty methods for non-Apple platforms.
(WebKit::WebPage::WebPage):
(WebKit::WebPage::webGLPolicyForURL):
(WebKit::WebPage::resolveWebGLPolicyForURL):
* WebProcess/WebPage/WebPage.h: Add m_systemWebGLPolicy.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::webGLPolicyForURL): Moved in from WebPage, but now they call
into WKSI and send the result to the client if necessary.
(WebKit::WebPage::resolveWebGLPolicyForURL):

Tools:

Dummy entry for setSystemWebGLLoadPolicy.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (165147 => 165148)


--- trunk/Source/WebKit2/ChangeLog	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-06 01:21:38 UTC (rev 165148)
@@ -1,3 +1,40 @@
+2014-03-05  Dean Jackson  <[email protected]>
+
+        [WebGL] Use WKSI to see what the system policy for WebGL is
+        https://bugs.webkit.org/show_bug.cgi?id=129722
+        <rdar://problem/15790542>
+
+        Reviewed by Tim Horton.
+
+        Use the WebKitSystemInterface methods WKShouldBlockWebGL
+        and WKShouldSuggestBlockingWebGL to query what the host
+        system thinks about the hardware. Tell the client about
+        the result in a new WebPage method setSystemWebGLPolicy.
+
+        * UIProcess/API/APILoaderClient.h:
+        (API::LoaderClient::setSystemWebGLLoadPolicy): New empty definition.
+        * UIProcess/API/C/WKAPICast.h:
+        (WebKit::toAPI): Convert a WebGLLoadPolicy into a WKWebGLLoadPolicy.
+        * UIProcess/API/C/WKPage.cpp: Call setSystemWebGLLoadPolicy.
+        (WKPageSetPageLoaderClient):
+        * UIProcess/API/C/WKPageLoaderClient.h: New typedef and entry in client structure.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setSystemWebGLPolicy):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in: Add SetSystemWebGLPolicy.
+        * Source/WebKit2/Configurations/WebKit2.xcconfig: We have to link against OpenGL now, because WKSI
+        uses it for hardware detection.
+        * WebProcess/WebPage/WebPage.cpp: Remove the implementation here, but leave
+        empty methods for non-Apple platforms.
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::webGLPolicyForURL):
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+        * WebProcess/WebPage/WebPage.h: Add m_systemWebGLPolicy.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::webGLPolicyForURL): Moved in from WebPage, but now they call
+        into WKSI and send the result to the client if necessary.
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+
 2014-03-05  Simon Fraser  <[email protected]>
 
         Fix a stupid error in r165118 that caused userVisibleString()

Modified: trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h	2014-03-06 01:21:38 UTC (rev 165148)
@@ -99,6 +99,7 @@
 #if ENABLE(WEBGL)
     virtual WebCore::WebGLLoadPolicy webGLLoadPolicy(WebKit::WebPageProxy*, const WTF::String&) const { return WebCore::WebGLLoadPolicy::WebGLAllowCreation; }
     virtual WebCore::WebGLLoadPolicy resolveWebGLLoadPolicy(WebKit::WebPageProxy*, const WTF::String&) const { return WebCore::WebGLLoadPolicy::WebGLAllowCreation; }
+    virtual void setSystemWebGLLoadPolicy(WebKit::WebPageProxy*, WebCore::WebGLLoadPolicy) const { }
 #endif // ENABLE(WEBGL)
 };
 

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h	2014-03-06 01:21:38 UTC (rev 165148)
@@ -492,6 +492,21 @@
     return WebCore::WebGLAllowCreation;
 }
 
+inline WKWebGLLoadPolicy toAPI(WebCore::WebGLLoadPolicy webGLLoadPolicy)
+{
+    switch (webGLLoadPolicy) {
+    case WebCore::WebGLAllowCreation:
+        return kWKWebGLLoadPolicyLoadNormally;
+    case WebCore::WebGLBlockCreation:
+        return kWKWebGLLoadPolicyBlocked;
+    case WebCore::WebGLPendingCreation:
+        return kWKWebGLLoadPolicyPending;
+    }
+
+    ASSERT_NOT_REACHED();
+    return kWKWebGLLoadPolicyLoadNormally;
+}
+
 inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail)
 {
     return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-03-06 01:21:38 UTC (rev 165148)
@@ -985,6 +985,12 @@
             return loadPolicy;
         }
 
+        virtual void setSystemWebGLLoadPolicy(WebPageProxy* page, WebCore::WebGLLoadPolicy policy) const override
+        {
+            if (m_client.setSystemWebGLLoadPolicy)
+                m_client.setSystemWebGLLoadPolicy(toAPI(page), toAPI(policy), m_client.base.clientInfo);
+        }
+
 #endif // ENABLE(WEBGL)
     };
 

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h	2014-03-06 01:21:38 UTC (rev 165148)
@@ -74,6 +74,7 @@
 typedef WKPluginLoadPolicy (*WKPagePluginLoadPolicyCallback)(WKPageRef page, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInfoDictionary, WKStringRef* unavailabilityDescription, const void* clientInfo);
 typedef void (*WKPagePluginDidFailCallback)(WKPageRef page, WKErrorCode errorCode, WKDictionaryRef pluginInfoDictionary, const void* clientInfo);
 typedef WKWebGLLoadPolicy (*WKPageWebGLLoadPolicyCallback)(WKPageRef page, WKStringRef url, const void* clientInfo);
+typedef void (*WKPageSetSystemWebGLLoadPolicyCallback)(WKPageRef page, WKWebGLLoadPolicy policy, const void* clientInfo);
 
 // Deprecated
 typedef void (*WKPageDidFailToInitializePluginCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
@@ -332,6 +333,7 @@
     // Version 4
     WKPageWebGLLoadPolicyCallback                                       webGLLoadPolicy;
     WKPageWebGLLoadPolicyCallback                                       resolveWebGLLoadPolicy;
+    WKPageSetSystemWebGLLoadPolicyCallback                              setSystemWebGLLoadPolicy;
 } WKPageLoaderClientV4;
 
 // FIXME: These should be deprecated.

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-03-06 01:21:38 UTC (rev 165148)
@@ -2753,6 +2753,11 @@
 {
     loadPolicy = static_cast<uint32_t>(m_loaderClient->resolveWebGLLoadPolicy(this, url));
 }
+
+void WebPageProxy::setSystemWebGLPolicy(uint32_t loadPolicy)
+{
+    m_loaderClient->setSystemWebGLLoadPolicy(this, static_cast<WebCore::WebGLLoadPolicy>(loadPolicy));
+}
 #endif // ENABLE(WEBGL)
 
 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-03-06 01:21:38 UTC (rev 165148)
@@ -988,6 +988,7 @@
 #if ENABLE(WEBGL)
     void webGLPolicyForURL(const String& url, uint32_t& loadPolicy);
     void resolveWebGLPolicyForURL(const String& url, uint32_t& loadPolicy);
+    void setSystemWebGLPolicy(uint32_t loadPolicy);
 #endif // ENABLE(WEBGL)
     void setToolbarsAreVisible(bool toolbarsAreVisible);
     void getToolbarsAreVisible(bool& toolbarsAreVisible);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (165147 => 165148)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2014-03-06 01:21:38 UTC (rev 165148)
@@ -34,6 +34,7 @@
     UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(WEBGL)
+    SetSystemWebGLPolicy(uint32_t loadPolicy) -> ()
     WebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
     ResolveWebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
 #endif // ENABLE(WEBGL)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (165147 => 165148)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-03-06 01:21:38 UTC (rev 165148)
@@ -296,6 +296,9 @@
     , m_pendingNavigationID(0)
     , m_pageScaleWithoutThumbnailScale(1)
     , m_thumbnailScale(1)
+#if ENABLE(WEBGL)
+    , m_systemWebGLPolicy(WebGLAllowCreation)
+#endif
 {
     ASSERT(m_pageID);
     // FIXME: This is a non-ideal location for this Setting and
@@ -616,27 +619,17 @@
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
-#if ENABLE(WEBGL)
+#if ENABLE(WEBGL) && !PLATFORM(MAC)
 WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame* frame, const String& url)
 {
-    uint32_t policyResult = 0;
-
-    if (sendSync(Messages::WebPageProxy::WebGLPolicyForURL(url), Messages::WebPageProxy::WebGLPolicyForURL::Reply(policyResult)))
-        return static_cast<WebGLLoadPolicy>(policyResult);
-
     return WebGLAllowCreation;
 }
 
 WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame* frame, const String& url)
 {
-    uint32_t policyResult = 0;
-
-    if (sendSync(Messages::WebPageProxy::ResolveWebGLPolicyForURL(url), Messages::WebPageProxy::ResolveWebGLPolicyForURL::Reply(policyResult)))
-        return static_cast<WebGLLoadPolicy>(policyResult);
-
     return WebGLAllowCreation;
 }
-#endif // ENABLE(WEBGL)
+#endif
 
 EditorState WebPage::editorState() const
 {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (165147 => 165148)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-03-06 01:21:38 UTC (rev 165148)
@@ -1125,6 +1125,10 @@
     double m_pageScaleWithoutThumbnailScale;
     WebCore::IntPoint m_scrollPositionIgnoringThumbnailScale;
     double m_thumbnailScale;
+
+#if ENABLE(WEBGL)
+    WebCore::WebGLLoadPolicy m_systemWebGLPolicy;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (165147 => 165148)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-03-06 01:21:38 UTC (rev 165148)
@@ -956,6 +956,38 @@
     send(Messages::WebPageProxy::DidUpdateViewState());
 }
 
+#if ENABLE(WEBGL)
+WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame* frame, const String& url)
+{
+    if (WKShouldBlockWebGL()) {
+        if (m_systemWebGLPolicy != WebGLBlockCreation)
+            sendSync(Messages::WebPageProxy::SetSystemWebGLPolicy(static_cast<uint32_t>(WebGLBlockCreation)), Messages::WebPageProxy::SetSystemWebGLPolicy::Reply());
+        m_systemWebGLPolicy = WebGLBlockCreation;
+    } else if (WKShouldSuggestBlockingWebGL()) {
+        if (m_systemWebGLPolicy != WebGLPendingCreation)
+            sendSync(Messages::WebPageProxy::SetSystemWebGLPolicy(static_cast<uint32_t>(WebGLPendingCreation)), Messages::WebPageProxy::SetSystemWebGLPolicy::Reply());
+        m_systemWebGLPolicy = WebGLPendingCreation;
+    }
+
+    uint32_t policyResult = 0;
+
+    if (sendSync(Messages::WebPageProxy::WebGLPolicyForURL(url), Messages::WebPageProxy::WebGLPolicyForURL::Reply(policyResult)))
+        return static_cast<WebGLLoadPolicy>(policyResult);
+
+    return WebGLAllowCreation;
+}
+
+WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame* frame, const String& url)
+{
+    uint32_t policyResult = 0;
+
+    if (sendSync(Messages::WebPageProxy::ResolveWebGLPolicyForURL(url), Messages::WebPageProxy::ResolveWebGLPolicyForURL::Reply(policyResult)))
+        return static_cast<WebGLLoadPolicy>(policyResult);
+
+    return WebGLAllowCreation;
+}
+#endif // ENABLE(WEBGL)
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)

Modified: trunk/Tools/ChangeLog (165147 => 165148)


--- trunk/Tools/ChangeLog	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Tools/ChangeLog	2014-03-06 01:21:38 UTC (rev 165148)
@@ -1,3 +1,16 @@
+2014-03-05  Dean Jackson  <[email protected]>
+
+        [WebGL] Use WKSI to see what the system policy for WebGL is
+        https://bugs.webkit.org/show_bug.cgi?id=129722
+        <rdar://problem/15790542>
+
+        Reviewed by Tim Horton.
+
+        Dummy entry for setSystemWebGLLoadPolicy.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions):
+
 2014-03-03  Martin Robinson  <[email protected]>
 
         [GTK][CMake] Generate documentation for the DOM bindings

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (165147 => 165148)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2014-03-06 01:21:23 UTC (rev 165147)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2014-03-06 01:21:38 UTC (rev 165148)
@@ -487,6 +487,7 @@
         pluginLoadPolicy, // pluginLoadPolicy
         0, // webGLLoadPolicy
         0, // resolveWebGLLoadPolicy
+        0, // setSystemWebGLLoadPolicy
     };
     WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient.base);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to