2006-03-03 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Mar 2006 09:54:37 +0000 (09:54 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Mar 2006 09:54:37 +0000 (09:54 +0000)
        Reviewed by mjs.

        Add WebFrame class (to hold Frame and FrameView).
        Add Location bar support to Spinneret.

        * Spinneret/Spinneret/Spinneret.cpp:
        (resizeSubViews):
        (_tWinMain):
        (WndProc):
        (MyEditProc):
        * Spinneret/Spinneret/Spinneret.vcproj:
        * Spinneret/Spinneret/WebFrame.cpp: Added.
        (WebKit::WebFrame::WebFramePrivate::WebFramePrivate):
        (WebKit::WebFrame::WebFramePrivate::~WebFramePrivate):
        (WebKit::WebFrame::WebFrame):
        (WebKit::WebFrame::loadFilePath):
        (WebKit::WebFrame::loadHTMLString):
        (WebKit::WebFrame::paint):
        (WebKit::WebFrame::impl):
        (WebKit::WebFrame::viewImpl):
        * Spinneret/Spinneret/WebFrame.h: Added.
        * Spinneret/Spinneret/WebView.cpp:
        (WebKit::WebView::WebViewPrivate::~WebViewPrivate):
        (WebKit::WebView::WebView):
        (WebKit::WebView::windowHandle):
        (WebKit::WebView::mainFrame):
        (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@13116 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Spinneret/Spinneret/Spinneret.cpp
WebKitTools/Spinneret/Spinneret/Spinneret.vcproj
WebKitTools/Spinneret/Spinneret/WebFrame.cpp [new file with mode: 0755]
WebKitTools/Spinneret/Spinneret/WebFrame.h [new file with mode: 0755]
WebKitTools/Spinneret/Spinneret/WebView.cpp
WebKitTools/Spinneret/Spinneret/WebView.h

index f5d3623f4cb11eaaea4128ab15ccfb4ed143e69c..daac4379e8119632b22bed4ebfeaf67fc91c53a3 100644 (file)
@@ -1,3 +1,38 @@
+2006-03-03  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by mjs.
+
+        Add WebFrame class (to hold Frame and FrameView).
+        Add Location bar support to Spinneret.
+
+        * Spinneret/Spinneret/Spinneret.cpp:
+        (resizeSubViews):
+        (_tWinMain):
+        (WndProc):
+        (MyEditProc):
+        * Spinneret/Spinneret/Spinneret.vcproj:
+        * Spinneret/Spinneret/WebFrame.cpp: Added.
+        (WebKit::WebFrame::WebFramePrivate::WebFramePrivate):
+        (WebKit::WebFrame::WebFramePrivate::~WebFramePrivate):
+        (WebKit::WebFrame::WebFrame):
+        (WebKit::WebFrame::loadFilePath):
+        (WebKit::WebFrame::loadHTMLString):
+        (WebKit::WebFrame::paint):
+        (WebKit::WebFrame::impl):
+        (WebKit::WebFrame::viewImpl):
+        * Spinneret/Spinneret/WebFrame.h: Added.
+        * Spinneret/Spinneret/WebView.cpp:
+        (WebKit::WebView::WebViewPrivate::~WebViewPrivate):
+        (WebKit::WebView::WebView):
+        (WebKit::WebView::windowHandle):
+        (WebKit::WebView::mainFrame):
+        (WebKit::WebView::mouseMoved):
+        (WebKit::WebView::mouseDown):
+        (WebKit::WebView::mouseUp):
+        (WebKit::WebView::mouseDoubleClick):
+        (WebKit::WebViewWndProc):
+        * Spinneret/Spinneret/WebView.h:
+
 2006-03-02  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by ggaren.
index 514e71b356e8d5f9a0544462ce95e461dd5a5539..17d0b4065623aa1edb3b255359e431e53c2a0f44 100755 (executable)
 #include "stdafx.h"
 #include "Spinneret.h"
 #include "WebView.h"
+#include "WebFrame.h"
+
+#include <commctrl.h>
 
 #define MAX_LOADSTRING 100
+#define URLBAR_HEIGHT  24
 
 using namespace WebKit;
 
 // Global Variables:
 HINSTANCE hInst;                                // current instance
 HWND hMainWnd;
+HWND hURLBarWnd;
+long DefEditProc;
 WebView* gWebView = 0;
 TCHAR szTitle[MAX_LOADSTRING];                    // The title bar text
 TCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name
@@ -43,6 +49,15 @@ ATOM                MyRegisterClass(HINSTANCE hInstance);
 BOOL                InitInstance(HINSTANCE, int);
 LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
 INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK    MyEditProc(HWND, UINT, WPARAM, LPARAM);
+
+static void resizeSubViews()
+{
+    RECT rcClient;
+    GetClientRect(hMainWnd, &rcClient);
+    MoveWindow(hURLBarWnd, 0, 0, rcClient.right, URLBAR_HEIGHT, TRUE);
+    MoveWindow(gWebView->windowHandle(), 0, URLBAR_HEIGHT, rcClient.right, rcClient.bottom - URLBAR_HEIGHT, TRUE);
+}
 
 int APIENTRY _tWinMain(HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
@@ -56,6 +71,12 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
     MSG msg;
     HACCEL hAccelTable;
 
+    INITCOMMONCONTROLSEX InitCtrlEx;
+
+    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
+    InitCtrlEx.dwICC  = ICC_STANDARD_CLASSES;
+    InitCommonControlsEx(&InitCtrlEx);
+
     // Initialize global strings
     LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
     LoadString(hInstance, IDC_SPINNERET, szWindowClass, MAX_LOADSTRING);
@@ -65,12 +86,18 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
     if (!InitInstance (hInstance, nCmdShow))
         return FALSE;
 
+    hURLBarWnd = CreateWindow(L"EDIT", 0,
+                        WS_CHILD | WS_VISIBLE  | ES_LEFT | ES_AUTOVSCROLL, 
+                        0, 0, 0, 0,
+                        hMainWnd,
+                        0,
+                        hInstance, 0);
+
+    DefEditProc = GetWindowLong(hURLBarWnd, GWL_WNDPROC);
+    SetWindowLong(hURLBarWnd, GWL_WNDPROC,(long)MyEditProc);
+
     gWebView = WebView::createWebView(hInstance, hMainWnd);
-    RECT rcClient;
-    GetClientRect(hMainWnd, &rcClient); 
-    MoveWindow(gWebView->windowHandle(), 
-                   0, 0, rcClient.right, rcClient.bottom, 
-                   TRUE);
+    resizeSubViews();
     ShowWindow(gWebView->windowHandle(), nCmdShow);
     UpdateWindow(gWebView->windowHandle());
 
@@ -89,21 +116,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
     return (int) msg.wParam;
 }
 
-
-
-//
-//  FUNCTION: MyRegisterClass()
-//
-//  PURPOSE: Registers the window class.
-//
-//  COMMENTS:
-//
-//    This function and its usage are only necessary if you want this code
-//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
-//    function that was added to Windows 95. It is important to call this function
-//    so that the application will get 'well formed' small icons associated
-//    with it.
-//
 ATOM MyRegisterClass(HINSTANCE hInstance)
 {
     WNDCLASSEX wcex;
@@ -176,16 +188,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
     case WM_SIZE:
         if (!gWebView)
             break;
-        // Get the dimensions of the main window's client 
-        // area, and enumerate the child windows. Pass the 
-        // dimensions to the child windows during enumeration. 
-
-        RECT rcClient;
-        GetClientRect(hWnd, &rcClient); 
-        MoveWindow(gWebView->windowHandle(), 
-                   0, 0, rcClient.right, rcClient.bottom, 
-                   TRUE);
-        ShowWindow(gWebView->windowHandle(), SW_SHOW); 
+        resizeSubViews();
         break; 
     default:
         return DefWindowProc(hWnd, message, wParam, lParam);
@@ -193,6 +196,40 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
     return 0;
 }
 
+
+#define MAX_URL_LENGTH  1024
+
+LRESULT CALLBACK MyEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message) {
+        case WM_CHAR:
+            if( wParam == 13 ) { // Enter Key
+                wchar_t strPtr[MAX_URL_LENGTH];
+                char    cstrPtr[MAX_URL_LENGTH];
+                *((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);            
+
+                return 0;
+            } else
+                return (LRESULT)CallWindowProc((WNDPROC)DefEditProc,hDlg,message,wParam,lParam);
+            break;
+        default:
+             return (LRESULT)CallWindowProc((WNDPROC)DefEditProc,hDlg,message,wParam,lParam);
+        break;
+    }
+    return 0;
+}
+
+
 // Message handler for about box.
 INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 {
index 86edb5ed22ff73ea4ccb49fbc411a09c54f6a3bd..a23ff1fbefbd98e11823021c7dec325aa928f95e 100755 (executable)
@@ -47,7 +47,7 @@
                                RuntimeLibrary="3"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="1"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="4"\r
                        />\r
                        <Tool\r
@@ -61,7 +61,7 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;"\r
+                               AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;&#x0D;&#x0A;comctl32.lib"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                RuntimeLibrary="2"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="1"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;"\r
+                               AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;&#x0D;&#x0A;comctl32.lib"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                        />\r
                                </FileConfiguration>\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\WebFrame.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\WebView.cpp"\r
                                >\r
                                RelativePath=".\stdafx.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\WebFrame.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\WebView.h"\r
                                >\r
diff --git a/WebKitTools/Spinneret/Spinneret/WebFrame.cpp b/WebKitTools/Spinneret/Spinneret/WebFrame.cpp
new file mode 100755 (executable)
index 0000000..1d212ca
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "stdafx.h"
+#include "config.h"
+
+#include "WebFrame.h"
+#include "WebView.h"
+
+#include "FrameView.h"
+#include "FrameWin.h"
+#include "GraphicsContext.h"
+#include "Page.h"
+#include "render_frames.h"
+
+#include <io.h>
+#include <fcntl.h>
+#include <direct.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebFrame::WebFramePrivate {
+public:
+    WebFramePrivate() { }
+    ~WebFramePrivate() { }
+
+    Frame* frame;
+    FrameView* frameView;
+    WebView* webView;
+};
+
+WebFrame::WebFrame(char* name, WebView* view)
+: d(new WebFrame::WebFramePrivate)
+{
+    d->webView = view;
+    Page *page = new Page();
+    d->frame = new FrameWin(page, 0);
+    d->frameView = new FrameView(d->frame);
+    d->frame->setView(d->frameView);
+    d->frameView->setWindowHandle(view->windowHandle());
+}
+
+void WebFrame::loadFilePath(char *path)
+{
+    FILE* file = fopen(path, "rb");
+    if (!file) {
+        printf("Failed to open file: %s\n", path);
+        printf("Current path: %s\n", _getcwd(0,0));
+        return;
+    }
+
+    d->frame->begin();
+
+    char buffer[4000];
+    int newBytes = 0;
+    while ((newBytes = fread(buffer, 1, 4000, file)) > 0) {
+        d->frame->write(buffer, newBytes);
+    }
+    fclose(file);
+
+    d->frame->end();
+}
+
+void WebFrame::loadHTMLString(char *html, char *baseURL)
+{
+    d->frame->begin();
+    d->frame->write(html);
+    d->frame->end();
+}
+
+void WebFrame::paint()
+{
+    PAINTSTRUCT ps;
+    HDC hdc = BeginPaint(d->webView->windowHandle(), &ps);
+    GraphicsContext context(ps.hdc);
+    d->frame->paint(&context, ps.rcPaint);
+    EndPaint(d->webView->windowHandle(), &ps);
+}
+
+WebCore::Frame* WebFrame::impl()
+{
+    return d->frame;
+}
+
+WebCore::FrameView* WebFrame::viewImpl()
+{
+    return d->frameView;
+}
+
+}
+
diff --git a/WebKitTools/Spinneret/Spinneret/WebFrame.h b/WebKitTools/Spinneret/Spinneret/WebFrame.h
new file mode 100755 (executable)
index 0000000..b148244
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+namespace WebCore {
+    class Frame;
+    class FrameView;
+}
+
+namespace WebKit {
+
+    class WebView;
+
+    class WebFrame {
+    public:
+    WebFrame(char* name, WebView*);
+
+    void loadFilePath(char*);
+    void loadHTMLString(char* html, char* baseURL = 0);
+
+    void paint();
+
+    WebCore::Frame* impl();
+    WebCore::FrameView* viewImpl();
+
+    private:
+        class WebFramePrivate;
+        WebFramePrivate *d;
+    };
+}
index 85fdf50911626af3bd774b53a97c31566a20c07f..613eb00f8f414fdbf0a20b78659299a1dc2a6e78 100755 (executable)
 #include "stdafx.h"
 #include "config.h"
 
+#include "WebFrame.h"
+
 #include "WebView.h"
 #include "Resource.h"
-
 #include "FrameView.h"
-#include "FrameWin.h"
-#include "GraphicsContext.h"
 #include "MouseEvent.h"
-#include "Page.h"
-#include "render_frames.h"
-
+#include "IntRect.h"
 
 using namespace WebCore;
 
@@ -49,11 +46,11 @@ public:
     WebViewPrivate() {}
     ~WebViewPrivate()
     {
-        delete frame;
+        delete mainFrame;
     }
 
-    FrameWin* frame;
-    FrameView* frameView;
+    WebFrame* mainFrame;
+
     HWND windowHandle;
 };
 
@@ -105,15 +102,8 @@ WebView::WebView(HWND hWnd)
 {
     d = new WebViewPrivate();
     d->windowHandle = hWnd;
-
-    Page *page = new Page();
-    d->frame = new FrameWin(page, 0);
-    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>");
-    d->frame->end();
+    d->mainFrame = new WebFrame("dummy", this);
+    d->mainFrame->loadHTMLString("<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>");
 }
 
 WebView::~WebView()
@@ -121,66 +111,47 @@ WebView::~WebView()
     delete d;
 }
 
-void WebView::drawRect(const PAINTSTRUCT& ps)
+HWND WebView::windowHandle()
 {
-    GraphicsContext context(ps.hdc);
-    d->frame->paint(&context, ps.rcPaint);
+    return d->windowHandle;
 }
 
-HWND WebView::windowHandle()
+WebFrame* WebView::mainFrame()
 {
-    return d->windowHandle;
+    return d->mainFrame;
 }
 
 void WebView::mouseMoved(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
     MouseEvent mouseEvent(hWnd, wParam, lParam, 0);
-    d->frameView->viewportMouseMoveEvent(&mouseEvent);
+    d->mainFrame->viewImpl()->viewportMouseMoveEvent(&mouseEvent);
 }
 
 void WebView::mouseDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
     MouseEvent mouseEvent(hWnd, wParam, lParam, 1);
-    d->frameView->viewportMousePressEvent(&mouseEvent);
+    d->mainFrame->viewImpl()->viewportMousePressEvent(&mouseEvent);
 }
 
 void WebView::mouseUp(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
     MouseEvent mouseEvent(hWnd, wParam, lParam, 1);
-    d->frameView->viewportMouseReleaseEvent(&mouseEvent);
+    d->mainFrame->viewImpl()->viewportMouseReleaseEvent(&mouseEvent);
 }
 
 void WebView::mouseDoubleClick(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
     MouseEvent mouseEvent(hWnd, wParam, lParam, 2);
-    d->frameView->viewportMouseReleaseEvent(&mouseEvent);
+    d->mainFrame->viewImpl()->viewportMouseReleaseEvent(&mouseEvent);
 }
 
 LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     int wmId, wmEvent;
-    HDC hdc;
-
     switch (message)
     {
-    case WM_COMMAND:
-        wmId    = LOWORD(wParam);
-        wmEvent = HIWORD(wParam);
-        // Parse the menu selections:
-        switch (wmId)
-        {
-        case IDM_EXIT:
-            DestroyWindow(hWnd);
-            break;
-        default:
-            return DefWindowProc(hWnd, message, wParam, lParam);
-        }
-        break;
     case WM_PAINT:
-        PAINTSTRUCT ps;
-        hdc = BeginPaint(hWnd, &ps);
-        gSharedWebViewHack->drawRect(ps);
-        EndPaint(hWnd, &ps);
+        gSharedWebViewHack->mainFrame()->paint();
         break;
     case WM_DESTROY:
         // Do nothing?
@@ -203,6 +174,8 @@ LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
     case WM_RBUTTONDBLCLK:
         gSharedWebViewHack->mouseDoubleClick(hWnd, wParam, lParam);
         break;
+    case WM_SIZE:
+        // FIXME: not sure if we need anything here...
     default:
         return DefWindowProc(hWnd, message, wParam, lParam);
     }
index f2e13d22373fb06afc43885621b63f08b9b93060..d28db5d57e24dccb9aefcf754964907cc27b3185 100755 (executable)
@@ -29,6 +29,8 @@
 #include <windows.h>
 
 namespace WebKit {
+
+    class WebFrame;
     
     class WebView {
     public:
@@ -43,6 +45,8 @@ namespace WebKit {
         void mouseUp(HWND, WPARAM, LPARAM);
         void mouseDoubleClick(HWND, WPARAM, LPARAM);
 
+        WebFrame* mainFrame();
+
         HWND windowHandle();
     private:
         WebView(HWND);