2006-05-01 Steve Falkenburg <sfalken@microsoft.com>
authorsfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 May 2006 22:10:06 +0000 (22:10 +0000)
committersfalken <sfalken@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 May 2006 22:10:06 +0000 (22:10 +0000)
        Reviewed by eric.

        Moved WebKit-like code from Spinnaret into WebKitWin.

        * .: Added.
        * WebFrame.cpp: Added.
        (WebKit::WebFrame::createWebFrame): Factory to create web frames.
        * WebFramePrivate.cpp: Added.
        (WebKit::WebFramePrivate::WebFrameData::WebFrameData):
        (WebKit::WebFramePrivate::WebFrameData::~WebFrameData):
        (WebKit::WebFramePrivate::WebFramePrivate):
        (WebKit::WebFramePrivate::~WebFramePrivate):
        (WebKit::WebFramePrivate::loadFilePath):
        (WebKit::WebFramePrivate::loadHTMLString):
        (WebKit::WebFramePrivate::openURL):
        (WebKit::WebFramePrivate::submitForm):
        (WebKit::WebFramePrivate::loadURL):
        (WebKit::WebFramePrivate::getURL):
        (WebKit::WebFramePrivate::reload):
        (WebKit::WebFramePrivate::receivedData):
        (WebKit::WebFramePrivate::receivedAllData):
        (WebKit::WebFramePrivate::paint):
        (WebKit::WebFramePrivate::impl):
        (WebKit::WebFramePrivate::toPrivate):
        * WebFramePrivate.h: Added.
        * WebKitWin.vcproj: Added.
        * WebKitWin.vcproj/WebKitWin: Added.
        * WebKitWin.vcproj/WebKitWin.sln: Added.
        * WebKitWin.vcproj/WebKitWin/WebKitWin.vcproj: Added.
        * WebKitWin.vcproj/WebKitWin/stdafx.cpp: Added.
        * WebKitWin.vcproj/WebKitWin/stdafx.h: Added.
        * WebView.cpp: Added.
        (WebKit::WebView::createWebView):
        (WebKit::WebView::WebView):
        (WebKit::WebView::mouseMoved):
        (WebKit::WebView::mouseDown):
        (WebKit::WebView::mouseUp):
        (WebKit::WebView::mouseDoubleClick):
        (WebKit::WebView::keyPress):
        (WebKit::WebViewWndProc):
        * public: Added.
        * public/WebFrame.h: Added.
        * public/WebHost.h: Added.
        * public/WebView.h: Added.

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

WebKitWin/WebFrame.cpp [new file with mode: 0755]
WebKitWin/WebFramePrivate.cpp [new file with mode: 0755]
WebKitWin/WebFramePrivate.h [new file with mode: 0755]
WebKitWin/WebKitWin.vcproj/WebKitWin.sln [new file with mode: 0755]
WebKitWin/WebKitWin.vcproj/WebKitWin/WebKitWin.vcproj [new file with mode: 0644]
WebKitWin/WebKitWin.vcproj/WebKitWin/stdafx.cpp [new file with mode: 0644]
WebKitWin/WebKitWin.vcproj/WebKitWin/stdafx.h [new file with mode: 0644]
WebKitWin/WebView.cpp [new file with mode: 0755]
WebKitWin/public/WebFrame.h [new file with mode: 0644]
WebKitWin/public/WebHost.h [new file with mode: 0644]
WebKitWin/public/WebView.h [new file with mode: 0755]

diff --git a/WebKitWin/WebFrame.cpp b/WebKitWin/WebFrame.cpp
new file mode 100755 (executable)
index 0000000..038c41f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 "WebFrame.h"
+#include "WebFramePrivate.h"
+
+namespace WebKit {
+
+WebFrame* WebFrame::createWebFrame(char* name, WebView* view, WebHost* host)
+{
+    return new WebFramePrivate(name, view, host);
+}
+
+}
diff --git a/WebKitWin/WebFramePrivate.cpp b/WebKitWin/WebFramePrivate.cpp
new file mode 100755 (executable)
index 0000000..10f4846
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * 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 "WebFramePrivate.h"
+#include "WebView.h"
+#include "WebHost.h"
+
+#include "Document.h"
+#include "FrameView.h"
+#include "FrameWin.h"
+#include "GraphicsContext.h"
+#include "Page.h"
+#include "render_frames.h"
+#include "cairo.h"
+#include "cairo-win32.h"
+#include "TransferJob.h"
+
+#include <io.h>
+#include <fcntl.h>
+#include <direct.h>
+#include <WinInet.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebFramePrivate::WebFrameData {
+public:
+    WebFrameData() { }
+    ~WebFrameData() { }
+
+    RefPtr<Frame> frame;
+    RefPtr<FrameView> frameView;
+    WebView* webView;
+    WebHost* m_host;};
+
+WebFramePrivate::WebFramePrivate(char* name, WebView* view, WebHost* host)
+: d(new WebFramePrivate::WebFrameData)
+{
+    d->m_host = host;
+    d->webView = view;
+    Page* page = new Page();
+    Frame* frame = new FrameWin(page, 0, this);
+    d->frame = frame;
+    frame->deref(); // Frames are created with a refcount of 1.  Release this ref, since we've assigned it to a RefPtr
+    page->setMainFrame(frame);
+    FrameView* frameView = new FrameView(frame);
+    d->frameView = frameView;
+    frameView->deref(); // FrameViews are created with a refcount of 1.  Release this ref, since we've assigned it to a RefPtr
+    d->frame->setView(frameView);
+    d->frameView->setWindowHandle(view->windowHandle());
+}
+
+WebFramePrivate::~WebFramePrivate()
+{
+    delete d->frame->page();
+    delete d;
+}
+
+void WebFramePrivate::loadFilePath(char* path)
+{
+    char URL[2048];
+    strcpy(URL, "file://localhost/");
+    strncat(URL, path, 2020);
+
+    d->frame->didOpenURL(URL);
+    d->frame->begin(URL);
+    HANDLE fileHandle = CreateFileA(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+     
+    bool result = false;
+    DWORD bytesRead = 0;
+    
+    do {
+      const int bufferSize = 8193;
+      char buffer[bufferSize];
+      result = ReadFile(fileHandle, &buffer, bufferSize - 1, &bytesRead, NULL); 
+      buffer[bytesRead] = '\0';
+      d->frame->write(buffer);
+      // Check for end of file. 
+    } while (result && bytesRead);
+
+    CloseHandle(fileHandle);
+    
+    d->frame->end();
+}
+
+void WebFramePrivate::loadHTMLString(char *html, char *baseURL)
+{
+    d->frame->begin();
+    d->frame->write(html);
+    d->frame->end();
+}
+
+void WebFramePrivate::openURL(const DeprecatedString& str)
+{
+    loadURL(str.ascii());
+}
+
+void WebFramePrivate::submitForm(const String& method, const KURL& url, const FormData* submitFormData)
+{
+    // FIXME: This is a dumb implementation, doesn't handle subframes, etc.
+    d->frame->didOpenURL(url);
+    d->frame->begin(url);
+    TransferJob* job;
+    if (method == "GET" || !submitFormData)
+        job = new TransferJob(this, method, url);
+    else
+        job = new TransferJob(this, method, url, *submitFormData);
+    job->start(d->frame->document()->docLoader());
+    if (d->m_host) {
+        DeprecatedCString urlString = url.prettyURL().utf8();
+        d->m_host->updateLocationBar(urlString);
+    }
+}
+
+void WebFramePrivate::loadURL(const char* URL)
+{
+    d->frame->didOpenURL(URL);
+    d->frame->begin(URL);
+    WebCore::TransferJob* job = new TransferJob(this, "GET", URL);
+    job->start(d->frame->document()->docLoader());
+    if (d->m_host)
+        d->m_host->updateLocationBar(URL);
+}
+
+void WebFramePrivate::getURL(char* url, int length)
+{
+    if (length <= 0)
+        return;
+    *url = 0;
+
+    DeprecatedCString urlString = d->frame->url().prettyURL().utf8();
+    const char* srcURL = urlString;
+    if (srcURL) {
+        int srcURLLength = strlen(srcURL);
+        if (length > srcURLLength)
+            strcpy(url, srcURL);
+    }
+}
+
+void WebFramePrivate::reload()
+{
+    if (!d->frame->url().url().startsWith("javascript:", false))
+        d->frame->scheduleLocationChange(d->frame->url().url(), d->frame->referrer(), true/*lock history*/, true/*userGesture*/);
+}
+    
+void WebFramePrivate::receivedData(WebCore::TransferJob*, const char* data, int length)
+{
+    d->frame->write(data, length);
+}
+
+void WebFramePrivate::receivedAllData(WebCore::TransferJob* job, WebCore::PlatformData)
+{
+    d->frame->end();
+}
+
+void WebFramePrivate::paint()
+{
+    d->frameView->layout();
+
+    PAINTSTRUCT ps;
+    HDC hdc = BeginPaint(d->webView->windowHandle(), &ps);
+    cairo_surface_t* finalSurface = cairo_win32_surface_create(hdc);
+    cairo_surface_t* surface = cairo_surface_create_similar(finalSurface,
+                                                            CAIRO_CONTENT_COLOR_ALPHA,
+                                                            ps.rcPaint.right, ps.rcPaint.bottom);
+
+    cairo_t* context = cairo_create(surface);
+    GraphicsContext gc(context);
+    
+    IntRect documentDirtyRect = ps.rcPaint;
+    documentDirtyRect.move(d->frameView->contentsX(), d->frameView->contentsY());
+
+    // FIXME: We have to set the transform using both cairo and GDI until we use cairo for text.
+    HDC surfaceDC = cairo_win32_surface_get_dc(surface);
+    SaveDC(surfaceDC);
+    OffsetViewportOrgEx(surfaceDC, -d->frameView->contentsX(), -d->frameView->contentsY(), 0);
+    cairo_translate(context, -d->frameView->contentsX(), -d->frameView->contentsY());
+    d->frame->paint(&gc, documentDirtyRect);
+    RestoreDC(surfaceDC, -1);
+
+    cairo_destroy(context);
+    context = cairo_create(finalSurface);
+    cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
+    cairo_set_source_surface(context, surface, 0, 0);
+    cairo_rectangle(context, 0, 0, ps.rcPaint.right, ps.rcPaint.bottom);
+    cairo_fill(context);
+    cairo_destroy(context);
+
+    cairo_surface_destroy(surface);
+    cairo_surface_destroy(finalSurface);
+
+    EndPaint(d->webView->windowHandle(), &ps);
+}
+
+WebCore::Frame* WebFramePrivate::impl()
+{
+    return d->frame.get();
+}
+
+WebFramePrivate* WebFramePrivate::toPrivate()
+{
+    return this;
+}
+
+}
+
diff --git a/WebKitWin/WebFramePrivate.h b/WebKitWin/WebFramePrivate.h
new file mode 100755 (executable)
index 0000000..0339be0
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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. 
+ */
+
+#ifndef WebFramePrivate_H
+#define WebFramePrivate_H
+
+#include "config.h"
+#include "TransferJobClient.h"
+#include "FrameWin.h"
+
+class KURL;
+
+namespace WebCore {
+    class FormData;
+    class Frame;
+    class FrameView;
+    class String;
+    class TransferJob;
+}
+
+namespace WebKit {
+
+class WebView;
+
+class WebFramePrivate : public WebFrame, public WebCore::TransferJobClient, public WebCore::FrameWinClient {
+    public:
+    WebFramePrivate(char* name, WebView*, WebHost*);
+    ~WebFramePrivate();
+
+    virtual void loadFilePath(char*);
+    virtual void loadHTMLString(char* html, char* baseURL = 0);
+    virtual void loadURL(const char*);
+    virtual void getURL(char* url, int length);
+    virtual void reload();
+
+    virtual WebFramePrivate* toPrivate();
+
+    virtual void openURL(const DeprecatedString&);
+    virtual void submitForm(const WebCore::String& method, const KURL&, const WebCore::FormData*);
+    
+    virtual void receivedData(WebCore::TransferJob*, const char*, int);
+    virtual void receivedAllData(WebCore::TransferJob*, WebCore::PlatformData);
+
+    void paint();
+
+    WebCore::Frame* impl();
+
+    private:
+        class WebFrameData;
+        WebFrameData* d;
+};
+
+}
+
+#endif
diff --git a/WebKitWin/WebKitWin.vcproj/WebKitWin.sln b/WebKitWin/WebKitWin.vcproj/WebKitWin.sln
new file mode 100755 (executable)
index 0000000..2c966f4
--- /dev/null
@@ -0,0 +1,36 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitWin", "WebKitWin\WebKitWin.vcproj", "{ACFF36C9-2C1B-4404-B6AC-0CA9F2901B4D}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} = {1C16337B-ACF3-4D03-AA90-851C5B5EADA6}\r
+               {011D10F1-B656-4A1B-A0C3-3842F02122C5} = {011D10F1-B656-4A1B-A0C3-3842F02122C5}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore", "..\..\WebCore\WebCore.vcproj\WebCore\WebCore.vcproj", "{1C16337B-ACF3-4D03-AA90-851C5B5EADA6}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaScriptCore", "..\..\JavaScriptCore\JavaScriptCore.vcproj\JavaScriptCore\JavaScriptCore.vcproj", "{011D10F1-B656-4A1B-A0C3-3842F02122C5}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {ACFF36C9-2C1B-4404-B6AC-0CA9F2901B4D}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {ACFF36C9-2C1B-4404-B6AC-0CA9F2901B4D}.Debug|Win32.Build.0 = Debug|Win32\r
+               {ACFF36C9-2C1B-4404-B6AC-0CA9F2901B4D}.Release|Win32.ActiveCfg = Release|Win32\r
+               {ACFF36C9-2C1B-4404-B6AC-0CA9F2901B4D}.Release|Win32.Build.0 = Release|Win32\r
+               {1C16337B-ACF3-4D03-AA90-851C5B5EADA6}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {1C16337B-ACF3-4D03-AA90-851C5B5EADA6}.Debug|Win32.Build.0 = Debug|Win32\r
+               {1C16337B-ACF3-4D03-AA90-851C5B5EADA6}.Release|Win32.ActiveCfg = Release|Win32\r
+               {1C16337B-ACF3-4D03-AA90-851C5B5EADA6}.Release|Win32.Build.0 = Release|Win32\r
+               {011D10F1-B656-4A1B-A0C3-3842F02122C5}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {011D10F1-B656-4A1B-A0C3-3842F02122C5}.Debug|Win32.Build.0 = Debug|Win32\r
+               {011D10F1-B656-4A1B-A0C3-3842F02122C5}.Release|Win32.ActiveCfg = Release|Win32\r
+               {011D10F1-B656-4A1B-A0C3-3842F02122C5}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/WebKitWin/WebKitWin.vcproj/WebKitWin/WebKitWin.vcproj b/WebKitWin/WebKitWin.vcproj/WebKitWin/WebKitWin.vcproj
new file mode 100644 (file)
index 0000000..705922e
--- /dev/null
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="WebKitWin"\r
+       ProjectGUID="{ACFF36C9-2C1B-4404-B6AC-0CA9F2901B4D}"\r
+       RootNamespace="WebKitWin"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(WebKitOutputDir)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(WebKitOutputDir)\WebKitWin.intermediate\$(ConfigurationName)\WebKitWin.intermediate"\r
+                       ConfigurationType="4"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\..\WebCore&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\loader&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml\dom&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml\ecma&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\html&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\css&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml\misc&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\platform&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\bridge\win&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\page&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\bridge&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\platform\cairo\cairo\src&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\platform\win&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\rendering&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\editing&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\dom&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\xml&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\kwq&quot;;&quot;$(ProjectDir)\..\..\..\iconv&quot;;&quot;$(ProjectDir)\..\..\..\libxml2&quot;;&quot;$(ProjectDir)\..\..\..\icu\include&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\os-win32&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\kxmlcore&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)\..\..\public&quot;"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               ExceptionHandling="0"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               RuntimeTypeInfo="false"\r
+                               UsePrecompiledHeader="2"\r
+                               WarningLevel="1"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               LinkLibraryDependencies="true"\r
+                               AdditionalDependencies="comctl32.lib wininet.lib &quot;$(ProjectDir)\..\..\..\iconv\lib\iconv.lib&quot; &quot;$(ProjectDir)\..\..\..\libxml\lib\libxml2.lib&quot; &quot;$(ProjectDir)\..\..\..\libxslt\lib\libxslt.lib&quot; &quot;$(ProjectDir)\..\..\..\icu\lib\icuuc.lib&quot;"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="xcopy /y /r /i &quot;$(ProjectDir)\..\..\public&quot; &quot;$(WebKitOutputDir)\$(ConfigurationName)\WebKitWin&quot;"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(WebKitOutputDir)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(WebKitOutputDir)\WebKitWin.intermediate\$(ConfigurationName)\WebKitWin.intermediate"\r
+                       ConfigurationType="4"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\..\WebCore&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\loader&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml\dom&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml\ecma&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\html&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\css&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\khtml\misc&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\platform&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\bridge\win&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\page&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\bridge&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\platform\cairo\cairo\src&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\platform\win&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\rendering&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\editing&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\dom&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\xml&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\kwq&quot;;&quot;$(ProjectDir)\..\..\..\iconv&quot;;&quot;$(ProjectDir)\..\..\..\libxml2&quot;;&quot;$(ProjectDir)\..\..\..\icu\include&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\os-win32&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\kxmlcore&quot;;&quot;$(ProjectDir)\..\..\..\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)\..\..\public&quot;"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"\r
+                               ExceptionHandling="0"\r
+                               RuntimeLibrary="2"\r
+                               RuntimeTypeInfo="false"\r
+                               UsePrecompiledHeader="2"\r
+                               WarningLevel="1"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               LinkLibraryDependencies="true"\r
+                               AdditionalDependencies="comctl32.lib wininet.lib &quot;$(ProjectDir)\..\..\..\iconv\lib\iconv.lib&quot; &quot;$(ProjectDir)\..\..\..\libxml\lib\libxml2.lib&quot; &quot;$(ProjectDir)\..\..\..\libxslt\lib\libxslt.lib&quot; &quot;$(ProjectDir)\..\..\..\icu\lib\icuuc.lib&quot;"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="xcopy /y /r /i &quot;$(ProjectDir)\..\..\public&quot; &quot;$(WebKitOutputDir)\$(ConfigurationName)\WebKitWin&quot;"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\stdafx.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               UsePrecompiledHeader="1"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               UsePrecompiledHeader="1"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\WebFrame.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\WebFramePrivate.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\WebView.cpp"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\stdafx.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\public\WebFrame.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\WebFramePrivate.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\public\WebHost.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\public\WebView.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/WebKitWin/WebKitWin.vcproj/WebKitWin/stdafx.cpp b/WebKitWin/WebKitWin.vcproj/WebKitWin/stdafx.cpp
new file mode 100644 (file)
index 0000000..541dcb1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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. 
+ */
+
+// stdafx.cpp : source file that includes just the standard includes
+// Spinneret.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/WebKitWin/WebKitWin.vcproj/WebKitWin/stdafx.h b/WebKitWin/WebKitWin.vcproj/WebKitWin/stdafx.h
new file mode 100644 (file)
index 0000000..86f76cc
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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. 
+ */
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER                // Allow use of features specific to Windows XP or later.
+#define WINVER 0x0501        // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT        // Allow use of features specific to Windows XP or later.                   
+#define _WIN32_WINNT 0x0501    // Change this to the appropriate value to target other versions of Windows.
+#endif                        
+
+#ifndef _WIN32_WINDOWS        // Allow use of features specific to Windows 98 or later.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE            // Allow use of features specific to IE 6.0 or later.
+#define _WIN32_IE 0x0600    // Change this to the appropriate value to target other versions of IE.
+#endif
+
+#define WIN32_LEAN_AND_MEAN        // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+// C RunTime Header Files
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+#if 0
+// Visual Studio Leak Detection
+// <http://msdn2.microsoft.com/en-US/library/e5ewb1h3.aspx>
+#if defined(_MSC_VER) && defined(_DEBUG)
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#endif
+#endif
diff --git a/WebKitWin/WebView.cpp b/WebKitWin/WebView.cpp
new file mode 100755 (executable)
index 0000000..6aafa79
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ * 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 "WebFramePrivate.h"
+
+#include "Document.h"
+#include "FrameView.h"
+#include "IntRect.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "SelectionController.h"
+#include "TypingCommand.h"
+#include "WebView.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebView::WebViewPrivate {
+public:
+    WebViewPrivate() {}
+    ~WebViewPrivate()
+    {
+        delete mainFrame;
+    }
+
+    WebFrame* mainFrame;
+    HWND windowHandle;
+};
+
+const LPCWSTR kWebViewWindowClassName = L"WebViewWindowClass";
+static bool nextCharIsInputText = false;
+
+LRESULT CALLBACK WebViewWndProc(HWND, UINT, WPARAM, LPARAM);
+
+static ATOM registerWebViewWithInstance(HINSTANCE hInstance)
+{
+    static bool haveRegisteredWindowClass = false;
+    if (haveRegisteredWindowClass)
+        return true;
+
+    WNDCLASSEX wcex;
+
+    wcex.cbSize = sizeof(WNDCLASSEX);
+
+    wcex.style          = CS_DBLCLKS;
+    wcex.lpfnWndProc    = WebViewWndProc;
+    wcex.cbClsExtra     = 0;
+    wcex.cbWndExtra     = 4; // 4 bytes for the WebView pointer
+    wcex.hInstance      = hInstance;
+    wcex.hIcon          = 0;
+    wcex.hCursor        = LoadCursor(0, IDC_ARROW);
+    wcex.hbrBackground  = 0;
+    wcex.lpszMenuName   = 0;
+    wcex.lpszClassName  = kWebViewWindowClassName;
+    wcex.hIconSm        = 0;
+
+    return RegisterClassEx(&wcex);
+}
+
+// FIXME: This should eventually just use the DLL instance, I think.
+WebView* WebView::createWebView(HINSTANCE hInstance, HWND parent, WebHost* host)
+{
+    // Save away our instace handle for WebCore to use.
+    Widget::instanceHandle = hInstance;
+
+    registerWebViewWithInstance(hInstance);
+
+    HWND hWnd = CreateWindow(kWebViewWindowClassName, 0, WS_CHILD | WS_HSCROLL | WS_VSCROLL,
+       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, parent, 0, hInstance, 0);
+
+    if (!hWnd)
+        return 0;
+
+    WebView* newWebView = new WebView(hWnd, host);
+    SetWindowLongPtr(hWnd, 0, (LONG)newWebView);
+    return newWebView;
+}
+
+WebView::WebView(HWND hWnd, WebHost* host)
+{
+    d = new WebViewPrivate();
+    d->windowHandle = hWnd;
+    d->mainFrame = WebFrame::createWebFrame("dummy", this, host);
+    d->mainFrame->loadHTMLString("<p style=\"background-color: #00FF00\">Testing</p><img src=\"http://webkit.opendarwin.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>");
+}
+
+WebView::~WebView()
+{
+    delete d;
+}
+
+HWND WebView::windowHandle()
+{
+    return d->windowHandle;
+}
+
+WebFrame* WebView::mainFrame()
+{
+    return d->mainFrame;
+}
+
+void WebView::mouseMoved(WPARAM wParam, LPARAM lParam)
+{
+    PlatformMouseEvent mouseEvent(windowHandle(), wParam, lParam, 0);
+    d->mainFrame->toPrivate()->impl()->view()->handleMouseMoveEvent(mouseEvent);
+}
+
+void WebView::mouseDown(WPARAM wParam, LPARAM lParam)
+{
+    PlatformMouseEvent mouseEvent(windowHandle(), wParam, lParam, 1);
+    d->mainFrame->toPrivate()->impl()->view()->handleMousePressEvent(mouseEvent);
+}
+
+void WebView::mouseUp(WPARAM wParam, LPARAM lParam)
+{
+    PlatformMouseEvent mouseEvent(windowHandle(), wParam, lParam, 1);
+    d->mainFrame->toPrivate()->impl()->view()->handleMouseReleaseEvent(mouseEvent);
+}
+
+void WebView::mouseDoubleClick(WPARAM wParam, LPARAM lParam)
+{
+    PlatformMouseEvent mouseEvent(windowHandle(), wParam, lParam, 2);
+    d->mainFrame->toPrivate()->impl()->view()->handleMouseReleaseEvent(mouseEvent);
+}
+
+bool WebView::keyPress(WPARAM wParam, LPARAM lParam)
+{
+    PlatformKeyboardEvent keyEvent(windowHandle(), wParam, lParam);
+
+    FrameWin* frame = static_cast<FrameWin*>(d->mainFrame->toPrivate()->impl());
+    bool handled = frame->keyPress(keyEvent);
+    if (!handled && !keyEvent.isKeyUp()) {
+        Node* start = frame->selection().start().node();
+        if (start && start->isContentEditable()) {
+            switch(keyEvent.WindowsKeyCode()) {
+            case VK_BACK:
+                TypingCommand::deleteKeyPressed(frame->document());
+                break;
+            case VK_DELETE:
+                TypingCommand::forwardDeleteKeyPressed(frame->document());
+                break;
+            case VK_LEFT:
+                frame->selection().modify(SelectionController::MOVE, SelectionController::LEFT, CharacterGranularity);
+                break;
+            case VK_RIGHT:
+                frame->selection().modify(SelectionController::MOVE, SelectionController::RIGHT, CharacterGranularity);
+                break;
+            case VK_UP:
+                frame->selection().modify(SelectionController::MOVE, SelectionController::BACKWARD, ParagraphGranularity);
+                break;
+            case VK_DOWN:
+                frame->selection().modify(SelectionController::MOVE, SelectionController::FORWARD, ParagraphGranularity);
+                break;
+            default:
+                nextCharIsInputText = true;
+            }
+            handled = true;
+        }
+    }
+    return handled;
+}
+
+#define LINE_SCROLL_SIZE 30
+
+static int calculateScrollDelta(WPARAM wParam, int oldPosition, int pageSize)
+{
+    switch (LOWORD(wParam)) {
+        case SB_PAGEUP: 
+            return -(pageSize - LINE_SCROLL_SIZE); 
+         case SB_PAGEDOWN: 
+            return (pageSize - LINE_SCROLL_SIZE); 
+        case SB_LINEUP: 
+            return -LINE_SCROLL_SIZE;
+        case SB_LINEDOWN: 
+            return LINE_SCROLL_SIZE;
+        case SB_THUMBPOSITION: 
+        case SB_THUMBTRACK:
+            return HIWORD(wParam) - oldPosition; 
+    }
+    return 0;
+}
+
+static int scrollMessageForKey(WPARAM keyCode)
+{
+    switch (keyCode) {
+    case VK_UP:
+        return SB_LINEUP;
+    case VK_PRIOR: 
+        return SB_PAGEUP;
+    case VK_NEXT:
+        return SB_PAGEDOWN;
+    case VK_DOWN:
+        return SB_LINEDOWN;
+    case VK_HOME:
+        return SB_TOP;
+    case VK_END:
+        return SB_BOTTOM;
+    case VK_SPACE:
+        return (GetKeyState(VK_SHIFT) & 0x8000) ? SB_PAGEUP : SB_PAGEDOWN;
+    }
+    return -1;
+}
+
+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:
+        webview->mainFrame()->toPrivate()->paint();
+        break;
+    case WM_DESTROY:
+        // Do nothing?
+        break;
+    case WM_MOUSEMOVE:
+        webview->mouseMoved(wParam, lParam);
+        break;
+    case WM_LBUTTONDOWN:
+        // Make ourselves the focused window before doing anything else
+        // FIXME: I'm not sure if this is the "right" way to do this
+        // but w/o this call, we never become focused since we don't allow
+        // the default handling of mouse events.
+        SetFocus(hWnd);
+    case WM_MBUTTONDOWN:
+    case WM_RBUTTONDOWN:
+        webview->mouseDown(wParam, lParam);
+        break;
+    case WM_LBUTTONUP:
+    case WM_MBUTTONUP:
+    case WM_RBUTTONUP:
+        webview->mouseUp(wParam, lParam);
+        break;
+    case WM_LBUTTONDBLCLK:
+    case WM_MBUTTONDBLCLK:
+    case WM_RBUTTONDBLCLK:
+        webview->mouseDoubleClick(wParam, lParam);
+        break;
+    case WM_HSCROLL: {
+        ScrollView* view = webview->mainFrame()->toPrivate()->impl()->view();
+        view->scrollBy(calculateScrollDelta(wParam, view->contentsX(), view->visibleWidth()), 0);
+        webview->mainFrame()->toPrivate()->impl()->sendScrollEvent();
+        break;
+    }
+    case WM_VSCROLL: {
+        ScrollView* view = webview->mainFrame()->toPrivate()->impl()->view();
+        view->scrollBy(0, calculateScrollDelta(wParam, view->contentsY(), view->visibleHeight()));
+        webview->mainFrame()->toPrivate()->impl()->sendScrollEvent();
+        break;
+    }
+    case WM_KEYDOWN: {
+        // FIXME: First we should send key events up through the DOM
+        // to form controls, etc.  If they are not handled, we fall
+        // through to the top level webview and do things like scrolling
+        if (webview->keyPress(wParam, lParam))
+            break;
+        WORD wScrollNotify = scrollMessageForKey(wParam);
+        if (wScrollNotify != -1)
+            SendMessage(hWnd, WM_VSCROLL, MAKELONG(wScrollNotify, 0), 0L);
+        break;
+    }
+    case WM_CHAR: {
+        // FIXME: We need to use WM_UNICHAR to support international text.
+        if (nextCharIsInputText) {
+            TypingCommand::insertText(webview->mainFrame()->toPrivate()->impl()->document(), QChar(wParam), false);
+            nextCharIsInputText = false;
+        }
+        break;
+    }
+    case WM_KEYUP: {
+        webview->keyPress(wParam, lParam);
+        break;
+    }
+    case WM_SIZE:
+        if (!webview)
+            break;
+        webview->mainFrame()->toPrivate()->impl()->sendResizeEvent();
+        break;
+    case WM_SETFOCUS:
+        webview->mainFrame()->toPrivate()->impl()->setWindowHasFocus(true);
+        webview->mainFrame()->toPrivate()->impl()->setDisplaysWithFocusAttributes(true);
+        break;
+    case WM_KILLFOCUS:
+        webview->mainFrame()->toPrivate()->impl()->setWindowHasFocus(false);
+        webview->mainFrame()->toPrivate()->impl()->setDisplaysWithFocusAttributes(false);
+        break;
+    default:
+        return DefWindowProc(hWnd, message, wParam, lParam);
+    }
+    return 0;
+}
+
+};
diff --git a/WebKitWin/public/WebFrame.h b/WebKitWin/public/WebFrame.h
new file mode 100644 (file)
index 0000000..2e90527
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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. 
+ */
+
+#ifndef WebFrame_H
+#define WebFrame_H
+
+namespace WebKit {
+
+    class WebView;
+    class WebFramePrivate;
+    class WebHost;
+
+    class WebFrame {
+    public:
+    static WebFrame* createWebFrame(char* name, WebView* view, WebHost* host);
+
+    virtual void loadFilePath(char*) = 0;
+    virtual void loadHTMLString(char* html, char* baseURL = 0) = 0;
+    virtual void loadURL(const char*) = 0;
+    virtual void getURL(char* url, int length) = 0;
+    virtual void reload() = 0;
+
+    virtual WebFramePrivate* toPrivate() = 0;
+
+    };
+}
+
+#endif
diff --git a/WebKitWin/public/WebHost.h b/WebKitWin/public/WebHost.h
new file mode 100644 (file)
index 0000000..ee7dd0d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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. 
+ */
+
+#ifndef WebHost_H
+#define WebHost_H
+
+namespace WebKit {
+
+class WebHost
+{
+public:
+    virtual void updateLocationBar(const char* URL) = 0;
+};
+
+}
+
+#endif
diff --git a/WebKitWin/public/WebView.h b/WebKitWin/public/WebView.h
new file mode 100755 (executable)
index 0000000..7c23713
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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. 
+ */
+
+#ifndef WebView_H
+#define WebView_H
+
+#include <windows.h>
+
+namespace WebKit {
+
+    class WebFrame;
+    class WebHost;
+
+    class WebView {
+    public:
+        static WebView* createWebView(HINSTANCE, HWND parent = 0, WebHost* host = 0);
+
+        ~WebView();
+
+        void drawRect(const PAINTSTRUCT&);
+
+        void mouseMoved(WPARAM, LPARAM);
+        void mouseDown(WPARAM, LPARAM);
+        void mouseUp(WPARAM, LPARAM);
+        void mouseDoubleClick(WPARAM, LPARAM);
+        bool keyPress(WPARAM, LPARAM);
+
+        WebFrame* mainFrame();
+
+        HWND windowHandle();
+    private:
+        WebView(HWND, WebHost*);
+        
+        class WebViewPrivate;
+        WebViewPrivate* d;
+    };
+}
+
+#endif