diff options
author | Upstream <upstream-import@none> | 1970-01-12 13:46:40 +0000 |
---|---|---|
committer | Upstream <upstream-import@none> | 1970-01-12 13:46:40 +0000 |
commit | d8543bb6618c17b12da906afa77d216f58cf4058 (patch) | |
tree | c58dc05ed86825bd0ef8d305d58c8205106b540f /WebKit/gtk/WebCoreSupport | |
download | external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.zip external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.tar.gz external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.tar.bz2 |
external/webkit r30707
Diffstat (limited to 'WebKit/gtk/WebCoreSupport')
-rw-r--r-- | WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp | 316 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/ChromeClientGtk.h | 104 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp | 75 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h | 54 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/DragClientGtk.cpp | 64 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/DragClientGtk.h | 51 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp | 451 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/EditorClientGtk.h | 118 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp | 789 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h | 186 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp | 80 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/InspectorClientGtk.h | 62 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp | 49 | ||||
-rw-r--r-- | WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h | 49 |
14 files changed, 2448 insertions, 0 deletions
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp new file mode 100644 index 0000000..28cd9b6 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Christian Dywan <christian@imendio.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "ChromeClientGtk.h" + +#include "FloatRect.h" +#include "IntRect.h" +#include "PlatformString.h" +#include "CString.h" +#include "HitTestResult.h" +#include "KURL.h" +#include "webkitwebview.h" +#include "webkitprivate.h" +#include "NotImplemented.h" +#include "WindowFeatures.h" + +using namespace WebCore; + +namespace WebKit { +ChromeClient::ChromeClient(WebKitWebView* webView) + : m_webView(webView) +{ +} + +void ChromeClient::chromeDestroyed() +{ + delete this; +} + +FloatRect ChromeClient::windowRect() +{ + if (!m_webView) + return FloatRect(); + GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView)); + if (window) { + gint left, top, width, height; + gtk_window_get_position(GTK_WINDOW(window), &left, &top); + gtk_window_get_size(GTK_WINDOW(window), &width, &height); + return IntRect(left, top, width, height); + } + return FloatRect(); +} + +void ChromeClient::setWindowRect(const FloatRect& r) +{ + notImplemented(); +} + +FloatRect ChromeClient::pageRect() +{ + if (!m_webView) + return FloatRect(); + GtkAllocation allocation = GTK_WIDGET(m_webView)->allocation; + return IntRect(allocation.x, allocation.y, allocation.width, allocation.height); +} + +float ChromeClient::scaleFactor() +{ + // Not implementable + return 1.0; +} + +void ChromeClient::focus() +{ + if (!m_webView) + return; + gtk_widget_grab_focus(GTK_WIDGET(m_webView)); +} + +void ChromeClient::unfocus() +{ + if (!m_webView) + return; + GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView)); + if (window) + gtk_window_set_focus(GTK_WINDOW(window), NULL); +} + +Page* ChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& features) +{ + if (features.dialog) { + notImplemented(); + return 0; + } else { + /* TODO: FrameLoadRequest is not used */ + WebKitWebView* webView = WEBKIT_WEB_VIEW_GET_CLASS(m_webView)->create_web_view(m_webView); + if (!webView) + return 0; + + WebKitWebViewPrivate* privateData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + return privateData->corePage; + } +} + +void ChromeClient::show() +{ + notImplemented(); +} + +bool ChromeClient::canRunModal() +{ + notImplemented(); + return false; +} + +void ChromeClient::runModal() +{ + notImplemented(); +} + +void ChromeClient::setToolbarsVisible(bool) +{ + notImplemented(); +} + +bool ChromeClient::toolbarsVisible() +{ + notImplemented(); + return false; +} + +void ChromeClient::setStatusbarVisible(bool) +{ + notImplemented(); +} + +bool ChromeClient::statusbarVisible() +{ + notImplemented(); + return false; +} + +void ChromeClient::setScrollbarsVisible(bool) +{ + notImplemented(); +} + +bool ChromeClient::scrollbarsVisible() { + notImplemented(); + return false; +} + +void ChromeClient::setMenubarVisible(bool) +{ + notImplemented(); +} + +bool ChromeClient::menubarVisible() +{ + notImplemented(); + return false; +} + +void ChromeClient::setResizable(bool) +{ + notImplemented(); +} + +void ChromeClient::closeWindowSoon() +{ + notImplemented(); +} + +bool ChromeClient::canTakeFocus(FocusDirection) +{ + if (!m_webView) + return false; + return GTK_WIDGET_CAN_FOCUS(m_webView); +} + +void ChromeClient::takeFocus(FocusDirection) +{ + unfocus(); +} + +bool ChromeClient::canRunBeforeUnloadConfirmPanel() +{ + return true; +} + +bool ChromeClient::runBeforeUnloadConfirmPanel(const WebCore::String& message, WebCore::Frame* frame) +{ + return runJavaScriptConfirm(frame, message); +} + +void ChromeClient::addMessageToConsole(const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceId) +{ + gboolean retval; + g_signal_emit_by_name(m_webView, "console-message", message.utf8().data(), lineNumber, sourceId.utf8().data(), &retval); +} + +void ChromeClient::runJavaScriptAlert(Frame* frame, const String& message) +{ + gboolean retval; + g_signal_emit_by_name(m_webView, "script-alert", kit(frame), message.utf8().data(), &retval); +} + +bool ChromeClient::runJavaScriptConfirm(Frame* frame, const String& message) +{ + gboolean retval; + gboolean didConfirm; + g_signal_emit_by_name(m_webView, "script-confirm", kit(frame), message.utf8().data(), &didConfirm, &retval); + return didConfirm == TRUE; +} + +bool ChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result) +{ + gboolean retval; + gchar* value = 0; + g_signal_emit_by_name(m_webView, "script-prompt", kit(frame), message.utf8().data(), defaultValue.utf8().data(), &value, &retval); + if (value) { + result = String::fromUTF8(value); + g_free(value); + return true; + } + return false; +} + +void ChromeClient::setStatusbarText(const String& string) +{ + CString stringMessage = string.utf8(); + g_signal_emit_by_name(m_webView, "status-bar-text-changed", stringMessage.data()); +} + +bool ChromeClient::shouldInterruptJavaScript() +{ + notImplemented(); + return false; +} + +bool ChromeClient::tabsToLinks() const +{ + return true; +} + +IntRect ChromeClient::windowResizerRect() const +{ + notImplemented(); + return IntRect(); +} + +void ChromeClient::addToDirtyRegion(const IntRect&) +{ + notImplemented(); +} + +void ChromeClient::scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect) +{ + notImplemented(); +} + +void ChromeClient::updateBackingStore() +{ + notImplemented(); +} + +void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags) +{ + // check if the element is a link... + bool isLink = hit.isLiveLink(); + if (isLink) { + KURL url = hit.absoluteLinkURL(); + if (!url.isEmpty() && url != m_hoveredLinkURL) { + CString titleString = hit.title().utf8(); + CString urlString = url.prettyURL().utf8(); + g_signal_emit_by_name(m_webView, "hovering-over-link", titleString.data(), urlString.data()); + m_hoveredLinkURL = url; + } + } else if (!isLink && !m_hoveredLinkURL.isEmpty()) { + g_signal_emit_by_name(m_webView, "hovering-over-link", 0, 0); + m_hoveredLinkURL = KURL(); + } +} + +void ChromeClient::setToolTip(const String& toolTip) +{ +#if GTK_CHECK_VERSION(2,12,0) + if (toolTip.isEmpty()) + g_object_set(G_OBJECT(m_webView), "has-tooltip", FALSE, NULL); + else + gtk_widget_set_tooltip_text(GTK_WIDGET(m_webView), toolTip.utf8().data()); +#else + // TODO: Support older GTK+ versions + // See http://bugs.webkit.org/show_bug.cgi?id=15793 + notImplemented(); +#endif +} + +void ChromeClient::print(Frame* frame) +{ + webkit_web_frame_print(kit(frame)); +} + +void ChromeClient::exceededDatabaseQuota(Frame*, const String&) +{ + notImplemented(); +} + +} diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h new file mode 100644 index 0000000..465dc9f --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007 Holger Hans Peter Freyther + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ChromeClientGtk_h +#define ChromeClientGtk_h + +#include "ChromeClient.h" +#include "KURL.h" + +typedef struct _WebKitWebView WebKitWebView; + +namespace WebKit { + + class ChromeClient : public WebCore::ChromeClient { + public: + ChromeClient(WebKitWebView*); + WebKitWebView* webView() const { return m_webView; } + + 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 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(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; + virtual void addToDirtyRegion(const WebCore::IntRect&); + virtual void scrollBackingStore(int dx, int dy, const WebCore::IntRect& scrollViewRect, const WebCore::IntRect& clipRect); + virtual void updateBackingStore(); + + virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); + + virtual void setToolTip(const WebCore::String&); + + virtual void print(WebCore::Frame*); + + virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String&); + + private: + WebKitWebView* m_webView; + WebCore::KURL m_hoveredLinkURL; + }; +} + +#endif // ChromeClient_h diff --git a/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp new file mode 100644 index 0000000..6a2feb2 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp @@ -0,0 +1,75 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "ContextMenu.h" +#include "ContextMenuClientGtk.h" + +#include "HitTestResult.h" +#include "KURL.h" +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void ContextMenuClient::contextMenuDestroyed() +{ + delete this; +} + +PlatformMenuDescription ContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* menu) +{ + return menu->releasePlatformDescription(); +} + +void ContextMenuClient::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) +{ + notImplemented(); +} + +void ContextMenuClient::downloadURL(const KURL& url) +{ + notImplemented(); +} + +void ContextMenuClient::copyImageToClipboard(const HitTestResult&) +{ + notImplemented(); +} + +void ContextMenuClient::searchWithGoogle(const Frame*) +{ + notImplemented(); +} + +void ContextMenuClient::lookUpInDictionary(Frame*) +{ + notImplemented(); +} + +void ContextMenuClient::speak(const String&) +{ + notImplemented(); +} + +void ContextMenuClient::stopSpeaking() +{ + notImplemented(); +} + +} + diff --git a/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h new file mode 100644 index 0000000..c0e8069 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2006 Zack Rusin <zack@kde.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ContextMenuClientGtk_h +#define ContextMenuClientGtk_h + +#include "ContextMenuClient.h" + +namespace WebCore { + class ContextMenu; +} + +namespace WebKit { + + class ContextMenuClient : public WebCore::ContextMenuClient + { + public: + 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 copyImageToClipboard(const WebCore::HitTestResult&); + virtual void searchWithGoogle(const WebCore::Frame*); + virtual void lookUpInDictionary(WebCore::Frame*); + virtual void speak(const WebCore::String&); + virtual void stopSpeaking(); + }; +} + +#endif diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp new file mode 100644 index 0000000..f55b6ea --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp @@ -0,0 +1,64 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "DragClientGtk.h" + +#include "NotImplemented.h" + +using namespace WebCore; + +namespace WebKit { + +void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*) +{ + notImplemented(); +} + +void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) +{ + notImplemented(); +} + +DragDestinationAction DragClient::actionMaskForDrag(DragData*) +{ + notImplemented(); + return DragDestinationActionAny; +} + +DragSourceAction DragClient::dragSourceActionMaskForPoint(const IntPoint&) +{ + notImplemented(); + return DragSourceActionAny; +} + +void DragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) +{ + notImplemented(); +} + +DragImageRef DragClient::createDragImageForLink(KURL&, const String& label, Frame*) +{ + notImplemented(); + return 0; +} + +void DragClient::dragControllerDestroyed() +{ + delete this; +} +} + diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.h b/WebKit/gtk/WebCoreSupport/DragClientGtk.h new file mode 100644 index 0000000..4367c68 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007 Holger Hans Peter Freyther + * + * 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. + * 3. Neither the name of Apple, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 DragClientGtk_h +#define DragClientGtk_h + +#include "DragClient.h" + +namespace WebKit { + class DragClient : public WebCore::DragClient { + public: + 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(); + }; +} + +#endif diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp new file mode 100644 index 0000000..8b6c954 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp @@ -0,0 +1,451 @@ +/* + * Copyright (C) 2007 Alp Toker <alp@atoker.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "EditorClientGtk.h" + +#include "EditCommand.h" +#include "Editor.h" +#include "FocusController.h" +#include "Frame.h" +#include "KeyboardCodes.h" +#include "KeyboardEvent.h" +#include "NotImplemented.h" +#include "Page.h" +#include "PlatformKeyboardEvent.h" +#include "webkitprivate.h" + +using namespace WebCore; + +namespace WebKit { + +static void imContextCommitted(GtkIMContext* context, const char* str, EditorClient* client) +{ + Frame* frame = core(client->m_webView)->focusController()->focusedOrMainFrame(); + frame->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(str), false); +} + +bool EditorClient::shouldDeleteRange(Range*) +{ + notImplemented(); + return true; +} + +bool EditorClient::shouldShowDeleteInterface(HTMLElement*) +{ + return false; +} + +bool EditorClient::isContinuousSpellCheckingEnabled() +{ + notImplemented(); + return false; +} + +bool EditorClient::isGrammarCheckingEnabled() +{ + notImplemented(); + return false; +} + +int EditorClient::spellCheckerDocumentTag() +{ + notImplemented(); + return 0; +} + +bool EditorClient::shouldBeginEditing(WebCore::Range*) +{ + notImplemented(); + return true; +} + +bool EditorClient::shouldEndEditing(WebCore::Range*) +{ + notImplemented(); + return true; +} + +bool EditorClient::shouldInsertText(String, Range*, EditorInsertAction) +{ + notImplemented(); + return true; +} + +bool EditorClient::shouldChangeSelectedRange(Range*, Range*, EAffinity, bool) +{ + notImplemented(); + return true; +} + +bool EditorClient::shouldApplyStyle(WebCore::CSSStyleDeclaration*, + WebCore::Range*) +{ + notImplemented(); + return true; +} + +bool EditorClient::shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) +{ + notImplemented(); + return true; +} + +void EditorClient::didBeginEditing() +{ + notImplemented(); +} + +void EditorClient::respondToChangedContents() +{ + notImplemented(); +} + +void EditorClient::respondToChangedSelection() +{ + notImplemented(); +} + +void EditorClient::didEndEditing() +{ + notImplemented(); +} + +void EditorClient::didWriteSelectionToPasteboard() +{ + notImplemented(); +} + +void EditorClient::didSetSelectionTypesForPasteboard() +{ + notImplemented(); +} + +bool EditorClient::isEditable() +{ + return webkit_web_view_get_editable(m_webView); +} + +void EditorClient::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand>) +{ + notImplemented(); +} + +void EditorClient::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand>) +{ + notImplemented(); +} + +void EditorClient::clearUndoRedoOperations() +{ + notImplemented(); +} + +bool EditorClient::canUndo() const +{ + notImplemented(); + return false; +} + +bool EditorClient::canRedo() const +{ + notImplemented(); + return false; +} + +void EditorClient::undo() +{ + notImplemented(); +} + +void EditorClient::redo() +{ + notImplemented(); +} + +bool EditorClient::shouldInsertNode(Node*, Range*, EditorInsertAction) +{ + notImplemented(); + return true; +} + +void EditorClient::pageDestroyed() +{ + delete this; +} + +bool EditorClient::smartInsertDeleteEnabled() +{ + notImplemented(); + return false; +} + +void EditorClient::toggleContinuousSpellChecking() +{ + notImplemented(); +} + +void EditorClient::toggleGrammarChecking() +{ +} + +void EditorClient::handleKeyboardEvent(KeyboardEvent* event) +{ + Frame* frame = core(m_webView)->focusController()->focusedOrMainFrame(); + if (!frame || !frame->document()->focusedNode()) + return; + + const PlatformKeyboardEvent* kevent = event->keyEvent(); + if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp) + return; + + Node* start = frame->selectionController()->start().node(); + if (!start) + return; + + // FIXME: Use GtkBindingSet instead of this hard-coded switch + // http://bugs.webkit.org/show_bug.cgi?id=15911 + + if (start->isContentEditable()) { + switch (kevent->windowsVirtualKeyCode()) { + case VK_BACK: + frame->editor()->deleteWithDirection(SelectionController::BACKWARD, + kevent->ctrlKey() ? WordGranularity : CharacterGranularity, false, true); + break; + case VK_DELETE: + frame->editor()->deleteWithDirection(SelectionController::FORWARD, + kevent->ctrlKey() ? WordGranularity : CharacterGranularity, false, true); + break; + case VK_LEFT: + frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + SelectionController::LEFT, + kevent->ctrlKey() ? WordGranularity : CharacterGranularity, + true); + break; + case VK_RIGHT: + frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + SelectionController::RIGHT, + kevent->ctrlKey() ? WordGranularity : CharacterGranularity, + true); + break; + case VK_UP: + frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + SelectionController::BACKWARD, + kevent->ctrlKey() ? ParagraphGranularity : LineGranularity, + true); + break; + case VK_DOWN: + frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + SelectionController::FORWARD, + kevent->ctrlKey() ? ParagraphGranularity : LineGranularity, + true); + break; + case VK_PRIOR: // PageUp + frame->editor()->command("MovePageUp").execute(); + break; + case VK_NEXT: // PageDown + frame->editor()->command("MovePageDown").execute(); + break; + case VK_HOME: + if (kevent->ctrlKey() && kevent->shiftKey()) + frame->editor()->command("MoveToBeginningOfDocumentAndModifySelection").execute(); + else if (kevent->ctrlKey()) + frame->editor()->command("MoveToBeginningOfDocument").execute(); + else if (kevent->shiftKey()) + frame->editor()->command("MoveToBeginningOfLineAndModifySelection").execute(); + else + frame->editor()->command("MoveToBeginningOfLine").execute(); + break; + case VK_END: + if (kevent->ctrlKey() && kevent->shiftKey()) + frame->editor()->command("MoveToEndOfDocumentAndModifySelection").execute(); + else if (kevent->ctrlKey()) + frame->editor()->command("MoveToEndOfDocument").execute(); + else if (kevent->shiftKey()) + frame->editor()->command("MoveToEndOfLineAndModifySelection").execute(); + else + frame->editor()->command("MoveToEndOfLine").execute(); + break; + case VK_RETURN: + frame->editor()->command("InsertLineBreak").execute(); + break; + case VK_TAB: + return; + default: + if (!kevent->ctrlKey() && !kevent->altKey() && !kevent->text().isEmpty()) { + if (kevent->text().length() == 1) { + UChar ch = kevent->text()[0]; + // Don't insert null or control characters as they can result in unexpected behaviour + if (ch < ' ') + break; + } + frame->editor()->insertText(kevent->text(), event); + } else if (kevent->ctrlKey()) { + switch (kevent->windowsVirtualKeyCode()) { + case VK_B: + frame->editor()->command("ToggleBold").execute(); + break; + case VK_I: + frame->editor()->command("ToggleItalic").execute(); + break; + case VK_Y: + frame->editor()->command("Redo").execute(); + break; + case VK_Z: + frame->editor()->command("Undo").execute(); + break; + default: + return; + } + } else return; + } + } else { + switch (kevent->windowsVirtualKeyCode()) { + case VK_UP: + frame->editor()->command("MoveUp").execute(); + break; + case VK_DOWN: + frame->editor()->command("MoveDown").execute(); + break; + case VK_PRIOR: // PageUp + frame->editor()->command("MovePageUp").execute(); + break; + case VK_NEXT: // PageDown + frame->editor()->command("MovePageDown").execute(); + break; + case VK_HOME: + if (kevent->ctrlKey()) + frame->editor()->command("MoveToBeginningOfDocument").execute(); + break; + case VK_END: + if (kevent->ctrlKey()) + frame->editor()->command("MoveToEndOfDocument").execute(); + break; + default: + return; + } + } + event->setDefaultHandled(); +} + + +void EditorClient::handleInputMethodKeydown(KeyboardEvent*) +{ + notImplemented(); +} + +EditorClient::EditorClient(WebKitWebView* webView) + : m_webView(webView) +{ + WebKitWebViewPrivate* priv = m_webView->priv; + g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this); +} + +EditorClient::~EditorClient() +{ + WebKitWebViewPrivate* priv = m_webView->priv; + g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextCommitted, this); +} + +void EditorClient::textFieldDidBeginEditing(Element*) +{ + gtk_im_context_focus_in(WEBKIT_WEB_VIEW_GET_PRIVATE(m_webView)->imContext); +} + +void EditorClient::textFieldDidEndEditing(Element*) +{ + WebKitWebViewPrivate* priv = m_webView->priv; + + gtk_im_context_focus_out(priv->imContext); +#ifdef MAEMO_CHANGES + hildon_gtk_im_context_hide(priv->imContext); +#endif +} + +void EditorClient::textDidChangeInTextField(Element*) +{ + notImplemented(); +} + +bool EditorClient::doTextFieldCommandFromEvent(Element* element, KeyboardEvent* event) +{ + WebKitWebViewPrivate* priv = m_webView->priv; + return gtk_im_context_filter_keypress(priv->imContext, event->keyEvent()->gdkEventKey()); +} + +void EditorClient::textWillBeDeletedInTextField(Element*) +{ + notImplemented(); +} + +void EditorClient::textDidChangeInTextArea(Element*) +{ + notImplemented(); +} + +void EditorClient::ignoreWordInSpellDocument(const String&) +{ + notImplemented(); +} + +void EditorClient::learnWord(const String&) +{ + notImplemented(); +} + +void EditorClient::checkSpellingOfString(const UChar*, int, int*, int*) +{ + notImplemented(); +} + +void EditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*) +{ + notImplemented(); +} + +void EditorClient::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) +{ + notImplemented(); +} + +void EditorClient::updateSpellingUIWithMisspelledWord(const String&) +{ + notImplemented(); +} + +void EditorClient::showSpellingUI(bool) +{ + notImplemented(); +} + +bool EditorClient::spellingUIIsShowing() +{ + notImplemented(); + return false; +} + +void EditorClient::getGuessesForWord(const String&, Vector<String>&) +{ + notImplemented(); +} + +void EditorClient::setInputMethodState(bool) +{ +} + +} diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h new file mode 100644 index 0000000..f2bc194 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2006 Zack Rusin <zack@kde.org> + * Copyright (C) 2006 Apple Computer, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EditorClientGtk_h +#define EditorClientGtk_h + +#include "EditorClient.h" + +#include <wtf/Forward.h> + +typedef struct _WebKitWebView WebKitWebView; + +namespace WebCore { + class Page; +} + +namespace WebKit { + + class EditorClient : public WebCore::EditorClient { + public: + EditorClient(WebKitWebView*); + ~EditorClient(); + + // from EditorClient + virtual void pageDestroyed(); + + virtual bool shouldDeleteRange(WebCore::Range*); + virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*); + virtual bool smartInsertDeleteEnabled(); + 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(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(WTF::PassRefPtr<WebCore::EditCommand>); + virtual void registerCommandForRedo(WTF::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*); + + virtual void ignoreWordInSpellDocument(const WebCore::String&); + virtual void learnWord(const WebCore::String&); + virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); + virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); + virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail&); + virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&); + virtual void showSpellingUI(bool show); + virtual bool spellingUIIsShowing(); + virtual void getGuessesForWord(const WebCore::String&, WTF::Vector<WebCore::String>& guesses); + virtual void setInputMethodState(bool enabled); + + WebKitWebView* m_webView; + }; +} + +#endif + +// vim: ts=4 sw=4 et diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp new file mode 100644 index 0000000..d518f60 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp @@ -0,0 +1,789 @@ +/* + * Copyright (C) 2007 Alp Toker <alp@atoker.com> + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther + * Copyright (C) 2007 Christian Dywan <christian@twotoasts.de> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "FrameLoaderClientGtk.h" + +#include "DocumentLoader.h" +#include "FrameLoader.h" +#include "FrameView.h" +#include "FrameTree.h" +#include "HTMLFormElement.h" +#include "HTMLFrameElement.h" +#include "HTMLFrameOwnerElement.h" +#include "HTMLNames.h" +#include "Language.h" +#include "MIMETypeRegistry.h" +#include "NotImplemented.h" +#include "PlatformString.h" +#include "ResourceRequest.h" +#include "CString.h" +#include "ProgressTracker.h" +#include "kjs_binding.h" +#include "kjs_proxy.h" +#include "kjs_window.h" +#include "webkitwebview.h" +#include "webkitwebframe.h" +#include "webkitprivate.h" + +#include <JavaScriptCore/APICast.h> +#include <stdio.h> +#if PLATFORM(UNIX) +#include <sys/utsname.h> +#endif + +using namespace WebCore; + +namespace WebKit { + +FrameLoaderClient::FrameLoaderClient(WebKitWebFrame* frame) + : m_frame(frame) + , m_userAgent("") +{ + ASSERT(m_frame); +} + +static String agentPlatform() +{ +#ifdef GDK_WINDOWING_X11 + return "X11"; +#elif defined(GDK_WINDOWING_WIN32) + return "Windows"; +#elif defined(GDK_WINDOWING_QUARTZ) + return "Macintosh"; +#elif defined(GDK_WINDOWING_DIRECTFB) + return "DirectFB"; +#else + notImplemented(); + return "Unknown"; +#endif +} + +static String agentOS() +{ +#if PLATFORM(DARWIN) +#if PLATFORM(X86) + return "Intel Mac OS X"; +#else + return "PPC Mac OS X"; +#endif +#elif PLATFORM(UNIX) + struct utsname name; + if (uname(&name) != -1) + return String::format("%s %s", name.sysname, name.machine); + else + return "Unknown"; +#elif PLATFORM(WIN_OS) + // FIXME: Compute the Windows version + return "Windows"; +#else + notImplemented(); + return "Unknown"; +#endif +} + +static String composeUserAgent() +{ + // This is a liberal interpretation of http://www.mozilla.org/build/revised-user-agent-strings.html + // See also http://developer.apple.com/internet/safari/faq.html#anchor2 + + String ua; + + // Product + ua += "Mozilla/5.0"; + + // Comment + ua += " ("; + ua += agentPlatform(); // Platform + ua += "; U; "; // Security + ua += agentOS(); // OS-or-CPU + ua += "; "; + ua += defaultLanguage(); // Localization information + ua += ") "; + + // WebKit Product + // FIXME: The WebKit version is hardcoded + static const String webKitVersion = "525.1+"; + ua += "AppleWebKit/" + webKitVersion; + ua += " (KHTML, like Gecko, "; + // We mention Safari since many broken sites check for it (OmniWeb does this too) + // We re-use the WebKit version, though it doesn't seem to matter much in practice + ua += "Safari/" + webKitVersion; + ua += ") "; + + // Vendor Product + ua += g_get_prgname(); + + return ua; +} + +String FrameLoaderClient::userAgent(const KURL&) +{ + if (m_userAgent.isEmpty()) + m_userAgent = composeUserAgent(); + + return m_userAgent; +} + +WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClient::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData) +{ + RefPtr<DocumentLoader> loader = new DocumentLoader(request, substituteData); + return loader.release(); +} + +void FrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction policyFunction, PassRefPtr<FormState>) +{ + // FIXME: This is surely too simple + ASSERT(policyFunction); + if (!policyFunction) + return; + (core(m_frame)->loader()->*policyFunction)(PolicyUse); +} + + +void FrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length) +{ + FrameLoader *fl = loader->frameLoader(); + fl->setEncoding(m_response.textEncodingName(), false); + fl->addData(data, length); +} + +void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) +{ + notImplemented(); +} + +void FrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) +{ + notImplemented(); +} + +void FrameLoaderClient::postProgressStartedNotification() +{ + WebKitWebView* webView = getViewFromFrame(m_frame); + g_signal_emit_by_name(webView, "load-started", m_frame); +} + +void FrameLoaderClient::postProgressEstimateChangedNotification() +{ + WebKitWebView* webView = getViewFromFrame(m_frame); + Page* corePage = core(webView); + + g_signal_emit_by_name(webView, "load-progress-changed", lround(corePage->progress()->estimatedProgress()*100)); +} + +void FrameLoaderClient::postProgressFinishedNotification() +{ + WebKitWebView* webView = getViewFromFrame(m_frame); + + g_signal_emit_by_name(webView, "load-finished", m_frame); +} + +void FrameLoaderClient::frameLoaderDestroyed() +{ + m_frame = 0; + delete this; +} + +void FrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse& response) +{ + m_response = response; +} + +void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String&, const ResourceRequest&) +{ + // FIXME: we need to call directly here (comment copied from Qt version) + ASSERT(policyFunction); + if (!policyFunction) + return; + (core(m_frame)->loader()->*policyFunction)(PolicyUse); +} + +void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, const String&) +{ + ASSERT(policyFunction); + if (!policyFunction) + return; + // FIXME: I think Qt version marshals this to another thread so when we + // have multi-threaded download, we might need to do the same + (core(m_frame)->loader()->*policyFunction)(PolicyIgnore); +} + +void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest) +{ + ASSERT(policyFunction); + if (!policyFunction) + return; + + WebKitWebView* webView = getViewFromFrame(m_frame); + WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data()); + WebKitNavigationResponse response; + + g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response); + + g_object_unref(request); + + if (response == WEBKIT_NAVIGATION_RESPONSE_IGNORE) { + (core(m_frame)->loader()->*policyFunction)(PolicyIgnore); + return; + } + + (core(m_frame)->loader()->*policyFunction)(PolicyUse); +} + +Widget* FrameLoaderClient::createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) +{ + notImplemented(); + return 0; +} + +PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, + const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) +{ + Frame* coreFrame = core(webFrame()); + + ASSERT(core(getViewFromFrame(webFrame())) == coreFrame->page()); + WebKitWebFrame* gtkFrame = WEBKIT_WEB_FRAME(webkit_web_frame_init_with_web_view(getViewFromFrame(webFrame()), ownerElement)); + RefPtr<Frame> childFrame(adoptRef(core(gtkFrame))); + + coreFrame->tree()->appendChild(childFrame); + + childFrame->tree()->setName(name); + childFrame->init(); + childFrame->loader()->load(url, referrer, FrameLoadTypeRedirectWithLockedHistory, String(), 0, 0); + + // The frame's onload handler may have removed it from the document. + if (!childFrame->tree()->parent()) + return 0; + + // Propagate the marginwidth/height and scrolling modes to the view. + if (ownerElement->hasTagName(HTMLNames::frameTag) || ownerElement->hasTagName(HTMLNames::iframeTag)) { + HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement); + if (frameElt->scrollingMode() == ScrollbarAlwaysOff) + childFrame->view()->setScrollbarsMode(ScrollbarAlwaysOff); + int marginWidth = frameElt->getMarginWidth(); + int marginHeight = frameElt->getMarginHeight(); + if (marginWidth != -1) + childFrame->view()->setMarginWidth(marginWidth); + if (marginHeight != -1) + childFrame->view()->setMarginHeight(marginHeight); + } + + return childFrame.release(); +} + +void FrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) +{ + notImplemented(); + return; +} + +Widget* FrameLoaderClient::createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL, + const Vector<String>& paramNames, const Vector<String>& paramValues) +{ + notImplemented(); + return 0; +} + +ObjectContentType FrameLoaderClient::objectContentType(const KURL& url, const String& mimeType) +{ + String type = mimeType; + // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure + if (type.isEmpty()) + type = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); + + if (type.isEmpty()) + return WebCore::ObjectContentFrame; + + if (MIMETypeRegistry::isSupportedImageMIMEType(type)) + return WebCore::ObjectContentImage; + + if (MIMETypeRegistry::isSupportedNonImageMIMEType(type)) + return WebCore::ObjectContentFrame; + + return WebCore::ObjectContentNone; +} + +String FrameLoaderClient::overrideMediaType() const +{ + notImplemented(); + return String(); +} + +void FrameLoaderClient::windowObjectCleared() +{ + // Is this obsolete now? + g_signal_emit_by_name(m_frame, "cleared"); + + Frame* coreFrame = core(webFrame()); + ASSERT(coreFrame); + + Settings* settings = coreFrame->settings(); + if (!settings || !settings->isJavaScriptEnabled()) + return; + + // TODO: Consider using g_signal_has_handler_pending() to avoid the overhead + // when there are no handlers. + JSGlobalContextRef context = toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec()); + JSObjectRef windowObject = toRef(KJS::Window::retrieve(coreFrame)->getObject()); + ASSERT(windowObject); + + WebKitWebView* webView = getViewFromFrame(m_frame); + g_signal_emit_by_name(webView, "window-object-cleared", m_frame, context, windowObject); + + // TODO: Re-attach debug clients if present. + // The Win port has an example of how we might do this. +} + +void FrameLoaderClient::didPerformFirstNavigation() const +{ +} + +void FrameLoaderClient::registerForIconNotification(bool) +{ + notImplemented(); +} + +void FrameLoaderClient::setMainFrameDocumentReady(bool) +{ + // this is only interesting once we provide an external API for the DOM +} + +bool FrameLoaderClient::hasWebView() const +{ + notImplemented(); + return true; +} + +bool FrameLoaderClient::hasFrameView() const +{ + notImplemented(); + return true; +} + +void FrameLoaderClient::dispatchDidFinishLoad() +{ + g_signal_emit_by_name(m_frame, "load-done", true); +} + +void FrameLoaderClient::frameLoadCompleted() +{ + notImplemented(); +} + +void FrameLoaderClient::saveViewStateToItem(HistoryItem*) +{ + notImplemented(); +} + +void FrameLoaderClient::restoreViewState() +{ + notImplemented(); +} + +bool FrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const +{ + // FIXME: This is a very simple implementation. More sophisticated + // implementation would delegate the decision to a PolicyDelegate. + // See mac implementation for example. + return item != 0; +} + +void FrameLoaderClient::makeRepresentation(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::forceLayout() +{ + notImplemented(); +} + +void FrameLoaderClient::forceLayoutForNonHTML() +{ + notImplemented(); +} + +void FrameLoaderClient::setCopiesOnScroll() +{ + notImplemented(); +} + +void FrameLoaderClient::detachedFromParent1() +{ + notImplemented(); +} + +void FrameLoaderClient::detachedFromParent2() +{ + notImplemented(); +} + +void FrameLoaderClient::detachedFromParent3() +{ + notImplemented(); +} + +void FrameLoaderClient::detachedFromParent4() +{ + ASSERT(m_frame); + g_object_unref(m_frame); + m_frame = 0; +} + +void FrameLoaderClient::loadedFromCachedPage() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidHandleOnloadEvents() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidCancelClientRedirect() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchWillPerformClientRedirect(const KURL&, double, double) +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidChangeLocationWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchWillClose() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidReceiveIcon() +{ + WebKitWebView* webView = getViewFromFrame(m_frame); + + g_signal_emit_by_name(webView, "icon-loaded", m_frame); +} + +void FrameLoaderClient::dispatchDidStartProvisionalLoad() +{ +} + +void FrameLoaderClient::dispatchDidReceiveTitle(const String& title) +{ + g_signal_emit_by_name(m_frame, "title-changed", title.utf8().data()); + + WebKitWebView* webView = getViewFromFrame(m_frame); + if (m_frame == webkit_web_view_get_main_frame(webView)) + g_signal_emit_by_name(webView, "title-changed", m_frame, title.utf8().data()); +} + +void FrameLoaderClient::dispatchDidCommitLoad() +{ + /* Update the URI once first data has been received. + * This means the URI is valid and successfully identify the page that's going to be loaded. + */ + WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(m_frame); + g_free(frameData->uri); + frameData->uri = g_strdup(core(m_frame)->loader()->url().prettyURL().utf8().data()); + + g_signal_emit_by_name(m_frame, "load-committed"); + + WebKitWebView* webView = getViewFromFrame(m_frame); + if (m_frame == webkit_web_view_get_main_frame(webView)) + g_signal_emit_by_name(webView, "load-committed", m_frame); +} + +void FrameLoaderClient::dispatchDidFinishDocumentLoad() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidFirstLayout() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchShow() +{ + notImplemented(); +} + +void FrameLoaderClient::cancelPolicyCheck() +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::revertToProvisionalState(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::clearUnarchivingState(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::willChangeTitle(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::didChangeTitle(DocumentLoader *l) +{ + setTitle(l->title(), l->url()); +} + +void FrameLoaderClient::finalSetupForReplace(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::setDefersLoading(bool) +{ + notImplemented(); +} + +bool FrameLoaderClient::isArchiveLoadPending(ResourceLoader*) const +{ + notImplemented(); + return false; +} + +void FrameLoaderClient::cancelPendingArchiveLoad(ResourceLoader*) +{ + notImplemented(); +} + +void FrameLoaderClient::clearArchivedResources() +{ + notImplemented(); +} + +bool FrameLoaderClient::canHandleRequest(const ResourceRequest&) const +{ + notImplemented(); + return true; +} + +bool FrameLoaderClient::canShowMIMEType(const String&) const +{ + notImplemented(); + return true; +} + +bool FrameLoaderClient::representationExistsForURLScheme(const String&) const +{ + notImplemented(); + return false; +} + +String FrameLoaderClient::generatedMIMETypeForURLScheme(const String&) const +{ + notImplemented(); + return String(); +} + +void FrameLoaderClient::finishedLoading(DocumentLoader* documentLoader) +{ + ASSERT(documentLoader->frame()); + // Setting the encoding on the frame loader is our way to get work done that is normally done + // when the first bit of data is received, even for the case of a document with no data (like about:blank). + String encoding = documentLoader->overrideEncoding(); + bool userChosen = !encoding.isNull(); + if (encoding.isNull()) + encoding = documentLoader->response().textEncodingName(); + documentLoader->frameLoader()->setEncoding(encoding, userChosen); +} + + +void FrameLoaderClient::provisionalLoadStarted() +{ + notImplemented(); +} + +void FrameLoaderClient::didFinishLoad() { + notImplemented(); +} + +void FrameLoaderClient::prepareForDataSourceReplacement() { notImplemented(); } + +void FrameLoaderClient::setTitle(const String& title, const KURL& url) +{ + WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(m_frame); + g_free(frameData->title); + frameData->title = g_strdup(title.utf8().data()); +} + +void FrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) +{ + notImplemented(); +} + +void FrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) +{ + notImplemented(); +} + +bool FrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) +{ + notImplemented(); + return false; +} + +void FrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&) +{ + g_signal_emit_by_name(m_frame, "load-done", false); +} + +void FrameLoaderClient::dispatchDidFailLoad(const ResourceError&) +{ + g_signal_emit_by_name(m_frame, "load-done", false); +} + +void FrameLoaderClient::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) +{ + notImplemented(); +} + +ResourceError FrameLoaderClient::cancelledError(const ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +ResourceError FrameLoaderClient::blockedError(const ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +ResourceError FrameLoaderClient::cannotShowURLError(const ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +ResourceError FrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +ResourceError FrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse&) +{ + notImplemented(); + return ResourceError(); +} + +ResourceError FrameLoaderClient::fileDoesNotExistError(const ResourceResponse&) +{ + notImplemented(); + return ResourceError(); +} + +bool FrameLoaderClient::shouldFallBack(const ResourceError&) +{ + notImplemented(); + return false; +} + +bool FrameLoaderClient::willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL& originalURL) const +{ + notImplemented(); + return false; +} + +bool FrameLoaderClient::canCachePage() const +{ + notImplemented(); + return false; +} + +Frame* FrameLoaderClient::dispatchCreatePage() +{ + notImplemented(); + return 0; +} + +void FrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&) +{ + notImplemented(); +} + +void FrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError&) +{ + notImplemented(); +} + +void FrameLoaderClient::startDownload(const ResourceRequest&) +{ + notImplemented(); +} + +void FrameLoaderClient::updateGlobalHistory(const KURL&) +{ + notImplemented(); +} + +void FrameLoaderClient::savePlatformDataToCachedPage(CachedPage*) +{ + notImplemented(); +} + +void FrameLoaderClient::transitionToCommittedFromCachedPage(CachedPage*) +{ + notImplemented(); +} + +void FrameLoaderClient::transitionToCommittedForNewPage() +{ + notImplemented(); +} + +} diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h new file mode 100644 index 0000000..7e5e8b8 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2006 Zack Rusin <zack@kde.org> + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FrameLoaderClientGtk_h +#define FrameLoaderClientGtk_h + +#include "FrameLoaderClient.h" +#include "ResourceResponse.h" + +typedef struct _WebKitWebFrame WebKitWebFrame; + +namespace WebKit { + + class FrameLoaderClient : public WebCore::FrameLoaderClient { + public: + FrameLoaderClient(WebKitWebFrame*); + virtual ~FrameLoaderClient() { } + virtual void frameLoaderDestroyed(); + + WebKitWebFrame* webFrame() const { return m_frame; } + + virtual bool hasWebView() const; + virtual bool hasFrameView() const; + + virtual void makeRepresentation(WebCore::DocumentLoader*); + virtual void forceLayout(); + virtual void forceLayoutForNonHTML(); + + virtual void setCopiesOnScroll(); + + virtual void detachedFromParent1(); + virtual void detachedFromParent2(); + virtual void detachedFromParent3(); + virtual void detachedFromParent4(); + + virtual void loadedFromCachedPage(); + + 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 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 dispatchDidHandleOnloadEvents(); + virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); + virtual void dispatchDidCancelClientRedirect(); + virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double, double); + virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchWillClose(); + virtual void dispatchDidReceiveIcon(); + virtual void dispatchDidStartProvisionalLoad(); + virtual void dispatchDidReceiveTitle(const WebCore::String&); + 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 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&, const WebCore::String& frameName); + virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&); + virtual void cancelPolicyCheck(); + + virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); + + virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, WTF::PassRefPtr<WebCore::FormState>); + + virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); + virtual void revertToProvisionalState(WebCore::DocumentLoader*); + virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); + virtual void clearUnarchivingState(WebCore::DocumentLoader*); + + virtual void postProgressStartedNotification(); + virtual void postProgressEstimateChangedNotification(); + virtual void postProgressFinishedNotification(); + + 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 WebCore::Widget* createPlugin(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL&, const WTF::Vector<WebCore::String>&, const WTF::Vector<WebCore::String>&, const WebCore::String&, bool); + virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); + virtual WebCore::Widget* createJavaAppletWidget(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL& baseURL, const WTF::Vector<WebCore::String>& paramNames, const WTF::Vector<WebCore::String>& paramValues); + virtual WebCore::String overrideMediaType() const; + virtual void windowObjectCleared(); + virtual void didPerformFirstNavigation() const; + + virtual void registerForIconNotification(bool); + + virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); + + 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 finalSetupForReplace(WebCore::DocumentLoader*); + + virtual void updateGlobalHistory(const WebCore::KURL&); + virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; + + 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 bool shouldFallBack(const WebCore::ResourceError&); + + virtual void setDefersLoading(bool); + + virtual bool willUseArchive(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, const WebCore::KURL& originalURL) const; + virtual bool isArchiveLoadPending(WebCore::ResourceLoader*) const; + virtual void cancelPendingArchiveLoad(WebCore::ResourceLoader*); + virtual void clearArchivedResources(); + + virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; + virtual bool canShowMIMEType(const WebCore::String&) const; + virtual bool representationExistsForURLScheme(const WebCore::String&) const; + virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String&) const; + + virtual void frameLoadCompleted(); + virtual void saveViewStateToItem(WebCore::HistoryItem*); + virtual void restoreViewState(); + virtual void provisionalLoadStarted(); + virtual void didFinishLoad(); + virtual void prepareForDataSourceReplacement(); + + virtual WTF::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 savePlatformDataToCachedPage(WebCore::CachedPage*); + virtual void transitionToCommittedFromCachedPage(WebCore::CachedPage*); + virtual void transitionToCommittedForNewPage(); + + virtual bool canCachePage() const; + virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); + private: + WebKitWebFrame* m_frame; + WebCore::ResourceResponse m_response; + WebCore::String m_userAgent; + }; + +} + +#endif diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp new file mode 100644 index 0000000..a54b6a0 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp @@ -0,0 +1,80 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "InspectorClientGtk.h" + +#include "NotImplemented.h" +#include "PlatformString.h" + +using namespace WebCore; + +namespace WebKit { + +void InspectorClient::inspectorDestroyed() +{ + delete this; +} + +Page* InspectorClient::createPage() +{ + notImplemented(); + return 0; +} + +String InspectorClient::localizedStringsURL() +{ + notImplemented(); + return String(); +} + +void InspectorClient::showWindow() +{ + notImplemented(); +} + +void InspectorClient::closeWindow() +{ + notImplemented(); +} + +void InspectorClient::attachWindow() +{ + notImplemented(); +} + +void InspectorClient::detachWindow() +{ + notImplemented(); +} + +void InspectorClient::highlight(Node* node) +{ + notImplemented(); +} + +void InspectorClient::hideHighlight() +{ + notImplemented(); +} + +void InspectorClient::inspectedURLChanged(const String&) +{ + notImplemented(); +} + +} + diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h new file mode 100644 index 0000000..9afd42b --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 InspectorClientGtk_h +#define InspectorClientGtk_h + +#include "InspectorClient.h" + +namespace WebCore { + class Node; + class Page; + class String; +} + +namespace WebKit { + + class InspectorClient : public WebCore::InspectorClient { + public: + virtual void inspectorDestroyed(); + + virtual WebCore::Page* createPage(); + + virtual WebCore::String localizedStringsURL(); + + virtual void showWindow(); + virtual void closeWindow(); + + virtual void attachWindow(); + virtual void detachWindow(); + + virtual void highlight(WebCore::Node*); + virtual void hideHighlight(); + virtual void inspectedURLChanged(const WebCore::String& newURL); + }; +} + +#endif diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp new file mode 100644 index 0000000..9ef366d --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "Frame.h" +#include "PasteboardHelperGtk.h" + +#include "webkitwebframe.h" +#include "webkitwebview.h" +#include "webkitprivate.h" + +#include <gtk/gtk.h> + +using namespace WebCore; + +namespace WebKit +{ + +GtkClipboard* PasteboardHelperGtk::getClipboard(Frame* frame) const { + WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); + return gtk_widget_get_clipboard(GTK_WIDGET (webView), + GDK_SELECTION_CLIPBOARD); +} + +GtkTargetList* PasteboardHelperGtk::getCopyTargetList(Frame* frame) const { + WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); + return webkit_web_view_get_copy_target_list(webView); +} + +GtkTargetList* PasteboardHelperGtk::getPasteTargetList(Frame* frame) const { + WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); + return webkit_web_view_get_paste_target_list(webView); +} + +} diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h new file mode 100644 index 0000000..77e0457 --- /dev/null +++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com> + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef PasteboardHelperGtk_h +#define PasteboardHelperGtk_h + +/* + * FIXME: this is for WebCore support and must be removed once + * a better solution is found + */ + +#include "Frame.h" +#include "PasteboardHelper.h" + +#include <gtk/gtk.h> + +using namespace WebCore; + +namespace WebKit { + +class PasteboardHelperGtk : public PasteboardHelper { +public: + PasteboardHelperGtk() { } + virtual GtkClipboard* getClipboard(Frame*) const; + virtual GtkTargetList* getCopyTargetList(Frame*) const; + virtual GtkTargetList* getPasteTargetList(Frame*) const; +}; + +} + +#endif // PasteboardHelperGtk_h |