2006-03-02 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Mar 2006 21:46:12 +0000 (21:46 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Mar 2006 21:46:12 +0000 (21:46 +0000)
        Reviewed by ggaren.

        * Spinneret/Spinneret/WebView.cpp:
        (WebKit::registerWebViewWithInstance):
        (WebKit::WebView::WebView):
        (WebKit::WebView::mouseMoved):
        (WebKit::WebView::mouseDown):
        (WebKit::WebView::mouseUp):
        (WebKit::WebView::mouseDoubleClick):
        (WebKit::WebViewWndProc):
        * Spinneret/Spinneret/WebView.h:

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

WebKitTools/ChangeLog
WebKitTools/Spinneret/Spinneret/WebView.cpp
WebKitTools/Spinneret/Spinneret/WebView.h

index 320124d6962e78b327929a21bfae95e03a159bc9..f5d3623f4cb11eaaea4128ab15ccfb4ed143e69c 100644 (file)
@@ -1,3 +1,17 @@
+2006-03-02  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by ggaren.
+
+        * Spinneret/Spinneret/WebView.cpp:
+        (WebKit::registerWebViewWithInstance):
+        (WebKit::WebView::WebView):
+        (WebKit::WebView::mouseMoved):
+        (WebKit::WebView::mouseDown):
+        (WebKit::WebView::mouseUp):
+        (WebKit::WebView::mouseDoubleClick):
+        (WebKit::WebViewWndProc):
+        * Spinneret/Spinneret/WebView.h:
+
 2006-03-01  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by andersca.
index 5499ce4078d849ed65bbf99853668fed1ea61f62..85fdf50911626af3bd774b53a97c31566a20c07f 100755 (executable)
 #include "WebView.h"
 #include "Resource.h"
 
-#include "FrameWin.h"
 #include "FrameView.h"
+#include "FrameWin.h"
+#include "GraphicsContext.h"
+#include "MouseEvent.h"
 #include "Page.h"
 #include "render_frames.h"
-#include "GraphicsContext.h"
 
 
 using namespace WebCore;
@@ -52,12 +53,13 @@ public:
     }
 
     FrameWin* frame;
+    FrameView* frameView;
     HWND windowHandle;
 };
 
 const LPCWSTR kWebViewWindowClassName = L"WebViewWindowClass";
 
-LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK WebViewWndProc(HWND, UINT, WPARAM, LPARAM);
 
 static ATOM registerWebViewWithInstance(HINSTANCE hInstance)
 {
@@ -70,7 +72,7 @@ static ATOM registerWebViewWithInstance(HINSTANCE hInstance)
     wcex.cbSize = sizeof(WNDCLASSEX);
 
     wcex.style          = CS_HREDRAW | CS_VREDRAW; // CS_DBLCLKS?
-    wcex.lpfnWndProc    = WndProc;
+    wcex.lpfnWndProc    = WebViewWndProc;
     wcex.cbClsExtra     = 0;
     wcex.cbWndExtra     = 0;
     wcex.hInstance      = hInstance;
@@ -106,8 +108,8 @@ WebView::WebView(HWND hWnd)
 
     Page *page = new Page();
     d->frame = new FrameWin(page, 0);
-    FrameView *frameView = new FrameView(d->frame);
-    d->frame->setView(frameView);
+    d->frameView = new FrameView(d->frame);
+    d->frame->setView(d->frameView);
 
     d->frame->begin();
     d->frame->write("<img src=\"data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7\" alt=\"Larry\"><div style=\"border: 1px black\">foo</div><ul><li>foo<li>bar<li>baz</ul>");
@@ -130,7 +132,31 @@ HWND WebView::windowHandle()
     return d->windowHandle;
 }
 
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+void WebView::mouseMoved(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    MouseEvent mouseEvent(hWnd, wParam, lParam, 0);
+    d->frameView->viewportMouseMoveEvent(&mouseEvent);
+}
+
+void WebView::mouseDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    MouseEvent mouseEvent(hWnd, wParam, lParam, 1);
+    d->frameView->viewportMousePressEvent(&mouseEvent);
+}
+
+void WebView::mouseUp(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    MouseEvent mouseEvent(hWnd, wParam, lParam, 1);
+    d->frameView->viewportMouseReleaseEvent(&mouseEvent);
+}
+
+void WebView::mouseDoubleClick(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    MouseEvent mouseEvent(hWnd, wParam, lParam, 2);
+    d->frameView->viewportMouseReleaseEvent(&mouseEvent);
+}
+
+LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     int wmId, wmEvent;
     HDC hdc;
@@ -153,13 +179,30 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
     case WM_PAINT:
         PAINTSTRUCT ps;
         hdc = BeginPaint(hWnd, &ps);
-        // TODO: Add any drawing code here...
         gSharedWebViewHack->drawRect(ps);
         EndPaint(hWnd, &ps);
         break;
     case WM_DESTROY:
         // Do nothing?
         break;
+    case WM_MOUSEMOVE:
+        gSharedWebViewHack->mouseMoved(hWnd, wParam, lParam);
+        break;
+    case WM_LBUTTONDOWN:
+    case WM_MBUTTONDOWN:
+    case WM_RBUTTONDOWN:
+        gSharedWebViewHack->mouseDown(hWnd, wParam, lParam);
+        break;
+    case WM_LBUTTONUP:
+    case WM_MBUTTONUP:
+    case WM_RBUTTONUP:
+        gSharedWebViewHack->mouseUp(hWnd, wParam, lParam);
+        break;
+    case WM_LBUTTONDBLCLK:
+    case WM_MBUTTONDBLCLK:
+    case WM_RBUTTONDBLCLK:
+        gSharedWebViewHack->mouseDoubleClick(hWnd, wParam, lParam);
+        break;
     default:
         return DefWindowProc(hWnd, message, wParam, lParam);
     }
index 3c1f113d29f7366a4fb2aad3aa9e4408f114339d..f2e13d22373fb06afc43885621b63f08b9b93060 100755 (executable)
@@ -26,6 +26,8 @@
 #ifndef WebView_H
 #define WebView_H
 
+#include <windows.h>
+
 namespace WebKit {
     
     class WebView {
@@ -36,6 +38,11 @@ namespace WebKit {
 
         void drawRect(const PAINTSTRUCT&);
 
+        void mouseMoved(HWND, WPARAM, LPARAM);
+        void mouseDown(HWND, WPARAM, LPARAM);
+        void mouseUp(HWND, WPARAM, LPARAM);
+        void mouseDoubleClick(HWND, WPARAM, LPARAM);
+
         HWND windowHandle();
     private:
         WebView(HWND);