⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 98403 in webkit


Ignore:
Timestamp:
Oct 25, 2011, 4:00:37 PM (15 years ago)
Author:
andersca@apple.com
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.
Location:
trunk
Files:
3 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98397 r98403  
     12011-10-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Plug-ins have to use JavaScript to find out the current device scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=67225
     5        <rdar://problem/10048258>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add tests.
     10
     11        * platform/mac-wk2/plugins/contents-scale-factor-expected.txt: Added.
     12        * platform/mac-wk2/plugins/contents-scale-factor.html: Added.
     13
    1142011-10-25  Julien Chaffraix  <jchaffraix@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r98402 r98403  
     12011-10-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Plug-ins have to use JavaScript to find out the current device scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=67225
     5
     6        Reviewed by Darin Adler.
     7
     8        Test: platform/mac-wk2/plugins/contents-scale-factor.html
     9
     10        Add NPNVcontentsScaleFactor, as per https://wiki.mozilla.org/NPAPI:ContentsScaleFactor.
     11
     12        * plugins/npapi.h:
     13
    1142011-10-25  Adam Klein  <adamk@chromium.org>
    215
  • trunk/Source/WebCore/plugins/npapi.h

    r97557 r98403  
    417417  /* Used for negotiating drawing models */
    418418  , NPNVpluginDrawingModel = 1000
     419  , NPNVcontentsScaleFactor = 1001
    419420#ifndef NP_NO_QUICKDRAW
    420421  , NPNVsupportsQuickDrawBool = 2000
  • trunk/Source/WebKit2/ChangeLog

    r98399 r98403  
     12011-10-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Plug-ins have to use JavaScript to find out the current device scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=67225
     5        <rdar://problem/10048258>
     6
     7        Reviewed by Darin Adler.
     8
     9        * PluginProcess/PluginControllerProxy.cpp:
     10        (WebKit::PluginControllerProxy::PluginControllerProxy):
     11        Initialize m_contentsScaleFactor.
     12
     13        * PluginProcess/PluginControllerProxy.h:
     14        Add contentsScaleFactor member function and m_contentsScaleFactor member variable.
     15
     16        * PluginProcess/PluginCreationParameters.cpp:
     17        (WebKit::PluginCreationParameters::PluginCreationParameters):
     18        (WebKit::PluginCreationParameters::encode):
     19        (WebKit::PluginCreationParameters::decode):
     20        * PluginProcess/PluginCreationParameters.h:
     21        Add contentsScaleFactor to the creation parameters.
     22
     23        * PluginProcess/mac/PluginControllerProxyMac.mm:
     24        (WebKit::PluginControllerProxy::contentsScaleFactor):
     25        Return the cached m_contentsScaleFactor.
     26
     27        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     28        (WebKit::NPN_GetValue):
     29        Handle getting the scale factor by calling NetscapePlugin::contentsScaleFactor.
     30
     31        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     32        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
     33        (WebKit::NetscapePlugin::contentsScaleFactor):
     34        Ask the plug-in controller for the contents scale factor.
     35
     36        * WebProcess/Plugins/PluginController.h:
     37        Add contentsScaleFactor pure virtual member function.
     38
     39        * WebProcess/Plugins/PluginProxy.cpp:
     40        (WebKit::PluginProxy::initialize):
     41        Set contentsScaleFactor in the creation parameters.
     42
     43        * WebProcess/Plugins/PluginView.cpp:
     44        (WebKit::PluginView::contentsScaleFactor):
     45        Get the device scale factor from the page.
     46
     47        * WebProcess/Plugins/PluginView.h:
     48        Add contentsScaleFactor().
     49
     50        * WebProcess/WebPage/WebPage.cpp:
     51        (WebKit::WebPage::setDeviceScaleFactor):
     52        Bail if the scale factor didn't change.
     53
    1542011-10-25  Sam Weinig  <sam@webkit.org>
    255
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp

    r95901 r98403  
    7171#if PLATFORM(MAC)
    7272    , m_isComplexTextInputEnabled(false)
     73    , m_contentsScaleFactor(creationParameters.contentsScaleFactor)
    7374#endif
    7475    , m_windowNPObject(0)
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h

    r95901 r98403  
    100100    virtual void setComplexTextInputState(PluginComplexTextInputState);
    101101    virtual mach_port_t compositingRenderServerPort();
     102    virtual float contentsScaleFactor();
    102103#endif
    103104
     
    192193    bool m_isComplexTextInputEnabled;
    193194
     195    // The contents scale factor of this plug-in.
     196    float m_contentsScaleFactor;
     197
    194198    // For CA plug-ins, this holds the information needed to export the layer hierarchy to the UI process.
    195199    RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
  • trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp

    r95901 r98403  
    4040    , isAcceleratedCompositingEnabled(false)
    4141#endif
     42#if PLATFORM(MAC)
     43    , contentsScaleFactor(1)
     44#endif
    4245{
    4346}
     
    5356#if USE(ACCELERATED_COMPOSITING)
    5457    encoder->encode(isAcceleratedCompositingEnabled);
     58#endif
     59
     60#if PLATFORM(MAC)
     61    encoder->encode(contentsScaleFactor);
    5562#endif
    5663}
     
    7885#endif
    7986
     87#if PLATFORM(MAC)
     88    if (!decoder->decode(result.contentsScaleFactor))
     89        return false;
     90#endif
     91
    8092    return true;
    8193}
  • trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.h

    r95901 r98403  
    6363    bool isAcceleratedCompositingEnabled;
    6464#endif
     65
     66#if PLATFORM(MAC)
     67    // The current contents scale factor that this plug-in should have.
     68    float contentsScaleFactor;
     69#endif
    6570};
    6671
  • trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm

    r95901 r98403  
    5252{
    5353    return PluginProcess::shared().compositingRenderServerPort();
     54}
     55
     56float PluginControllerProxy::contentsScaleFactor()
     57{
     58    return m_contentsScaleFactor;
    5459}
    5560
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r95901 r98403  
    459459           
    460460            *(NPBool*)value = plugin->isAcceleratedCompositingEnabled();
     461            break;
     462        }
     463        case NPNVcontentsScaleFactor: {
     464            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     465
     466            *(double*)value = plugin->contentsScaleFactor();
    461467            break;
    462468        }
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r98369 r98403  
    6464
    6565    mach_port_t compositingRenderServerPort();
     66    double contentsScaleFactor();
    6667
    6768#ifndef NP_NO_CARBON
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm

    r95901 r98403  
    180180}
    181181
     182double NetscapePlugin::contentsScaleFactor()
     183{
     184    return controller()->contentsScaleFactor();
     185}
     186
    182187#ifndef NP_NO_CARBON
    183188typedef HashMap<WindowRef, NetscapePlugin*> WindowMap;
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginController.h

    r95901 r98403  
    121121    // Returns the mach port of the compositing render server.
    122122    virtual mach_port_t compositingRenderServerPort() = 0;
     123
     124    // Returns the contents scale factor.
     125    virtual float contentsScaleFactor() = 0;
    123126#endif
    124127
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp

    r98369 r98403  
    102102    creationParameters.isAcceleratedCompositingEnabled = controller()->isAcceleratedCompositingEnabled();
    103103#endif
     104#if PLATFORM(MAC)
     105    creationParameters.contentsScaleFactor = controller()->contentsScaleFactor();
     106#endif
    104107
    105108    bool result = false;
     
    376379    m_connection->connection()->send(Messages::PluginControllerProxy::SendComplexTextInput(textInput), m_pluginInstanceID);
    377380}
    378 
    379381#endif
    380382
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r98394 r98403  
    11411141    return WebProcess::shared().compositingRenderServerPort();
    11421142}
     1143
     1144float PluginView::contentsScaleFactor()
     1145{
     1146    if (Page* page = frame() ? frame()->page() : 0)
     1147        return page->deviceScaleFactor();
     1148       
     1149    return 1;
     1150}
    11431151#endif
    11441152   
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h

    r98369 r98403  
    151151    virtual void setComplexTextInputState(PluginComplexTextInputState);
    152152    virtual mach_port_t compositingRenderServerPort();
     153    virtual float contentsScaleFactor();
    153154#endif
    154155    virtual String proxiesForURL(const String&);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r98325 r98403  
    847847void WebPage::setDeviceScaleFactor(float scaleFactor)
    848848{
     849    if (scaleFactor == m_page->deviceScaleFactor())
     850        return;
     851
    849852    m_page->setDeviceScaleFactor(scaleFactor);
    850853}
  • trunk/Tools/ChangeLog

    r98399 r98403  
     12011-10-25  Anders Carlsson  <andersca@apple.com>
     2
     3        Plug-ins have to use JavaScript to find out the current device scale factor
     4        https://bugs.webkit.org/show_bug.cgi?id=67225
     5        <rdar://problem/10048258>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a plug-in test for getting the contents scale factor.
     10
     11        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
     12        * DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp: Added.
     13        (ContentsScaleFactor::ContentsScaleFactor):
     14        (ContentsScaleFactor::contentsScaleFactor):
     15        (ContentsScaleFactor::ScriptableObject::hasProperty):
     16        (ContentsScaleFactor::ScriptableObject::getProperty):
     17        (ContentsScaleFactor::ScriptableObject::pluginTest):
     18        (ContentsScaleFactor::NPP_GetValue):
     19
    1202011-10-25  Sam Weinig  <sam@webkit.org>
    221
  • trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r94430 r98403  
    4242                1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
    4343                1A5CC1F5137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */; };
     44                1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */; };
    4445                1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F024C0BB9B056008CFA34 /* TestObject.h */; };
    4546                1AC6C8490D07638600CD3161 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C77F0D07589B00CD3161 /* main.cpp */; };
     
    226227                1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
    227228                1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURL.cpp; sourceTree = "<group>"; };
     229                1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentsScaleFactor.cpp; sourceTree = "<group>"; };
    228230                1A8F024C0BB9B056008CFA34 /* TestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObject.h; sourceTree = "<group>"; };
    229231                1AC6C77F0D07589B00CD3161 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
     
    526528                                1A31EB3713466AC100017372 /* ConvertPoint.cpp */,
    527529                                1A14C8A31406DE0400B254F7 /* SupportsCarbonEventModel.cpp */,
     530                                1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */,
    528531                        );
    529532                        path = mac;
     
    836839                                1A14C8A51406DE0400B254F7 /* SupportsCarbonEventModel.cpp in Sources */,
    837840                                1A1E4298141141C400388758 /* PrivateBrowsing.cpp in Sources */,
     841                                1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
    838842                        );
    839843                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.