DOMイベントハンドリングふたたび
DOMイベントハンドリング - ロックスターになりたい
のつづき。
mEventCallback
がわかんないという件。
nsWindow::StandardWindowCreateの
EVENT_CALLBACK aHandleEventFunction
がどこから来てるかというところから仕切りなおし。
~/mozilla/widget/src/windows/nsWindow.cpp
NS_METHOD nsWindow::Create(nsIWidget *aParent, const nsRect &aRect, EVENT_CALLBACK aHandleEventFunction, nsIDeviceContext *aContext, nsIAppShell *aAppShell, nsIToolkit *aToolkit, nsWidgetInitData *aInitData) { if (aInitData) mUnicodeWidget = aInitData->mUnicode; return(StandardWindowCreate(aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData, nsnull)); }
Createから呼ばれる。CreateはCallMethodを介して呼ばれる。
こういう小細工をするのはメインスレッドに実行してほしいから。理由は知らない。
//------------------------------------------------------------------------- // // Every function that needs a thread switch goes through this function // by calling SendMessage (..WM_CALLMETHOD..) in nsToolkit::CallMethod. // //------------------------------------------------------------------------- BOOL nsWindow::CallMethod(MethodInfo *info) { BOOL bRet = TRUE; switch (info->methodId) { case nsWindow::CREATE: NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod"); Create((nsIWidget*)(info->args[0]), (nsRect&)*(nsRect*)(info->args[1]), (EVENT_CALLBACK)(info->args[2]), (nsIDeviceContext*)(info->args[3]), (nsIAppShell *)(info->args[4]), (nsIToolkit*)(info->args[5]), (nsWidgetInitData*)(info->args[6])); break;
~/mozilla/widget/src/windows/nsToolkit.cpp
//------------------------------------------------------------------------- // // nsToolkit WindowProc. Used to call methods on the "main GUI thread"... // //------------------------------------------------------------------------- LRESULT CALLBACK nsToolkit::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CALLMETHOD: { MethodInfo *info = (MethodInfo *)lParam; return info->Invoke(); }
Createがよくわかんない。ただnsWebShellWindowはこうなってて
~/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp
mWindow->SetClientData(this); mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget r, // Widget dimensions nsWebShellWindow::HandleEvent, // Event handler function nsnull, // Device context aShell, // Application shell nsnull, // nsIToolkit &widgetInitData); // Widget initialization data
HandleEventでハンドルするものなのかと思って調べたら
nsEventListenerManager::HandleEventがそれっぽかった。
nsEventListenerManagerはフレームのいれこ構造だったり、キャレットだったり、いろいろ管理してるのだ。
管理してるのはnsEventStateManager.