Title: [98403] trunk
Revision
98403
Author
[email protected]
Date
2011-10-25 16:00:37 -0700 (Tue, 25 Oct 2011)

Log Message

Source/WebCore: Plug-ins have to use _javascript_ to find out the current device scale factor
https://bugs.webkit.org/show_bug.cgi?id=67225

Reviewed by Darin Adler.

Test: platform/mac-wk2/plugins/contents-scale-factor.html

Add NPNVcontentsScaleFactor, as per https://wiki.mozilla.org/NPAPI:ContentsScaleFactor.

* plugins/npapi.h:

Source/WebKit2: Plug-ins have to use _javascript_ to find out the current device scale factor
https://bugs.webkit.org/show_bug.cgi?id=67225
<rdar://problem/10048258>

Reviewed by Darin Adler.

* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::PluginControllerProxy):
Initialize m_contentsScaleFactor.

* PluginProcess/PluginControllerProxy.h:
Add contentsScaleFactor member function and m_contentsScaleFactor member variable.

* PluginProcess/PluginCreationParameters.cpp:
(WebKit::PluginCreationParameters::PluginCreationParameters):
(WebKit::PluginCreationParameters::encode):
(WebKit::PluginCreationParameters::decode):
* PluginProcess/PluginCreationParameters.h:
Add contentsScaleFactor to the creation parameters.

* PluginProcess/mac/PluginControllerProxyMac.mm:
(WebKit::PluginControllerProxy::contentsScaleFactor):
Return the cached m_contentsScaleFactor.

* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_GetValue):
Handle getting the scale factor by calling NetscapePlugin::contentsScaleFactor.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::contentsScaleFactor):
Ask the plug-in controller for the contents scale factor.

* WebProcess/Plugins/PluginController.h:
Add contentsScaleFactor pure virtual member function.

* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::initialize):
Set contentsScaleFactor in the creation parameters.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::contentsScaleFactor):
Get the device scale factor from the page.

* WebProcess/Plugins/PluginView.h:
Add contentsScaleFactor().

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setDeviceScaleFactor):
Bail if the scale factor didn't change.

Tools: Plug-ins have to use _javascript_ to find out the current device scale factor
https://bugs.webkit.org/show_bug.cgi?id=67225
<rdar://problem/10048258>

Reviewed by Darin Adler.

Add a plug-in test for getting the contents scale factor.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp: Added.
(ContentsScaleFactor::ContentsScaleFactor):
(ContentsScaleFactor::contentsScaleFactor):
(ContentsScaleFactor::ScriptableObject::hasProperty):
(ContentsScaleFactor::ScriptableObject::getProperty):
(ContentsScaleFactor::ScriptableObject::pluginTest):
(ContentsScaleFactor::NPP_GetValue):

LayoutTests: Plug-ins have to use _javascript_ to find out the current device scale factor
https://bugs.webkit.org/show_bug.cgi?id=67225
<rdar://problem/10048258>

Reviewed by Darin Adler.

Add tests.

* platform/mac-wk2/plugins/contents-scale-factor-expected.txt: Added.
* platform/mac-wk2/plugins/contents-scale-factor.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98402 => 98403)


--- trunk/LayoutTests/ChangeLog	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/LayoutTests/ChangeLog	2011-10-25 23:00:37 UTC (rev 98403)
@@ -1,3 +1,16 @@
+2011-10-25  Anders Carlsson  <[email protected]>
+
+        Plug-ins have to use _javascript_ to find out the current device scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=67225
+        <rdar://problem/10048258>
+
+        Reviewed by Darin Adler.
+
+        Add tests.
+
+        * platform/mac-wk2/plugins/contents-scale-factor-expected.txt: Added.
+        * platform/mac-wk2/plugins/contents-scale-factor.html: Added.
+
 2011-10-25  Julien Chaffraix  <[email protected]>
 
         More unreviewed gardening.

Added: trunk/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor-expected.txt (0 => 98403)


--- trunk/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor-expected.txt	2011-10-25 23:00:37 UTC (rev 98403)
@@ -0,0 +1,8 @@
+Tests that plug-ins can query for the contents scale factor
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS plugin1.contentsScaleFactor is 1.0
+PASS plugin2.contentsScaleFactor is 2.0
+

Added: trunk/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor.html (0 => 98403)


--- trunk/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor.html	2011-10-25 23:00:37 UTC (rev 98403)
@@ -0,0 +1,50 @@
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body _onload_="runTest()">
+<p id="description"></p>
+<div id="console"></div>
+<script>
+function createTestPlugin(testName)
+{
+    var plugin = document.createElement("embed");
+    plugin.type = "application/x-webkit-test-netscape";
+    plugin.setAttribute('test', testName);
+
+    return plugin;
+}
+
+function runTest() 
+{
+    if (!window.layoutTestController) {
+        debug("This test can only run from within DumpRenderTree because it requires TestNetscapePlugin.\n");
+        return;
+    }
+
+    layoutTestController.waitUntilDone();
+
+    plugin1 = createTestPlugin('contents-scale-factor');
+    document.body.appendChild(plugin1);
+    
+    shouldBe("plugin1.contentsScaleFactor", "1.0");
+
+    // Now change the backing scale factor.
+    layoutTestController.setBackingScaleFactor(2, function() {
+    
+        plugin2 = createTestPlugin('contents-scale-factor');
+        document.body.appendChild(plugin2);
+    
+        shouldBe("plugin2.contentsScaleFactor", "2.0");
+
+        layoutTestController.notifyDone();
+    });
+}
+</script>
+
+<script>
+description("Tests that plug-ins can query for the contents scale factor")
+
+
+successfullyParsed = true;
+</script>

Modified: trunk/Source/WebCore/ChangeLog (98402 => 98403)


--- trunk/Source/WebCore/ChangeLog	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebCore/ChangeLog	2011-10-25 23:00:37 UTC (rev 98403)
@@ -1,3 +1,16 @@
+2011-10-25  Anders Carlsson  <[email protected]>
+
+        Plug-ins have to use _javascript_ to find out the current device scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=67225
+
+        Reviewed by Darin Adler.
+
+        Test: platform/mac-wk2/plugins/contents-scale-factor.html
+
+        Add NPNVcontentsScaleFactor, as per https://wiki.mozilla.org/NPAPI:ContentsScaleFactor.
+
+        * plugins/npapi.h:
+
 2011-10-25  Adam Klein  <[email protected]>
 
         Forward declare MutationObserverEntry as a struct to fix clang build

Modified: trunk/Source/WebCore/plugins/npapi.h (98402 => 98403)


--- trunk/Source/WebCore/plugins/npapi.h	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebCore/plugins/npapi.h	2011-10-25 23:00:37 UTC (rev 98403)
@@ -416,6 +416,7 @@
 #if defined(XP_MACOSX)
   /* Used for negotiating drawing models */
   , NPNVpluginDrawingModel = 1000
+  , NPNVcontentsScaleFactor = 1001
 #ifndef NP_NO_QUICKDRAW
   , NPNVsupportsQuickDrawBool = 2000
 #endif

Modified: trunk/Source/WebKit2/ChangeLog (98402 => 98403)


--- trunk/Source/WebKit2/ChangeLog	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-25 23:00:37 UTC (rev 98403)
@@ -1,3 +1,56 @@
+2011-10-25  Anders Carlsson  <[email protected]>
+
+        Plug-ins have to use _javascript_ to find out the current device scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=67225
+        <rdar://problem/10048258>
+
+        Reviewed by Darin Adler.
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::PluginControllerProxy):
+        Initialize m_contentsScaleFactor.
+
+        * PluginProcess/PluginControllerProxy.h:
+        Add contentsScaleFactor member function and m_contentsScaleFactor member variable.
+
+        * PluginProcess/PluginCreationParameters.cpp:
+        (WebKit::PluginCreationParameters::PluginCreationParameters):
+        (WebKit::PluginCreationParameters::encode):
+        (WebKit::PluginCreationParameters::decode):
+        * PluginProcess/PluginCreationParameters.h:
+        Add contentsScaleFactor to the creation parameters.
+
+        * PluginProcess/mac/PluginControllerProxyMac.mm:
+        (WebKit::PluginControllerProxy::contentsScaleFactor):
+        Return the cached m_contentsScaleFactor.
+
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_GetValue):
+        Handle getting the scale factor by calling NetscapePlugin::contentsScaleFactor.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::contentsScaleFactor):
+        Ask the plug-in controller for the contents scale factor.
+
+        * WebProcess/Plugins/PluginController.h:
+        Add contentsScaleFactor pure virtual member function.
+
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::initialize):
+        Set contentsScaleFactor in the creation parameters.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::contentsScaleFactor):
+        Get the device scale factor from the page.
+
+        * WebProcess/Plugins/PluginView.h:
+        Add contentsScaleFactor().
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setDeviceScaleFactor):
+        Bail if the scale factor didn't change.
+
 2011-10-25  Sam Weinig  <[email protected]>
 
         Flesh out WKBrowsingContextLoadDelegate a bit

Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp (98402 => 98403)


--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -70,6 +70,7 @@
     , m_pluginCanceledManualStreamLoad(false)
 #if PLATFORM(MAC)
     , m_isComplexTextInputEnabled(false)
+    , m_contentsScaleFactor(creationParameters.contentsScaleFactor)
 #endif
     , m_windowNPObject(0)
     , m_pluginElementNPObject(0)

Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h (98402 => 98403)


--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h	2011-10-25 23:00:37 UTC (rev 98403)
@@ -99,6 +99,7 @@
     virtual void pluginFocusOrWindowFocusChanged(bool);
     virtual void setComplexTextInputState(PluginComplexTextInputState);
     virtual mach_port_t compositingRenderServerPort();
+    virtual float contentsScaleFactor();
 #endif
 
     virtual String proxiesForURL(const String&);
@@ -191,6 +192,9 @@
     // Whether complex text input is enabled for this plug-in.
     bool m_isComplexTextInputEnabled;
 
+    // The contents scale factor of this plug-in.
+    float m_contentsScaleFactor;
+
     // For CA plug-ins, this holds the information needed to export the layer hierarchy to the UI process.
     RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
 #endif

Modified: trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp (98402 => 98403)


--- trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -39,6 +39,9 @@
 #if USE(ACCELERATED_COMPOSITING)
     , isAcceleratedCompositingEnabled(false)
 #endif
+#if PLATFORM(MAC)
+    , contentsScaleFactor(1)
+#endif
 {
 }
 
@@ -53,6 +56,10 @@
 #if USE(ACCELERATED_COMPOSITING)
     encoder->encode(isAcceleratedCompositingEnabled);
 #endif
+
+#if PLATFORM(MAC)
+    encoder->encode(contentsScaleFactor);
+#endif
 }
 
 bool PluginCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, PluginCreationParameters& result)
@@ -77,6 +84,11 @@
         return false;
 #endif
 
+#if PLATFORM(MAC)
+    if (!decoder->decode(result.contentsScaleFactor))
+        return false;
+#endif
+
     return true;
 }
 

Modified: trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.h (98402 => 98403)


--- trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.h	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.h	2011-10-25 23:00:37 UTC (rev 98403)
@@ -62,6 +62,11 @@
     // Whether accelerated compositing is enabled.
     bool isAcceleratedCompositingEnabled;
 #endif
+
+#if PLATFORM(MAC)
+    // The current contents scale factor that this plug-in should have.
+    float contentsScaleFactor;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm (98402 => 98403)


--- trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm	2011-10-25 23:00:37 UTC (rev 98403)
@@ -53,6 +53,11 @@
     return PluginProcess::shared().compositingRenderServerPort();
 }
 
+float PluginControllerProxy::contentsScaleFactor()
+{
+    return m_contentsScaleFactor;
+}
+
 void PluginControllerProxy::platformInitialize()
 {
     CALayer * platformLayer = m_plugin->pluginLayer();

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -460,6 +460,12 @@
             *(NPBool*)value = plugin->isAcceleratedCompositingEnabled();
             break;
         }
+        case NPNVcontentsScaleFactor: {
+            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+
+            *(double*)value = plugin->contentsScaleFactor();
+            break;
+        }
         case NPNVsupportsCocoaBool:
             // Always claim to support the Cocoa event model.
             *(NPBool*)value = true;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-10-25 23:00:37 UTC (rev 98403)
@@ -63,6 +63,7 @@
     bool hasHandledAKeyDownEvent() const { return m_hasHandledAKeyDownEvent; }
 
     mach_port_t compositingRenderServerPort();
+    double contentsScaleFactor();
 
 #ifndef NP_NO_CARBON
     WindowRef windowRef() const;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-10-25 23:00:37 UTC (rev 98403)
@@ -179,6 +179,11 @@
     return controller()->compositingRenderServerPort();
 }
 
+double NetscapePlugin::contentsScaleFactor()
+{
+    return controller()->contentsScaleFactor();
+}
+
 #ifndef NP_NO_CARBON
 typedef HashMap<WindowRef, NetscapePlugin*> WindowMap;
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginController.h (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginController.h	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginController.h	2011-10-25 23:00:37 UTC (rev 98403)
@@ -120,6 +120,9 @@
 
     // Returns the mach port of the compositing render server.
     virtual mach_port_t compositingRenderServerPort() = 0;
+
+    // Returns the contents scale factor.
+    virtual float contentsScaleFactor() = 0;
 #endif
 
     // Returns the proxies for the given URL or null on failure.

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -101,6 +101,9 @@
 #if USE(ACCELERATED_COMPOSITING)
     creationParameters.isAcceleratedCompositingEnabled = controller()->isAcceleratedCompositingEnabled();
 #endif
+#if PLATFORM(MAC)
+    creationParameters.contentsScaleFactor = controller()->contentsScaleFactor();
+#endif
 
     bool result = false;
     uint32_t remoteLayerClientID = 0;
@@ -375,7 +378,6 @@
 {
     m_connection->connection()->send(Messages::PluginControllerProxy::SendComplexTextInput(textInput), m_pluginInstanceID);
 }
-
 #endif
 
 void PluginProxy::privateBrowsingStateChanged(bool isPrivateBrowsingEnabled)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -1140,6 +1140,14 @@
 {
     return WebProcess::shared().compositingRenderServerPort();
 }
+
+float PluginView::contentsScaleFactor()
+{
+    if (Page* page = frame() ? frame()->page() : 0)
+        return page->deviceScaleFactor();
+        
+    return 1;
+}
 #endif
     
 String PluginView::proxiesForURL(const String& urlString)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2011-10-25 23:00:37 UTC (rev 98403)
@@ -150,6 +150,7 @@
     virtual void pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus);
     virtual void setComplexTextInputState(PluginComplexTextInputState);
     virtual mach_port_t compositingRenderServerPort();
+    virtual float contentsScaleFactor();
 #endif
     virtual String proxiesForURL(const String&);
     virtual String cookiesForURL(const String&);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (98402 => 98403)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -846,6 +846,9 @@
 
 void WebPage::setDeviceScaleFactor(float scaleFactor)
 {
+    if (scaleFactor == m_page->deviceScaleFactor())
+        return;
+
     m_page->setDeviceScaleFactor(scaleFactor);
 }
 

Modified: trunk/Tools/ChangeLog (98402 => 98403)


--- trunk/Tools/ChangeLog	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Tools/ChangeLog	2011-10-25 23:00:37 UTC (rev 98403)
@@ -1,3 +1,22 @@
+2011-10-25  Anders Carlsson  <[email protected]>
+
+        Plug-ins have to use _javascript_ to find out the current device scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=67225
+        <rdar://problem/10048258>
+
+        Reviewed by Darin Adler.
+
+        Add a plug-in test for getting the contents scale factor.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp: Added.
+        (ContentsScaleFactor::ContentsScaleFactor):
+        (ContentsScaleFactor::contentsScaleFactor):
+        (ContentsScaleFactor::ScriptableObject::hasProperty):
+        (ContentsScaleFactor::ScriptableObject::getProperty):
+        (ContentsScaleFactor::ScriptableObject::pluginTest):
+        (ContentsScaleFactor::NPP_GetValue):
+
 2011-10-25  Sam Weinig  <[email protected]>
 
         Flesh out WKBrowsingContextLoadDelegate a bit

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (98402 => 98403)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2011-10-25 22:55:50 UTC (rev 98402)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2011-10-25 23:00:37 UTC (rev 98403)
@@ -41,6 +41,7 @@
 		1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A31EB3713466AC100017372 /* ConvertPoint.cpp */; };
 		1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
 		1A5CC1F5137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */; };
+		1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */; };
 		1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F024C0BB9B056008CFA34 /* TestObject.h */; };
 		1AC6C8490D07638600CD3161 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C77F0D07589B00CD3161 /* main.cpp */; };
 		1AC6C84A0D07638600CD3161 /* PluginObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7800D07589B00CD3161 /* PluginObject.cpp */; };
@@ -225,6 +226,7 @@
 		1A31EB3713466AC100017372 /* ConvertPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertPoint.cpp; sourceTree = "<group>"; };
 		1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
 		1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURL.cpp; sourceTree = "<group>"; };
+		1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentsScaleFactor.cpp; sourceTree = "<group>"; };
 		1A8F024C0BB9B056008CFA34 /* TestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObject.h; sourceTree = "<group>"; };
 		1AC6C77F0D07589B00CD3161 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
 		1AC6C7800D07589B00CD3161 /* PluginObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginObject.cpp; sourceTree = "<group>"; };
@@ -525,6 +527,7 @@
 			children = (
 				1A31EB3713466AC100017372 /* ConvertPoint.cpp */,
 				1A14C8A31406DE0400B254F7 /* SupportsCarbonEventModel.cpp */,
+				1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -835,6 +838,7 @@
 				4AD6A11413C8124000EA9737 /* FormValue.cpp in Sources */,
 				1A14C8A51406DE0400B254F7 /* SupportsCarbonEventModel.cpp in Sources */,
 				1A1E4298141141C400388758 /* PrivateBrowsing.cpp in Sources */,
+				1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp (0 => 98403)


--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp	2011-10-25 23:00:37 UTC (rev 98403)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 "PluginTest.h"
+
+using namespace std;
+
+class ContentsScaleFactor : public PluginTest {
+public:
+    ContentsScaleFactor(NPP npp, const string& identifier)
+        : PluginTest(npp, identifier)
+    {
+    }
+
+private:
+    double contentsScaleFactor()
+    {
+        double contentsScaleFactor = 1.0;
+        NPN_GetValue(NPNVcontentsScaleFactor, &contentsScaleFactor);
+        return contentsScaleFactor;
+    }
+
+    class ScriptableObject : public Object<ScriptableObject> { 
+    public:
+        bool hasProperty(NPIdentifier propertyName)
+        {
+            return identifierIs(propertyName, "contentsScaleFactor");
+        }
+
+        bool getProperty(NPIdentifier propertyName, NPVariant* result)
+        {
+            if (identifierIs(propertyName, "contentsScaleFactor")) {
+                DOUBLE_TO_NPVARIANT(pluginTest()->contentsScaleFactor(), *result);
+                return true;
+            }
+
+            return false;
+        }
+
+    private:
+        ContentsScaleFactor* pluginTest() const { return static_cast<ContentsScaleFactor*>(Object<ScriptableObject>::pluginTest()); }
+
+    };
+
+    virtual NPError NPP_GetValue(NPPVariable variable, void* value)
+    {
+        if (variable != NPPVpluginScriptableNPObject)
+            return NPERR_GENERIC_ERROR;
+        
+        *(NPObject**)value = ScriptableObject::create(this);
+        
+        return NPERR_NO_ERROR;
+    }
+};
+
+static PluginTest::Register<ContentsScaleFactor> contentsScaleFactor("contents-scale-factor");
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to