Changeset 73387 in webkit


Ignore:
Timestamp:
Dec 6, 2010 12:34:47 PM (13 years ago)
Author:
andersca@apple.com
Message:

Add a shim for IsWindowActive
https://bugs.webkit.org/show_bug.cgi?id=50582

Reviewed by Adam Roben.

  • PluginProcess/mac/PluginProcessMac.mm:

(WebKit::isWindowActive):
Get the NetscapePlugin from the WindowRef and check if the plug-in's window is active.

(WebKit::PluginProcess::initializeShim):

  • PluginProcess/mac/PluginProcessShim.cpp

(WebKit::shimIsWindowActive):
Call isWindowActive. If it returns true, return the result value. Otherwise, call the real
IsWindowActive function.

  • PluginProcess/mac/PluginProcessShim.h:
  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_isWindowactive.

  • WebProcess/Plugins/Netscape/NetscapePlugin.h:

(WebKit::NetscapePlugin::isWindowActive):
Return whether the window is active.

  • WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:

(WebKit::windowMap):
(WebKit::NetscapePlugin::platformPostInitialize):
(WebKit::NetscapePlugin::platformDestroy):
(WebKit::NetscapePlugin::netscapePluginFromWindow):
Add a mapping between windows and the corresponding NetscapePlugin objects.

(WebKit::NetscapePlugin::windowFocusChanged):
Update the window focus member variable.

Location:
trunk/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r73383 r73387  
     12010-12-06  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Add a shim for IsWindowActive
     6        https://bugs.webkit.org/show_bug.cgi?id=50582
     7
     8        * PluginProcess/mac/PluginProcessMac.mm:
     9        (WebKit::isWindowActive):
     10        Get the NetscapePlugin from the WindowRef and check if the plug-in's window is active.
     11
     12        (WebKit::PluginProcess::initializeShim):
     13        * PluginProcess/mac/PluginProcessShim.cpp       
     14        (WebKit::shimIsWindowActive):
     15        Call isWindowActive. If it returns true, return the result value. Otherwise, call the real
     16        IsWindowActive function.
     17
     18        * PluginProcess/mac/PluginProcessShim.h:
     19        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     20        (WebKit::NetscapePlugin::NetscapePlugin):
     21        Initialize m_isWindowactive.
     22
     23        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     24        (WebKit::NetscapePlugin::isWindowActive):
     25        Return whether the window is active.
     26
     27        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
     28        (WebKit::windowMap):
     29        (WebKit::NetscapePlugin::platformPostInitialize):
     30        (WebKit::NetscapePlugin::platformDestroy):
     31        (WebKit::NetscapePlugin::netscapePluginFromWindow):
     32        Add a mapping between windows and the corresponding NetscapePlugin objects.
     33
     34        (WebKit::NetscapePlugin::windowFocusChanged):
     35        Update the window focus member variable.
     36
    1372010-12-06  Anders Carlsson  <andersca@apple.com>
    238
  • trunk/WebKit2/PluginProcess/mac/PluginProcessMac.mm

    r72972 r73387  
    2828#include "PluginProcess.h"
    2929
     30#include "NetscapePlugin.h"
    3031#include "PluginProcessShim.h"
    3132#include <dlfcn.h>
     
    5051    return isUserbreakSet;
    5152}
    52    
     53
     54static bool isWindowActive(WindowRef windowRef, bool& result)
     55{
     56#ifndef NP_NO_CARBON
     57    if (NetscapePlugin* plugin = NetscapePlugin::netscapePluginFromWindow(windowRef)) {
     58        result = plugin->isWindowActive();
     59        return true;
     60    }
     61#endif
     62    return false;
     63}
     64
    5365void PluginProcess::initializeShim()
    5466{
    5567    const PluginProcessShimCallbacks callbacks = {
    5668        shouldCallRealDebugger,
     69        isWindowActive,
    5770    };
    5871
  • trunk/WebKit2/PluginProcess/mac/PluginProcessShim.cpp

    r72973 r73387  
    5454}
    5555
     56static Boolean shimIsWindowActive(WindowRef window)
     57{
     58    bool result;
     59    if (pluginProcessShimCallbacks.isWindowActive(window, result))
     60        return result;
     61   
     62    return IsWindowActive(window);
     63}
     64   
    5665DYLD_INTERPOSE(shimDebugger, Debugger);
     66DYLD_INTERPOSE(shimIsWindowActive, IsWindowActive);
     67   
    5768#endif
    5869
  • trunk/WebKit2/PluginProcess/mac/PluginProcessShim.h

    r72972 r73387  
    2727#define PluginProcessShim_h
    2828
     29#include <Carbon/Carbon.h>
     30
    2931namespace WebKit {
    3032
    3133struct PluginProcessShimCallbacks {
    3234    bool (*shouldCallRealDebugger)();
     35    bool (*isWindowActive)(WindowRef, bool& result);
    3336};
    3437
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r73057 r73387  
    4343// The plug-in that we're currently calling NPP_New for.
    4444static NetscapePlugin* currentNPPNewPlugin;
    45    
     45
    4646NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
    4747    : m_pluginController(0)
     
    6363    , m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired)
    6464    , m_npCGContext()
     65    , m_isWindowActive(false)
    6566#endif   
    6667#endif
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r73090 r73387  
    5959#ifndef NP_NO_CARBON
    6060    WindowRef windowRef() const;
     61    bool isWindowActive() const { return m_isWindowActive; }
     62
     63    static NetscapePlugin* netscapePluginFromWindow(WindowRef);
    6164#endif
    6265#elif PLATFORM(WIN)
     
    201204    RunLoop::Timer<NetscapePlugin> m_nullEventTimer;
    202205    NP_CGContext m_npCGContext;
     206    bool m_isWindowActive;
    203207#endif
    204208#elif PLATFORM(WIN)
  • trunk/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm

    r73381 r73387  
    3333namespace WebKit {
    3434
    35 #ifndef NP_NO_QUICKDRAW
     35#ifndef NP_NO_CARBON
    3636static const double nullEventIntervalActive = 0.02;
    3737static const double nullEventIntervalNotActive = 0.25;
     
    8080    return NPERR_NO_ERROR;
    8181}
     82
     83#ifndef NP_NO_CARBON
     84typedef HashMap<WindowRef, NetscapePlugin*> WindowMap;
     85
     86static WindowMap& windowMap()
     87{
     88    DEFINE_STATIC_LOCAL(WindowMap, windowMap, ());
     89
     90    return windowMap;
     91}
     92#endif
    8293
    8394bool NetscapePlugin::platformPostInitialize()
     
    138149        m_npWindow.window = &m_npCGContext;
    139150
     151        ASSERT(!windowMap().contains(windowRef()));
     152        windowMap().set(windowRef(), this);
     153
    140154        // Start the null event timer.
    141155        // FIXME: Throttle null events when the plug-in isn't visible on screen.
     
    155169            DisposeWindow(static_cast<WindowRef>(m_npCGContext.window));
    156170
     171        ASSERT(windowMap().contains(windowRef()));
     172        windowMap().remove(windowRef());
     173
    157174        // Stop the null event timer.
    158175        m_nullEventTimer.stop();
     
    181198
    182199#ifndef NP_NO_CARBON
     200NetscapePlugin* NetscapePlugin::netscapePluginFromWindow(WindowRef windowRef)
     201{
     202    return windowMap().get(windowRef);
     203}
     204
    183205WindowRef NetscapePlugin::windowRef() const
    184206{
     
    603625#ifndef NP_NO_CARBON
    604626        case NPEventModelCarbon: {
     627            m_isWindowActive = hasFocus;
     628           
    605629            HiliteWindow(windowRef(), hasFocus);
    606630            if (hasFocus)
Note: See TracChangeset for help on using the changeset viewer.