2006-03-04 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Mar 2006 00:33:53 +0000 (00:33 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Mar 2006 00:33:53 +0000 (00:33 +0000)
        Reviewed by ggaren.

        Hang WebView pointer off of HWND (gets rid of global hack).
        Remove MessageBox displayed on url change.

        * Spinneret/Spinneret/Spinneret.cpp:
        (WndProc):
        (MyEditProc):
        * Spinneret/Spinneret/WebView.cpp:
        (WebKit::registerWebViewWithInstance):
        (WebKit::WebView::createWebView):
        (WebKit::WebViewWndProc):

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

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

index afa94e6d81ec5f87b01b76c9181e609b4386a0ff..75418a7eeedb627a7bb0e2692ac8a394a1c2d072 100644 (file)
@@ -1,3 +1,18 @@
+2006-03-04  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by ggaren.
+
+        Hang WebView pointer off of HWND (gets rid of global hack).
+        Remove MessageBox displayed on url change.
+
+        * Spinneret/Spinneret/Spinneret.cpp:
+        (WndProc):
+        (MyEditProc):
+        * Spinneret/Spinneret/WebView.cpp:
+        (WebKit::registerWebViewWithInstance):
+        (WebKit::WebView::createWebView):
+        (WebKit::WebViewWndProc):
+
 2006-03-04  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Eric.
index 17d0b4065623aa1edb3b255359e431e53c2a0f44..8da35897634815a9b682eae97a8bfbb1268773a2 100755 (executable)
@@ -177,11 +177,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
             return DefWindowProc(hWnd, message, wParam, lParam);
         }
         break;
-    case WM_PAINT:
-        hdc = BeginPaint(hWnd, &ps);
-        // TODO: Add any drawing code here...
-        EndPaint(hWnd, &ps);
-        break;
     case WM_DESTROY:
         PostQuitMessage(0);
         break;
@@ -209,14 +204,12 @@ LRESULT CALLBACK MyEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPara
                 *((LPWORD)strPtr) = MAX_URL_LENGTH; 
                 int strLen = SendMessage(hDlg, EM_GETLINE, 0, (LPARAM)strPtr);
 
-                MessageBox(hMainWnd, strPtr, L"Foo", MB_OK);
-
                 int x;
                 for(x = 0; x < strLen; x++)
                     cstrPtr[x] = strPtr[x];
                 cstrPtr[x] = 0;
-    
-                gWebView->mainFrame()->loadFilePath(cstrPtr);            
+
+                gWebView->mainFrame()->loadFilePath(cstrPtr);
 
                 return 0;
             } else
index 1494ded2905a267646a4662c7c588555d87dfc5e..a472e1755ad9860151622578925b5163f9e6cdd9 100755 (executable)
@@ -38,9 +38,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-// FIXME: we need to hang a pointer off the HWND
-WebView* gSharedWebViewHack = 0;
-
 class WebView::WebViewPrivate {
 public:
     WebViewPrivate() {}
@@ -50,7 +47,6 @@ public:
     }
 
     WebFrame* mainFrame;
-
     HWND windowHandle;
 };
 
@@ -71,7 +67,7 @@ static ATOM registerWebViewWithInstance(HINSTANCE hInstance)
     wcex.style          = CS_HREDRAW | CS_VREDRAW; // CS_DBLCLKS?
     wcex.lpfnWndProc    = WebViewWndProc;
     wcex.cbClsExtra     = 0;
-    wcex.cbWndExtra     = 0;
+    wcex.cbWndExtra     = 4; // 4 bytes for the WebView pointer
     wcex.hInstance      = hInstance;
     wcex.hIcon          = 0;
     wcex.hCursor        = LoadCursor(0, IDC_ARROW);
@@ -94,8 +90,9 @@ WebView* WebView::createWebView(HINSTANCE hInstance, HWND parent)
    if (!hWnd)
       return 0;
 
-   gSharedWebViewHack = new WebView(hWnd);
-   return gSharedWebViewHack;
+   WebView* newWebView = new WebView(hWnd);
+   SetWindowLongPtr(hWnd, 0, (LONG)newWebView);
+   return newWebView;
 }
 
 WebView::WebView(HWND hWnd)
@@ -148,31 +145,32 @@ void WebView::mouseDoubleClick(HWND hWnd, WPARAM wParam, LPARAM lParam)
 LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     int wmId, wmEvent;
+    WebView* webview = (WebView*)GetWindowLongPtr(hWnd, 0);
     switch (message)
     {
     case WM_PAINT:
-        gSharedWebViewHack->mainFrame()->paint();
+        webview->mainFrame()->paint();
         break;
     case WM_DESTROY:
         // Do nothing?
         break;
     case WM_MOUSEMOVE:
-        gSharedWebViewHack->mouseMoved(hWnd, wParam, lParam);
+        webview->mouseMoved(hWnd, wParam, lParam);
         break;
     case WM_LBUTTONDOWN:
     case WM_MBUTTONDOWN:
     case WM_RBUTTONDOWN:
-        gSharedWebViewHack->mouseDown(hWnd, wParam, lParam);
+        webview->mouseDown(hWnd, wParam, lParam);
         break;
     case WM_LBUTTONUP:
     case WM_MBUTTONUP:
     case WM_RBUTTONUP:
-        gSharedWebViewHack->mouseUp(hWnd, wParam, lParam);
+        webview->mouseUp(hWnd, wParam, lParam);
         break;
     case WM_LBUTTONDBLCLK:
     case WM_MBUTTONDBLCLK:
     case WM_RBUTTONDBLCLK:
-        gSharedWebViewHack->mouseDoubleClick(hWnd, wParam, lParam);
+        webview->mouseDoubleClick(hWnd, wParam, lParam);
         break;
     case WM_SIZE:
         // FIXME: not sure if we need anything here...