Source/WebCore: Plug-ins have to use JavaScript to find out the current device scale...
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 23:00:37 +0000 (23:00 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 23:00:37 +0000 (23:00 +0000)
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.

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

22 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/plugins/contents-scale-factor-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/plugins/contents-scale-factor.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/plugins/npapi.h
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/PluginProcess/PluginCreationParameters.cpp
Source/WebKit2/PluginProcess/PluginCreationParameters.h
Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
Source/WebKit2/WebProcess/Plugins/PluginController.h
Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp [new file with mode: 0644]

index 2a6fe42..6d95cea 100644 (file)
@@ -1,3 +1,16 @@
+2011-10-25  Anders Carlsson  <andersca@apple.com>
+
+        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  <jchaffraix@webkit.org>
 
         More unreviewed gardening.
diff --git a/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor-expected.txt b/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor-expected.txt
new file mode 100644 (file)
index 0000000..31cd5b8
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor.html b/LayoutTests/platform/mac-wk2/plugins/contents-scale-factor.html
new file mode 100644 (file)
index 0000000..858ccd1
--- /dev/null
@@ -0,0 +1,50 @@
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</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>
index 0d4baab..17e6be6 100644 (file)
@@ -1,3 +1,16 @@
+2011-10-25  Anders Carlsson  <andersca@apple.com>
+
+        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  <adamk@chromium.org>
 
         Forward declare MutationObserverEntry as a struct to fix clang build
index cce4fd3..00c68de 100644 (file)
@@ -416,6 +416,7 @@ typedef enum {
 #if defined(XP_MACOSX)
   /* Used for negotiating drawing models */
   , NPNVpluginDrawingModel = 1000
+  , NPNVcontentsScaleFactor = 1001
 #ifndef NP_NO_QUICKDRAW
   , NPNVsupportsQuickDrawBool = 2000
 #endif
index daf3323..0c2a11e 100644 (file)
@@ -1,3 +1,56 @@
+2011-10-25  Anders Carlsson  <andersca@apple.com>
+
+        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  <sam@webkit.org>
 
         Flesh out WKBrowsingContextLoadDelegate a bit
index aa49a3d..fe5244e 100644 (file)
@@ -70,6 +70,7 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, c
     , m_pluginCanceledManualStreamLoad(false)
 #if PLATFORM(MAC)
     , m_isComplexTextInputEnabled(false)
+    , m_contentsScaleFactor(creationParameters.contentsScaleFactor)
 #endif
     , m_windowNPObject(0)
     , m_pluginElementNPObject(0)
index d82d6cf..fe9280b 100644 (file)
@@ -99,6 +99,7 @@ private:
     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 @@ private:
     // 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
index 6c8ea11..37a1fbf 100644 (file)
@@ -39,6 +39,9 @@ PluginCreationParameters::PluginCreationParameters()
 #if USE(ACCELERATED_COMPOSITING)
     , isAcceleratedCompositingEnabled(false)
 #endif
+#if PLATFORM(MAC)
+    , contentsScaleFactor(1)
+#endif
 {
 }
 
@@ -53,6 +56,10 @@ void PluginCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
 #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 @@ bool PluginCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, PluginC
         return false;
 #endif
 
+#if PLATFORM(MAC)
+    if (!decoder->decode(result.contentsScaleFactor))
+        return false;
+#endif
+
     return true;
 }
 
index dafde7e..a004030 100644 (file)
@@ -62,6 +62,11 @@ struct PluginCreationParameters {
     // 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
index 5fe98f7..fcb0c08 100644 (file)
@@ -53,6 +53,11 @@ mach_port_t PluginControllerProxy::compositingRenderServerPort()
     return PluginProcess::shared().compositingRenderServerPort();
 }
 
+float PluginControllerProxy::contentsScaleFactor()
+{
+    return m_contentsScaleFactor;
+}
+
 void PluginControllerProxy::platformInitialize()
 {
     CALayer * platformLayer = m_plugin->pluginLayer();
index 807b7b5..e4450cd 100644 (file)
@@ -460,6 +460,12 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
             *(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;
index 84f66fc..e2d9100 100644 (file)
@@ -63,6 +63,7 @@ public:
     bool hasHandledAKeyDownEvent() const { return m_hasHandledAKeyDownEvent; }
 
     mach_port_t compositingRenderServerPort();
+    double contentsScaleFactor();
 
 #ifndef NP_NO_CARBON
     WindowRef windowRef() const;
index d8563ec..6aca0ca 100644 (file)
@@ -179,6 +179,11 @@ mach_port_t NetscapePlugin::compositingRenderServerPort()
     return controller()->compositingRenderServerPort();
 }
 
+double NetscapePlugin::contentsScaleFactor()
+{
+    return controller()->contentsScaleFactor();
+}
+
 #ifndef NP_NO_CARBON
 typedef HashMap<WindowRef, NetscapePlugin*> WindowMap;
 
index 76ede1f..8008a56 100644 (file)
@@ -120,6 +120,9 @@ public:
 
     // 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.
index 9684c60..05301c5 100644 (file)
@@ -101,6 +101,9 @@ bool PluginProxy::initialize(const Parameters& parameters)
 #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 @@ void PluginProxy::sendComplexTextInput(const String& textInput)
 {
     m_connection->connection()->send(Messages::PluginControllerProxy::SendComplexTextInput(textInput), m_pluginInstanceID);
 }
-
 #endif
 
 void PluginProxy::privateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
index ec67178..00e51c8 100644 (file)
@@ -1140,6 +1140,14 @@ mach_port_t PluginView::compositingRenderServerPort()
 {
     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)
index 56acecb..21b6e77 100644 (file)
@@ -150,6 +150,7 @@ private:
     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&);
index 400d7e2..ca5f0d1 100644 (file)
@@ -846,6 +846,9 @@ double WebPage::pageScaleFactor() const
 
 void WebPage::setDeviceScaleFactor(float scaleFactor)
 {
+    if (scaleFactor == m_page->deviceScaleFactor())
+        return;
+
     m_page->setDeviceScaleFactor(scaleFactor);
 }
 
index edc03f4..7f33a0c 100644 (file)
@@ -1,3 +1,22 @@
+2011-10-25  Anders Carlsson  <andersca@apple.com>
+
+        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  <sam@webkit.org>
 
         Flesh out WKBrowsingContextLoadDelegate a bit
index 233ef51..1eda670 100644 (file)
@@ -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 */; };
                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>"; };
                        children = (
                                1A31EB3713466AC100017372 /* ConvertPoint.cpp */,
                                1A14C8A31406DE0400B254F7 /* SupportsCarbonEventModel.cpp */,
+                               1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */,
                        );
                        path = mac;
                        sourceTree = "<group>";
                                4AD6A11413C8124000EA9737 /* FormValue.cpp in Sources */,
                                1A14C8A51406DE0400B254F7 /* SupportsCarbonEventModel.cpp in Sources */,
                                1A1E4298141141C400388758 /* PrivateBrowsing.cpp in Sources */,
+                               1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp b/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp
new file mode 100644 (file)
index 0000000..e41b492
--- /dev/null
@@ -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");