Add WebKit2/WebProcess directory.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Apr 2010 00:49:12 +0000 (00:49 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Apr 2010 00:49:12 +0000 (00:49 +0000)
Patch by Anders Carlsson <andersca@apple.com> on 2010-04-08
Reviewed by Sam Weinig and Oliver Hunt.

* WebProcess: Added.
* WebProcess/Launching: Added.
* WebProcess/Launching/mac: Added.
* WebProcess/Launching/mac/WebProcessMain.mm: Added.
* WebProcess/Launching/win: Added.
* WebProcess/Launching/win/WebProcessWinMain.cpp: Added.
* WebProcess/WebCoreSupport: Added.
* WebProcess/WebCoreSupport/WebChromeClient.cpp: Added.
* WebProcess/WebCoreSupport/WebChromeClient.h: Added.
* WebProcess/WebCoreSupport/WebContextMenuClient.cpp: Added.
* WebProcess/WebCoreSupport/WebContextMenuClient.h: Added.
* WebProcess/WebCoreSupport/WebDragClient.cpp: Added.
* WebProcess/WebCoreSupport/WebDragClient.h: Added.
* WebProcess/WebCoreSupport/WebEditorClient.cpp: Added.
* WebProcess/WebCoreSupport/WebEditorClient.h: Added.
* WebProcess/WebCoreSupport/WebErrors.h: Added.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: Added.
* WebProcess/WebCoreSupport/WebInspectorClient.h: Added.
* WebProcess/WebCoreSupport/mac: Added.
* WebProcess/WebCoreSupport/mac/WebErrorsMac.mm: Added.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.h: Added.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.m: Added.
* WebProcess/WebCoreSupport/win: Added.
* WebProcess/WebCoreSupport/win/WebCoreLocalizedStrings.cpp: Added.
* WebProcess/WebCoreSupport/win/WebErrorsWin.cpp: Added.
* WebProcess/WebPage: Added.
* WebProcess/WebPage/DrawingArea.cpp: Added.
* WebProcess/WebPage/DrawingArea.h: Added.
* WebProcess/WebPage/WebFrame.cpp: Added.
* WebProcess/WebPage/WebFrame.h: Added.
* WebProcess/WebPage/WebPage.cpp: Added.
* WebProcess/WebPage/WebPage.h: Added.
* WebProcess/WebPage/mac: Added.
* WebProcess/WebPage/mac/DrawingAreaUpdateChunk.cpp: Added.
* WebProcess/WebPage/mac/DrawingAreaUpdateChunk.h: Added.
* WebProcess/WebPage/mac/WebPageMac.mm: Added.
* WebProcess/WebPage/win: Added.
* WebProcess/WebPage/win/DrawingAreaUpdateChunk.cpp: Added.
* WebProcess/WebPage/win/DrawingAreaUpdateChunk.h: Added.
* WebProcess/WebPage/win/WebPageWin.cpp: Added.
* WebProcess/WebProcess.cpp: Added.
* WebProcess/WebProcess.h: Added.
* WebProcess/win: Added.
* WebProcess/win/DllMain.cpp: Added.
* WebProcess/win/WebLocalizableStrings.cpp: Added.
* WebProcess/win/WebLocalizableStrings.h: Added.
* WebProcess/win/WebProcessMain.cpp: Added.
* WebProcess/win/WebProcessMain.h: Added.

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

40 files changed:
WebKit2/ChangeLog
WebKit2/WebProcess/Launching/mac/WebProcessMain.mm [new file with mode: 0644]
WebKit2/WebProcess/Launching/win/WebProcessWinMain.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebDragClient.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebErrors.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.m [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/win/WebCoreLocalizedStrings.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/DrawingArea.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/DrawingArea.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebFrame.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebFrame.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebPage.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebPage.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/mac/DrawingAreaUpdateChunk.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/mac/DrawingAreaUpdateChunk.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/mac/WebPageMac.mm [new file with mode: 0644]
WebKit2/WebProcess/WebPage/win/DrawingAreaUpdateChunk.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/win/DrawingAreaUpdateChunk.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/win/WebPageWin.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebProcess.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebProcess.h [new file with mode: 0644]
WebKit2/WebProcess/win/DllMain.cpp [new file with mode: 0644]
WebKit2/WebProcess/win/WebLocalizableStrings.cpp [new file with mode: 0644]
WebKit2/WebProcess/win/WebLocalizableStrings.h [new file with mode: 0644]
WebKit2/WebProcess/win/WebProcessMain.cpp [new file with mode: 0644]
WebKit2/WebProcess/win/WebProcessMain.h [new file with mode: 0644]

index 905ed82..1f1a112 100644 (file)
@@ -1,3 +1,58 @@
+2010-04-08  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig and Oliver Hunt.
+
+        Add WebKit2/WebProcess directory.
+
+        * WebProcess: Added.
+        * WebProcess/Launching: Added.
+        * WebProcess/Launching/mac: Added.
+        * WebProcess/Launching/mac/WebProcessMain.mm: Added.
+        * WebProcess/Launching/win: Added.
+        * WebProcess/Launching/win/WebProcessWinMain.cpp: Added.
+        * WebProcess/WebCoreSupport: Added.
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp: Added.
+        * WebProcess/WebCoreSupport/WebChromeClient.h: Added.
+        * WebProcess/WebCoreSupport/WebContextMenuClient.cpp: Added.
+        * WebProcess/WebCoreSupport/WebContextMenuClient.h: Added.
+        * WebProcess/WebCoreSupport/WebDragClient.cpp: Added.
+        * WebProcess/WebCoreSupport/WebDragClient.h: Added.
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp: Added.
+        * WebProcess/WebCoreSupport/WebEditorClient.h: Added.
+        * WebProcess/WebCoreSupport/WebErrors.h: Added.
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: Added.
+        * WebProcess/WebCoreSupport/WebInspectorClient.h: Added.
+        * WebProcess/WebCoreSupport/mac: Added.
+        * WebProcess/WebCoreSupport/mac/WebErrorsMac.mm: Added.
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.h: Added.
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.m: Added.
+        * WebProcess/WebCoreSupport/win: Added.
+        * WebProcess/WebCoreSupport/win/WebCoreLocalizedStrings.cpp: Added.
+        * WebProcess/WebCoreSupport/win/WebErrorsWin.cpp: Added.
+        * WebProcess/WebPage: Added.
+        * WebProcess/WebPage/DrawingArea.cpp: Added.
+        * WebProcess/WebPage/DrawingArea.h: Added.
+        * WebProcess/WebPage/WebFrame.cpp: Added.
+        * WebProcess/WebPage/WebFrame.h: Added.
+        * WebProcess/WebPage/WebPage.cpp: Added.
+        * WebProcess/WebPage/WebPage.h: Added.
+        * WebProcess/WebPage/mac: Added.
+        * WebProcess/WebPage/mac/DrawingAreaUpdateChunk.cpp: Added.
+        * WebProcess/WebPage/mac/DrawingAreaUpdateChunk.h: Added.
+        * WebProcess/WebPage/mac/WebPageMac.mm: Added.
+        * WebProcess/WebPage/win: Added.
+        * WebProcess/WebPage/win/DrawingAreaUpdateChunk.cpp: Added.
+        * WebProcess/WebPage/win/DrawingAreaUpdateChunk.h: Added.
+        * WebProcess/WebPage/win/WebPageWin.cpp: Added.
+        * WebProcess/WebProcess.cpp: Added.
+        * WebProcess/WebProcess.h: Added.
+        * WebProcess/win: Added.
+        * WebProcess/win/DllMain.cpp: Added.
+        * WebProcess/win/WebLocalizableStrings.cpp: Added.
+        * WebProcess/win/WebLocalizableStrings.h: Added.
+        * WebProcess/win/WebProcessMain.cpp: Added.
+        * WebProcess/win/WebProcessMain.h: Added.
+
 2010-04-08  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit2/WebProcess/Launching/mac/WebProcessMain.mm b/WebKit2/WebProcess/Launching/mac/WebProcessMain.mm
new file mode 100644 (file)
index 0000000..40a94c5
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#import "RunLoop.h"
+#import "WebProcess.h"
+#import "WebSystemInterface.h"
+#import <runtime/InitializeThreading.h>
+#import <servers/bootstrap.h>
+#import <signal.h>
+#import <unistd.h>
+
+// FIXME: We should be doing this another way.
+extern "C" kern_return_t bootstrap_look_up2(mach_port_t, const name_t, mach_port_t*, pid_t, uint64_t);
+
+#define SHOW_CRASH_REPORTER 0
+
+using namespace WebKit;
+
+int main(int argc, char** argv)
+{
+    mach_port_t serverPort;
+    kern_return_t kr = bootstrap_look_up2(bootstrap_port, "com.apple.WebKit.WebProcess", &serverPort, getppid(), /* BOOTSTRAP_PER_PID_SERVICE */ 1);
+    if (kr) {
+        printf("bootstrap_look_up2 result: %x", kr);
+        return 2;
+    }
+    
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+#if !SHOW_CRASH_REPORTER
+    // Installs signal handlers that exit on a crash so that CrashReporter does not show up.
+    signal(SIGILL, _exit);
+    signal(SIGFPE, _exit);
+    signal(SIGBUS, _exit);
+    signal(SIGSEGV, _exit);
+#endif
+
+    InitWebCoreSystemInterface();
+    JSC::initializeThreading();
+    RunLoop::initializeMainRunLoop();
+    
+    // Create the connection.
+    WebProcess::shared().initialize(serverPort, RunLoop::mainRunLoop());
+    
+    [pool drain];
+
+     // Initialize AppKit.
+    [NSApplication sharedApplication];
+
+    RunLoop::mainRunLoop()->run();
+
+    // FIXME: Do more cleanup here.
+
+    return 0;
+}
diff --git a/WebKit2/WebProcess/Launching/win/WebProcessWinMain.cpp b/WebKit2/WebProcess/Launching/win/WebProcessWinMain.cpp
new file mode 100644 (file)
index 0000000..ba803bf
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 <windows.h>
+#include <tchar.h>
+
+#include "WebProcessMain.h"
+
+#if defined _M_IX86
+#define PROCESSORARCHITECTURE "x86"
+#elif defined _M_IA64
+#define PROCESSORARCHITECTURE "ia64"
+#elif defined _M_X64
+#define PROCESSORARCHITECTURE "amd64"
+#else
+#define PROCESSORARCHITECTURE "*"
+#endif
+
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
+
+static void enableTerminationOnHeapCorruption()
+{
+    // Enable termination on heap corruption on OSes that support it (Vista and XPSP3).
+    // http://msdn.microsoft.com/en-us/library/aa366705(VS.85).aspx
+
+    const HEAP_INFORMATION_CLASS heapEnableTerminationOnCorruption = static_cast<HEAP_INFORMATION_CLASS>(1);
+
+    HMODULE hMod = ::GetModuleHandleW(L"kernel32.dll");
+    if (!hMod)
+        return;
+
+    typedef BOOL (WINAPI*HSI)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
+    HSI heapSetInformation = reinterpret_cast<HSI>(::GetProcAddress(hMod, "HeapSetInformation"));
+    if (!heapSetInformation)
+        return;
+
+    heapSetInformation(0, heapEnableTerminationOnCorruption, 0, 0);
+}
+
+int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
+{
+    enableTerminationOnHeapCorruption();
+
+    return WebKit::WebProcessMain(hInstance, lpstrCmdLine);
+}
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
new file mode 100644 (file)
index 0000000..8094a20
--- /dev/null
@@ -0,0 +1,460 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebChromeClient.h"
+
+#include "DrawingArea.h"
+#include "NotImplemented.h"
+#include "WebCoreTypeArgumentMarshalling.h"
+#include "WebFrame.h"
+#include "WebFrameLoaderClient.h"
+#include "WebPage.h"
+#include "WebPageProxyMessageKinds.h"
+#include "WebPreferencesStore.h"
+#include "WebProcess.h"
+
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/FileChooser.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebChromeClient::chromeDestroyed()
+{
+    delete this;
+}
+
+void WebChromeClient::setWindowRect(const FloatRect&)
+{
+    notImplemented();
+}
+
+FloatRect WebChromeClient::windowRect()
+{
+    notImplemented();
+    return FloatRect();
+}
+
+FloatRect WebChromeClient::pageRect()
+{
+    notImplemented();
+    return FloatRect();
+}
+
+float WebChromeClient::scaleFactor()
+{
+    notImplemented();
+    return 1.0;
+}
+
+void WebChromeClient::focus()
+{
+    notImplemented();
+}
+
+void WebChromeClient::unfocus()
+{
+    notImplemented();
+}
+
+bool WebChromeClient::canTakeFocus(FocusDirection)
+{
+    notImplemented();
+    return true;
+}
+
+void WebChromeClient::takeFocus(FocusDirection direction)
+{
+    WebProcess::shared().connection()->send(WebPageProxyMessage::TakeFocus, m_page->pageID(),
+                                            direction == FocusDirectionForward ? true : false);
+}
+
+void WebChromeClient::focusedNodeChanged(Node*)
+{
+    notImplemented();
+}
+
+Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&)
+{
+    uint64_t newPageID = 0;
+    IntSize viewSize;
+    WebPreferencesStore store;
+    uint32_t drawingAreaType;
+    if (!WebProcess::shared().connection()->sendSync(WebPageProxyMessage::CreateNewPage,
+                                                     m_page->pageID(), CoreIPC::In(),
+                                                     CoreIPC::Out(newPageID, viewSize, store, drawingAreaType),
+                                                     CoreIPC::Connection::NoTimeout)) {
+        return 0;
+    }
+
+    if (!newPageID)
+        return 0;
+
+    WebPage* newWebPage = WebProcess::shared().createWebPage(newPageID, viewSize, store, static_cast<DrawingArea::Type>(drawingAreaType));
+    return newWebPage->corePage();
+}
+
+void WebChromeClient::show()
+{
+    m_page->show();
+}
+
+bool WebChromeClient::canRunModal()
+{
+    notImplemented();
+    return false;
+}
+
+void WebChromeClient::runModal()
+{
+    notImplemented();
+}
+
+void WebChromeClient::setToolbarsVisible(bool)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::toolbarsVisible()
+{
+    notImplemented();
+    return true;
+}
+
+void WebChromeClient::setStatusbarVisible(bool)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::statusbarVisible()
+{
+    notImplemented();
+    return true;
+}
+
+void WebChromeClient::setScrollbarsVisible(bool)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::scrollbarsVisible()
+{
+    notImplemented();
+    return true;
+}
+
+void WebChromeClient::setMenubarVisible(bool)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::menubarVisible()
+{
+    notImplemented();
+    return true;
+}
+
+void WebChromeClient::setResizable(bool)
+{
+    notImplemented();
+}
+
+void WebChromeClient::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
+{
+    notImplemented();
+    return false;
+}
+
+bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
+{
+    notImplemented();
+    return false;
+}
+
+void WebChromeClient::closeWindowSoon()
+{
+    notImplemented();
+}
+
+void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
+{
+    WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    WebProcess::shared().connection()->sendSync(WebPageProxyMessage::RunJavaScriptAlert, m_page->pageID(),
+                                                CoreIPC::In(webFrame->frameID(), alertText),
+                                                CoreIPC::Out(),
+                                                CoreIPC::Connection::NoTimeout);
+}
+
+bool WebChromeClient::runJavaScriptConfirm(Frame*, const String&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebChromeClient::runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result)
+{
+    notImplemented();
+    return false;
+}
+
+void WebChromeClient::setStatusbarText(const String&)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::shouldInterruptJavaScript()
+{
+    notImplemented();
+    return false;
+}
+
+bool WebChromeClient::tabsToLinks() const
+{
+    notImplemented();
+    return false;
+}
+
+IntRect WebChromeClient::windowResizerRect() const
+{
+    IntSize pageSize = m_page->size();
+    
+    static const int windowResizerSize = 15;
+    
+    return IntRect(pageSize.width() - windowResizerSize, pageSize.height() - windowResizerSize, 
+                   windowResizerSize, windowResizerSize);
+}
+
+void WebChromeClient::invalidateWindow(const IntRect& rect, bool immediate)
+{
+    m_page->drawingArea()->invalidateWindow(rect, immediate);
+}
+
+void WebChromeClient::invalidateContentsAndWindow(const IntRect& rect, bool immediate)
+{
+    m_page->drawingArea()->invalidateContentsAndWindow(rect, immediate);
+}
+
+void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool immediate)
+{
+    m_page->drawingArea()->invalidateContentsForSlowScroll(rect, immediate);
+}
+
+void WebChromeClient::scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
+{
+    m_page->drawingArea()->scroll(scrollDelta, rectToScroll, clipRect);
+}
+
+IntPoint WebChromeClient::screenToWindow(const IntPoint&) const
+{
+    notImplemented();
+    return IntPoint();
+}
+
+IntRect WebChromeClient::windowToScreen(const IntRect&) const
+{
+    notImplemented();
+    return IntRect();
+}
+
+PlatformPageClient WebChromeClient::platformPageClient() const
+{
+    notImplemented();
+    return 0;
+}
+
+void WebChromeClient::contentsSizeChanged(Frame*, const IntSize&) const
+{
+    notImplemented();
+}
+
+void WebChromeClient::scrollRectIntoView(const IntRect&, const ScrollView*) const
+{
+    notImplemented();
+}
+
+void WebChromeClient::scrollbarsModeDidChange() const
+{
+    notImplemented();
+}
+
+void WebChromeClient::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags)
+{
+    notImplemented();
+}
+
+void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
+{
+    // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
+
+    if (toolTip == m_cachedToolTip)
+        return;
+    m_cachedToolTip = toolTip;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::SetToolTip, m_page->pageID(), CoreIPC::In(m_cachedToolTip));
+}
+
+void WebChromeClient::print(Frame*)
+{
+    notImplemented();
+}
+
+#if ENABLE(DATABASE)
+void WebChromeClient::exceededDatabaseQuota(Frame*, const String& databaseName)
+{
+    notImplemented();
+}
+#endif
+
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+void WebChromeClient::reachedMaxAppCacheSize(int64_t)
+{
+    notImplemented();
+}
+#endif
+
+#if ENABLE(DASHBOARD_SUPPORT)
+void WebChromeClient::dashboardRegionsChanged()
+{
+    notImplemented();
+}
+#endif
+
+void WebChromeClient::populateVisitedLinks()
+{
+    notImplemented();
+}
+
+FloatRect WebChromeClient::customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect)
+{
+    notImplemented();
+    return FloatRect();
+}
+
+void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
+                                  bool behindText, bool entireLine)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
+{
+    notImplemented();
+    return false;
+}
+
+String WebChromeClient::generateReplacementFile(const String& path)
+{
+    notImplemented();
+    return String();
+}
+
+bool WebChromeClient::paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, 
+                                           ScrollbarControlState, ScrollbarPart pressedPart, bool vertical,
+                                           float value, float proportion, ScrollbarControlPartMask)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebChromeClient::paintCustomScrollCorner(GraphicsContext*, const FloatRect&)
+{
+    notImplemented();
+    return false;
+}
+
+void WebChromeClient::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
+{
+    notImplemented();
+}
+
+void WebChromeClient::cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*)
+{
+    notImplemented();
+}
+
+void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser>)
+{
+    notImplemented();
+}
+
+void WebChromeClient::chooseIconForFiles(const Vector<String>&, PassRefPtr<FileChooser>)
+{
+    notImplemented();
+}
+
+bool WebChromeClient::setCursor(PlatformCursorHandle)
+{
+    notImplemented();
+    return false;
+}
+
+void WebChromeClient::formStateDidChange(const Node*)
+{
+    notImplemented();
+}
+
+void WebChromeClient::formDidFocus(const Node*)
+{ 
+    notImplemented();
+}
+
+void WebChromeClient::formDidBlur(const Node*)
+{
+    notImplemented();
+}
+
+PassOwnPtr<HTMLParserQuirks> WebChromeClient::createHTMLParserQuirks()
+{
+    notImplemented();
+    return 0;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void WebChromeClient::attachRootGraphicsLayer(Frame*, GraphicsLayer*)
+{
+    notImplemented();
+}
+
+void WebChromeClient::setNeedsOneShotDrawingSynchronization()
+{
+    notImplemented();
+}
+
+void WebChromeClient::scheduleCompositingLayerSync()
+{
+    notImplemented();
+}
+
+#endif
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
new file mode 100644 (file)
index 0000000..a6156ad
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebChromeClient_h
+#define WebChromeClient_h
+
+#include <WebCore/ChromeClient.h>
+#include <WebCore/PlatformString.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebChromeClient : public WebCore::ChromeClient {
+public:
+    WebChromeClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+    
+private:
+    virtual void chromeDestroyed();
+    
+    virtual void setWindowRect(const WebCore::FloatRect&);
+    virtual WebCore::FloatRect windowRect();
+    
+    virtual WebCore::FloatRect pageRect();
+    
+    virtual float scaleFactor();
+    
+    virtual void focus();
+    virtual void unfocus();
+    
+    virtual bool canTakeFocus(WebCore::FocusDirection);
+    virtual void takeFocus(WebCore::FocusDirection);
+
+    virtual void focusedNodeChanged(WebCore::Node*);
+
+    // The Frame pointer provides the ChromeClient with context about which
+    // Frame wants to create the new Page.  Also, the newly created window
+    // should not be shown to the user until the ChromeClient of the newly
+    // created Page has its show method called.
+    virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&);
+    virtual void show();
+    
+    virtual bool canRunModal();
+    virtual void runModal();
+    
+    virtual void setToolbarsVisible(bool);
+    virtual bool toolbarsVisible();
+    
+    virtual void setStatusbarVisible(bool);
+    virtual bool statusbarVisible();
+    
+    virtual void setScrollbarsVisible(bool);
+    virtual bool scrollbarsVisible();
+    
+    virtual void setMenubarVisible(bool);
+    virtual bool menubarVisible();
+    
+    virtual void setResizable(bool);
+    
+    virtual void addMessageToConsole(WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel, const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceID);
+    
+    virtual bool canRunBeforeUnloadConfirmPanel();
+    virtual bool runBeforeUnloadConfirmPanel(const WebCore::String& message, WebCore::Frame* frame);
+    
+    virtual void closeWindowSoon();
+    
+    virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&);
+    virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&);
+    virtual bool runJavaScriptPrompt(WebCore::Frame*, const WebCore::String& message, const WebCore::String& defaultValue, WebCore::String& result);
+    virtual void setStatusbarText(const WebCore::String&);
+    virtual bool shouldInterruptJavaScript();
+    virtual bool tabsToLinks() const;
+    
+    virtual WebCore::IntRect windowResizerRect() const;
+    
+    // Methods used by HostWindow.
+    virtual void invalidateWindow(const WebCore::IntRect&, bool);
+    virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
+    virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
+    virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect);
+    virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
+    virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
+    virtual PlatformPageClient platformPageClient() const;
+    virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
+    virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; // Currently only Mac has a non empty implementation.
+    // End methods used by HostWindow.
+
+    virtual void scrollbarsModeDidChange() const;
+    virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags);
+    
+    virtual void setToolTip(const WebCore::String&, WebCore::TextDirection);
+    
+    virtual void print(WebCore::Frame*);
+    
+#if ENABLE(DATABASE)
+    virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String& databaseName);
+#endif
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
+#endif
+
+#if ENABLE(DASHBOARD_SUPPORT)
+    virtual void dashboardRegionsChanged();
+#endif
+
+    virtual void populateVisitedLinks();
+    
+    virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WebCore::AtomicString& type, const WebCore::FloatRect& lineRect);
+    virtual void paintCustomHighlight(WebCore::Node*, const WebCore::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect,
+                                      bool behindText, bool entireLine);
+    
+    virtual bool shouldReplaceWithGeneratedFileForUpload(const WebCore::String& path, WebCore::String& generatedFilename);
+    virtual WebCore::String generateReplacementFile(const WebCore::String& path);
+    
+    virtual bool paintCustomScrollbar(WebCore::GraphicsContext*, const WebCore::FloatRect&, WebCore::ScrollbarControlSize, 
+                                      WebCore::ScrollbarControlState, WebCore::ScrollbarPart pressedPart, bool vertical,
+                                      float value, float proportion, WebCore::ScrollbarControlPartMask);
+    virtual bool paintCustomScrollCorner(WebCore::GraphicsContext*, const WebCore::FloatRect&);
+    
+    // This is an asynchronous call. The ChromeClient can display UI asking the user for permission
+    // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately.
+    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
+    virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
+    
+    virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
+    virtual void chooseIconForFiles(const Vector<WebCore::String>&, PassRefPtr<WebCore::FileChooser>);
+
+    virtual bool setCursor(WebCore::PlatformCursorHandle);
+    
+    // Notification that the given form element has changed. This function
+    // will be called frequently, so handling should be very fast.
+    virtual void formStateDidChange(const WebCore::Node*);
+    
+    virtual void formDidFocus(const WebCore::Node*);
+    virtual void formDidBlur(const WebCore::Node*);
+    
+    virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks();
+
+#if USE(ACCELERATED_COMPOSITING)
+    virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
+    virtual void setNeedsOneShotDrawingSynchronization();
+    virtual void scheduleCompositingLayerSync();
+#endif
+    
+    WebCore::String m_cachedToolTip;
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebChromeClient_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp
new file mode 100644 (file)
index 0000000..95af30c
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebContextMenuClient.h"
+
+#include "NotImplemented.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebContextMenuClient::contextMenuDestroyed()
+{
+    delete this;
+}
+
+PlatformMenuDescription WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu*)
+{
+    notImplemented();
+    return 0;
+}
+
+void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*)
+{
+    notImplemented();
+}
+
+void WebContextMenuClient::downloadURL(const KURL& url)
+{
+    notImplemented();
+}
+
+void WebContextMenuClient::searchWithGoogle(const Frame*)
+{
+    notImplemented();
+}
+
+void WebContextMenuClient::lookUpInDictionary(Frame*)
+{
+    notImplemented();
+}
+
+bool WebContextMenuClient::isSpeaking()
+{
+    notImplemented();
+    return false;
+}
+
+void WebContextMenuClient::speak(const String&)
+{
+    notImplemented();
+}
+
+void WebContextMenuClient::stopSpeaking()
+{
+    notImplemented();
+}
+
+#if PLATFORM(MAC)
+void WebContextMenuClient::searchWithSpotlight()
+{
+    notImplemented();
+}
+#endif
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h b/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h
new file mode 100644 (file)
index 0000000..2412576
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebContextMenuClient_h
+#define WebContextMenuClient_h
+
+#include <WebCore/ContextMenuClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebContextMenuClient : public WebCore::ContextMenuClient {
+public:
+    WebContextMenuClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+    
+private:
+    virtual void contextMenuDestroyed();
+    
+    virtual WebCore::PlatformMenuDescription getCustomMenuFromDefaultItems(WebCore::ContextMenu*);
+    virtual void contextMenuItemSelected(WebCore::ContextMenuItem*, const WebCore::ContextMenu*);
+    
+    virtual void downloadURL(const WebCore::KURL& url);
+    virtual void searchWithGoogle(const WebCore::Frame*);
+    virtual void lookUpInDictionary(WebCore::Frame*);
+    virtual bool isSpeaking();
+    virtual void speak(const WebCore::String&);
+    virtual void stopSpeaking();
+    
+#if PLATFORM(MAC)
+    virtual void searchWithSpotlight();
+#endif
+    
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebContextMenuClient_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
new file mode 100644 (file)
index 0000000..ab4065f
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebDragClient.h"
+
+#include "NotImplemented.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebDragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*)
+{
+    notImplemented();
+}
+
+void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+{
+    notImplemented();
+}
+
+DragDestinationAction WebDragClient::actionMaskForDrag(DragData*)
+{
+    notImplemented();
+    return DragDestinationActionNone;
+}
+
+DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
+{
+    notImplemented();
+    return DragSourceActionNone;
+}
+
+void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool)
+{
+    notImplemented();
+}
+
+DragImageRef WebDragClient::createDragImageForLink(KURL&, const String&, Frame*)
+{
+    notImplemented();
+    return 0;
+}
+
+void WebDragClient::dragControllerDestroyed()
+{
+    delete this;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
new file mode 100644 (file)
index 0000000..9fb49e6
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebDragClient_h
+#define WebDragClient_h
+
+#include <WebCore/DragClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebDragClient : public WebCore::DragClient {
+public:
+    WebDragClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+
+private:
+    virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);
+    virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
+    virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
+    virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint);
+
+    virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false);
+    virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL&, const WebCore::String& label, WebCore::Frame*);
+
+    virtual void dragControllerDestroyed();
+
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebDragClient_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
new file mode 100644 (file)
index 0000000..e3fd9a6
--- /dev/null
@@ -0,0 +1,422 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebEditorClient.h"
+
+#include "NotImplemented.h"
+#include "WebPage.h"
+
+#include <WebCore/EditCommand.h>
+#include <WebCore/KeyboardEvent.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebEditorClient::pageDestroyed()
+{
+    delete this;
+}
+
+bool WebEditorClient::shouldDeleteRange(Range*)
+{
+    notImplemented();
+    return true;
+}
+
+bool WebEditorClient::shouldShowDeleteInterface(HTMLElement*)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebEditorClient::smartInsertDeleteEnabled()
+{
+    notImplemented();
+    return true;
+}
+bool WebEditorClient::isSelectTrailingWhitespaceEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+bool WebEditorClient::isContinuousSpellCheckingEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleContinuousSpellChecking()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::isGrammarCheckingEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleGrammarChecking()
+{
+    notImplemented();
+}
+
+int WebEditorClient::spellCheckerDocumentTag()
+{
+    notImplemented();
+    return false;
+}
+
+    
+bool WebEditorClient::isEditable()
+{
+    notImplemented();
+    return false;
+}
+
+
+bool WebEditorClient::shouldBeginEditing(Range*)
+{
+    notImplemented();
+    return true;
+}
+
+bool WebEditorClient::shouldEndEditing(Range*)
+{
+    notImplemented();
+    return true;
+}
+
+bool WebEditorClient::shouldInsertNode(Node*, Range*, EditorInsertAction)
+{
+    notImplemented();
+    return true;
+}
+
+bool WebEditorClient::shouldInsertText(const String&, Range*, EditorInsertAction)
+{
+    return true;
+}
+
+bool WebEditorClient::shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting)
+{
+    return true;
+}
+    
+bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration*, Range*)
+{
+    notImplemented();
+    return true;
+}
+
+bool WebEditorClient::shouldMoveRangeAfterDelete(Range*, Range*)
+{
+    notImplemented();
+    return true;
+}
+
+void WebEditorClient::didBeginEditing()
+{
+    notImplemented();
+}
+
+void WebEditorClient::respondToChangedContents()
+{
+    notImplemented();
+}
+
+void WebEditorClient::respondToChangedSelection()
+{
+    notImplemented();
+}
+
+void WebEditorClient::didEndEditing()
+{
+    notImplemented();
+}
+
+void WebEditorClient::didWriteSelectionToPasteboard()
+{
+    notImplemented();
+}
+
+void WebEditorClient::didSetSelectionTypesForPasteboard()
+{
+    notImplemented();
+}
+
+void WebEditorClient::registerCommandForUndo(PassRefPtr<EditCommand>)
+{
+    notImplemented();
+}
+
+void WebEditorClient::registerCommandForRedo(PassRefPtr<EditCommand>)
+{
+    notImplemented();
+}
+
+void WebEditorClient::clearUndoRedoOperations()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::canUndo() const
+{
+    notImplemented();
+    return false;
+}
+
+bool WebEditorClient::canRedo() const
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::undo()
+{
+    notImplemented();
+}
+
+void WebEditorClient::redo()
+{
+    notImplemented();
+}
+
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
+{
+    if (m_page->handleEditingKeyboardEvent(event))
+        event->setDefaultHandled();
+}
+
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent*)
+{
+    notImplemented();
+}
+
+void WebEditorClient::textFieldDidBeginEditing(Element*)
+{
+    notImplemented();
+}
+
+void WebEditorClient::textFieldDidEndEditing(Element*)
+{
+    notImplemented();
+}
+
+void WebEditorClient::textDidChangeInTextField(Element*)
+{
+    notImplemented();
+}
+
+bool WebEditorClient::doTextFieldCommandFromEvent(Element*, KeyboardEvent*)
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::textWillBeDeletedInTextField(Element*)
+{
+    notImplemented();
+}
+
+void WebEditorClient::textDidChangeInTextArea(Element*)
+{
+    notImplemented();
+}
+
+#if PLATFORM(MAC)
+NSString* WebEditorClient::userVisibleString(NSURL*)
+{
+    notImplemented();
+    return nil;
+}
+
+#ifdef BUILDING_ON_TIGER
+NSArray* WebEditorClient::pasteboardTypesForSelection(Frame*)
+{
+    notImplemented();
+    return nil;
+}
+#endif
+#endif
+
+#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+void WebEditorClient::uppercaseWord()
+{
+    notImplemented();
+}
+
+void WebEditorClient::lowercaseWord()
+{
+    notImplemented();
+}
+
+void WebEditorClient::capitalizeWord()
+{
+    notImplemented();
+}
+
+void WebEditorClient::showSubstitutionsPanel(bool)
+{
+    notImplemented();
+}
+
+bool WebEditorClient::substitutionsPanelIsShowing()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleSmartInsertDelete()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::isAutomaticQuoteSubstitutionEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleAutomaticQuoteSubstitution()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::isAutomaticLinkDetectionEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleAutomaticLinkDetection()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::isAutomaticDashSubstitutionEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleAutomaticDashSubstitution()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::isAutomaticTextReplacementEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleAutomaticTextReplacement()
+{
+    notImplemented();
+}
+
+bool WebEditorClient::isAutomaticSpellingCorrectionEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::toggleAutomaticSpellingCorrection()
+{
+    notImplemented();
+}
+
+#endif
+
+void WebEditorClient::ignoreWordInSpellDocument(const String&)
+{
+    notImplemented();
+}
+
+void WebEditorClient::learnWord(const String&)
+{
+    notImplemented();
+}
+
+void WebEditorClient::checkSpellingOfString(const UChar*, int, int*, int*)
+{
+    notImplemented();
+}
+
+String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&)
+{
+    notImplemented();
+    return String();
+}
+
+void WebEditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
+{
+    notImplemented();
+}
+
+#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+void WebEditorClient::checkTextOfParagraph(const UChar*, int length, uint64_t, Vector<TextCheckingResult>&)
+{
+    notImplemented();
+}
+#endif
+
+void WebEditorClient::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&)
+{
+    notImplemented();
+}
+
+void WebEditorClient::updateSpellingUIWithMisspelledWord(const String&)
+{
+    notImplemented();
+}
+
+void WebEditorClient::showSpellingUI(bool)
+{
+    notImplemented();
+}
+
+bool WebEditorClient::spellingUIIsShowing()
+{
+    notImplemented();
+    return false;
+}
+
+void WebEditorClient::getGuessesForWord(const String&, Vector<String>&)
+{
+    notImplemented();
+}
+
+void WebEditorClient::setInputMethodState(bool)
+{
+    notImplemented();
+}
+
+} // namespace WebKit
+
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
new file mode 100644 (file)
index 0000000..e0ad99b
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebEditorClient_h
+#define WebEditorClient_h
+
+#include <WebCore/EditorClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebEditorClient : public WebCore::EditorClient {
+public:
+    WebEditorClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+
+private:    
+    virtual void pageDestroyed();
+    
+    virtual bool shouldDeleteRange(WebCore::Range*);
+    virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*);
+    virtual bool smartInsertDeleteEnabled(); 
+    virtual bool isSelectTrailingWhitespaceEnabled();
+    virtual bool isContinuousSpellCheckingEnabled();
+    virtual void toggleContinuousSpellChecking();
+    virtual bool isGrammarCheckingEnabled();
+    virtual void toggleGrammarChecking();
+    virtual int spellCheckerDocumentTag();
+    
+    virtual bool isEditable();
+
+    virtual bool shouldBeginEditing(WebCore::Range*);
+    virtual bool shouldEndEditing(WebCore::Range*);
+    virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction);
+    virtual bool shouldInsertText(const WebCore::String&, WebCore::Range*, WebCore::EditorInsertAction);
+    virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting);
+    
+    virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
+    virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*);
+
+    virtual void didBeginEditing();
+    virtual void respondToChangedContents();
+    virtual void respondToChangedSelection();
+    virtual void didEndEditing();
+    virtual void didWriteSelectionToPasteboard();
+    virtual void didSetSelectionTypesForPasteboard();
+    
+    virtual void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>);
+    virtual void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>);
+    virtual void clearUndoRedoOperations();
+
+    virtual bool canUndo() const;
+    virtual bool canRedo() const;
+    
+    virtual void undo();
+    virtual void redo();
+
+    virtual void handleKeyboardEvent(WebCore::KeyboardEvent*);
+    virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*);
+    
+    virtual void textFieldDidBeginEditing(WebCore::Element*);
+    virtual void textFieldDidEndEditing(WebCore::Element*);
+    virtual void textDidChangeInTextField(WebCore::Element*);
+    virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
+    virtual void textWillBeDeletedInTextField(WebCore::Element*);
+    virtual void textDidChangeInTextArea(WebCore::Element*);
+
+#if PLATFORM(MAC)
+    virtual NSString* userVisibleString(NSURL*);
+#ifdef BUILDING_ON_TIGER
+    virtual NSArray* pasteboardTypesForSelection(WebCore::Frame*);
+#endif
+#endif
+
+#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+    virtual void uppercaseWord();
+    virtual void lowercaseWord();
+    virtual void capitalizeWord();
+    virtual void showSubstitutionsPanel(bool show);
+    virtual bool substitutionsPanelIsShowing();
+    virtual void toggleSmartInsertDelete();
+    virtual bool isAutomaticQuoteSubstitutionEnabled();
+    virtual void toggleAutomaticQuoteSubstitution();
+    virtual bool isAutomaticLinkDetectionEnabled();
+    virtual void toggleAutomaticLinkDetection();
+    virtual bool isAutomaticDashSubstitutionEnabled();
+    virtual void toggleAutomaticDashSubstitution();
+    virtual bool isAutomaticTextReplacementEnabled();
+    virtual void toggleAutomaticTextReplacement();
+    virtual bool isAutomaticSpellingCorrectionEnabled();
+    virtual void toggleAutomaticSpellingCorrection();
+#endif
+
+    virtual void ignoreWordInSpellDocument(const WebCore::String&);
+    virtual void learnWord(const WebCore::String&);
+    virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
+    virtual WebCore::String getAutoCorrectSuggestionForMisspelledWord(const WebCore::String& misspelledWord);
+    virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
+#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+    virtual void checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results);
+#endif
+    virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail& detail);
+    virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&);
+    virtual void showSpellingUI(bool show);
+    virtual bool spellingUIIsShowing();
+    virtual void getGuessesForWord(const WebCore::String&, Vector<WebCore::String>& guesses);
+    virtual void setInputMethodState(bool enabled);
+
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebEditorClient_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebErrors.h b/WebKit2/WebProcess/WebCoreSupport/WebErrors.h
new file mode 100644 (file)
index 0000000..42e5822
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebErrors_h
+#define WebErrors_h
+
+#include <WebCore/ResourceError.h>
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/ResourceResponse.h>
+
+namespace WebKit {
+
+WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&);
+WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
+WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
+WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&);
+WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&);
+WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&);
+
+} // namespace WebKit
+
+#endif // WebErrors_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
new file mode 100644 (file)
index 0000000..59b1a99
--- /dev/null
@@ -0,0 +1,755 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebFrameLoaderClient.h"
+
+#include "NotImplemented.h"
+#include "WebCoreTypeArgumentMarshalling.h"
+#include "WebErrors.h"
+#include "WebFrame.h"
+#include "WebPage.h"
+#include "WebPageProxyMessageKinds.h"
+#include "WebProcess.h"
+
+#include <WebCore/Chrome.h>
+#include <WebCore/DocumentLoader.h>
+#include <WebCore/FormState.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoadRequest.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/HTMLFormElement.h>
+#include <WebCore/Page.h>
+#include <WebCore/ProgressTracker.h>
+#include <WebCore/ResourceError.h>
+#include <WebCore/WindowFeatures.h>
+#include <WebCore/Widget.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebFrameLoaderClient::frameLoaderDestroyed()
+{
+    m_frame->invalidate();
+
+    // Balences explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe.
+    m_frame->deref();
+}
+
+bool WebFrameLoaderClient::hasHTMLView() const
+{
+    return true;
+}
+
+bool WebFrameLoaderClient::hasWebView() const
+{
+    return m_frame->page();
+}
+
+void WebFrameLoaderClient::makeRepresentation(DocumentLoader*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::forceLayout()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::forceLayoutForNonHTML()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::setCopiesOnScroll()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::detachedFromParent2()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::detachedFromParent3()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&)
+{
+    notImplemented();
+}
+
+
+void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse)
+{
+    notImplemented();
+}
+
+bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier)
+{
+    notImplemented();
+    return false;
+}
+
+void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)    
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&)
+{
+    notImplemented();
+}
+
+bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
+{
+    notImplemented();
+    return false;
+}
+
+void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString&)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveServerRedirectForProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidPopStateWithinPage()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchWillClose()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidReceiveIcon()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
+    const KURL& url = provisionalLoader->url();
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidStartProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID(), url));
+}
+
+void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveTitleForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID(), title));
+}
+
+void WebFrameLoaderClient::dispatchDidCommitLoad()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidCommitLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&)
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidFailProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError&)
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidFailLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchDidFinishLoad()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidFinishLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+void WebFrameLoaderClient::dispatchDidFirstLayout()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidFirstLayoutForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidFirstVisuallyNonEmptyLayoutForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+}
+
+Frame* WebFrameLoaderClient::dispatchCreatePage()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return 0;
+
+    // Just call through to the chrome client.
+    Page* newPage = webPage->corePage()->chrome()->createWindow(m_frame->coreFrame(), FrameLoadRequest(), WindowFeatures());
+    if (!newPage)
+        return 0;
+    
+    return newPage->mainFrame();
+}
+
+void WebFrameLoaderClient::dispatchShow()
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    webPage->show();
+}
+
+void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest& request)
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    uint64_t listenerID = m_frame->setUpPolicyListener(function);
+    KURL url = request.url(); // FIXME: Pass entire request.
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForMIMEType, webPage->pageID(),
+                                            CoreIPC::In(m_frame->frameID(), MIMEType, url, listenerID));
+}
+
+void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>, const String& frameName)
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    uint64_t listenerID = m_frame->setUpPolicyListener(function);
+
+    // FIXME: Pass more than just the navigation action type.
+    // FIXME: Pass the frame name.
+    KURL url = request.url(); // FIXME: Pass entire request.
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForNewWindowAction, webPage->pageID(),
+                                            CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), url, listenerID));
+}
+
+void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>)
+{
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    uint64_t listenerID = m_frame->setUpPolicyListener(function);
+
+    // FIXME: Pass more than just the navigation action type.
+    KURL url = request.url(); // FIXME: Pass entire request.
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForNavigationAction, webPage->pageID(),
+                                            CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), url, listenerID));
+}
+
+void WebFrameLoaderClient::cancelPolicyCheck()
+{
+    m_frame->invalidatePolicyListener();
+}
+
+void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState>)
+{
+    notImplemented();
+
+    Frame* coreFrame = m_frame->coreFrame();
+    (coreFrame->loader()->policyChecker()->*function)(PolicyUse);
+}
+
+void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError&)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::willChangeEstimatedProgress()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::didChangeEstimatedProgress()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::postProgressStartedNotification()
+{
+    if (WebPage* webPage = m_frame->page())
+        WebProcess::shared().connection()->send(WebPageProxyMessage::DidStartProgress, webPage->pageID(), CoreIPC::In());
+}
+
+void WebFrameLoaderClient::postProgressEstimateChangedNotification()
+{
+    if (WebPage* webPage = m_frame->page()) {
+        double progress = webPage->corePage()->progress()->estimatedProgress();
+        WebProcess::shared().connection()->send(WebPageProxyMessage::DidChangeProgress, webPage->pageID(), CoreIPC::In(progress));
+    }
+}
+
+void WebFrameLoaderClient::postProgressFinishedNotification()
+{
+    if (WebPage* webPage = m_frame->page())
+        WebProcess::shared().connection()->send(WebPageProxyMessage::DidFinishProgress, webPage->pageID(), CoreIPC::In());
+}
+
+void WebFrameLoaderClient::setMainFrameDocumentReady(bool)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::startDownload(const ResourceRequest&)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::willChangeTitle(DocumentLoader*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::didChangeTitle(DocumentLoader*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
+{
+    const String& textEncoding = loader->response().textEncodingName();
+    
+    receivedData(data, length, textEncoding);
+}
+
+void WebFrameLoaderClient::receivedData(const char* data, int length, const String& textEncoding)
+{
+    Frame* coreFrame = m_frame->coreFrame();
+    if (!coreFrame)
+        return;
+    
+    // Set the encoding. This only needs to be done once, but it's harmless to do it again later.
+    String encoding = coreFrame->loader()->documentLoader()->overrideEncoding();
+    bool userChosen = !encoding.isNull();
+    if (encoding.isNull())
+        encoding = textEncoding;
+    coreFrame->loader()->setEncoding(encoding, userChosen);
+    
+    coreFrame->loader()->addData(data, length);
+}
+
+void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
+{
+    committedLoad(loader, 0, 0);
+}
+
+void WebFrameLoaderClient::updateGlobalHistory()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
+{
+    notImplemented();
+}
+
+bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const
+{
+    notImplemented();
+    return true;
+}
+
+void WebFrameLoaderClient::dispatchDidAddBackForwardItem(HistoryItem*) const
+{
+    if (WebPage* webPage = m_frame->page())
+        webPage->backForwardListDidChange();
+}
+
+void WebFrameLoaderClient::dispatchDidRemoveBackForwardItem(HistoryItem*) const
+{
+    if (WebPage* webPage = m_frame->page())
+        webPage->backForwardListDidChange();
+}
+
+void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const
+{
+    if (WebPage* webPage = m_frame->page())
+        webPage->backForwardListDidChange();
+}
+
+void WebFrameLoaderClient::didDisplayInsecureContent()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*)
+{
+    notImplemented();
+}
+
+ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
+{
+    return WebKit::cancelledError(request);
+}
+
+ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
+{
+    return WebKit::blockedError(request);
+}
+
+ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
+{
+    return WebKit::cannotShowURLError(request);
+}
+
+ResourceError WebFrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest& request)
+{
+    return WebKit::interruptForPolicyChangeError(request);
+}
+
+ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
+{
+    return WebKit::cannotShowMIMETypeError(response);
+}
+
+ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
+{
+    return WebKit::fileDoesNotExistError(response);
+}
+
+ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse&)
+{
+    notImplemented();
+    return ResourceError();
+}
+
+bool WebFrameLoaderClient::shouldFallBack(const ResourceError&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const
+{
+    notImplemented();
+    return true;
+}
+
+bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
+{
+    notImplemented();
+    return true;
+}
+
+bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
+{
+    notImplemented();
+    return false;
+}
+
+String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
+{
+    notImplemented();
+    return String();
+}
+
+void WebFrameLoaderClient::frameLoadCompleted()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::restoreViewState()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::provisionalLoadStarted()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::didFinishLoad()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::prepareForDataSourceReplacement()
+{
+    notImplemented();
+}
+
+PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& data)
+{
+    return DocumentLoader::create(request, data);
+}
+
+void WebFrameLoaderClient::setTitle(const String& title, const KURL&)
+{
+    notImplemented();
+}
+
+String WebFrameLoaderClient::userAgent(const KURL&)
+{
+    notImplemented();
+    return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4";
+}
+
+void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::transitionToCommittedForNewPage()
+{
+    m_frame->coreFrame()->createView(m_frame->page()->size(), Color::white, false, IntSize(), false);
+}
+
+bool WebFrameLoaderClient::canCachePage() const
+{
+    notImplemented();
+    return false;
+}
+
+void WebFrameLoaderClient::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&)
+{
+    notImplemented();
+}
+
+PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
+                                                    const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
+{
+    WebPage* webPage = m_frame->page();
+
+    RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement);
+
+    // Notify the UI process that subframe has been added.
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidCreateSubFrame, webPage->pageID(), CoreIPC::In(subframe->frameID()));
+
+    Frame* coreSubframe = subframe->coreFrame();
+
+     // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
+    m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe);
+
+    // The frame's onload handler may have removed it from the document.
+    if (!coreSubframe->tree()->parent())
+        return 0;
+
+    return coreSubframe;
+}
+
+void WebFrameLoaderClient::didTransferChildFrameToNewDocument()
+{
+    notImplemented();
+}    
+
+PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually)
+{
+    notImplemented();
+    return 0;
+}
+
+void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
+{
+    notImplemented();
+}
+
+PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues)
+{
+    notImplemented();
+    return 0;
+}
+
+ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeType)
+{
+    notImplemented();
+    return ObjectContentNone;
+}
+
+String WebFrameLoaderClient::overrideMediaType() const
+{
+    notImplemented();
+    return String();
+}
+
+void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*)
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::documentElementAvailable()
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::didPerformFirstNavigation() const
+{
+    notImplemented();
+}
+
+void WebFrameLoaderClient::registerForIconNotification(bool listen)
+{
+    notImplemented();
+}
+
+#if PLATFORM(MAC)
+#if ENABLE(MAC_JAVA_BRIDGE)
+jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; }
+#endif
+NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const
+{
+    notImplemented();
+    return 0;
+}
+
+#endif
+#if USE(CFNETWORK)
+bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length)
+{
+    notImplemented();
+    return false;
+}
+
+#endif
+
+bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
+{
+    notImplemented();
+    return false;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
new file mode 100644 (file)
index 0000000..f61f316
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebFrameLoaderClient_h
+#define WebFrameLoaderClient_h
+
+#include <WebCore/FrameLoaderClient.h>
+
+namespace WebKit {
+
+class WebFrame;
+
+class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
+public:
+    WebFrameLoaderClient(WebFrame* frame)
+        : m_frame(frame)
+    {
+    }
+
+    WebFrame* webFrame() const { return m_frame; }
+
+private:
+    virtual void frameLoaderDestroyed();
+
+    virtual bool hasHTMLView() const;
+    virtual bool hasWebView() const;
+    
+    virtual void makeRepresentation(WebCore::DocumentLoader*);
+    virtual void forceLayout();
+    virtual void forceLayoutForNonHTML();
+    
+    virtual void setCopiesOnScroll();
+    
+    virtual void detachedFromParent2();
+    virtual void detachedFromParent3();
+    
+    virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
+    
+    virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
+    virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier);
+    virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
+    virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);        
+    virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&);
+    virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived);
+    virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier);
+    virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&);
+    virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
+    virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&);
+    
+    virtual void dispatchDidHandleOnloadEvents();
+    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
+    virtual void dispatchDidCancelClientRedirect();
+    virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate);
+    virtual void dispatchDidChangeLocationWithinPage();
+    virtual void dispatchDidPushStateWithinPage();
+    virtual void dispatchDidReplaceStateWithinPage();
+    virtual void dispatchDidPopStateWithinPage();
+    virtual void dispatchWillClose();
+    virtual void dispatchDidReceiveIcon();
+    virtual void dispatchDidStartProvisionalLoad();
+    virtual void dispatchDidReceiveTitle(const WebCore::String& title);
+    virtual void dispatchDidCommitLoad();
+    virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
+    virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
+    virtual void dispatchDidFinishDocumentLoad();
+    virtual void dispatchDidFinishLoad();
+    virtual void dispatchDidFirstLayout();
+    virtual void dispatchDidFirstVisuallyNonEmptyLayout();
+    
+    virtual WebCore::Frame* dispatchCreatePage();
+    virtual void dispatchShow();
+    
+    virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, const WebCore::String& MIMEType, const WebCore::ResourceRequest&);
+    virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WebCore::String& frameName);
+    virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>);
+    virtual void cancelPolicyCheck();
+    
+    virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
+    
+    virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>);
+    
+    virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*);
+    virtual void revertToProvisionalState(WebCore::DocumentLoader*);
+    virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&);
+    
+    // Maybe these should go into a ProgressTrackerClient some day
+    virtual void willChangeEstimatedProgress();
+    virtual void didChangeEstimatedProgress();
+    virtual void postProgressStartedNotification();
+    virtual void postProgressEstimateChangedNotification();
+    virtual void postProgressFinishedNotification();
+    
+    virtual void setMainFrameDocumentReady(bool);
+    
+    virtual void startDownload(const WebCore::ResourceRequest&);
+    
+    virtual void willChangeTitle(WebCore::DocumentLoader*);
+    virtual void didChangeTitle(WebCore::DocumentLoader*);
+    
+    virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
+    virtual void finishedLoading(WebCore::DocumentLoader*);
+    
+    virtual void updateGlobalHistory();
+    virtual void updateGlobalHistoryRedirectLinks();
+    
+    virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const;
+    virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const;
+    virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const;
+    virtual void dispatchDidChangeBackForwardIndex() const;
+
+    virtual void didDisplayInsecureContent();
+    virtual void didRunInsecureContent(WebCore::SecurityOrigin*);
+
+    virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&);
+    virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
+    virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
+    virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&);
+    
+    virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&);
+    virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&);
+    virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&);
+    
+    virtual bool shouldFallBack(const WebCore::ResourceError&);
+    
+    virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
+    virtual bool canShowMIMEType(const WebCore::String& MIMEType) const;
+    virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const;
+    virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const;
+    
+    virtual void frameLoadCompleted();
+    virtual void saveViewStateToItem(WebCore::HistoryItem*);
+    virtual void restoreViewState();
+    virtual void provisionalLoadStarted();
+    virtual void didFinishLoad();
+    virtual void prepareForDataSourceReplacement();
+    
+    virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
+    virtual void setTitle(const WebCore::String& title, const WebCore::KURL&);
+    
+    virtual WebCore::String userAgent(const WebCore::KURL&);
+    
+    virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
+    virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
+    virtual void transitionToCommittedForNewPage();
+    
+    virtual bool canCachePage() const;
+    virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
+    
+    virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
+                                          const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
+    virtual void didTransferChildFrameToNewDocument();
+    
+    virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WebCore::String>&, const Vector<WebCore::String>&, const WebCore::String&, bool loadManually);
+    virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
+    
+    virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues);
+    
+    virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType);
+    virtual WebCore::String overrideMediaType() const;
+
+    virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
+
+    virtual void documentElementAvailable();
+    virtual void didPerformFirstNavigation() const; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
+    
+    virtual void registerForIconNotification(bool listen = true);
+    
+#if PLATFORM(MAC)
+#if ENABLE(MAC_JAVA_BRIDGE)
+    virtual jobject javaApplet(NSView*);
+#endif
+    virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const;
+#endif
+#if USE(CFNETWORK)
+    virtual bool shouldCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&, const unsigned char* data, unsigned long long length);
+#endif
+    
+    virtual bool shouldUsePluginDocument(const WebCore::String& /*mimeType*/) const;
+    
+    void receivedData(const char* data, int length, const WebCore::String& textEncoding);
+
+    WebFrame* m_frame;
+};
+
+} // namespace WebKit
+
+#endif // WebFrameLoaderClient_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
new file mode 100644 (file)
index 0000000..ecaef86
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebInspectorClient.h"
+
+#include "NotImplemented.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebInspectorClient::inspectorDestroyed()
+{
+    delete this;
+}
+
+void WebInspectorClient::openInspectorFrontend(InspectorController*)
+{
+    notImplemented();
+}
+
+Page* WebInspectorClient::createPage()
+{
+    notImplemented();
+    return 0;
+}
+
+String WebInspectorClient::localizedStringsURL()
+{
+    notImplemented();
+    return String();
+}
+
+String WebInspectorClient::hiddenPanels()
+{
+    notImplemented();
+    return String();
+}
+
+void WebInspectorClient::showWindow()
+{
+    notImplemented();
+}
+
+void WebInspectorClient::closeWindow()
+{
+    notImplemented();
+}
+
+void WebInspectorClient::attachWindow()
+{
+    notImplemented();
+}
+
+void WebInspectorClient::detachWindow()
+{
+    notImplemented();
+}
+
+void WebInspectorClient::setAttachedWindowHeight(unsigned height)
+{
+    notImplemented();
+}
+
+void WebInspectorClient::highlight(Node*)
+{
+    notImplemented();
+}
+
+void WebInspectorClient::hideHighlight()
+{
+    notImplemented();
+}
+
+void WebInspectorClient::inspectedURLChanged(const String& newURL)
+{
+    notImplemented();
+}
+
+void WebInspectorClient::populateSetting(const String& key, String*)
+{
+    notImplemented();
+}
+
+void WebInspectorClient::storeSetting(const String&, const String&)
+{
+    notImplemented();
+}
+
+void WebInspectorClient::inspectorWindowObjectCleared()
+{
+    notImplemented();
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h b/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h
new file mode 100644 (file)
index 0000000..95d94ef
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebInspectorClient_h
+#define WebInspectorClient_h
+
+#include <WebCore/InspectorClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebInspectorClient : public WebCore::InspectorClient {
+public:
+    WebInspectorClient(WebPage* page)
+        : m_page(page)
+    {
+    }
+    
+private:
+    virtual void inspectorDestroyed();
+    
+    virtual void openInspectorFrontend(WebCore::InspectorController*);
+
+    virtual WebCore::Page* createPage();
+    
+    virtual WebCore::String localizedStringsURL();
+    
+    virtual WebCore::String hiddenPanels();
+    
+    virtual void showWindow();
+    virtual void closeWindow();
+    
+    virtual void attachWindow();
+    virtual void detachWindow();
+    
+    virtual void setAttachedWindowHeight(unsigned height);
+    
+    virtual void highlight(WebCore::Node*);
+    virtual void hideHighlight();
+    
+    virtual void inspectedURLChanged(const WebCore::String& newURL);
+
+    virtual void populateSetting(const WebCore::String& key, WebCore::String* value);
+    virtual void storeSetting(const WebCore::String& key, const WebCore::String& value);
+
+    virtual void inspectorWindowObjectCleared();
+    
+    WebPage* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebInspectorClient_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm
new file mode 100644 (file)
index 0000000..d7ff44f
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebErrors.h"
+
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/ResourceResponse.h>
+#include <pthread.h>
+
+using namespace WebCore;
+
+// FIXME: We probably don't need to use NSErrors here.
+
+enum {
+    WebKitErrorCannotShowMIMEType =                             100,
+    WebKitErrorCannotShowURL =                                  101,
+    WebKitErrorFrameLoadInterruptedByPolicyChange =             102,
+};
+enum {
+    WebKitErrorCannotFindPlugIn =                               200,
+    WebKitErrorCannotLoadPlugIn =                               201,
+    WebKitErrorJavaUnavailable =                                202,
+};
+enum {
+    WebKitErrorCannotUseRestrictedPort =                        103,
+};
+
+#define WebKitErrorPlugInCancelledConnection 203
+#define WebKitErrorPlugInWillHandleLoad 204
+
+static NSString *WebKitErrorDomain = @"WebKitErrorDomain";
+
+static NSString * const WebKitErrorMIMETypeKey =               @"WebKitErrorMIMETypeKey";
+static NSString * const WebKitErrorPlugInNameKey =             @"WebKitErrorPlugInNameKey";
+static NSString * const WebKitErrorPlugInPageURLStringKey =    @"WebKitErrorPlugInPageURLStringKey";
+
+#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
+
+// Policy errors
+#define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description")
+#define WebKitErrorDescriptionCannotShowURL UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description")
+#define WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description")
+#define WebKitErrorDescriptionCannotUseRestrictedPort UI_STRING("Not allowed to use restricted network port", "WebKitErrorCannotUseRestrictedPort description")
+
+// Plug-in and java errors
+#define WebKitErrorDescriptionCannotFindPlugin UI_STRING("The plug-in can’t be found", "WebKitErrorCannotFindPlugin description")
+#define WebKitErrorDescriptionCannotLoadPlugin UI_STRING("The plug-in can’t be loaded", "WebKitErrorCannotLoadPlugin description")
+#define WebKitErrorDescriptionJavaUnavailable UI_STRING("Java is unavailable", "WebKitErrorJavaUnavailable description")
+#define WebKitErrorDescriptionPlugInCancelledConnection UI_STRING("Plug-in cancelled", "WebKitErrorPlugInCancelledConnection description")
+#define WebKitErrorDescriptionPlugInWillHandleLoad UI_STRING("Plug-in handled load", "WebKitErrorPlugInWillHandleLoad description")
+
+static pthread_once_t registerErrorsControl = PTHREAD_ONCE_INIT;
+static void registerErrors(void);
+
+@interface NSError (WebKitExtras)
++ (NSError *)_webKitErrorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL;
+@end
+
+@implementation NSError (WebKitExtras)
+
+static NSMutableDictionary *descriptions = nil;
+
++ (void)_registerWebKitErrors
+{
+    pthread_once(&registerErrorsControl, registerErrors);
+}
+
+-(id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL
+{
+    NSDictionary *descriptionsDict;
+    NSString *localizedDesc;
+    NSDictionary *dict;
+    // insert a localized string here for those folks not savvy to our category methods
+    descriptionsDict = [descriptions objectForKey:domain];
+    localizedDesc = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil;
+    dict = [NSDictionary dictionaryWithObjectsAndKeys:
+        URL, @"NSErrorFailingURLKey",
+        [URL absoluteString], @"NSErrorFailingURLStringKey",
+        localizedDesc, NSLocalizedDescriptionKey,
+        nil];
+    return [self initWithDomain:domain code:code userInfo:dict];
+}
+
++(id)_webkit_errorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL
+{
+    return [[[self alloc] _webkit_initWithDomain:domain code:code URL:URL] autorelease];
+}
+
++ (NSError *)_webKitErrorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL
+{
+    [self _registerWebKitErrors];
+    return [self _webkit_errorWithDomain:domain code:code URL:URL];
+}
+
++ (NSError *)_webKitErrorWithCode:(int)code failingURL:(NSString *)URLString
+{
+    return [self _webKitErrorWithDomain:WebKitErrorDomain code:code URL:[NSURL URLWithString:URLString]];
+}
+
++ (void)_webkit_addErrorsWithCodesAndDescriptions:(NSDictionary *)dictionary inDomain:(NSString *)domain
+{
+    if (!descriptions)
+        descriptions = [[NSMutableDictionary alloc] init];
+
+    [descriptions setObject:dictionary forKey:domain];
+}
+
+static void registerErrors()
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+        // Policy errors
+        WebKitErrorDescriptionCannotShowMIMEType,                   [NSNumber numberWithInt: WebKitErrorCannotShowMIMEType],
+        WebKitErrorDescriptionCannotShowURL,                        [NSNumber numberWithInt: WebKitErrorCannotShowURL],
+        WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange,   [NSNumber numberWithInt: WebKitErrorFrameLoadInterruptedByPolicyChange],
+        WebKitErrorDescriptionCannotUseRestrictedPort,              [NSNumber numberWithInt: WebKitErrorCannotUseRestrictedPort],
+        
+        // Plug-in and java errors
+        WebKitErrorDescriptionCannotFindPlugin,                     [NSNumber numberWithInt: WebKitErrorCannotFindPlugIn],
+        WebKitErrorDescriptionCannotLoadPlugin,                     [NSNumber numberWithInt: WebKitErrorCannotLoadPlugIn],
+        WebKitErrorDescriptionJavaUnavailable,                      [NSNumber numberWithInt: WebKitErrorJavaUnavailable],
+        WebKitErrorDescriptionPlugInCancelledConnection,            [NSNumber numberWithInt: WebKitErrorPlugInCancelledConnection],
+        WebKitErrorDescriptionPlugInWillHandleLoad,                 [NSNumber numberWithInt: WebKitErrorPlugInWillHandleLoad],
+        nil];
+
+    [NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebKitErrorDomain];
+
+    [pool drain];
+}
+
+@end
+
+namespace WebKit {
+
+ResourceError cancelledError(const ResourceRequest& request)
+{
+    return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:request.url()];
+}
+
+ResourceError blockedError(const ResourceRequest& request)
+{
+    return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotUseRestrictedPort URL:request.url()];
+}
+
+ResourceError cannotShowURLError(const ResourceRequest& request)
+{
+    return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:request.url()];
+}
+
+ResourceError interruptForPolicyChangeError(const ResourceRequest& request)
+{
+    return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:request.url()];
+}
+
+ResourceError cannotShowMIMETypeError(const ResourceResponse& response)
+{
+    return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:response.url()];
+}
+
+ResourceError fileDoesNotExistError(const ResourceResponse& response)
+{
+    return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:response.url()];    
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h b/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h
new file mode 100644 (file)
index 0000000..616263a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void InitWebCoreSystemInterface(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.m b/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.m
new file mode 100644 (file)
index 0000000..5a2b440
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#import "WebSystemInterface.h"
+
+#import <WebCore/WebCoreSystemInterface.h>
+#import <WebKitSystemInterface.h>
+
+#define INIT(function) wk##function = WK##function
+
+void InitWebCoreSystemInterface(void)
+{
+    static bool didInit;
+    if (didInit)
+        return;
+
+    INIT(AdvanceDefaultButtonPulseAnimation);
+    INIT(CGContextGetShouldSmoothFonts);
+    INIT(CopyCONNECTProxyResponse);
+    INIT(CreateCustomCFReadStream);
+    INIT(CreateNSURLConnectionDelegateProxy);
+    INIT(DrawCapsLockIndicator);
+    INIT(DrawBezeledTextArea);
+    INIT(DrawBezeledTextFieldCell);
+    INIT(DrawFocusRing);
+    INIT(DrawMediaUIPart);
+    INIT(DrawMediaSliderTrack);
+    INIT(DrawTextFieldCellFocusRing);
+    INIT(GetExtensionsForMIMEType);
+    INIT(GetFontInLanguageForCharacter);
+    INIT(GetFontInLanguageForRange);
+    INIT(GetGlyphTransformedAdvances);
+    INIT(GetMIMETypeForExtension);
+    INIT(GetNSURLResponseLastModifiedDate);
+    INIT(GetPreferredExtensionForMIMEType);
+    INIT(GetWheelEventDeltas);
+    INIT(HitTestMediaUIPart);
+    INIT(InitializeMaximumHTTPConnectionCountPerHost);
+    INIT(IsLatchingWheelEvent);
+    INIT(MeasureMediaUIPart);
+    INIT(MediaControllerThemeAvailable);
+    INIT(PopupMenu);
+    INIT(SetCGFontRenderingMode);
+    INIT(SetCONNECTProxyAuthorizationForStream);
+    INIT(SetCONNECTProxyForStream);
+    INIT(SetDragImage);
+    INIT(SetNSURLConnectionDefersCallbacks);
+    INIT(SetNSURLRequestShouldContentSniff);
+    INIT(SetPatternBaseCTM);
+    INIT(SetPatternPhaseInUserSpace);
+    INIT(GetUserToBaseCTM);
+    INIT(SetUpFontCache);
+    INIT(SignalCFReadStreamEnd);
+    INIT(SignalCFReadStreamError);
+    INIT(SignalCFReadStreamHasBytes);
+    INIT(QTIncludeOnlyModernMediaFileTypes);
+    INIT(QTMovieDataRate);
+    INIT(QTMovieMaxTimeLoaded);
+    INIT(QTMovieMaxTimeLoadedChangeNotification);
+    INIT(QTMovieMaxTimeSeekable);
+    INIT(QTMovieGetType);
+    INIT(QTMovieHasClosedCaptions);
+    INIT(QTMovieSetShowClosedCaptions);
+    INIT(QTMovieViewSetDrawSynchronously);
+
+#ifndef BUILDING_ON_TIGER
+    INIT(GetGlyphsForCharacters);
+#else
+    INIT(ClearGlyphVector);
+    INIT(ConvertCharToGlyphs);
+    INIT(CopyFullFontName);
+    INIT(GetATSStyleGroup);
+    INIT(GetCGFontFromNSFont);
+    INIT(GetFontMetrics);
+    INIT(GetGlyphVectorFirstRecord);
+    INIT(GetGlyphVectorNumGlyphs);
+    INIT(GetGlyphVectorRecordSize);
+    INIT(GetNSFontATSUFontId);
+    INIT(InitializeGlyphVector);
+    INIT(ReleaseStyleGroup);
+    INIT(SupportsMultipartXMixedReplace);
+#endif
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    INIT(NoteOpenPanelFiles);
+#endif
+
+    didInit = true;
+}
diff --git a/WebKit2/WebProcess/WebCoreSupport/win/WebCoreLocalizedStrings.cpp b/WebKit2/WebProcess/WebCoreSupport/win/WebCoreLocalizedStrings.cpp
new file mode 100644 (file)
index 0000000..1b7a54b
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2007, 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 <windows.h>
+#include "WebLocalizableStrings.h"
+#include <WebCore/IntSize.h>
+#include <WebCore/LocalizedStrings.h>
+#include <WebCore/PlatformString.h>
+#include <wtf/MathExtras.h>
+#include <wtf/RetainPtr.h>
+
+using namespace WebCore;
+
+String WebCore::searchableIndexIntroduction() { return String(LPCTSTR_UI_STRING("This is a searchable index. Enter search keywords: ", "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'")); }
+String WebCore::submitButtonDefaultLabel() { return String(LPCTSTR_UI_STRING("Submit", "default label for Submit buttons in forms on web pages")); }
+String WebCore::inputElementAltText() { return String(LPCTSTR_UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value")); }
+String WebCore::resetButtonDefaultLabel() { return String(LPCTSTR_UI_STRING("Reset", "default label for Reset buttons in forms on web pages")); }
+String WebCore::fileButtonChooseFileLabel() { return String(LPCTSTR_UI_STRING("Choose File", "title for file button used in HTML forms")); }
+String WebCore::fileButtonNoFileSelectedLabel() { return String(LPCTSTR_UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected")); }
+String WebCore::contextMenuItemTagOpenLinkInNewWindow() { return String(LPCTSTR_UI_STRING("Open Link in New Window", "Open in New Window context menu item")); }
+String WebCore::contextMenuItemTagDownloadLinkToDisk() { return String(LPCTSTR_UI_STRING("Download Linked File", "Download Linked File context menu item")); }
+String WebCore::contextMenuItemTagCopyLinkToClipboard() { return String(LPCTSTR_UI_STRING("Copy Link", "Copy Link context menu item")); }
+String WebCore::contextMenuItemTagOpenImageInNewWindow() { return String(LPCTSTR_UI_STRING("Open Image in New Window", "Open Image in New Window context menu item")); }
+String WebCore::contextMenuItemTagDownloadImageToDisk() { return String(LPCTSTR_UI_STRING("Download Image", "Download Image context menu item")); }
+String WebCore::contextMenuItemTagCopyImageToClipboard() { return String(LPCTSTR_UI_STRING("Copy Image", "Copy Image context menu item")); }
+String WebCore::contextMenuItemTagOpenFrameInNewWindow() { return String(LPCTSTR_UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item")); }
+String WebCore::contextMenuItemTagCopy() { return String(LPCTSTR_UI_STRING("Copy", "Copy context menu item")); }
+String WebCore::contextMenuItemTagGoBack() { return String(LPCTSTR_UI_STRING("Back", "Back context menu item")); }
+String WebCore::contextMenuItemTagGoForward() { return String(LPCTSTR_UI_STRING("Forward", "Forward context menu item")); }
+String WebCore::contextMenuItemTagStop() { return String(LPCTSTR_UI_STRING("Stop", "Stop context menu item")); }
+String WebCore::contextMenuItemTagReload() { return String(LPCTSTR_UI_STRING("Reload", "Reload context menu item")); }
+String WebCore::contextMenuItemTagCut() { return String(LPCTSTR_UI_STRING("Cut", "Cut context menu item")); }
+String WebCore::contextMenuItemTagPaste() { return String(LPCTSTR_UI_STRING("Paste", "Paste context menu item")); }
+String WebCore::contextMenuItemTagNoGuessesFound() { return String(LPCTSTR_UI_STRING("No Guesses Found", "No Guesses Found context menu item")); }
+String WebCore::contextMenuItemTagIgnoreSpelling() { return String(LPCTSTR_UI_STRING("Ignore Spelling", "Ignore Spelling context menu item")); }
+String WebCore::contextMenuItemTagLearnSpelling() { return String(LPCTSTR_UI_STRING("Learn Spelling", "Learn Spelling context menu item")); }
+String WebCore::contextMenuItemTagSearchWeb() { return String(LPCTSTR_UI_STRING("Search with Google", "Search in Google context menu item")); }
+String WebCore::contextMenuItemTagLookUpInDictionary() { return String(LPCTSTR_UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item")); }
+String WebCore::contextMenuItemTagOpenLink() { return String(LPCTSTR_UI_STRING("Open Link", "Open Link context menu item")); }
+String WebCore::contextMenuItemTagIgnoreGrammar() { return String(LPCTSTR_UI_STRING("Ignore Grammar", "Ignore Grammar context menu item")); }
+String WebCore::contextMenuItemTagSpellingMenu() { return String(LPCTSTR_UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item")); }
+String WebCore::contextMenuItemTagCheckSpelling() { return String(LPCTSTR_UI_STRING("Check Document Now", "Check spelling context menu item")); }
+String WebCore::contextMenuItemTagCheckSpellingWhileTyping() { return String(LPCTSTR_UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item")); }
+String WebCore::contextMenuItemTagCheckGrammarWithSpelling() { return String(LPCTSTR_UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item")); }
+String WebCore::contextMenuItemTagFontMenu() { return String(LPCTSTR_UI_STRING("Font", "Font context sub-menu item")); }
+String WebCore::contextMenuItemTagBold() { return String(LPCTSTR_UI_STRING("Bold", "Bold context menu item")); }
+String WebCore::contextMenuItemTagItalic() { return String(LPCTSTR_UI_STRING("Italic", "Italic context menu item")); }
+String WebCore::contextMenuItemTagUnderline() { return String(LPCTSTR_UI_STRING("Underline", "Underline context menu item")); }
+String WebCore::contextMenuItemTagOutline() { return String(LPCTSTR_UI_STRING("Outline", "Outline context menu item")); }
+String WebCore::contextMenuItemTagWritingDirectionMenu() { return String(LPCTSTR_UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item")); }
+String WebCore::contextMenuItemTagTextDirectionMenu() { return String(LPCTSTR_UI_STRING("Selection Direction", "Selection direction context sub-menu item")); }
+String WebCore::contextMenuItemTagDefaultDirection() { return String(LPCTSTR_UI_STRING("Default", "Default writing direction context menu item")); }
+String WebCore::contextMenuItemTagLeftToRight() { return String(LPCTSTR_UI_STRING("Left to Right", "Left to Right context menu item")); }
+String WebCore::contextMenuItemTagRightToLeft() { return String(LPCTSTR_UI_STRING("Right to Left", "Right to Left context menu item")); }
+String WebCore::contextMenuItemTagShowSpellingPanel(bool show) { return String(show ? LPCTSTR_UI_STRING("Show Spelling and Grammar", "menu item title") : LPCTSTR_UI_STRING("Hide Spelling and Grammar", "menu item title")); }
+String WebCore::contextMenuItemTagInspectElement() { return String(LPCTSTR_UI_STRING("Inspect Element", "Inspect Element context menu item")); }
+String WebCore::searchMenuNoRecentSearchesText() { return String(LPCTSTR_UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed")); }
+String WebCore::searchMenuRecentSearchesText() { return String(LPCTSTR_UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title")); }
+String WebCore::searchMenuClearRecentSearchesText() { return String(LPCTSTR_UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents")); }
+String WebCore::AXWebAreaText() { return String(LPCTSTR_UI_STRING("web area", "accessibility role description for web area")); }
+String WebCore::AXLinkText() { return String(LPCTSTR_UI_STRING("link", "accessibility role description for link")); }
+String WebCore::AXListMarkerText() { return String(LPCTSTR_UI_STRING("list marker", "accessibility role description for list marker")); }
+String WebCore::AXImageMapText() { return String(LPCTSTR_UI_STRING("image map", "accessibility role description for image map")); }
+String WebCore::AXHeadingText() { return String(LPCTSTR_UI_STRING("heading", "accessibility role description for headings")); }
+String WebCore::AXDefinitionListTermText() { return String(LPCTSTR_UI_STRING("term", "term word of a definition")); }
+String WebCore::AXDefinitionListDefinitionText() { return String(LPCTSTR_UI_STRING("definition", "definition phrase")); }
+String WebCore::AXButtonActionVerb() { return String(LPCTSTR_UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility")); }
+String WebCore::AXRadioButtonActionVerb() { return String(LPCTSTR_UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility")); }
+String WebCore::AXTextFieldActionVerb() { return String(LPCTSTR_UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility")); }
+String WebCore::AXCheckedCheckBoxActionVerb() { return String(LPCTSTR_UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility")); }
+String WebCore::AXUncheckedCheckBoxActionVerb() { return String(LPCTSTR_UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility")); }
+String WebCore::AXLinkActionVerb() { return String(LPCTSTR_UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility")); }
+String WebCore::AXMenuListActionVerb() { return String(LPCTSTR_UI_STRING("open", "Verb stating the action that will occur when a select element is clicked, as used by accessibility")); }
+String WebCore::AXMenuListPopupActionVerb() { return String(LPCTSTR_UI_STRING("press", "Verb stating the action that will occur when a select element's popup list is clicked, as used by accessibility")); }
+String WebCore::unknownFileSizeText() { return String(LPCTSTR_UI_STRING("Unknown", "Unknown filesize FTP directory listing item")); }
+String WebCore::uploadFileText() { return String(LPCTSTR_UI_STRING("Upload file", "(Windows) Form submit file upload dialog title")); }
+String WebCore::allFilesText() { return String(LPCTSTR_UI_STRING("All Files", "(Windows) Form submit file upload all files pop-up")); }
+String WebCore::missingPluginText() { return String(LPCTSTR_UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing")); }
+String WebCore::crashedPluginText() { return String(LPCTSTR_UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed")); }
+
+String WebCore::imageTitle(const String& filename, const IntSize& size) 
+{ 
+    static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%@ %d\xC3\x97%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"));
+
+    RetainPtr<CFStringRef> filenameCF(AdoptCF, filename.createCFString());
+    RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), filenameCF.get(), size.width(), size.height()));
+
+    return result.get();
+}
+
+String multipleFileUploadText(unsigned numberOfFiles)
+{
+    static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"));
+    RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), numberOfFiles));
+
+    return result.get();
+}
+
+#if ENABLE(VIDEO)
+String WebCore::mediaElementLoadingStateText() { return String(LPCTSTR_UI_STRING("Loading...", "Media controller status message when the media is loading")); }
+String WebCore::mediaElementLiveBroadcastStateText() { return String(LPCTSTR_UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast")); }
+
+String WebCore::localizedMediaControlElementString(const String& name)
+{
+    if (name == "AudioElement")
+        return String(LPCTSTR_UI_STRING("audio element controller", "accessibility role description for audio element controller"));
+    if (name == "VideoElement")
+        return String(LPCTSTR_UI_STRING("video element controller", "accessibility role description for video element controller"));
+    if (name == "MuteButton")
+        return String(LPCTSTR_UI_STRING("mute", "accessibility role description for mute button"));
+    if (name == "UnMuteButton")
+        return String(LPCTSTR_UI_STRING("unmute", "accessibility role description for turn mute off button"));
+    if (name == "PlayButton")
+        return String(LPCTSTR_UI_STRING("play", "accessibility role description for play button"));
+    if (name == "PauseButton")
+        return String(LPCTSTR_UI_STRING("pause", "accessibility role description for pause button"));
+    if (name == "Slider")
+        return String(LPCTSTR_UI_STRING("movie time", "accessibility role description for timeline slider"));
+    if (name == "SliderThumb")
+        return String(LPCTSTR_UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb"));
+    if (name == "RewindButton")
+        return String(LPCTSTR_UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button"));
+    if (name == "ReturnToRealtimeButton")
+        return String(LPCTSTR_UI_STRING("return to realtime", "accessibility role description for return to real time button"));
+    if (name == "CurrentTimeDisplay")
+        return String(LPCTSTR_UI_STRING("elapsed time", "accessibility role description for elapsed time display"));
+    if (name == "TimeRemainingDisplay")
+        return String(LPCTSTR_UI_STRING("remaining time", "accessibility role description for time remaining display"));
+    if (name == "StatusDisplay")
+        return String(LPCTSTR_UI_STRING("status", "accessibility role description for movie status"));
+    if (name == "FullscreenButton")
+        return String(LPCTSTR_UI_STRING("fullscreen", "accessibility role description for enter fullscreen button"));
+    if (name == "SeekForwardButton")
+        return String(LPCTSTR_UI_STRING("fast forward", "accessibility role description for fast forward button"));
+    if (name == "SeekBackButton")
+        return String(LPCTSTR_UI_STRING("fast reverse", "accessibility role description for fast reverse button"));
+    if (name == "ShowClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("show closed captions", "accessibility role description for show closed captions button"));
+    if (name == "HideClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"));
+
+    ASSERT_NOT_REACHED();
+    return String();
+}
+
+String WebCore::localizedMediaControlElementHelpText(const String& name)
+{
+    if (name == "AudioElement")
+        return String(LPCTSTR_UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller"));
+    if (name == "VideoElement")
+        return String(LPCTSTR_UI_STRING("video element playback controls and status display", "accessibility role description for video element controller"));
+    if (name == "MuteButton")
+        return String(LPCTSTR_UI_STRING("mute audio tracks", "accessibility help text for mute button"));
+    if (name == "UnMuteButton")
+        return String(LPCTSTR_UI_STRING("unmute audio tracks", "accessibility help text for un mute button"));
+    if (name == "PlayButton")
+        return String(LPCTSTR_UI_STRING("begin playback", "accessibility help text for play button"));
+    if (name == "PauseButton")
+        return String(LPCTSTR_UI_STRING("pause playback", "accessibility help text for pause button"));
+    if (name == "Slider")
+        return String(LPCTSTR_UI_STRING("movie time scrubber", "accessibility help text for timeline slider"));
+    if (name == "SliderThumb")
+        return String(LPCTSTR_UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb"));
+    if (name == "RewindButton")
+        return String(LPCTSTR_UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button"));
+    if (name == "ReturnToRealtimeButton")
+        return String(LPCTSTR_UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button"));
+    if (name == "CurrentTimeDisplay")
+        return String(LPCTSTR_UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display"));
+    if (name == "TimeRemainingDisplay")
+        return String(LPCTSTR_UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display"));
+    if (name == "StatusDisplay")
+        return String(LPCTSTR_UI_STRING("current movie status", "accessibility help text for movie status display"));
+    if (name == "SeekBackButton")
+        return String(LPCTSTR_UI_STRING("seek quickly back", "accessibility help text for fast rewind button"));
+    if (name == "SeekForwardButton")
+        return String(LPCTSTR_UI_STRING("seek quickly forward", "accessibility help text for fast forward button"));
+    if (name == "FullscreenButton")
+        return String(LPCTSTR_UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"));
+    if (name == "ShowClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"));
+    if (name == "HideClosedCaptionsButton")
+        return String(LPCTSTR_UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"));
+
+    ASSERT_NOT_REACHED();
+    return String();
+}
+
+String WebCore::localizedMediaTimeDescription(float time)
+{
+    if (!isfinite(time))
+        return String(LPCTSTR_UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value"));
+
+    int seconds = (int)fabsf(time);
+    int days = seconds / (60 * 60 * 24);
+    int hours = seconds / (60 * 60);
+    int minutes = (seconds / 60) % 60;
+    seconds %= 60;
+
+    if (days) {
+        static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"));
+        RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), days, hours, minutes, seconds));
+        return result.get();
+    }
+
+    if (hours) {
+        static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"));
+        RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), hours, minutes, seconds));
+        return result.get();
+    }
+
+    if (minutes) {
+        static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"));
+        RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), minutes, seconds));
+        return result.get();
+    }
+
+    static RetainPtr<CFStringRef> format(AdoptCF, UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"));
+    RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormat(0, 0, format.get(), seconds));
+    return result.get();
+}
+
+#endif  // ENABLE(VIDEO)
+
+String WebCore::validationMessageValueMissingText() { return String(LPCTSTR_UI_STRING("value missing", "Validation message for required form control elements that have no value")); }
+String WebCore::validationMessageTypeMismatchText() { return String(LPCTSTR_UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type")); }
+String WebCore::validationMessagePatternMismatchText() { return String(LPCTSTR_UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern")); }
+String WebCore::validationMessageTooLongText() { return String(LPCTSTR_UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length")); }
+String WebCore::validationMessageRangeUnderflowText() { return String(LPCTSTR_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum")); }
+String WebCore::validationMessageRangeOverflowText() { return String(LPCTSTR_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum")); }
+String WebCore::validationMessageStepMismatchText() { return String(LPCTSTR_UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute")); }
diff --git a/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp b/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp
new file mode 100644 (file)
index 0000000..ffba645
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebErrors.h"
+
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/ResourceResponse.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#define WebURLErrorDomain TEXT("CFURLErrorDomain")
+
+enum
+{
+    WebURLErrorUnknown =                         -1,
+    WebURLErrorCancelled =                       -999,
+    WebURLErrorBadURL =                          -1000,
+    WebURLErrorTimedOut =                        -1001,
+    WebURLErrorUnsupportedURL =                  -1002,
+    WebURLErrorCannotFindHost =                  -1003,
+    WebURLErrorCannotConnectToHost =             -1004,
+    WebURLErrorNetworkConnectionLost =           -1005,
+    WebURLErrorDNSLookupFailed =                 -1006,
+    WebURLErrorHTTPTooManyRedirects =            -1007,
+    WebURLErrorResourceUnavailable =             -1008,
+    WebURLErrorNotConnectedToInternet =          -1009,
+    WebURLErrorRedirectToNonExistentLocation =   -1010,
+    WebURLErrorBadServerResponse =               -1011,
+    WebURLErrorUserCancelledAuthentication =     -1012,
+    WebURLErrorUserAuthenticationRequired =      -1013,
+    WebURLErrorZeroByteResource =                -1014,
+    WebURLErrorFileDoesNotExist =                -1100,
+    WebURLErrorFileIsDirectory =                 -1101,
+    WebURLErrorNoPermissionsToReadFile =         -1102,
+    WebURLErrorSecureConnectionFailed =          -1200,
+    WebURLErrorServerCertificateHasBadDate =     -1201,
+    WebURLErrorServerCertificateUntrusted =      -1202,
+    WebURLErrorServerCertificateHasUnknownRoot = -1203,
+    WebURLErrorServerCertificateNotYetValid =    -1204,
+    WebURLErrorClientCertificateRejected =       -1205,
+    WebURLErrorClientCertificateRequired =       -1206,
+    WebURLErrorCannotLoadFromNetwork =           -2000,
+
+    // Download and file I/O errors
+    WebURLErrorCannotCreateFile =                -3000,
+    WebURLErrorCannotOpenFile =                  -3001,
+    WebURLErrorCannotCloseFile =                 -3002,
+    WebURLErrorCannotWriteToFile =               -3003,
+    WebURLErrorCannotRemoveFile =                -3004,
+    WebURLErrorCannotMoveFile =                  -3005,
+    WebURLErrorDownloadDecodingFailedMidStream = -3006,
+    WebURLErrorDownloadDecodingFailedToComplete =-3007,
+};
+
+#define WebKitErrorDomain TEXT("WebKitErrorDomain")
+
+enum {
+    WebKitErrorCannotShowMIMEType =                             100,
+    WebKitErrorCannotShowURL =                                  101,
+    WebKitErrorFrameLoadInterruptedByPolicyChange =             102,
+    WebKitErrorCannotUseRestrictedPort =                        103,
+};
+
+enum {
+    WebKitErrorCannotFindPlugIn =                               200,
+    WebKitErrorCannotLoadPlugIn =                               201,
+    WebKitErrorJavaUnavailable =                                202,
+};
+
+enum {
+    WebKitErrorGeolocationLocationUnknown  =                    300,
+};
+
+#define WebKitErrorMIMETypeKey TEXT("WebKitErrorMIMETypeKey")
+#define WebKitErrorPlugInNameKey TEXT("WebKitErrorPlugInNameKey")
+#define WebKitErrorPlugInPageURLStringKey TEXT("WebKitErrorPlugInPageURLStringKey")
+
+#define WebPOSIXErrorDomain TEXT("NSPOSIXErrorDomain")
+#define WebPOSIXErrorECONNRESET 54
+
+ResourceError cancelledError(const ResourceRequest& request)
+{
+    return ResourceError(String(WebURLErrorDomain), WebURLErrorCancelled, request.url().string(), String());
+}
+
+ResourceError blockedError(const ResourceRequest& request)
+{
+    return ResourceError(String(WebKitErrorDomain), WebKitErrorCannotUseRestrictedPort, request.url().string(), String());
+}
+
+ResourceError cannotShowURLError(const ResourceRequest& request)
+{
+    return ResourceError(String(WebKitErrorDomain), WebKitErrorCannotShowURL, request.url().string(), String());
+}
+
+ResourceError interruptForPolicyChangeError(const ResourceRequest& request)
+{
+    return ResourceError(String(WebKitErrorDomain), WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), String());
+}
+
+ResourceError cannotShowMIMETypeError(const ResourceResponse& response)
+{
+    return ResourceError();
+}
+
+ResourceError fileDoesNotExistError(const ResourceResponse& response)
+{
+    return ResourceError();
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/DrawingArea.cpp b/WebKit2/WebProcess/WebPage/DrawingArea.cpp
new file mode 100644 (file)
index 0000000..d6d3061
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "DrawingArea.h"
+
+// Subclasses
+#include "DrawingAreaUpdateChunk.h"
+
+namespace WebKit {
+
+DrawingArea* DrawingArea::create(Type type, WebPage* webPage)
+{
+    DrawingArea* drawingArea = 0;
+    switch (type) {
+        case DrawingAreaUpdateChunkType:
+            drawingArea = new DrawingAreaUpdateChunk(webPage);
+            break;
+    }
+
+    return drawingArea;
+}
+
+DrawingArea::DrawingArea(Type type, WebPage* webPage)
+    : m_type(type)
+    , m_webPage(webPage)
+{
+}
+
+DrawingArea::~DrawingArea()
+{
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/DrawingArea.h b/WebKit2/WebProcess/WebPage/DrawingArea.h
new file mode 100644 (file)
index 0000000..706ac08
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 DrawingArea_h
+#define DrawingArea_h
+
+#include <WebCore/IntRect.h>
+
+namespace WebCore {
+    class IntRect;
+    class IntSize;
+}
+
+namespace CoreIPC {
+    class ArgumentDecoder;
+    class Connection;
+    class MessageID;
+}
+
+namespace WebKit {
+
+class WebPage;
+
+class DrawingArea {
+public:
+    enum Type {
+        DrawingAreaUpdateChunkType
+    };
+
+    // FIXME: It might make sense to move this create function into a factory style class. 
+    static DrawingArea* create(Type, WebPage*);
+    virtual ~DrawingArea();
+    
+    virtual void invalidateWindow(const WebCore::IntRect& rect, bool immediate) = 0;
+    virtual void invalidateContentsAndWindow(const WebCore::IntRect& rect, bool immediate) = 0;
+    virtual void invalidateContentsForSlowScroll(const WebCore::IntRect& rect, bool immediate) = 0;
+    virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect) = 0;
+
+    virtual void setNeedsDisplay(const WebCore::IntRect&) = 0;
+    virtual void display() = 0;
+
+    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&) = 0;
+
+    // The DrawingArea should never be encoded itself. Instead, the DrawingAreaProxy should be encoded.
+    // The DrawingArea should also never be decoded itself. Instead, the DrawingArea::Type should be decoded.
+
+protected:
+    DrawingArea(Type, WebPage*);
+
+    Type m_type;
+    WebPage* m_webPage;
+};
+
+} // namespace WebKit
+
+#endif // DrawingArea_h
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
new file mode 100644 (file)
index 0000000..f750056
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebFrame.h"
+
+#include "WebPage.h"
+#include <WebCore/Frame.h>
+#include <WebCore/HTMLFrameOwnerElement.h>
+#include <WebCore/PlatformString.h>
+
+#ifndef NDEBUG
+#include <wtf/RefCountedLeakCounter.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#ifndef NDEBUG
+static WTF::RefCountedLeakCounter webFrameCounter("WebFrame");
+#endif
+
+static uint64_t generateFrameID()
+{
+    static uint64_t uniqueFrameID = 1;
+    return uniqueFrameID++;
+}
+
+static uint64_t generateListenerID()
+{
+    static uint64_t uniqueListenerID = 1;
+    return uniqueListenerID++;
+}
+
+PassRefPtr<WebFrame> WebFrame::createMainFrame(WebPage* page)
+{
+    return adoptRef(new WebFrame(page, String(), 0));
+}
+
+PassRefPtr<WebFrame> WebFrame::createSubframe(WebPage* page, const String& frameName, HTMLFrameOwnerElement* ownerElement)
+{
+    return adoptRef(new WebFrame(page, frameName, ownerElement));
+}
+
+WebFrame::WebFrame(WebPage* page, const String& frameName, HTMLFrameOwnerElement* ownerElement)
+    : m_page(page)
+    , m_coreFrame(0)
+    , m_policyListenerID(0)
+    , m_policyFunction(0)
+    , m_frameLoaderClient(this)
+    , m_frameID(generateFrameID())
+{
+    // Add explict ref() that will be balanced in WebFrameLoaderClient::frameLoaderDestroyed().
+    ref();
+
+    m_page->addWebFrame(m_frameID, this);
+
+    RefPtr<Frame> frame = Frame::create(page->corePage(), ownerElement, &m_frameLoaderClient);
+    m_coreFrame = frame.get();
+
+    frame->tree()->setName(frameName);
+
+    if (ownerElement) {
+        ASSERT(ownerElement->document()->frame());
+        ownerElement->document()->frame()->tree()->appendChild(frame);
+    }
+
+    frame->init();
+
+#ifndef NDEBUG
+    webFrameCounter.increment();
+#endif
+}
+
+WebFrame::~WebFrame()
+{
+    ASSERT(!m_coreFrame);
+
+#ifndef NDEBUG
+    webFrameCounter.decrement();
+#endif
+}
+
+void WebFrame::invalidate()
+{
+    m_page->removeWebFrame(m_frameID);
+    m_coreFrame = 0;
+}
+
+uint64_t WebFrame::setUpPolicyListener(WebCore::FramePolicyFunction policyFunction)
+{
+    // FIXME: <rdar://5634381> We need to support multiple active policy listeners.
+
+    invalidatePolicyListener();
+
+    m_policyListenerID = generateListenerID();
+    m_policyFunction = policyFunction;
+    return m_policyListenerID;
+}
+
+void WebFrame::invalidatePolicyListener()
+{
+    if (!m_policyListenerID)
+        return;
+
+    m_policyListenerID = 0;
+    m_policyFunction = 0;
+}
+
+void WebFrame::didReceivePolicyDecision(uint64_t listenerID, PolicyAction action)
+{
+    if (!m_coreFrame)
+        return;
+
+    if (!m_policyListenerID)
+        return;
+
+    if (listenerID != m_policyListenerID)
+        return;
+
+    ASSERT(m_policyFunction);
+
+    FramePolicyFunction function = m_policyFunction;
+
+    invalidatePolicyListener();
+
+    (m_coreFrame->loader()->policyChecker()->*function)(action);
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.h b/WebKit2/WebProcess/WebPage/WebFrame.h
new file mode 100644 (file)
index 0000000..e60904f
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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
+
+#include "WebFrameLoaderClient.h"
+#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/PolicyChecker.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+    class Frame;
+    class HTMLFrameOwnerElement;
+    class String;
+}
+
+namespace WebKit {
+
+class WebPage;
+
+class WebFrame : public RefCounted<WebFrame> {
+public:
+    static PassRefPtr<WebFrame> createMainFrame(WebPage*);
+    static PassRefPtr<WebFrame> createSubframe(WebPage*, const WebCore::String& frameName, WebCore::HTMLFrameOwnerElement*);
+    ~WebFrame();
+
+    // Called when the FrameLoaderClient (and therefore the WebCore::Frame) is being torn down.
+    void invalidate();
+
+    WebPage* page() const { return m_page; }
+    WebCore::Frame* coreFrame() const { return m_coreFrame; }
+
+    uint64_t frameID() const { return m_frameID; }
+
+    uint64_t setUpPolicyListener(WebCore::FramePolicyFunction);
+    void invalidatePolicyListener();
+    void didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyAction);
+
+private:
+    WebFrame(WebPage*, const WebCore::String& frameName, WebCore::HTMLFrameOwnerElement*);
+
+    WebPage* m_page;
+    WebCore::Frame* m_coreFrame;
+
+    uint64_t m_policyListenerID;
+    WebCore::FramePolicyFunction m_policyFunction;
+
+    WebFrameLoaderClient m_frameLoaderClient;
+
+    uint64_t m_frameID;
+};
+
+} // namespace WebKit
+
+#endif // WebFrame_h
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
new file mode 100644 (file)
index 0000000..ad708e4
--- /dev/null
@@ -0,0 +1,436 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebPage.h"
+
+#include "Arguments.h"
+#include "MessageID.h"
+
+#include "DrawingArea.h"
+#include "WebChromeClient.h"
+#include "WebContextMenuClient.h"
+#include "WebCoreTypeArgumentMarshalling.h"
+#include "WebDragClient.h"
+#include "WebEditorClient.h"
+#include "WebEvent.h"
+#include "WebEventConversion.h"
+#include "WebFrame.h"
+#include "WebInspectorClient.h"
+#include "WebPageMessageKinds.h"
+#include "WebPageProxyMessageKinds.h"
+#include "WebPreferencesStore.h"
+#include "WebProcess.h"
+
+#include <WebCore/BackForwardList.h>
+#include <WebCore/EventHandler.h>
+#include <WebCore/FocusController.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/KURL.h>
+#include <WebCore/KeyboardEvent.h>
+#include <WebCore/Page.h>
+#include <WebCore/PlatformKeyboardEvent.h>
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/Settings.h>
+
+#include <runtime/JSLock.h>
+#include <runtime/JSValue.h>
+
+#ifndef NDEBUG
+#include <WebCore/Cache.h>
+#include <WebCore/GCController.h>
+#include <wtf/RefCountedLeakCounter.h>
+#endif
+
+using namespace JSC;
+using namespace WebCore;
+
+namespace WebKit {
+
+#ifndef NDEBUG
+static WTF::RefCountedLeakCounter webPageCounter("WebPage");
+#endif
+
+PassRefPtr<WebPage> WebPage::create(uint64_t pageID, const IntSize& viewSize, const WebPreferencesStore& store, DrawingArea::Type drawingAreaType)
+{
+    return adoptRef(new WebPage(pageID, viewSize, store, drawingAreaType));
+}
+
+WebPage::WebPage(uint64_t pageID, const IntSize& viewSize, const WebPreferencesStore& store, DrawingArea::Type drawingAreaType)
+    : m_page(new Page(new WebChromeClient(this), new WebContextMenuClient(this), new WebEditorClient(this), new WebDragClient(this), new WebInspectorClient(this), 0, 0))
+    , m_viewSize(viewSize)
+    , m_drawingArea(DrawingArea::create(drawingAreaType, this))
+    , m_canGoBack(false)
+    , m_canGoForward(false)
+    , m_pageID(pageID)
+{
+    ASSERT(m_pageID != 0);
+
+    m_page->settings()->setJavaScriptEnabled(store.javaScriptEnabled);
+    m_page->settings()->setLoadsImagesAutomatically(store.loadsImagesAutomatically);
+    m_page->settings()->setMinimumFontSize(store.minimumFontSize);
+    m_page->settings()->setMinimumLogicalFontSize(store.minimumLogicalFontSize);
+    m_page->settings()->setDefaultFontSize(store.defaultFontSize);
+    m_page->settings()->setDefaultFixedFontSize(store.defaultFixedFontSize);
+    m_page->settings()->setStandardFontFamily(store.standardFontFamily);
+    m_page->settings()->setCursiveFontFamily(store.cursiveFontFamily);
+    m_page->settings()->setFantasyFontFamily(store.fantasyFontFamily);
+    m_page->settings()->setFixedFontFamily(store.fixedFontFamily);
+    m_page->settings()->setSansSerifFontFamily(store.sansSerifFontFamily);
+    m_page->settings()->setSerifFontFamily(store.serifFontFamily);
+
+    platformInitialize();
+
+    m_mainFrame = WebFrame::createMainFrame(this);
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidCreateMainFrame, m_pageID, CoreIPC::In(m_mainFrame->frameID()));
+
+#ifndef NDEBUG
+    webPageCounter.increment();
+#endif
+}
+
+WebPage::~WebPage()
+{
+    ASSERT(!m_page);
+#ifndef NDEBUG
+    webPageCounter.decrement();
+#endif
+}
+
+WebFrame* WebPage::webFrame(uint64_t frameID) const
+{
+    return m_frameMap.get(frameID);
+}
+
+void WebPage::addWebFrame(uint64_t frameID, WebFrame* frame)
+{
+    m_frameMap.set(frameID, frame);
+}
+
+void WebPage::removeWebFrame(uint64_t frameID)
+{
+    m_frameMap.remove(frameID);
+}
+
+void WebPage::close()
+{
+    m_mainFrame->coreFrame()->loader()->detachFromParent();
+
+    delete m_page;
+    m_page = 0;
+
+    WebProcess::shared().removeWebPage(m_pageID);
+}
+
+void WebPage::tryClose()
+{
+    if (!m_mainFrame->coreFrame()->shouldClose())
+        return;
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::ClosePage, m_pageID, CoreIPC::In());
+}
+
+void WebPage::loadURL(const KURL& url)
+{
+    m_mainFrame->coreFrame()->loader()->load(ResourceRequest(url), false);
+}
+
+void WebPage::stopLoading()
+{
+    m_mainFrame->coreFrame()->loader()->stopForUserCancel();
+}
+
+void WebPage::reload()
+{
+    m_mainFrame->coreFrame()->loader()->reload(false);
+}
+
+void WebPage::goForward()
+{
+    m_page->goForward();
+}
+
+void WebPage::goBack()
+{
+    m_page->goBack();
+}
+
+void WebPage::backForwardListDidChange()
+{
+    bool canNowGoBack = !!m_page->backForwardList()->backItem();
+    if (canNowGoBack != m_canGoBack) {
+        m_canGoBack = canNowGoBack;
+        WebProcess::shared().connection()->send(WebPageProxyMessage::DidChangeCanGoBack, m_pageID, CoreIPC::In(m_canGoBack));
+    }
+
+    bool canNowGoForward = !!m_page->backForwardList()->forwardItem();
+    if (canNowGoForward != m_canGoForward) {
+        m_canGoForward = canNowGoForward;
+        WebProcess::shared().connection()->send(WebPageProxyMessage::DidChangeCanGoForward, m_pageID, CoreIPC::In(m_canGoForward));
+    }
+}
+
+void WebPage::layoutIfNeeded()
+{
+    if (m_mainFrame->coreFrame()->view())
+        m_mainFrame->coreFrame()->view()->layoutIfNeededRecursive();
+}
+
+void WebPage::setSize(const WebCore::IntSize& viewSize)
+{
+    if (m_viewSize == viewSize)
+        return;
+
+    Frame* frame = m_page->mainFrame();
+    
+    frame->view()->resize(viewSize);
+    frame->view()->setNeedsLayout();
+    m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), viewSize));
+    
+    m_viewSize = viewSize;
+}
+
+void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
+{
+    graphicsContext.save();
+    graphicsContext.clip(rect);
+    m_mainFrame->coreFrame()->view()->paint(&graphicsContext, rect);
+    graphicsContext.restore();
+}
+
+// Events 
+
+void WebPage::mouseEvent(const PlatformMouseEvent& event)
+{
+    if (!m_mainFrame->coreFrame()->view())
+        return;
+
+    switch (event.eventType()) {
+        case WebCore::MouseEventPressed:
+            m_mainFrame->coreFrame()->eventHandler()->handleMousePressEvent(event);
+            break;
+        case WebCore::MouseEventReleased:
+            m_mainFrame->coreFrame()->eventHandler()->handleMouseReleaseEvent(event);
+            break;
+        case WebCore::MouseEventMoved:
+            m_mainFrame->coreFrame()->eventHandler()->mouseMoved(event);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+}
+
+void WebPage::wheelEvent(PlatformWheelEvent& event)
+{
+    if (!m_mainFrame->coreFrame()->view())
+        return;
+
+    m_mainFrame->coreFrame()->eventHandler()->handleWheelEvent(event);
+}
+
+void WebPage::keyEvent(const PlatformKeyboardEvent& event)
+{
+    if (!m_mainFrame->coreFrame()->view())
+        return;
+
+    m_page->focusController()->focusedOrMainFrame()->eventHandler()->keyEvent(event);
+}
+
+void WebPage::setActive(bool isActive)
+{
+    m_page->focusController()->setActive(isActive);
+}
+
+void WebPage::setFocused(bool isFocused)
+{
+    m_page->focusController()->setFocused(isFocused);
+}
+
+void WebPage::didReceivePolicyDecision(WebFrame* frame, uint64_t listenerID, WebCore::PolicyAction policyAction)
+{
+    if (!frame)
+        return;
+    frame->didReceivePolicyDecision(listenerID, policyAction);
+}
+
+void WebPage::show()
+{
+    WebProcess::shared().connection()->send(WebPageProxyMessage::ShowPage, m_pageID, CoreIPC::In());
+}
+
+void WebPage::runJavaScriptInMainFrame(const WebCore::String& script, uint64_t callbackID)
+{
+    // NOTE: We need to be careful when running scripts that the objects we depend on don't
+    // disappear during script execution.
+
+    JSLock lock(SilenceAssertionsOnly);
+    JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue();
+    String resultString = resultValue.toString(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec());
+
+    WebProcess::shared().connection()->send(WebPageProxyMessage::DidRunJavaScriptInMainFrame, m_pageID, CoreIPC::In(resultString, callbackID));
+}
+
+void WebPage::preferencesDidChange(const WebPreferencesStore& store)
+{
+    m_page->settings()->setJavaScriptEnabled(store.javaScriptEnabled);
+    m_page->settings()->setLoadsImagesAutomatically(store.loadsImagesAutomatically);
+}
+
+bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt)
+{
+    Node* node = evt->target()->toNode();
+    ASSERT(node);
+    Frame* frame = node->document()->frame();
+    ASSERT(frame);
+
+    const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
+    if (!keyEvent)
+        return false;
+
+    Editor::Command command = frame->editor()->command(interpretKeyEvent(evt));
+
+    if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+        // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
+        // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
+        // (e.g. Tab that inserts a Tab character, or Enter).
+        return !command.isTextInsertion() && command.execute(evt);
+    }
+
+     if (command.execute(evt))
+        return true;
+
+    // Don't insert null or control characters as they can result in unexpected behaviour
+    if (evt->charCode() < ' ')
+        return false;
+
+    return frame->editor()->insertText(evt->keyEvent()->text(), evt);
+}
+
+void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments)
+{
+    if (messageID.is<CoreIPC::MessageClassDrawingArea>()) {
+        ASSERT(m_drawingArea);
+        m_drawingArea->didReceiveMessage(connection, messageID, arguments);
+        return;
+    }
+
+    switch (messageID.get<WebPageMessage::Kind>()) {
+        case WebPageMessage::SetActive: {
+            bool active;
+            if (!arguments.decode(active))
+                return;
+         
+            setActive(active);
+            break;
+        }
+        case WebPageMessage::SetFocused: {
+            bool focused;
+            if (!arguments.decode(focused))
+                return;
+            
+            setFocused(focused);
+            break;
+        }
+        case WebPageMessage::MouseEvent: {
+            WebMouseEvent event;
+            if (!arguments.decode(event))
+                return;
+            connection->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In((uint32_t)event.type()));
+            PlatformMouseEvent platformEvent = platform(event);
+            mouseEvent(platformEvent);
+            break;
+        }
+        case WebPageMessage::WheelEvent: {
+            WebWheelEvent event;
+            if (!arguments.decode(event))
+                return;
+            connection->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In((uint32_t)event.type()));
+            PlatformWheelEvent platformEvent = platform(event);
+            wheelEvent(platformEvent);
+            break;
+        }
+        case WebPageMessage::KeyEvent: {
+            WebKeyboardEvent event;
+            if (!arguments.decode(event))
+                return;
+            connection->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In((uint32_t)event.type()));
+            PlatformKeyboardEvent platformEvent = platform(event);
+            keyEvent(platformEvent);
+            break;
+        }
+        case WebPageMessage::LoadURL: {
+            KURL url;
+            if (!arguments.decode(url))
+                return;
+            
+            loadURL(url);
+            break;
+        }
+        case WebPageMessage::StopLoading:
+            stopLoading();
+            break;
+        case WebPageMessage::Reload:
+            reload();
+            break;
+        case WebPageMessage::GoForward:
+            goForward();
+            break;
+        case WebPageMessage::GoBack:
+            goBack();
+            break;
+        case WebPageMessage::DidReceivePolicyDecision: {
+            uint64_t frameID;
+            uint64_t listenerID;
+            uint32_t policyAction;
+            if (!arguments.decode(CoreIPC::Out(frameID, listenerID, policyAction)))
+                return;
+            didReceivePolicyDecision(webFrame(frameID), listenerID, (WebCore::PolicyAction)policyAction);
+            break;
+        }
+        case WebPageMessage::RunJavaScriptInMainFrame: {
+            String script;
+            uint64_t callbackID;
+            if (!arguments.decode(CoreIPC::Out(script, callbackID)))
+                return;
+            runJavaScriptInMainFrame(script, callbackID);
+            break;
+        }
+        case WebPageMessage::Close: {
+            close();
+            break;
+        }
+        case WebPageMessage::TryClose: {
+            tryClose();
+            break;
+        }
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
new file mode 100644 (file)
index 0000000..4cc5a7a
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebPage_h
+#define WebPage_h
+
+#include "DrawingArea.h"
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/IntRect.h>
+#include <wtf/HashMap.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace CoreIPC {
+    class ArgumentDecoder;
+    class Connection;
+    class MessageID;
+}
+
+namespace WebCore {
+    class GraphicsContext;
+    class KURL;
+    class KeyboardEvent;
+    class Page;
+    class PlatformKeyboardEvent;
+    class PlatformMouseEvent;
+    class PlatformWheelEvent;
+    class String;
+}
+
+namespace WebKit {
+
+class DrawingArea;
+class WebFrame;
+class WebPreferencesStore;
+
+class WebPage : public RefCounted<WebPage> {
+public:
+    static PassRefPtr<WebPage> create(uint64_t pageID, const WebCore::IntSize& viewSize, const WebPreferencesStore&, DrawingArea::Type);
+    ~WebPage();
+
+    WebCore::Page* corePage() const { return m_page; }
+    uint64_t pageID() const { return m_pageID; }
+
+    WebFrame* webFrame(uint64_t) const;
+    void addWebFrame(uint64_t, WebFrame*);
+    void removeWebFrame(uint64_t);
+
+    void setSize(const WebCore::IntSize&);
+    const WebCore::IntSize& size() const { return m_viewSize; }
+
+    DrawingArea* drawingArea() const { return m_drawingArea; }
+
+    // -- Called by the DrawingArea.
+    // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
+    void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
+    void layoutIfNeeded();
+
+    // -- Called from WebCore clients.
+    void backForwardListDidChange();
+    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
+    void show();
+
+    // -- Called from WebProcess.
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&);
+
+private:
+    WebPage(uint64_t pageID, const WebCore::IntSize& viewSize, const WebPreferencesStore&, DrawingArea::Type);
+
+    void platformInitialize();
+    static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
+
+    // Actions
+    void close();
+    void tryClose();
+    void loadURL(const WebCore::KURL&);
+    void stopLoading();
+    void reload();
+    void goForward();
+    void goBack();
+    void setActive(bool);
+    void setFocused(bool);
+    void mouseEvent(const WebCore::PlatformMouseEvent&);
+    void wheelEvent(WebCore::PlatformWheelEvent&);
+    void keyEvent(const WebCore::PlatformKeyboardEvent&);
+    void runJavaScriptInMainFrame(const WebCore::String&, uint64_t callbackID);
+    void preferencesDidChange(const WebPreferencesStore&);
+
+    void didReceivePolicyDecision(WebFrame*, uint64_t listenerID, WebCore::PolicyAction policyAction);
+    
+    WebCore::Page* m_page;
+    RefPtr<WebFrame> m_mainFrame;
+    HashMap<uint64_t, WebFrame*> m_frameMap;
+
+    WebCore::IntSize m_viewSize;
+    DrawingArea* m_drawingArea;
+
+    bool m_canGoBack;
+    bool m_canGoForward;
+
+    uint64_t m_pageID;
+};
+
+} // namespace WebKit
+
+#endif // WebPage_h
diff --git a/WebKit2/WebProcess/WebPage/mac/DrawingAreaUpdateChunk.cpp b/WebKit2/WebProcess/WebPage/mac/DrawingAreaUpdateChunk.cpp
new file mode 100644 (file)
index 0000000..0bd0eb8
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "DrawingAreaUpdateChunk.h"
+
+#include "MessageID.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "UpdateChunk.h"
+#include "WebCoreTypeArgumentMarshalling.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <WebCore/GraphicsContext.h>
+#include <wtf/RetainPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DrawingAreaUpdateChunk::DrawingAreaUpdateChunk(WebPage* webPage)
+    : DrawingArea(DrawingAreaUpdateChunkType, webPage)
+    , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaUpdateChunk::display)
+{
+}
+
+DrawingAreaUpdateChunk::~DrawingAreaUpdateChunk()
+{
+}
+
+void DrawingAreaUpdateChunk::invalidateWindow(const IntRect& rect, bool immediate)
+{
+}
+
+void DrawingAreaUpdateChunk::invalidateContentsAndWindow(const IntRect& rect, bool immediate)
+{
+    setNeedsDisplay(rect);
+}
+
+void DrawingAreaUpdateChunk::invalidateContentsForSlowScroll(const IntRect& rect, bool immediate)
+{
+    setNeedsDisplay(rect);
+}
+
+void DrawingAreaUpdateChunk::scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
+{
+    // FIXME: Do something much smarter.
+    setNeedsDisplay(rectToScroll);
+}
+
+void DrawingAreaUpdateChunk::setNeedsDisplay(const IntRect& rect)
+{
+    // FIXME: Collect a set of rects/region instead of just the union
+    // of all rects.
+    m_dirtyRect.unite(rect);
+    scheduleDisplay();
+}
+
+void DrawingAreaUpdateChunk::display()
+{
+    if (m_dirtyRect.isEmpty())
+        return;
+
+    // Layout if necessary.
+    m_webPage->layoutIfNeeded();
+    IntRect dirtyRect = m_dirtyRect;
+    m_dirtyRect = IntRect();
+
+    // FIXME: Move this code to draw into an UpdateChunk into a seperate function.
+
+    // Create a new UpdateChunk and paint into it.
+    UpdateChunk updateChunk(dirtyRect);
+
+    RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+    RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(updateChunk.data(), dirtyRect.width(), dirtyRect.height(), 8, dirtyRect.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedLast));
+
+    // Now paint into the backing store.
+    GraphicsContext graphicsContext(bitmapContext.get());
+    graphicsContext.translate(-dirtyRect.x(), -dirtyRect.y());
+
+    m_webPage->drawRect(graphicsContext, dirtyRect);
+
+    WebProcess::shared().connection()->send(DrawingAreaProxyMessage::Update, m_webPage->pageID(), CoreIPC::In(updateChunk));
+
+    m_displayTimer.stop();
+}
+
+void DrawingAreaUpdateChunk::scheduleDisplay()
+{
+    if (m_displayTimer.isActive())
+        return;
+
+    m_displayTimer.startOneShot(0);
+}
+
+void DrawingAreaUpdateChunk::setSize(const IntSize& viewSize)
+{
+    m_webPage->setSize(viewSize);
+
+    // FIXME: Move this code to draw into an UpdateChunk into a seperate function.
+
+    // Layout if necessary.
+    m_webPage->layoutIfNeeded();
+
+    IntRect rect(0, 0, viewSize.width(), viewSize.height());
+
+    // Create a new UpdateChunk and paint into it.
+    UpdateChunk updateChunk(rect);
+
+    RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+    RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(updateChunk.data(), rect.width(), rect.height(), 8, rect.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedLast));
+
+    // Now paint into the backing store.
+    GraphicsContext graphicsContext(bitmapContext.get());
+    graphicsContext.translate(-rect.x(), -rect.y());
+
+    m_webPage->drawRect(graphicsContext, rect);
+
+    m_displayTimer.stop();
+
+    WebProcess::shared().connection()->send(DrawingAreaProxyMessage::DidSetFrame, m_webPage->pageID(), CoreIPC::In(viewSize, updateChunk));
+}
+
+void DrawingAreaUpdateChunk::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments)
+{
+    switch (messageID.get<DrawingAreaMessage::Kind>()) {
+        case DrawingAreaMessage::SetFrame: {
+            IntSize size;
+            if (!arguments.decode(CoreIPC::Out(size)))
+                return;
+
+            setSize(size);
+            break;
+        }
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/mac/DrawingAreaUpdateChunk.h b/WebKit2/WebProcess/WebPage/mac/DrawingAreaUpdateChunk.h
new file mode 100644 (file)
index 0000000..09e1975
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 DrawingAreaUpdateChunk_h
+#define DrawingAreaUpdateChunk_h
+
+#include "DrawingArea.h"
+#include "RunLoop.h"
+#include <WebCore/IntPoint.h>
+
+namespace WebKit {
+
+class DrawingAreaUpdateChunk : public DrawingArea {
+public:
+    DrawingAreaUpdateChunk(WebPage*);
+    virtual ~DrawingAreaUpdateChunk();
+
+    virtual void invalidateWindow(const WebCore::IntRect& rect, bool immediate);
+    virtual void invalidateContentsAndWindow(const WebCore::IntRect& rect, bool immediate);
+    virtual void invalidateContentsForSlowScroll(const WebCore::IntRect& rect, bool immediate);
+    virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect);
+    virtual void setNeedsDisplay(const WebCore::IntRect&);
+    virtual void display();
+
+    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&);
+
+private:
+    void scheduleDisplay();
+    void setSize(const WebCore::IntSize& viewSize);
+
+    WebCore::IntRect m_dirtyRect;
+    RunLoop::Timer<DrawingAreaUpdateChunk> m_displayTimer;
+};
+
+} // namespace WebKit
+
+#endif // DrawingAreaUpdateChunk_h
diff --git a/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
new file mode 100644 (file)
index 0000000..ff7929b
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebPage.h"
+
+#include <WebCore/KeyboardEvent.h>
+#include <WebCore/Page.h>
+#include <WebCore/PlatformKeyboardEvent.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPage::platformInitialize()
+{
+    m_page->addSchedulePair(SchedulePair::create([NSRunLoop currentRunLoop], kCFRunLoopCommonModes));
+}
+
+// FIXME: Editor commands should not be hard coded and instead should come from AppKit.  
+
+static const unsigned CtrlKey   = 1 << 0;
+static const unsigned AltKey    = 1 << 1;
+static const unsigned ShiftKey  = 1 << 2;
+static const unsigned MetaKey   = 1 << 3;
+
+static const unsigned VKEY_BACK         = 0x08;
+static const unsigned VKEY_TAB          = 0x09;
+static const unsigned VKEY_RETURN       = 0x0D;
+static const unsigned VKEY_ESCAPE       = 0x1B;
+static const unsigned VKEY_PRIOR        = 0x21;
+static const unsigned VKEY_NEXT         = 0x22;
+static const unsigned VKEY_END          = 0x23;
+static const unsigned VKEY_HOME         = 0x24;
+static const unsigned VKEY_LEFT         = 0x25;
+static const unsigned VKEY_UP           = 0x26;
+static const unsigned VKEY_RIGHT        = 0x27;
+static const unsigned VKEY_DOWN         = 0x28;
+static const unsigned VKEY_INSERT       = 0x2D;
+static const unsigned VKEY_DELETE       = 0x2E;
+static const unsigned VKEY_OEM_PERIOD   = 0xBE;
+
+// Keys with special meaning. These will be delegated to the editor using
+// the execCommand() method
+struct KeyDownEntry {
+    unsigned virtualKey;
+    unsigned modifiers;
+    const char* name;
+};
+
+struct KeyPressEntry {
+    unsigned charCode;
+    unsigned modifiers;
+    const char* name;
+};
+
+static const KeyDownEntry keyDownEntries[] = {
+    { VKEY_LEFT,   0,                   "MoveLeft"                                      },
+    { VKEY_LEFT,   ShiftKey,            "MoveLeftAndModifySelection"                    },
+    { VKEY_LEFT,   AltKey,              "MoveWordLeft"                                  },
+    { VKEY_LEFT,   AltKey | ShiftKey,   "MoveWordLeftAndModifySelection"                },
+    { VKEY_RIGHT,  0,                   "MoveRight"                                     },
+    { VKEY_RIGHT,  ShiftKey,            "MoveRightAndModifySelection"                   },
+    { VKEY_RIGHT,  AltKey,              "MoveWordRight"                                 },
+    { VKEY_RIGHT,  AltKey | ShiftKey,   "MoveWordRightAndModifySelection"               },
+    { VKEY_UP,     0,                   "MoveUp"                                        },
+    { VKEY_UP,     ShiftKey,            "MoveUpAndModifySelection"                      },
+    { VKEY_PRIOR,  ShiftKey,            "MovePageUpAndModifySelection"                  },
+    { VKEY_DOWN,   0,                   "MoveDown"                                      },
+    { VKEY_DOWN,   ShiftKey,            "MoveDownAndModifySelection"                    },
+    { VKEY_NEXT,   ShiftKey,            "MovePageDownAndModifySelection"                },
+    { VKEY_PRIOR,  0,                   "MovePageUp"                                    },
+    { VKEY_NEXT,   0,                   "MovePageDown"                                  },
+
+    { VKEY_HOME,   0,                   "MoveToBeginningOfLine"                         },
+    { VKEY_HOME,   ShiftKey,            "MoveToBeginningOfLineAndModifySelection"       },
+    { VKEY_LEFT,   MetaKey,             "MoveToBeginningOfLine"                         },
+    { VKEY_LEFT,   MetaKey | ShiftKey,  "MoveToBeginningOfLineAndModifySelection"       },
+    { VKEY_UP,     MetaKey,             "MoveToBeginningOfDocument"                     },
+    { VKEY_UP,     MetaKey | ShiftKey,  "MoveToBeginningOfDocumentAndModifySelection"   },
+
+    { VKEY_END,    0,                   "MoveToEndOfLine"                               },
+    { VKEY_END,    ShiftKey,            "MoveToEndOfLineAndModifySelection"             },
+    { VKEY_DOWN,   MetaKey,             "MoveToEndOfDocument"                           },
+    { VKEY_DOWN,   MetaKey | ShiftKey,  "MoveToEndOfDocumentAndModifySelection"         },
+    { VKEY_RIGHT,  MetaKey,             "MoveToEndOfLine"                               },
+    { VKEY_RIGHT,  MetaKey | ShiftKey,  "MoveToEndOfLineAndModifySelection"             },
+
+    { VKEY_BACK,   0,                   "DeleteBackward"                                },
+    { VKEY_BACK,   ShiftKey,            "DeleteBackward"                                },
+    { VKEY_DELETE, 0,                   "DeleteForward"                                 },
+    { VKEY_BACK,   AltKey,              "DeleteWordBackward"                            },
+    { VKEY_DELETE, AltKey,              "DeleteWordForward"                             },
+
+    { 'B',         CtrlKey,             "ToggleBold"                                    },
+    { 'I',         CtrlKey,             "ToggleItalic"                                  },
+
+    { VKEY_ESCAPE, 0,                   "Cancel"                                        },
+    { VKEY_OEM_PERIOD, CtrlKey,         "Cancel"                                        },
+    { VKEY_TAB,    0,                   "InsertTab"                                     },
+    { VKEY_TAB,    ShiftKey,            "InsertBacktab"                                 },
+    { VKEY_RETURN, 0,                   "InsertNewline"                                 },
+    { VKEY_RETURN, CtrlKey,             "InsertNewline"                                 },
+    { VKEY_RETURN, AltKey,              "InsertNewline"                                 },
+    { VKEY_RETURN, AltKey | ShiftKey,   "InsertNewline"                                 },
+    { VKEY_RETURN, ShiftKey,            "InsertLineBreak"                               },
+
+    { 'C',         MetaKey,             "Copy"                                          },
+    { 'V',         MetaKey,             "Paste"                                         },
+    { 'X',         MetaKey,             "Cut"                                           },
+    { 'A',         MetaKey,             "SelectAll"                                     },
+    { VKEY_INSERT, CtrlKey,             "Copy"                                          },
+    { VKEY_INSERT, ShiftKey,            "Paste"                                         },
+    { VKEY_DELETE, ShiftKey,            "Cut"                                           },
+    { 'Z',         MetaKey,             "Undo"                                          },
+    { 'Z',         MetaKey | ShiftKey,  "Redo"                                          },
+};
+
+static const KeyPressEntry keyPressEntries[] = {
+    { '\t',        0,                   "InsertTab"                                     },
+    { '\t',        ShiftKey,            "InsertBacktab"                                 },
+    { '\r',        0,                   "InsertNewline"                                 },
+    { '\r',        CtrlKey,             "InsertNewline"                                 },
+    { '\r',        ShiftKey,            "InsertLineBreak"                               },
+    { '\r',        AltKey,              "InsertNewline"                                 },
+    { '\r',        AltKey | ShiftKey,   "InsertNewline"                                 },
+};
+
+const char* WebPage::interpretKeyEvent(const KeyboardEvent* evt)
+{
+    const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
+    ASSERT(keyEvent);
+
+    static HashMap<int, const char*>* keyDownCommandsMap = 0;
+    static HashMap<int, const char*>* keyPressCommandsMap = 0;
+
+    if (!keyDownCommandsMap) {
+        keyDownCommandsMap = new HashMap<int, const char*>;
+        keyPressCommandsMap = new HashMap<int, const char*>;
+
+        for (unsigned i = 0; i < (sizeof(keyDownEntries) / sizeof(keyDownEntries[0])); i++) {
+            keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey,
+                                    keyDownEntries[i].name);
+        }
+
+        for (unsigned i = 0; i < (sizeof(keyPressEntries) / sizeof(keyPressEntries[0])); i++) {
+            keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode,
+                                     keyPressEntries[i].name);
+        }
+    }
+
+    unsigned modifiers = 0;
+    if (keyEvent->shiftKey())
+        modifiers |= ShiftKey;
+    if (keyEvent->altKey())
+        modifiers |= AltKey;
+    if (keyEvent->ctrlKey())
+        modifiers |= CtrlKey;
+    if (keyEvent->metaKey())
+        modifiers |= MetaKey;
+
+    if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+        int mapKey = modifiers << 16 | evt->keyCode();
+        return mapKey ? keyDownCommandsMap->get(mapKey) : 0;
+    }
+
+    int mapKey = modifiers << 16 | evt->charCode();
+    return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/win/DrawingAreaUpdateChunk.cpp b/WebKit2/WebProcess/WebPage/win/DrawingAreaUpdateChunk.cpp
new file mode 100644 (file)
index 0000000..6455c07
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "DrawingAreaUpdateChunk.h"
+
+#include "MessageID.h"
+
+#include "WebPage.h"
+#include "UpdateChunk.h"
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "WebCoreTypeArgumentMarshalling.h"
+#include "WebProcess.h"
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+
+DrawingAreaUpdateChunk::DrawingAreaUpdateChunk(WebPage* webPage)
+    : DrawingArea(DrawingAreaUpdateChunkType, webPage)
+    , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingArea::display)
+{
+}
+
+DrawingAreaUpdateChunk::~DrawingAreaUpdateChunk()
+{
+}
+
+void DrawingAreaUpdateChunk::invalidateWindow(const IntRect& rect, bool immediate)
+{
+}
+
+void DrawingAreaUpdateChunk::invalidateContentsAndWindow(const IntRect& rect, bool immediate)
+{
+    setNeedsDisplay(rect);
+}
+
+void DrawingAreaUpdateChunk::invalidateContentsForSlowScroll(const IntRect& rect, bool immediate)
+{
+    setNeedsDisplay(rect);
+}
+
+void DrawingAreaUpdateChunk::scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
+{
+    setNeedsDisplay(rectToScroll);
+}
+
+void DrawingAreaUpdateChunk::setNeedsDisplay(const WebCore::IntRect& rect)
+{
+    m_dirtyRect.unite(rect);
+    scheduleDisplay();
+}
+
+void DrawingAreaUpdateChunk::display()
+{
+    if (m_dirtyRect.isEmpty())
+        return;
+
+    // Layout if necessary.
+    m_webPage->layoutIfNeeded();
+
+    IntRect dirtyRect = m_dirtyRect;
+    m_dirtyRect = IntRect();
+
+    OwnPtr<HDC> hdc(::CreateCompatibleDC(0));
+
+    // Create our shared memory mapping.
+    unsigned memorySize = dirtyRect.height() * dirtyRect.width() * 4;
+    HANDLE memory = ::CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, memorySize, 0);
+
+    void* bits;
+    BitmapInfo bmp = BitmapInfo::createBottomUp(dirtyRect.size());
+    OwnPtr<HBITMAP> hbmp(::CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, memory, 0));
+
+    HBITMAP hbmpOld = static_cast<HBITMAP>(::SelectObject(hdc.get(), hbmp.get()));
+    
+    GraphicsContext gc(hdc.get());
+    gc.save();
+    
+    // FIXME: Is this white fill needed?
+    RECT rect = dirtyRect;
+    ::FillRect(hdc.get(), &rect, (HBRUSH)::GetStockObject(WHITE_BRUSH));
+    gc.translate(-dirtyRect.x(), -dirtyRect.y());
+
+    m_webPage->drawRect(gc, dirtyRect);
+
+    gc.restore();
+
+    // Re-select the old HBITMAP
+    ::SelectObject(hdc.get(), hbmpOld);
+
+    UpdateChunk updateChunk(dirtyRect, memory);
+
+    WebProcess::shared().connection()->send(DrawingAreaProxyMessage::Update, m_webPage->pageID(), CoreIPC::In(updateChunk));
+
+    m_displayTimer.stop();
+}
+
+void DrawingAreaUpdateChunk::scheduleDisplay()
+{
+    if (m_displayTimer.isActive())
+        return;
+
+    m_displayTimer.startOneShot(0);
+}
+
+void DrawingAreaUpdateChunk::setSize(const WebCore::IntSize& size)
+{
+    m_webPage->setSize(size);
+}
+
+void DrawingAreaUpdateChunk::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments)
+{
+    switch (messageID.get<DrawingAreaMessage::Kind>()) {
+        case DrawingAreaMessage::SetFrame: {
+            IntSize size;
+            if (!arguments.decode(size))
+                return;
+            setSize(size);
+            break;
+        }
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/win/DrawingAreaUpdateChunk.h b/WebKit2/WebProcess/WebPage/win/DrawingAreaUpdateChunk.h
new file mode 100644 (file)
index 0000000..f9da1de
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 DrawingAreaUpdateChunk_h
+#define DrawingAreaUpdateChunk_h
+
+#include "DrawingArea.h"
+#include "RunLoop.h"
+
+namespace WebCore {
+    class IntSize;
+}
+
+namespace CoreIPC {
+    class ArgumentDecoder;
+    class Connection;
+    class MessageID;
+}
+
+namespace WebKit {
+
+class WebPage;
+
+class DrawingAreaUpdateChunk : public DrawingArea {
+public:
+    DrawingAreaUpdateChunk(WebPage*);
+    virtual ~DrawingAreaUpdateChunk();
+
+    virtual void invalidateWindow(const WebCore::IntRect& rect, bool immediate);
+    virtual void invalidateContentsAndWindow(const WebCore::IntRect& rect, bool immediate);
+    virtual void invalidateContentsForSlowScroll(const WebCore::IntRect& rect, bool immediate);
+    virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect);
+    virtual void setNeedsDisplay(const WebCore::IntRect&);
+    virtual void display();
+
+    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&);
+
+private:
+    void setSize(const WebCore::IntSize&);
+    void scheduleDisplay();
+
+    WebCore::IntRect m_dirtyRect;
+    RunLoop::Timer<DrawingArea> m_displayTimer;
+};
+    
+} // namespace WebKit
+
+#endif // DrawingAreaUpdateChunk_h
diff --git a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
new file mode 100644 (file)
index 0000000..8c73ee0
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebPage.h"
+
+#include <WebCore/KeyboardEvent.h>
+#include <WebCore/Page.h>
+#include <WebCore/PlatformKeyboardEvent.h>
+
+#include <WinUser.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPage::platformInitialize()
+{
+}
+
+static const unsigned CtrlKey = 1 << 0;
+static const unsigned AltKey = 1 << 1;
+static const unsigned ShiftKey = 1 << 2;
+
+struct KeyDownEntry {
+    unsigned virtualKey;
+    unsigned modifiers;
+    const char* name;
+};
+
+struct KeyPressEntry {
+    unsigned charCode;
+    unsigned modifiers;
+    const char* name;
+};
+
+static const KeyDownEntry keyDownEntries[] = {
+    { VK_LEFT,   0,                  "MoveLeft"                                    },
+    { VK_LEFT,   ShiftKey,           "MoveLeftAndModifySelection"                  },
+    { VK_LEFT,   CtrlKey,            "MoveWordLeft"                                },
+    { VK_LEFT,   CtrlKey | ShiftKey, "MoveWordLeftAndModifySelection"              },
+    { VK_RIGHT,  0,                  "MoveRight"                                   },
+    { VK_RIGHT,  ShiftKey,           "MoveRightAndModifySelection"                 },
+    { VK_RIGHT,  CtrlKey,            "MoveWordRight"                               },
+    { VK_RIGHT,  CtrlKey | ShiftKey, "MoveWordRightAndModifySelection"             },
+    { VK_UP,     0,                  "MoveUp"                                      },
+    { VK_UP,     ShiftKey,           "MoveUpAndModifySelection"                    },
+    { VK_PRIOR,  ShiftKey,           "MovePageUpAndModifySelection"                },
+    { VK_DOWN,   0,                  "MoveDown"                                    },
+    { VK_DOWN,   ShiftKey,           "MoveDownAndModifySelection"                  },
+    { VK_NEXT,   ShiftKey,           "MovePageDownAndModifySelection"              },
+    { VK_PRIOR,  0,                  "MovePageUp"                                  },
+    { VK_NEXT,   0,                  "MovePageDown"                                },
+    { VK_HOME,   0,                  "MoveToBeginningOfLine"                       },
+    { VK_HOME,   ShiftKey,           "MoveToBeginningOfLineAndModifySelection"     },
+    { VK_HOME,   CtrlKey,            "MoveToBeginningOfDocument"                   },
+    { VK_HOME,   CtrlKey | ShiftKey, "MoveToBeginningOfDocumentAndModifySelection" },
+
+    { VK_END,    0,                  "MoveToEndOfLine"                             },
+    { VK_END,    ShiftKey,           "MoveToEndOfLineAndModifySelection"           },
+    { VK_END,    CtrlKey,            "MoveToEndOfDocument"                         },
+    { VK_END,    CtrlKey | ShiftKey, "MoveToEndOfDocumentAndModifySelection"       },
+
+    { VK_BACK,   0,                  "DeleteBackward"                              },
+    { VK_BACK,   ShiftKey,           "DeleteBackward"                              },
+    { VK_DELETE, 0,                  "DeleteForward"                               },
+    { VK_BACK,   CtrlKey,            "DeleteWordBackward"                          },
+    { VK_DELETE, CtrlKey,            "DeleteWordForward"                           },
+    
+    { 'B',       CtrlKey,            "ToggleBold"                                  },
+    { 'I',       CtrlKey,            "ToggleItalic"                                },
+
+    { VK_ESCAPE, 0,                  "Cancel"                                      },
+    { VK_OEM_PERIOD, CtrlKey,        "Cancel"                                      },
+    { VK_TAB,    0,                  "InsertTab"                                   },
+    { VK_TAB,    ShiftKey,           "InsertBacktab"                               },
+    { VK_RETURN, 0,                  "InsertNewline"                               },
+    { VK_RETURN, CtrlKey,            "InsertNewline"                               },
+    { VK_RETURN, AltKey,             "InsertNewline"                               },
+    { VK_RETURN, ShiftKey,           "InsertNewline"                               },
+    { VK_RETURN, AltKey | ShiftKey,  "InsertNewline"                               },
+
+    // It's not quite clear whether clipboard shortcuts and Undo/Redo should be handled
+    // in the application or in WebKit. We chose WebKit.
+    { 'C',       CtrlKey,            "Copy"                                        },
+    { 'V',       CtrlKey,            "Paste"                                       },
+    { 'X',       CtrlKey,            "Cut"                                         },
+    { 'A',       CtrlKey,            "SelectAll"                                   },
+    { VK_INSERT, CtrlKey,            "Copy"                                        },
+    { VK_DELETE, ShiftKey,           "Cut"                                         },
+    { VK_INSERT, ShiftKey,           "Paste"                                       },
+    { 'Z',       CtrlKey,            "Undo"                                        },
+    { 'Z',       CtrlKey | ShiftKey, "Redo"                                        },
+};
+
+static const KeyPressEntry keyPressEntries[] = {
+    { '\t',   0,                  "InsertTab"                                   },
+    { '\t',   ShiftKey,           "InsertBacktab"                               },
+    { '\r',   0,                  "InsertNewline"                               },
+    { '\r',   CtrlKey,            "InsertNewline"                               },
+    { '\r',   AltKey,             "InsertNewline"                               },
+    { '\r',   ShiftKey,           "InsertNewline"                               },
+    { '\r',   AltKey | ShiftKey,  "InsertNewline"                               },
+};
+
+const char* WebPage::interpretKeyEvent(const KeyboardEvent* evt)
+{
+    ASSERT(evt->type() == eventNames().keydownEvent || evt->type() == eventNames().keypressEvent);
+
+    static HashMap<int, const char*>* keyDownCommandsMap = 0;
+    static HashMap<int, const char*>* keyPressCommandsMap = 0;
+
+    if (!keyDownCommandsMap) {
+        keyDownCommandsMap = new HashMap<int, const char*>;
+        keyPressCommandsMap = new HashMap<int, const char*>;
+
+        for (unsigned i = 0; i < _countof(keyDownEntries); i++)
+            keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, keyDownEntries[i].name);
+
+        for (unsigned i = 0; i < _countof(keyPressEntries); i++)
+            keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode, keyPressEntries[i].name);
+    }
+
+    unsigned modifiers = 0;
+    if (evt->shiftKey())
+        modifiers |= ShiftKey;
+    if (evt->altKey())
+        modifiers |= AltKey;
+    if (evt->ctrlKey())
+        modifiers |= CtrlKey;
+
+    if (evt->type() == eventNames().keydownEvent) {
+        int mapKey = modifiers << 16 | evt->keyCode();
+        return mapKey ? keyDownCommandsMap->get(mapKey) : 0;
+    }
+
+    int mapKey = modifiers << 16 | evt->charCode();
+    return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
new file mode 100644 (file)
index 0000000..cb8cf58
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2009, 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "WebProcess.h"
+
+#include "RunLoop.h"
+#include "WebCoreTypeArgumentMarshalling.h"
+#include "WebFrame.h"
+#include "WebPage.h"
+#include "WebPreferencesStore.h"
+#include "WebProcessMessageKinds.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebProcess& WebProcess::shared()
+{
+    static WebProcess& process = *new WebProcess;
+    return process;
+}
+
+WebProcess::WebProcess()
+{
+}
+
+void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, RunLoop* runLoop)
+{
+    ASSERT(!m_connection);
+
+    m_connection = CoreIPC::Connection::createClientConnection(serverIdentifier, this, runLoop);
+    m_connection->open();
+
+    m_runLoop = runLoop;
+}
+
+WebPage* WebProcess::webPage(uint64_t pageID) const
+{
+    return m_pageMap.get(pageID).get();
+}
+
+WebPage* WebProcess::createWebPage(uint64_t pageID, const IntSize& viewSize, const WebPreferencesStore& store, DrawingArea::Type drawingAreaType)
+{
+    std::pair<HashMap<uint64_t, RefPtr<WebPage> >::iterator, bool> result = m_pageMap.add(pageID, WebPage::create(pageID, viewSize, store, drawingAreaType));
+    ASSERT(result.second);
+    return result.first->second.get();
+}
+
+void WebProcess::removeWebPage(uint64_t pageID)
+{
+    m_pageMap.remove(pageID);
+
+    // If we don't have any pages left, shut down.
+    if (m_pageMap.isEmpty())
+        shutdown();
+}
+
+bool WebProcess::isSeparateProcess() const
+{
+    // If we're running on the main run loop, we assume that we're in a separate process.
+    return m_runLoop == RunLoop::mainRunLoop();
+}
+void WebProcess::shutdown()
+{
+    // Keep running forever if we're running in the same process.
+    if (!isSeparateProcess())
+        return;
+    
+    // Invalidate our connection.
+    m_connection->invalidate();
+    m_connection = 0;
+
+    m_runLoop->stop();
+}
+
+void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+    if (messageID.is<CoreIPC::MessageClassWebProcess>()) {
+        switch (messageID.get<WebProcessMessage::Kind>()) {
+            case WebProcessMessage::Create: {
+                uint64_t pageID = arguments->destinationID();
+                IntSize viewSize;
+                WebPreferencesStore store;
+                uint32_t drawingAreaType;
+                if (!arguments->decode(CoreIPC::Out(viewSize, store, drawingAreaType)))
+                    return;
+
+                createWebPage(pageID, viewSize, store, static_cast<DrawingArea::Type>(drawingAreaType));
+                return;
+            }
+        }
+    }
+
+    uint64_t pageID = arguments->destinationID();
+    if (!pageID)
+        return;
+    
+    WebPage* page = webPage(pageID);
+    if (!page)
+        return;
+    
+    page->didReceiveMessage(connection, messageID, *arguments);    
+}
+
+void WebProcess::didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*)
+{
+    // The web process should never ever get sync messages.
+    ASSERT_NOT_REACHED();
+}
+
+void WebProcess::didClose(CoreIPC::Connection*)
+{
+    // When running in the same process the connection will never be closed.
+    ASSERT(isSeparateProcess());
+
+    // The UI process closed this connection, shut down.
+    m_runLoop->stop();
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebProcess.h b/WebKit2/WebProcess/WebProcess.h
new file mode 100644 (file)
index 0000000..5fe6204
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebProcess_h
+#define WebProcess_h
+
+#include "DrawingArea.h"
+#include "Connection.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+    class IntSize;
+}
+
+namespace WebKit {
+
+class WebPage;
+class WebPreferencesStore;
+
+class WebProcess : CoreIPC::Connection::Client {
+public:
+    static WebProcess& shared();
+
+    void initialize(CoreIPC::Connection::Identifier, RunLoop* runLoop);
+
+    CoreIPC::Connection* connection() const { return m_connection.get(); }
+    RunLoop* runLoop() const { return m_runLoop; }
+
+    WebPage* webPage(uint64_t pageID) const;
+    WebPage* createWebPage(uint64_t pageID, const WebCore::IntSize& viewSize, const WebPreferencesStore&, DrawingArea::Type);
+    void removeWebPage(uint64_t pageID);
+
+    bool isSeparateProcess() const;
+    
+private:
+    WebProcess();
+    void shutdown();
+
+    // CoreIPC::Connection::Client
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+    void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+    void didClose(CoreIPC::Connection*);
+
+    RefPtr<CoreIPC::Connection> m_connection;
+    HashMap<uint64_t, RefPtr<WebPage> > m_pageMap;
+
+    RunLoop* m_runLoop;
+};
+
+} // namespace WebKit
+
+#endif // WebProcess_h
diff --git a/WebKit2/WebProcess/win/DllMain.cpp b/WebKit2/WebProcess/win/DllMain.cpp
new file mode 100644 (file)
index 0000000..17fc232
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2006, 2007, 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 <WebCore/RenderThemeWin.h>
+#include <WebCore/SharedBuffer.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+
+using namespace WebCore;
+
+STDAPI_(BOOL) DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
+{
+    switch (ul_reason_for_call) {
+        case DLL_PROCESS_ATTACH:
+            setInstanceHandle(hModule);
+            return TRUE;
+
+        case DLL_PROCESS_DETACH:
+            WebCore::RenderThemeWin::setWebKitIsBeingUnloaded();
+            break;
+
+        case DLL_THREAD_ATTACH:
+        case DLL_THREAD_DETACH:
+            break;
+    }
+    return FALSE;
+}
+
+// FIXME: We should consider moving this to a new file for cross-project functionality
+PassRefPtr<WebCore::SharedBuffer> loadResourceIntoBuffer(const char* name)
+{
+    return 0;
+}
diff --git a/WebKit2/WebProcess/win/WebLocalizableStrings.cpp b/WebKit2/WebProcess/win/WebLocalizableStrings.cpp
new file mode 100644 (file)
index 0000000..2d42359
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2006, 2007, 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 <windows.h>
+#include "WebLocalizableStrings.h"
+
+#pragma warning(push, 0)
+#include <WebCore/PlatformString.h>
+#include <WebCore/StringHash.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#pragma warning(pop)
+
+#include <wtf/Assertions.h>
+#include <wtf/HashMap.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/StdLibExtras.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+class LocalizedString;
+
+using namespace WebCore;
+
+WebLocalizableStringsBundle WebKitLocalizableStringsBundle = { "com.apple.WebKit", 0 };
+
+typedef HashMap<String, LocalizedString*> LocalizedStringMap;
+
+static Mutex& mainBundleLocStringsMutex()
+{
+    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    return mutex;
+}
+
+static LocalizedStringMap& mainBundleLocStrings()
+{
+    DEFINE_STATIC_LOCAL(LocalizedStringMap, map, ());
+    return map;
+}
+
+static Mutex& frameworkLocStringsMutex()
+{
+    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    return mutex;
+}
+
+static LocalizedStringMap frameworkLocStrings()
+{
+    DEFINE_STATIC_LOCAL(LocalizedStringMap, map, ());
+    return map;
+}
+
+class LocalizedString : public Noncopyable {
+public:
+    LocalizedString(CFStringRef string)
+        : m_cfString(string)
+    {
+        ASSERT_ARG(string, string);
+    }
+
+    operator LPCTSTR() const;
+    operator CFStringRef() const { return m_cfString; }
+
+private:
+    CFStringRef m_cfString;
+    mutable String m_string;
+};
+
+LocalizedString::operator LPCTSTR() const
+{
+    if (!m_string.isEmpty())
+        return m_string.charactersWithNullTermination();
+
+    m_string = m_cfString;
+
+    for (unsigned int i = 1; i < m_string.length(); i++)
+        if (m_string[i] == '@' && (m_string[i - 1] == '%' || (i > 2 && m_string[i - 1] == '$' && m_string[i - 2] >= '1' && m_string[i - 2] <= '9' && m_string[i - 3] == '%')))
+            m_string.replace(i, 1, "s");
+
+    return m_string.charactersWithNullTermination();
+}
+
+static CFBundleRef createWebKitBundle()
+{
+    static CFBundleRef bundle;
+    static bool initialized;
+
+    if (initialized)
+        return bundle;
+    initialized = true;
+
+    WCHAR pathStr[MAX_PATH];
+    DWORD length = ::GetModuleFileNameW(instanceHandle(), pathStr, MAX_PATH);
+    if (!length || (length == MAX_PATH && GetLastError() == ERROR_INSUFFICIENT_BUFFER))
+        return 0;
+
+    bool found = false;
+    for (int i = length - 1; i >= 0; i--) {
+        // warning C6385: Invalid data: accessing 'pathStr', the readable size is '520' bytes, but '2000' bytes might be read
+        #pragma warning(suppress: 6385)
+        if (pathStr[i] == L'\\') {
+            // warning C6386: Buffer overrun: accessing 'pathStr', the writable size is '520' bytes, but '1996' bytes might be written
+            #pragma warning(suppress: 6386)
+            pathStr[i] = 0;
+            found = true;
+            break;
+        }
+    }
+    if (!found)
+        return 0;
+
+    if (wcscat_s(pathStr, MAX_PATH, L"\\WebKit.resources"))
+        return 0;
+
+    String bundlePathString(pathStr);
+    CFStringRef bundlePathCFString = bundlePathString.createCFString();
+    if (!bundlePathCFString)
+        return 0;
+
+    CFURLRef bundleURLRef = CFURLCreateWithFileSystemPath(0, bundlePathCFString, kCFURLWindowsPathStyle, true);
+    CFRelease(bundlePathCFString);
+    if (!bundleURLRef)
+        return 0;
+
+    bundle = CFBundleCreate(0, bundleURLRef);
+    CFRelease(bundleURLRef);
+    return bundle;
+}
+
+static CFBundleRef cfBundleForStringsBundle(WebLocalizableStringsBundle* stringsBundle)
+{
+    if (!stringsBundle) {
+        static CFBundleRef mainBundle = CFBundleGetMainBundle();
+        return mainBundle;
+    }
+
+    createWebKitBundle();
+
+    if (!stringsBundle->bundle)
+        stringsBundle->bundle = CFBundleGetBundleWithIdentifier(RetainPtr<CFStringRef>(AdoptCF, CFStringCreateWithCString(0, stringsBundle->identifier, kCFStringEncodingASCII)).get());
+    return stringsBundle->bundle;
+}
+
+static CFStringRef copyLocalizedStringFromBundle(WebLocalizableStringsBundle* stringsBundle, const String& key)
+{
+    static CFStringRef notFound = CFSTR("localized string not found");
+
+    CFBundleRef bundle = cfBundleForStringsBundle(stringsBundle);
+    if (!bundle)
+        return notFound;
+
+    RetainPtr<CFStringRef> keyString(AdoptCF, key.createCFString());
+    CFStringRef result = CFCopyLocalizedStringWithDefaultValue(keyString.get(), 0, bundle, notFound, 0);
+
+    ASSERT_WITH_MESSAGE(result != notFound, "could not find localizable string %s in bundle", key);
+    return result;
+}
+
+static LocalizedString* findCachedString(WebLocalizableStringsBundle* stringsBundle, const String& key)
+{
+    if (!stringsBundle) {
+        MutexLocker lock(mainBundleLocStringsMutex());
+        return mainBundleLocStrings().get(key);
+    }
+
+    if (stringsBundle->bundle == WebKitLocalizableStringsBundle.bundle) {
+        MutexLocker lock(frameworkLocStringsMutex());
+        return frameworkLocStrings().get(key);
+    }
+
+    return 0;
+}
+
+static void cacheString(WebLocalizableStringsBundle* stringsBundle, const String& key, LocalizedString* value)
+{
+    if (!stringsBundle) {
+        MutexLocker lock(mainBundleLocStringsMutex());
+        mainBundleLocStrings().set(key, value);
+        return;
+    }
+
+    MutexLocker lock(frameworkLocStringsMutex());
+    frameworkLocStrings().set(key, value);
+}
+
+static const LocalizedString& localizedString(WebLocalizableStringsBundle* stringsBundle, const String& key)
+{
+    LocalizedString* string = findCachedString(stringsBundle, key);
+    if (string)
+        return *string;
+
+    string = new LocalizedString(copyLocalizedStringFromBundle(stringsBundle, key));
+    cacheString(stringsBundle, key, string);
+
+    return *string;
+}
+
+CFStringRef WebLocalizedStringUTF8(WebLocalizableStringsBundle* stringsBundle, LPCSTR key)
+{
+    if (!key)
+        return 0;
+
+    return localizedString(stringsBundle, String::fromUTF8(key));
+}
+
+LPCTSTR WebLocalizedLPCTSTRUTF8(WebLocalizableStringsBundle* stringsBundle, LPCSTR key)
+{
+    if (!key)
+        return 0;
+
+    return localizedString(stringsBundle, String::fromUTF8(key));
+}
+
+// These functions are deprecated.
+
+CFStringRef WebLocalizedString(WebLocalizableStringsBundle* stringsBundle, LPCTSTR key)
+{
+    if (!key)
+        return 0;
+
+    return localizedString(stringsBundle, String(key));
+}
+
+LPCTSTR WebLocalizedLPCTSTR(WebLocalizableStringsBundle* stringsBundle, LPCTSTR key)
+{
+    if (!key)
+        return 0;
+
+    return localizedString(stringsBundle, String(key));
+}
+
+void SetWebLocalizedStringMainBundle(CFBundleRef)
+{
+}
diff --git a/WebKit2/WebProcess/win/WebLocalizableStrings.h b/WebKit2/WebProcess/win/WebLocalizableStrings.h
new file mode 100644 (file)
index 0000000..102a25b
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2006, 2007, 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebLocalizableStrings_H
+#define WebLocalizableStrings_H
+
+#include <CoreFoundation/CoreFoundation.h>
+
+typedef struct {
+    const char *identifier;
+    CFBundleRef bundle;
+} WebLocalizableStringsBundle;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CFStringRef WebLocalizedStringUTF8(WebLocalizableStringsBundle*, LPCSTR key);
+LPCTSTR WebLocalizedLPCTSTRUTF8(WebLocalizableStringsBundle*, LPCSTR key);
+
+void SetWebLocalizedStringMainBundle(CFBundleRef bundle);
+
+// These functions are deprecated. Use the UTF-8 versions instead.
+CFStringRef WebLocalizedString(WebLocalizableStringsBundle *bundle, LPCTSTR key);
+LPCTSTR WebLocalizedLPCTSTR(WebLocalizableStringsBundle *bundle, LPCTSTR key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef FRAMEWORK_NAME
+
+#define LOCALIZABLE_STRINGS_BUNDLE(F) LOCALIZABLE_STRINGS_BUNDLE_HELPER(F)
+#define LOCALIZABLE_STRINGS_BUNDLE_HELPER(F) F ## LocalizableStringsBundle
+extern WebLocalizableStringsBundle LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME);
+
+#define UI_STRING(string, comment) WebLocalizedStringUTF8(&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), string)
+#define UI_STRING_KEY(string, key, comment) WebLocalizedStringUTF8(&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), key)
+#define LPCTSTR_UI_STRING(string, comment) WebLocalizedLPCTSTRUTF8(&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), string)
+#define LPCTSTR_UI_STRING_KEY(string, key, comment) WebLocalizedLPCTSTRUTF8(&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), key)
+
+#else
+
+#define UI_STRING(string, comment) WebLocalizedStringUTF8(0, string)
+#define UI_STRING_KEY(string, key, comment) WebLocalizedStringUTF8(0, key)
+#define LPCTSTR_UI_STRING(string, comment) WebLocalizedLPCTSTRUTF8(0, string)
+#define LPCTSTR_UI_STRING_KEY(string, key, comment) WebLocalizedLPCTSTRUTF8(0, key)
+
+#endif
+
+#endif
diff --git a/WebKit2/WebProcess/win/WebProcessMain.cpp b/WebKit2/WebProcess/win/WebProcessMain.cpp
new file mode 100644 (file)
index 0000000..740a34a
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (C) 2010 Apple Inc. All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS\r
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r
+ * THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#include "WebProcessMain.h"\r
+\r
+#include "RunLoop.h"\r
+#include "WebProcess.h"\r
+#include <runtime/InitializeThreading.h>\r
+\r
+namespace WebKit {\r
+\r
+int WebProcessMain(HINSTANCE hInstance, LPTSTR lpstrCmdLine)\r
+{\r
+    OleInitialize(0);\r
+\r
+    JSC::initializeThreading();\r
+    RunLoop::initializeMainRunLoop();\r
+\r
+    // FIXME: This should come from the command line string.\r
+    const wchar_t* uiProcessName = L"UIProcess";\r
+\r
+    WebProcess::shared().initialize(uiProcessName, RunLoop::mainRunLoop());\r
+\r
+    RunLoop::mainRunLoop()->run();\r
+\r
+    return 0;\r
+}\r
+\r
+} // namespace WebKit\r
diff --git a/WebKit2/WebProcess/win/WebProcessMain.h b/WebKit2/WebProcess/win/WebProcessMain.h
new file mode 100644 (file)
index 0000000..74e33f1
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 WebProcessMain_h
+#define WebProcessMain_h
+
+namespace WebKit {
+
+// This is called only from the _tWinMain function of the WebProcess.
+int WebProcessMain(HINSTANCE hInstance, LPTSTR lpstrCmdLine);
+
+} // namespace WebKit
+
+#endif // WebProcessMain_h