diff options
Diffstat (limited to 'WebKit/wx')
25 files changed, 4836 insertions, 0 deletions
diff --git a/WebKit/wx/Bakefiles.bkgen b/WebKit/wx/Bakefiles.bkgen new file mode 100644 index 0000000..44cc496 --- /dev/null +++ b/WebKit/wx/Bakefiles.bkgen @@ -0,0 +1,112 @@ +<?xml version="1.0" ?> +<!-- +Copyright (C) 2005, 2006, 2007 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. +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. + +Build configuration script for Bakefile. +--> + +<bakefile-gen> + + <input> + ../../JavaScriptCore/jscore.bkl + ../../WebCore/webcore-wx.bkl + wxwebkit.bkl + bindings/python/wxwebkit-py.bkl + ../../WebKitTools/wx/browser/browser.bkl + </input> + + <!-- List of output formats to generate: --> + <add-formats> + gnu,msvs2005prj,msvc + </add-formats> + + <!-- JSCore settings --> + <add-flags files="../../JavaScriptCore/jscore.bkl" formats="gnu"> + -o../../JavaScriptCore/GNUmakefile + </add-flags> + <add-flags files="../../JavaScriptCore/jscore.bkl" formats="msvs2005prj"> + -o../../JavaScriptCore/JavaScriptCore.sln + </add-flags> + <add-flags files="../../JavaScriptCore/jscore.bkl" formats="msvc"> + -o../../JavaScriptCore/makefile.vc + </add-flags> + <!-- testing XCode backend + <add-flags files="jscore.bkl" formats="xcode2"> + -o../WebCore/Projects/base/WebCoreBase.xcode + </add-flags> + --> + + <!-- wx port settings --> + <add-flags files="../../WebCore/webcore-wx.bkl" formats="gnu"> + -o../../WebCore/GNUmakefile + </add-flags> + <add-flags files="../../WebCore/webcore-wx.bkl" formats="msvs2005prj"> + -o../../WebCore/webcore-wx.sln + </add-flags> + <add-flags files="../../WebCore/webcore-wx.bkl" formats="msvc"> + -o../../WebCore/makefile.vc + </add-flags> + + <add-flags files="wxwebkit.bkl" formats="gnu"> + -oGNUmakefile + </add-flags> + <add-flags files="wxwebkit.bkl" formats="msvs2005prj"> + -owxWebKit.sln + </add-flags> + <add-flags files="wxwebkit.bkl" formats="msvc"> + -omakefile.vc + </add-flags> + + <add-flags files="bindings/python/wxwebkit-py.bkl" formats="gnu"> + -obindings/python/GNUmakefile + </add-flags> + <add-flags files="bindings/python/wxwebkit-py.bkl" formats="msvs2005prj"> + -obindings/python/wxWebKit.sln + </add-flags> + <add-flags files="bindings/python/wxwebkit-py.bkl" formats="msvc"> + -obindings/python/makefile.vc + </add-flags> + + <add-flags files="../../WebKitTools/wx/browser/browser.bkl" formats="gnu"> + -o../../WebKitTools/wx/browser/GNUmakefile + </add-flags> + <add-flags files="../../WebKitTools/wx/browser/browser.bkl" formats="msvs2005prj"> + -o../../WebKitTools/wx/browser/browser.sln + </add-flags> + <add-flags files="../../WebKitTools/wx/browser/browser.bkl" formats="msvc"> + -o../../WebKitTools/wx/browser/makefile.vc + </add-flags> + <!-- testing XCode backend + <add-flags files="webcore-wx.bkl" formats="xcode2"> + -o../WebCore/Projects/wx/wxWebCore.xcode + </add-flags> + --> + + <!-- Personal customizations (not in SVN): --> + <include file="Bakefiles.local.bkgen" ignore_missing="1"/> + +</bakefile-gen> diff --git a/WebKit/wx/WebFrame.cpp b/WebKit/wx/WebFrame.cpp new file mode 100644 index 0000000..cd46af6 --- /dev/null +++ b/WebKit/wx/WebFrame.cpp @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2007 Kevin Ollivier 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. + * + * This class provides a default new window implementation for wxWebView clients + * who don't want/need to roll their own browser frame UI. + */ + +#include "config.h" + +#include "wx/wxprec.h" +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/artprov.h" + +#include "WebView.h" +#include "WebFrame.h" +#include "WebViewPrivate.h" + +wxPageSourceViewFrame::wxPageSourceViewFrame(const wxString& source) + : wxFrame(NULL, wxID_ANY, _("Page Source View"), wxDefaultPosition, wxSize(600, 500)) +{ + wxTextCtrl* control = new wxTextCtrl(this, -1, source, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); +} + +enum { + ID_LOADFILE = wxID_HIGHEST + 1, + ID_TEXTCTRL = wxID_HIGHEST + 2, + ID_BACK = wxID_HIGHEST + 3, + ID_FORWARD = wxID_HIGHEST + 4, + ID_TOGGLE_BEFORE_LOAD = wxID_HIGHEST + 5, + ID_MAKE_TEXT_LARGER = wxID_HIGHEST + 6, + ID_MAKE_TEXT_SMALLER = wxID_HIGHEST + 7, + ID_STOP = wxID_HIGHEST + 8, + ID_RELOAD = wxID_HIGHEST + 9, + ID_GET_SOURCE = wxID_HIGHEST + 10, + ID_SET_SOURCE = wxID_HIGHEST + 11, + ID_SEARCHCTRL = wxID_HIGHEST + 12, + ID_LOADURL = wxID_HIGHEST + 13, + ID_NEW_WINDOW = wxID_HIGHEST + 14, + ID_BROWSE = wxID_HIGHEST + 15, + ID_EDIT = wxID_HIGHEST + 16, + ID_RUN_SCRIPT = wxID_HIGHEST + 17 +}; + +BEGIN_EVENT_TABLE(wxWebFrame, wxFrame) + EVT_MENU(wxID_EXIT, wxWebFrame::OnQuit) + EVT_MENU(wxID_ABOUT, wxWebFrame::OnAbout) + EVT_MENU(ID_LOADFILE, wxWebFrame::OnLoadFile) + EVT_TEXT_ENTER(ID_TEXTCTRL, wxWebFrame::OnAddressBarEnter) + EVT_TEXT_ENTER(ID_SEARCHCTRL, wxWebFrame::OnSearchCtrlEnter) + EVT_WEBVIEW_LOAD(wxWebFrame::OnLoadEvent) + EVT_WEBVIEW_BEFORE_LOAD(wxWebFrame::OnBeforeLoad) + EVT_MENU(ID_BACK, wxWebFrame::OnBack) + EVT_MENU(ID_FORWARD, wxWebFrame::OnForward) + EVT_MENU(ID_STOP, wxWebFrame::OnStop) + EVT_MENU(ID_RELOAD, wxWebFrame::OnReload) + EVT_MENU(ID_MAKE_TEXT_LARGER, wxWebFrame::OnMakeTextLarger) + EVT_MENU(ID_MAKE_TEXT_SMALLER, wxWebFrame::OnMakeTextSmaller) + EVT_MENU(ID_GET_SOURCE, wxWebFrame::OnGetSource) + EVT_MENU(ID_SET_SOURCE, wxWebFrame::OnSetSource) + EVT_MENU(ID_BROWSE, wxWebFrame::OnBrowse) + EVT_MENU(ID_EDIT, wxWebFrame::OnEdit) + EVT_MENU(ID_RUN_SCRIPT, wxWebFrame::OnRunScript) +END_EVENT_TABLE() + + +wxWebFrame::wxWebFrame(const wxString& title) : + wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600, 500)), + m_checkBeforeLoad(false) +{ + + // create a menu bar + wxMenu *fileMenu = new wxMenu; + fileMenu->Append(ID_NEW_WINDOW, _T("New Window\tCTRL+N")); + fileMenu->Append(ID_LOADFILE, _T("Open File...\tCTRL+O")); + fileMenu->Append(ID_LOADURL, _("Open Location...\tCTRL+L")); + fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program")); + + wxMenu *editMenu = new wxMenu; + editMenu->Append(wxID_CUT, _T("Cut\tCTRL+X")); + editMenu->Append(wxID_COPY, _T("Copy\tCTRL+C")); + editMenu->Append(wxID_PASTE, _T("Paste\tCTRL+V")); + + wxMenu* viewMenu = new wxMenu; + viewMenu->AppendRadioItem(ID_BROWSE, _("Browse")); + viewMenu->AppendRadioItem(ID_EDIT, _("Edit")); + viewMenu->AppendSeparator(); + viewMenu->Append(ID_STOP, _("Stop")); + viewMenu->Append(ID_RELOAD, _("Reload Page")); + viewMenu->Append(ID_MAKE_TEXT_SMALLER, _("Make Text Smaller\tCTRL+-")); + viewMenu->Append(ID_MAKE_TEXT_LARGER, _("Make Text Bigger\tCTRL++")); + viewMenu->AppendSeparator(); + viewMenu->Append(ID_GET_SOURCE, _("View Page Source")); + viewMenu->AppendSeparator(); + + m_debugMenu = new wxMenu; + m_debugMenu->Append(ID_SET_SOURCE, _("Test SetPageSource")); + m_debugMenu->Append(ID_RUN_SCRIPT, _("Test RunScript")); + + // the "About" item should be in the help menu + wxMenu *helpMenu = new wxMenu; + helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog")); + + // now append the freshly created menu to the menu bar... + wxMenuBar *menuBar = new wxMenuBar(); + menuBar->Append(fileMenu, _T("&File")); + menuBar->Append(editMenu, _T("&Edit")); + menuBar->Append(viewMenu, _T("&View")); + menuBar->Append(helpMenu, _T("&Help")); + + // ... and attach this menu bar to the frame + SetMenuBar(menuBar); + + wxToolBar* toolbar = CreateToolBar(); + toolbar->SetToolBitmapSize(wxSize(32, 32)); + + wxBitmap back = wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_TOOLBAR, wxSize(32,32)); + toolbar->AddTool(ID_BACK, back, wxT("Back")); + + wxBitmap forward = wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_TOOLBAR, wxSize(32,32)); + toolbar->AddTool(ID_FORWARD, forward, wxT("Next")); + + addressBar = new wxTextCtrl(toolbar, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(400, -1), wxTE_PROCESS_ENTER); + toolbar->AddControl(addressBar); + + searchCtrl = new wxSearchCtrl(toolbar, ID_SEARCHCTRL, _("Search"), wxDefaultPosition, wxSize(200, -1), wxTE_PROCESS_ENTER); + toolbar->AddControl(searchCtrl); + toolbar->Realize(); + + SetToolBar(toolbar); + + // Create the wxWebView Window + webview = new wxWebView((wxWindow*)this, 1001, wxDefaultPosition, wxSize(200, 200)); + webview->SetBackgroundColour(*wxWHITE); + + // create a status bar just for fun (by default with 1 pane only) + CreateStatusBar(2); +} + +wxWebFrame::~wxWebFrame() +{ + if (m_debugMenu && GetMenuBar()->FindMenu(_("&Debug")) == wxNOT_FOUND) + delete m_debugMenu; +} + +void wxWebFrame::ShowDebugMenu(bool show) +{ + int debugMenu = GetMenuBar()->FindMenu(_("&Debug")); + if (show && debugMenu == wxNOT_FOUND) { + int prevMenu = GetMenuBar()->FindMenu(_("&View")); + if (prevMenu != wxNOT_FOUND) + GetMenuBar()->Insert((size_t)prevMenu+1, m_debugMenu, _("&Debug")); + } + else if (!show && debugMenu != wxNOT_FOUND) { + GetMenuBar()->Remove(debugMenu); + } +} + +// event handlers + +void wxWebFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +{ + // true is to force the frame to close + Close(true); +} + +void wxWebFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) +{ + wxString msg; + msg.Printf(_T("This is the About dialog of the wxWebKit sample.\n") + _T("Welcome to %s"), wxVERSION_STRING); + + wxMessageBox(msg, _T("About wxWebKit Sample"), wxOK | wxICON_INFORMATION, this); + +} + +void wxWebFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event)) +{ + wxFileDialog* dialog = new wxFileDialog(this, wxT("Choose a file")); + if (dialog->ShowModal() == wxID_OK) { + wxString path = dialog->GetPath().Prepend(wxT("file://")); + + if (webview) + webview->LoadURL(path); + } +} + +void wxWebFrame::OnLoadEvent(wxWebViewLoadEvent& event) +{ + if (GetStatusBar() != NULL){ + if (event.GetState() == wxWEBVIEW_LOAD_NEGOTIATING) { + GetStatusBar()->SetStatusText(_("Contacting ") + event.GetURL()); + } + else if (event.GetState() == wxWEBVIEW_LOAD_TRANSFERRING) { + GetStatusBar()->SetStatusText(_("Loading ") + event.GetURL()); + } + else if (event.GetState() == wxWEBVIEW_LOAD_ONLOAD_HANDLED) { + GetStatusBar()->SetStatusText(_("Load complete.")); + addressBar->SetValue(event.GetURL()); + SetTitle(webview->GetPageTitle()); + } + else if (event.GetState() == wxWEBVIEW_LOAD_FAILED) { + GetStatusBar()->SetStatusText(_("Failed to load ") + event.GetURL()); + } + } +} + +void wxWebFrame::OnBeforeLoad(wxWebViewBeforeLoadEvent& myEvent) +{ + if (m_checkBeforeLoad) { + int reply = wxMessageBox(_("Would you like to continue loading ") + myEvent.GetURL() + wxT("?"), _("Continue Loading?"), wxYES_NO); + if (reply == wxNO) { + myEvent.Cancel(); + } + } +} + +void wxWebFrame::OnAddressBarEnter(wxCommandEvent& event) +{ + if (webview) + webview->LoadURL(addressBar->GetValue()); +} + +void wxWebFrame::OnSearchCtrlEnter(wxCommandEvent& event) +{ + if (webview) { + webview->LoadURL(wxString::Format(wxT("http://www.google.com/search?rls=en&q=%s&ie=UTF-8&oe=UTF-8"), searchCtrl->GetValue().wc_str())); + } +} + +void wxWebFrame::OnBack(wxCommandEvent& event) +{ + if (webview) + webview->GoBack(); +} + +void wxWebFrame::OnForward(wxCommandEvent& event) +{ + if (webview) + webview->GoForward(); +} + +void wxWebFrame::OnStop(wxCommandEvent& myEvent) +{ + if (webview) + webview->Stop(); +} + +void wxWebFrame::OnReload(wxCommandEvent& myEvent) +{ + if (webview) + webview->Reload(); +} + +void wxWebFrame::OnMakeTextLarger(wxCommandEvent& myEvent) +{ + if (webview) { + if (webview->CanIncreaseTextSize()) + webview->IncreaseTextSize(); + } +} + +void wxWebFrame::OnMakeTextSmaller(wxCommandEvent& myEvent) +{ + if (webview) { + if (webview->CanDecreaseTextSize()) + webview->DecreaseTextSize(); + } +} + +void wxWebFrame::OnGetSource(wxCommandEvent& myEvent) +{ + if (webview) { + wxPageSourceViewFrame* wxWebFrame = new wxPageSourceViewFrame(webview->GetPageSource()); + wxWebFrame->Show(); + } +} + +void wxWebFrame::OnSetSource(wxCommandEvent& event) +{ + if (webview) + webview->SetPageSource(wxString(wxT("<p>Hello World!</p>"))); +} + +void wxWebFrame::OnBrowse(wxCommandEvent& event) +{ + if (webview) + webview->MakeEditable(!event.IsChecked()); +} + +void wxWebFrame::OnEdit(wxCommandEvent& event) +{ + if (webview) + webview->MakeEditable(event.IsChecked()); +} + +void wxWebFrame::OnRunScript(wxCommandEvent& myEvent){ + if (webview) { + wxTextEntryDialog* dialog = new wxTextEntryDialog(this, _("Type in a JavaScript to exectute.")); + if (dialog->ShowModal() == wxID_OK) + wxMessageBox(wxT("Result is: ") + webview->RunScript(dialog->GetValue())); + + dialog->Destroy(); + } +} diff --git a/WebKit/wx/WebFrame.h b/WebKit/wx/WebFrame.h new file mode 100644 index 0000000..046a650 --- /dev/null +++ b/WebKit/wx/WebFrame.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * 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 WXWEBFRAME_H +#define WXWEBFRAME_H + +#include "wx/wxprec.h" +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "WebView.h" +#include <wx/srchctrl.h> + +class WXDLLIMPEXP_WEBKIT wxWebFrame : public wxFrame +{ +public: + // ctor(s) +#if SWIG + %pythonAppend wxWebFrame "self._setOORInfo(self)" +#endif + wxWebFrame(const wxString& title); + +#ifndef SWIG + ~wxWebFrame(); +#endif + + void ShowDebugMenu(bool show = true); + wxWebView* webview; + +protected: + + // event handlers (these functions should _not_ be virtual) + void OnQuit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + void OnLoadFile(wxCommandEvent& event); + void OnAddressBarEnter(wxCommandEvent& event); + void OnSearchCtrlEnter(wxCommandEvent& event); + void OnLoadEvent(wxWebViewLoadEvent& event); + void OnBeforeLoad(wxWebViewBeforeLoadEvent& event); + void OnBack(wxCommandEvent& event); + void OnForward(wxCommandEvent& event); + void OnStop(wxCommandEvent& event); + void OnReload(wxCommandEvent& event); + void OnBrowse(wxCommandEvent& event); + void OnEdit(wxCommandEvent& event); + + void OnMakeTextLarger(wxCommandEvent& event); + void OnMakeTextSmaller(wxCommandEvent& event); + void OnGetSource(wxCommandEvent& event); + + // debug menu items + void OnSetSource(wxCommandEvent& event); + void OnRunScript(wxCommandEvent& myEvent); + +private: + wxTextCtrl* addressBar; + wxSearchCtrl* searchCtrl; + + bool m_checkBeforeLoad; + wxMenu* m_debugMenu; + // any class wishing to process wxWindows events must use this macro +#ifndef SWIG + DECLARE_EVENT_TABLE() +#endif +}; + +class WXDLLIMPEXP_WEBKIT wxPageSourceViewFrame : public wxFrame +{ +public: + wxPageSourceViewFrame(const wxString& source); +}; + +#endif // ifndef WXWEBFRAME_H diff --git a/WebKit/wx/WebKitSupport/ChromeClientWx.cpp b/WebKit/wx/WebKitSupport/ChromeClientWx.cpp new file mode 100644 index 0000000..579e3f9 --- /dev/null +++ b/WebKit/wx/WebKitSupport/ChromeClientWx.cpp @@ -0,0 +1,322 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ChromeClientWx.h" +#include "FloatRect.h" +#include "FrameLoadRequest.h" +#include "NotImplemented.h" +#include "PlatformString.h" + +#include <stdio.h> + +#include <wx/wxprec.h> +#ifndef WX_PRECOMP + #include <wx/wx.h> +#endif +#include <wx/textdlg.h> + +#include "WebFrame.h" +#include "WebView.h" +#include "WebViewPrivate.h" + +namespace WebCore { + +ChromeClientWx::ChromeClientWx(wxWebView* webView) +{ + m_webView = webView; +} + +ChromeClientWx::~ChromeClientWx() +{ +} + +void ChromeClientWx::chromeDestroyed() +{ + notImplemented(); +} + +void ChromeClientWx::setWindowRect(const FloatRect&) +{ + notImplemented(); +} + +FloatRect ChromeClientWx::windowRect() +{ + notImplemented(); + return FloatRect(); +} + +FloatRect ChromeClientWx::pageRect() +{ + notImplemented(); + return FloatRect(); +} + +float ChromeClientWx::scaleFactor() +{ + notImplemented(); + return 0.0; +} + +void ChromeClientWx::focus() +{ + notImplemented(); +} + +void ChromeClientWx::unfocus() +{ + notImplemented(); +} + +bool ChromeClientWx::canTakeFocus(FocusDirection) +{ + notImplemented(); + return false; +} + +void ChromeClientWx::takeFocus(FocusDirection) +{ + notImplemented(); +} + + +Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures&) +{ + + // FIXME: Create a EVT_WEBKIT_NEW_WINDOW event, and only run this code + // when that event is not handled. + + Page* myPage = 0; + wxWebFrame* newFrame = new wxWebFrame(wxTheApp->GetAppName()); + + if (newFrame->webview) { + newFrame->webview->LoadURL(request.resourceRequest().url().string()); + newFrame->Show(true); + + WebViewPrivate* impl = newFrame->webview->m_impl; + if (impl) + myPage = impl->frame->page(); + } + + return myPage; +} + +Page* ChromeClientWx::createModalDialog(Frame*, const FrameLoadRequest&) +{ + notImplemented(); + return 0; +} + +void ChromeClientWx::show() +{ + notImplemented(); +} + +bool ChromeClientWx::canRunModal() +{ + notImplemented(); + return false; +} + +void ChromeClientWx::runModal() +{ + notImplemented(); +} + +void ChromeClientWx::setToolbarsVisible(bool) +{ + notImplemented(); +} + +bool ChromeClientWx::toolbarsVisible() +{ + notImplemented(); + return false; +} + +void ChromeClientWx::setStatusbarVisible(bool) +{ + notImplemented(); +} + +bool ChromeClientWx::statusbarVisible() +{ + notImplemented(); + return false; +} + +void ChromeClientWx::setScrollbarsVisible(bool) +{ + notImplemented(); +} + +bool ChromeClientWx::scrollbarsVisible() +{ + notImplemented(); + return false; +} + +void ChromeClientWx::setMenubarVisible(bool) +{ + notImplemented(); +} + +bool ChromeClientWx::menubarVisible() +{ + notImplemented(); + return false; +} + +void ChromeClientWx::setResizable(bool) +{ + notImplemented(); +} + +void ChromeClientWx::addMessageToConsole(const String& message, + unsigned int lineNumber, + const String& sourceID) +{ + if (m_webView) { + wxWebViewConsoleMessageEvent wkEvent(m_webView); + wkEvent.SetMessage(message); + wkEvent.SetLineNumber(lineNumber); + wkEvent.SetSourceID(sourceID); + m_webView->GetEventHandler()->ProcessEvent(wkEvent); + } +} + +bool ChromeClientWx::canRunBeforeUnloadConfirmPanel() +{ + notImplemented(); + return true; +} + +bool ChromeClientWx::runBeforeUnloadConfirmPanel(const String& string, + Frame* frame) +{ + wxMessageDialog dialog(NULL, string, wxT("Confirm Action?"), wxYES_NO); + return dialog.ShowModal() == wxYES; +} + +void ChromeClientWx::closeWindowSoon() +{ + notImplemented(); +} + +/* + Sites for testing prompts: + Alert - just type in a bad web address or http://www.htmlite.com/JS002.php + Prompt - http://www.htmlite.com/JS007.php + Confirm - http://www.htmlite.com/JS006.php +*/ + +void ChromeClientWx::runJavaScriptAlert(Frame* frame, const String& string) +{ + wxMessageBox(string, wxT("JavaScript Alert"), wxOK); +} + +bool ChromeClientWx::runJavaScriptConfirm(Frame* frame, const String& string) +{ + wxMessageDialog dialog(NULL, string, wxT("JavaScript Confirm"), wxYES_NO); + dialog.Centre(); + return (dialog.ShowModal() == wxID_YES); +} + +bool ChromeClientWx::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result) +{ + wxTextEntryDialog dialog(NULL, message, wxT("JavaScript Prompt"), wxEmptyString, wxOK | wxCANCEL); + dialog.Centre(); + if (dialog.ShowModal() == wxID_OK) { + result = dialog.GetValue(); + return true; + } + + return false; +} + +void ChromeClientWx::setStatusbarText(const String&) +{ + notImplemented(); +} + +bool ChromeClientWx::shouldInterruptJavaScript() +{ + notImplemented(); + return false; +} + +bool ChromeClientWx::tabsToLinks() const +{ + notImplemented(); + return false; +} + +IntRect ChromeClientWx::windowResizerRect() const +{ + notImplemented(); + return IntRect(); +} + +void ChromeClientWx::addToDirtyRegion(const IntRect&) +{ + notImplemented(); +} + +void ChromeClientWx::scrollBackingStore(int dx, int dy, + const IntRect& scrollViewRect, + const IntRect& clipRect) +{ + notImplemented(); +} + +void ChromeClientWx::updateBackingStore() +{ + notImplemented(); +} + +void ChromeClientWx::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) +{ + notImplemented(); +} + +void ChromeClientWx::setToolTip(const String&) +{ + notImplemented(); +} + +void ChromeClientWx::print(Frame*) +{ + notImplemented(); +} + +void ChromeClientWx::exceededDatabaseQuota(Frame*, const String&) +{ + notImplemented(); +} + +} diff --git a/WebKit/wx/WebKitSupport/ChromeClientWx.h b/WebKit/wx/WebKitSupport/ChromeClientWx.h new file mode 100644 index 0000000..d80f3f2 --- /dev/null +++ b/WebKit/wx/WebKitSupport/ChromeClientWx.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * 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 ChromeClientWx_H +#define ChromeClientWx_H + +#include "ChromeClient.h" +#include "FocusDirection.h" +#include "IntRect.h" +#include "WebView.h" + +namespace WebCore { + +class ChromeClientWx : public ChromeClient { +public: + ChromeClientWx(wxWebView*); + virtual ~ChromeClientWx(); + virtual void chromeDestroyed(); + + virtual void setWindowRect(const FloatRect&); + virtual FloatRect windowRect(); + + virtual FloatRect pageRect(); + + virtual float scaleFactor(); + + virtual void focus(); + virtual void unfocus(); + + virtual bool canTakeFocus(FocusDirection); + virtual void takeFocus(FocusDirection); + + virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&); + virtual Page* createModalDialog(Frame*, const FrameLoadRequest&); + 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 String& message, + unsigned int lineNumber, + const String& sourceID); + + virtual bool canRunBeforeUnloadConfirmPanel(); + virtual bool runBeforeUnloadConfirmPanel(const String& message, + Frame* frame); + + virtual void closeWindowSoon(); + + virtual void runJavaScriptAlert(Frame*, const String&); + virtual bool runJavaScriptConfirm(Frame*, const String&); + virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result); + virtual void setStatusbarText(const String&); + virtual bool shouldInterruptJavaScript(); + + virtual bool tabsToLinks() const; + + virtual IntRect windowResizerRect() const; + virtual void addToDirtyRegion(const IntRect&); + virtual void scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect); + virtual void updateBackingStore(); + + virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); + + virtual void setToolTip(const String&); + + virtual void print(Frame*); + + virtual void exceededDatabaseQuota(Frame*, const String&); + +private: + wxWebView* m_webView; +}; + +} +#endif // ChromeClientWx_H diff --git a/WebKit/wx/WebKitSupport/ContextMenuClientWx.cpp b/WebKit/wx/WebKitSupport/ContextMenuClientWx.cpp new file mode 100644 index 0000000..8f88f1a --- /dev/null +++ b/WebKit/wx/WebKitSupport/ContextMenuClientWx.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ContextMenuClientWx.h" +#include "NotImplemented.h" +#include <stdio.h> + +namespace WebCore { + +ContextMenuClientWx::~ContextMenuClientWx() +{ +} + +void ContextMenuClientWx::contextMenuDestroyed() +{ + notImplemented(); +} + +PlatformMenuDescription ContextMenuClientWx::getCustomMenuFromDefaultItems(ContextMenu*) +{ + notImplemented(); + return 0; +} + +void ContextMenuClientWx::contextMenuItemSelected(ContextMenuItem*, + const ContextMenu*) +{ + notImplemented(); +} + +void ContextMenuClientWx::downloadURL(const KURL&) +{ + notImplemented(); +} + +void ContextMenuClientWx::copyImageToClipboard(const HitTestResult&) +{ + notImplemented(); +} + +void ContextMenuClientWx::searchWithGoogle(const Frame*) +{ + notImplemented(); +} + +void ContextMenuClientWx::lookUpInDictionary(Frame*) +{ + notImplemented(); +} + +void ContextMenuClientWx::speak(const String&) +{ + notImplemented(); +} + +void ContextMenuClientWx::stopSpeaking() +{ + notImplemented(); +} + +} diff --git a/WebKit/wx/WebKitSupport/ContextMenuClientWx.h b/WebKit/wx/WebKitSupport/ContextMenuClientWx.h new file mode 100644 index 0000000..2655974 --- /dev/null +++ b/WebKit/wx/WebKitSupport/ContextMenuClientWx.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * 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 ContextMenuClientWx_h +#define ContextMenuClientWx_h + +#include "ContextMenuClient.h" +#include "PlatformMenuDescription.h" + +namespace WebCore { + +class ContextMenuClientWx : public ContextMenuClient { +public: + virtual ~ContextMenuClientWx(); + virtual void contextMenuDestroyed(); + + virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*); + virtual void contextMenuItemSelected(ContextMenuItem*, + const ContextMenu*); + + virtual void downloadURL(const KURL&); + virtual void copyImageToClipboard(const HitTestResult&); + virtual void searchWithGoogle(const Frame*); + virtual void lookUpInDictionary(Frame*); + virtual void speak(const String&); + virtual void stopSpeaking(); +}; + +} + +#endif // ContextMenuClientWx_h diff --git a/WebKit/wx/WebKitSupport/DragClientWx.cpp b/WebKit/wx/WebKitSupport/DragClientWx.cpp new file mode 100644 index 0000000..dcccc34 --- /dev/null +++ b/WebKit/wx/WebKitSupport/DragClientWx.cpp @@ -0,0 +1,75 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "DragClientWx.h" +#include "NotImplemented.h" + +#include <stdio.h> + +namespace WebCore { + +DragDestinationAction DragClientWx::actionMaskForDrag(DragData*) +{ + notImplemented(); + return DragDestinationActionAny; +} + +void DragClientWx::willPerformDragDestinationAction(DragDestinationAction, + DragData*) +{ + notImplemented(); +} + +void DragClientWx::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) +{ + notImplemented(); +} + +void DragClientWx::dragControllerDestroyed() +{ + notImplemented(); +} + +DragSourceAction DragClientWx::dragSourceActionMaskForPoint(const IntPoint&) +{ + notImplemented(); + return DragSourceActionAny; +} + +void DragClientWx::startDrag(DragImageRef dragImage, + const IntPoint& dragImageOrigin, + const IntPoint& eventPos, Clipboard*, + Frame*, bool linkDrag) +{ + notImplemented(); +} + +DragImageRef DragClientWx::createDragImageForLink(KURL&, const String& label, Frame*) +{ + notImplemented(); + return 0; +} + +} diff --git a/WebKit/wx/WebKitSupport/DragClientWx.h b/WebKit/wx/WebKitSupport/DragClientWx.h new file mode 100644 index 0000000..0e93e66 --- /dev/null +++ b/WebKit/wx/WebKitSupport/DragClientWx.h @@ -0,0 +1,45 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "DragClient.h" +#include "DragData.h" + +namespace WebCore { + +class DragClientWx : 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 void dragControllerDestroyed(); + virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint&); + + 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*); +}; + +} diff --git a/WebKit/wx/WebKitSupport/EditorClientWx.cpp b/WebKit/wx/WebKitSupport/EditorClientWx.cpp new file mode 100644 index 0000000..7e8889c --- /dev/null +++ b/WebKit/wx/WebKitSupport/EditorClientWx.cpp @@ -0,0 +1,390 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "config.h" +#include "EditorClientWx.h" + +#include "EditCommand.h" +#include "Editor.h" +#include "FocusController.h" +#include "Frame.h" +#include "FrameView.h" +#include "KeyboardEvent.h" +#include "KeyboardCodes.h" +#include "NotImplemented.h" +#include "Page.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformString.h" +#include "SelectionController.h" +#include "WebView.h" + +#include <stdio.h> + +namespace WebCore { + +EditorClientWx::~EditorClientWx() +{ + m_page = NULL; +} + +void EditorClientWx::setPage(Page* page) +{ + m_page = page; +} + +void EditorClientWx::pageDestroyed() +{ + notImplemented(); +} + +bool EditorClientWx::shouldDeleteRange(Range*) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldShowDeleteInterface(HTMLElement*) +{ + notImplemented(); + return false; +} + +bool EditorClientWx::smartInsertDeleteEnabled() +{ + notImplemented(); + return false; +} + +bool EditorClientWx::isContinuousSpellCheckingEnabled() +{ + notImplemented(); + return false; +} + +void EditorClientWx::toggleContinuousSpellChecking() +{ + notImplemented(); +} + +bool EditorClientWx::isGrammarCheckingEnabled() +{ + notImplemented(); + return false; +} + +void EditorClientWx::toggleGrammarChecking() +{ + notImplemented(); +} + +int EditorClientWx::spellCheckerDocumentTag() +{ + notImplemented(); + return 0; +} + +bool EditorClientWx::selectWordBeforeMenuEvent() +{ + notImplemented(); + return false; +} + +bool EditorClientWx::isEditable() +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + + if (frame) { + wxWebView* webKitWin = dynamic_cast<wxWebView*>(frame->view()->nativeWindow()); + if (webKitWin) + return webKitWin->IsEditable(); + } + return false; +} + +bool EditorClientWx::shouldBeginEditing(Range*) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldEndEditing(Range*) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldInsertNode(Node*, Range*, + EditorInsertAction) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldInsertText(String, Range*, + EditorInsertAction) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldApplyStyle(CSSStyleDeclaration*, + Range*) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldMoveRangeAfterDelete(Range*, Range*) +{ + notImplemented(); + return true; +} + +bool EditorClientWx::shouldChangeSelectedRange(Range* fromRange, Range* toRange, + EAffinity, bool stillSelecting) +{ + notImplemented(); + return true; +} + +void EditorClientWx::didBeginEditing() +{ + notImplemented(); +} + +void EditorClientWx::respondToChangedContents() +{ + notImplemented(); +} + +void EditorClientWx::didEndEditing() +{ + notImplemented(); +} + +void EditorClientWx::didWriteSelectionToPasteboard() +{ + notImplemented(); +} + +void EditorClientWx::didSetSelectionTypesForPasteboard() +{ + notImplemented(); +} + +void EditorClientWx::registerCommandForUndo(PassRefPtr<EditCommand>) +{ + notImplemented(); +} + +void EditorClientWx::registerCommandForRedo(PassRefPtr<EditCommand>) +{ + notImplemented(); +} + +void EditorClientWx::clearUndoRedoOperations() +{ + notImplemented(); +} + +bool EditorClientWx::canUndo() const +{ + notImplemented(); + return false; +} + +bool EditorClientWx::canRedo() const +{ + notImplemented(); + return false; +} + +void EditorClientWx::undo() +{ + notImplemented(); +} + +void EditorClientWx::redo() +{ + notImplemented(); +} + +void EditorClientWx::handleInputMethodKeydown(KeyboardEvent* event) +{ +// NOTE: we don't currently need to handle this. When key events occur, +// both this method and handleKeyboardEvent get a chance at handling them. +// We might use this method later on for IME-specific handling. +} + +void EditorClientWx::handleKeyboardEvent(KeyboardEvent* event) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return; + + const PlatformKeyboardEvent* kevent = event->keyEvent(); + if (!kevent->type() == PlatformKeyboardEvent::KeyUp) { + Node* start = frame->selectionController()->start().node(); + if (!start || !start->isContentEditable()) + return; + + if (kevent->type() == PlatformKeyboardEvent::Char && !kevent->ctrlKey() && !kevent->altKey()) { + switch (kevent->windowsVirtualKeyCode()) { + // we handled these on key down, ignore them for char events + case VK_BACK: + case VK_DELETE: + case VK_LEFT: + case VK_RIGHT: + case VK_UP: + case VK_DOWN: + case VK_RETURN: + break; + default: + frame->editor()->insertText(kevent->text(), event); + } + event->setDefaultHandled(); + return; + } + + switch (kevent->windowsVirtualKeyCode()) { + case VK_BACK: + frame->editor()->deleteWithDirection(SelectionController::BACKWARD, + CharacterGranularity, false, true); + break; + case VK_DELETE: + frame->editor()->deleteWithDirection(SelectionController::FORWARD, + CharacterGranularity, false, true); + break; + case VK_LEFT: + frame->editor()->command("MoveLeft").execute(); + break; + case VK_RIGHT: + frame->editor()->command("MoveRight").execute(); + break; + case VK_UP: + frame->editor()->command("MoveUp").execute(); + break; + case VK_DOWN: + frame->editor()->command("MoveDown").execute(); + break; + case VK_RETURN: + frame->editor()->command("InsertLineBreak").execute(); + default: + break; + } + + event->setDefaultHandled(); + } +} + +void EditorClientWx::textFieldDidBeginEditing(Element*) +{ + notImplemented(); +} + +void EditorClientWx::textFieldDidEndEditing(Element*) +{ + notImplemented(); +} + +void EditorClientWx::textDidChangeInTextField(Element*) +{ + notImplemented(); +} + +bool EditorClientWx::doTextFieldCommandFromEvent(Element*, KeyboardEvent*) +{ + notImplemented(); + return false; +} + +void EditorClientWx::textWillBeDeletedInTextField(Element*) +{ + notImplemented(); +} + +void EditorClientWx::textDidChangeInTextArea(Element*) +{ + notImplemented(); +} + +void EditorClientWx::respondToChangedSelection() +{ + notImplemented(); +} + +void EditorClientWx::ignoreWordInSpellDocument(const String&) +{ + notImplemented(); +} + +void EditorClientWx::learnWord(const String&) +{ + notImplemented(); +} + +void EditorClientWx::checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) +{ + notImplemented(); +} + +void EditorClientWx::checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) +{ + notImplemented(); +} + +void EditorClientWx::updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail) +{ + notImplemented(); +} + +void EditorClientWx::updateSpellingUIWithMisspelledWord(const String&) +{ + notImplemented(); +} + +void EditorClientWx::showSpellingUI(bool show) +{ + notImplemented(); +} + +bool EditorClientWx::spellingUIIsShowing() +{ + notImplemented(); + return false; +} + +void EditorClientWx::getGuessesForWord(const String&, Vector<String>& guesses) +{ + notImplemented(); +} + +void EditorClientWx::setInputMethodState(bool enabled) +{ + notImplemented(); +} + +} diff --git a/WebKit/wx/WebKitSupport/EditorClientWx.h b/WebKit/wx/WebKitSupport/EditorClientWx.h new file mode 100644 index 0000000..c2234d0 --- /dev/null +++ b/WebKit/wx/WebKitSupport/EditorClientWx.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * 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 EditorClientWx_h +#define EditorClientWx_h + +#include "EditorClient.h" +#include "Page.h" + +namespace WebCore { + +class EditorClientWx : public EditorClient { +public: + virtual ~EditorClientWx(); + void setPage(Page*); + virtual void pageDestroyed(); + + virtual bool shouldDeleteRange(Range*); + virtual bool shouldShowDeleteInterface(HTMLElement*); + virtual bool smartInsertDeleteEnabled(); + virtual bool isContinuousSpellCheckingEnabled(); + virtual void toggleContinuousSpellChecking(); + virtual bool isGrammarCheckingEnabled(); + virtual void toggleGrammarChecking(); + virtual int spellCheckerDocumentTag(); + + virtual bool selectWordBeforeMenuEvent(); + virtual bool isEditable(); + + virtual bool shouldBeginEditing(Range*); + virtual bool shouldEndEditing(Range*); + virtual bool shouldInsertNode(Node*, Range*, + EditorInsertAction); + virtual bool shouldInsertText(String, Range*, + EditorInsertAction); + virtual bool shouldApplyStyle(CSSStyleDeclaration*, + Range*); + virtual bool shouldMoveRangeAfterDelete(Range*, Range*); + virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, + EAffinity, bool stillSelecting); + + virtual void didBeginEditing(); + virtual void respondToChangedContents(); + virtual void respondToChangedSelection(); + virtual void didEndEditing(); + virtual void didWriteSelectionToPasteboard(); + virtual void didSetSelectionTypesForPasteboard(); + + virtual void registerCommandForUndo(PassRefPtr<EditCommand>); + virtual void registerCommandForRedo(PassRefPtr<EditCommand>); + virtual void clearUndoRedoOperations(); + + virtual bool canUndo() const; + virtual bool canRedo() const; + + virtual void undo(); + virtual void redo(); + + virtual void handleKeyboardEvent(KeyboardEvent*); + virtual void handleInputMethodKeydown(KeyboardEvent*); + + virtual void textFieldDidBeginEditing(Element*); + virtual void textFieldDidEndEditing(Element*); + virtual void textDidChangeInTextField(Element*); + virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*); + virtual void textWillBeDeletedInTextField(Element*); + virtual void textDidChangeInTextArea(Element*); + + virtual void ignoreWordInSpellDocument(const String&); + virtual void learnWord(const String&); + virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); + virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); + virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail); + virtual void updateSpellingUIWithMisspelledWord(const String&); + virtual void showSpellingUI(bool show); + virtual bool spellingUIIsShowing(); + virtual void getGuessesForWord(const String&, Vector<String>& guesses); + virtual void setInputMethodState(bool enabled); + +private: + Page* m_page; +}; + +} + +#endif // EditorClientWx_h diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp new file mode 100644 index 0000000..6367e22 --- /dev/null +++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp @@ -0,0 +1,906 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FrameLoaderClientWx.h" + +#include "DocumentLoader.h" +#include "Frame.h" +#include "FrameLoaderTypes.h" +#include "FrameView.h" +#include "FrameTree.h" +#include "HTMLFormElement.h" +#include "NotImplemented.h" +#include "Page.h" +#include "PlatformString.h" +#include "ProgressTracker.h" +#include "ResourceError.h" +#include "ResourceResponse.h" + +#include <stdio.h> + +#include "WebView.h" +#include "WebViewPrivate.h" + +namespace WebCore { + +inline int wxNavTypeFromWebNavType(NavigationType type){ + if (type == NavigationTypeLinkClicked) + return wxWEBVIEW_NAV_LINK_CLICKED; + + if (type == NavigationTypeFormSubmitted) + return wxWEBVIEW_NAV_FORM_SUBMITTED; + + if (type == NavigationTypeBackForward) + return wxWEBVIEW_NAV_BACK_NEXT; + + if (type == NavigationTypeReload) + return wxWEBVIEW_NAV_RELOAD; + + if (type == NavigationTypeFormResubmitted) + return wxWEBVIEW_NAV_FORM_RESUBMITTED; + + return wxWEBVIEW_NAV_OTHER; +} + +FrameLoaderClientWx::FrameLoaderClientWx() + : RefCounted<FrameLoaderClientWx>(0) + , m_frame(0) +{ +} + + +FrameLoaderClientWx::~FrameLoaderClientWx() +{ +} + +void FrameLoaderClientWx::setFrame(Frame *frame) +{ + m_frame = frame; +} + +void FrameLoaderClientWx::detachFrameLoader() +{ + m_frame = 0; +} + +void FrameLoaderClientWx::ref() +{ + RefCounted<FrameLoaderClientWx>::ref(); +} + +void FrameLoaderClientWx::deref() +{ + RefCounted<FrameLoaderClientWx>::deref(); +} + +bool FrameLoaderClientWx::hasWebView() const +{ + notImplemented(); + return true; +} + + +bool FrameLoaderClientWx::hasFrameView() const +{ + notImplemented(); + return true; +} + + +bool FrameLoaderClientWx::hasBackForwardList() const +{ + notImplemented(); + return true; +} + + +void FrameLoaderClientWx::resetBackForwardList() +{ + notImplemented(); +} + + +bool FrameLoaderClientWx::provisionalItemIsTarget() const +{ + notImplemented(); + return false; +} + +void FrameLoaderClientWx::makeRepresentation(DocumentLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::forceLayout() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::forceLayoutForNonHTML() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::updateHistoryForCommit() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::updateHistoryForBackForwardNavigation() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::updateHistoryForReload() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::updateHistoryForStandardLoad() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::updateHistoryForInternalLoad() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::updateHistoryAfterClientRedirect() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::setCopiesOnScroll() +{ + // apparently mac specific + notImplemented(); +} + + +LoadErrorResetToken* FrameLoaderClientWx::tokenForLoadErrorReset() +{ + notImplemented(); + return 0; +} + + +void FrameLoaderClientWx::resetAfterLoadError(LoadErrorResetToken*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::doNotResetAfterLoadError(LoadErrorResetToken*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::willCloseDocument() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::detachedFromParent1() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::detachedFromParent2() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::detachedFromParent3() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::detachedFromParent4() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::loadedFromCachedPage() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchDidHandleOnloadEvents() +{ + wxWindow* target = m_frame->view()->nativeWindow(); + if (target) { + wxWebViewLoadEvent wkEvent(target); + wkEvent.SetState(wxWEBVIEW_LOAD_ONLOAD_HANDLED); + wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string()); + target->GetEventHandler()->ProcessEvent(wkEvent); + } +} + + +void FrameLoaderClientWx::dispatchDidReceiveServerRedirectForProvisionalLoad() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchDidCancelClientRedirect() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchWillPerformClientRedirect(const KURL&, + double interval, + double fireDate) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchDidChangeLocationWithinPage() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchWillClose() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchDidStartProvisionalLoad() +{ + wxWindow* target = m_frame->view()->nativeWindow(); + if (target) { + wxWebViewLoadEvent wkEvent(target); + wkEvent.SetState(wxWEBVIEW_LOAD_NEGOTIATING); + wkEvent.SetURL(m_frame->loader()->provisionalDocumentLoader()->request().url().string()); + target->GetEventHandler()->ProcessEvent(wkEvent); + } +} + + +void FrameLoaderClientWx::dispatchDidReceiveTitle(const String& title) +{ + wxWebView* target = static_cast<wxWebView*>(m_frame->view()->nativeWindow()); + if (target) + target->SetPageTitle(title); +} + + +void FrameLoaderClientWx::dispatchDidCommitLoad() +{ + wxWindow* target = m_frame->view()->nativeWindow(); + if (target) { + wxWebViewLoadEvent wkEvent(target); + wkEvent.SetState(wxWEBVIEW_LOAD_TRANSFERRING); + wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string()); + target->GetEventHandler()->ProcessEvent(wkEvent); + } +} + +void FrameLoaderClientWx::dispatchDidFinishDocumentLoad() +{ + wxWindow* target = m_frame->view()->nativeWindow(); + if (target) { + wxWebViewLoadEvent wkEvent(target); + wkEvent.SetState(wxWEBVIEW_LOAD_DOC_COMPLETED); + wkEvent.SetURL(m_frame->loader()->url().string()); + target->GetEventHandler()->ProcessEvent(wkEvent); + } +} + +void FrameLoaderClientWx::dispatchDidFinishLoad() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchDidFirstLayout() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchShow() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::cancelPolicyCheck() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::dispatchWillSubmitForm(FramePolicyFunction function, + PassRefPtr<FormState>) +{ + // FIXME: Send an event to allow for alerts and cancellation + if (!m_frame) + return; + (m_frame->loader()->*function)(PolicyUse); +} + + +void FrameLoaderClientWx::dispatchDidLoadMainResource(DocumentLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::revertToProvisionalState(DocumentLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::clearUnarchivingState(DocumentLoader*) +{ + notImplemented(); +} + +void FrameLoaderClientWx::postProgressStartedNotification() +{ + notImplemented(); +} + +void FrameLoaderClientWx::postProgressEstimateChangedNotification() +{ + notImplemented(); +} + +void FrameLoaderClientWx::postProgressFinishedNotification() +{ + wxWindow* target = m_frame->view()->nativeWindow(); + if (target) { + wxWebViewLoadEvent wkEvent(target); + wkEvent.SetState(wxWEBVIEW_LOAD_DL_COMPLETED); + wkEvent.SetURL(m_frame->loader()->url().string()); + target->GetEventHandler()->ProcessEvent(wkEvent); + } +} + +void FrameLoaderClientWx::progressStarted() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::progressCompleted() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::setMainFrameDocumentReady(bool b) +{ + notImplemented(); + // this is only interesting once we provide an external API for the DOM +} + + +void FrameLoaderClientWx::willChangeTitle(DocumentLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::didChangeTitle(DocumentLoader *l) +{ + setTitle(l->title(), l->url()); +} + + +void FrameLoaderClientWx::finishedLoading(DocumentLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::finalSetupForReplace(DocumentLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::setDefersLoading(bool) +{ + notImplemented(); +} + + +bool FrameLoaderClientWx::isArchiveLoadPending(ResourceLoader*) const +{ + notImplemented(); + return false; +} + + +void FrameLoaderClientWx::cancelPendingArchiveLoad(ResourceLoader*) +{ + notImplemented(); +} + + +void FrameLoaderClientWx::clearArchivedResources() +{ + notImplemented(); +} + + +bool FrameLoaderClientWx::canShowMIMEType(const String& MIMEType) const +{ + notImplemented(); + return true; +} + + +bool FrameLoaderClientWx::representationExistsForURLScheme(const String& URLScheme) const +{ + notImplemented(); + return false; +} + + +String FrameLoaderClientWx::generatedMIMETypeForURLScheme(const String& URLScheme) const +{ + notImplemented(); + return String(); +} + + +void FrameLoaderClientWx::frameLoadCompleted() +{ + notImplemented(); +} + +void FrameLoaderClientWx::saveViewStateToItem(HistoryItem*) +{ + notImplemented(); +} + +void FrameLoaderClientWx::restoreViewState() +{ + notImplemented(); +} + +void FrameLoaderClientWx::restoreScrollPositionAndViewState() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::provisionalLoadStarted() +{ + notImplemented(); +} + + +bool FrameLoaderClientWx::shouldTreatURLAsSameAsCurrent(const KURL&) const +{ + notImplemented(); + return false; +} + + +void FrameLoaderClientWx::addHistoryItemForFragmentScroll() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::didFinishLoad() +{ + notImplemented(); +} + + +void FrameLoaderClientWx::prepareForDataSourceReplacement() +{ + if (m_frame && m_frame->loader()) + m_frame->loader()->detachChildren(); +} + + +void FrameLoaderClientWx::setTitle(const String& title, const KURL&) +{ + notImplemented(); +} + + +String FrameLoaderClientWx::userAgent(const KURL&) +{ + // FIXME: Use the new APIs introduced by the GTK port to fill in these values. + return String("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3"); +} + +void FrameLoaderClientWx::dispatchDidReceiveIcon() +{ + notImplemented(); +} + +void FrameLoaderClientWx::frameLoaderDestroyed() +{ + m_frame = 0; + delete this; +} + +bool FrameLoaderClientWx::canHandleRequest(const WebCore::ResourceRequest&) const +{ + notImplemented(); + return true; +} + +void FrameLoaderClientWx::partClearedInBegin() +{ + notImplemented(); +} + +void FrameLoaderClientWx::updateGlobalHistory(const WebCore::KURL&) +{ + notImplemented(); +} + +bool FrameLoaderClientWx::shouldGoToHistoryItem(WebCore::HistoryItem*) const +{ + notImplemented(); + return true; +} + +void FrameLoaderClientWx::saveScrollPositionAndViewStateToItem(WebCore::HistoryItem*) +{ + notImplemented(); +} + +bool FrameLoaderClientWx::canCachePage() const +{ + return false; +} + +void FrameLoaderClientWx::setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length) +{ + if (!m_frame) + return; + FrameLoader* fl = loader->frameLoader(); + fl->setEncoding(m_response.textEncodingName(), false); + fl->addData(data, length); +} + +WebCore::ResourceError FrameLoaderClientWx::cancelledError(const WebCore::ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +WebCore::ResourceError FrameLoaderClientWx::blockedError(const ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +WebCore::ResourceError FrameLoaderClientWx::cannotShowURLError(const WebCore::ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +WebCore::ResourceError FrameLoaderClientWx::interruptForPolicyChangeError(const WebCore::ResourceRequest&) +{ + notImplemented(); + return ResourceError(); +} + +WebCore::ResourceError FrameLoaderClientWx::cannotShowMIMETypeError(const WebCore::ResourceResponse&) +{ + notImplemented(); + return ResourceError(); +} + +WebCore::ResourceError FrameLoaderClientWx::fileDoesNotExistError(const WebCore::ResourceResponse&) +{ + notImplemented(); + return ResourceError(); +} + +bool FrameLoaderClientWx::shouldFallBack(const WebCore::ResourceError& error) +{ + notImplemented(); + return false; +} + +WTF::PassRefPtr<DocumentLoader> FrameLoaderClientWx::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) +{ + RefPtr<DocumentLoader> loader = new DocumentLoader(request, substituteData); + return loader.release(); +} + +void FrameLoaderClientWx::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest& request, const ResourceResponse& response) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long id, const ResourceResponse& response) +{ + notImplemented(); + m_response = response; + m_firstData = true; +} + +void FrameLoaderClientWx::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long id, int length) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidFinishLoading(DocumentLoader*, unsigned long) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&) +{ + notImplemented(); +} + +bool FrameLoaderClientWx::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int) +{ + notImplemented(); + return false; +} + +void FrameLoaderClientWx::dispatchDidFailProvisionalLoad(const ResourceError&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::dispatchDidFailLoad(const ResourceError&) +{ + notImplemented(); +} + +Frame* FrameLoaderClientWx::dispatchCreatePage() +{ + notImplemented(); + return false; +} + +void FrameLoaderClientWx::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& mimetype, const ResourceRequest& request) +{ + if (!m_frame) + return; + + notImplemented(); + (m_frame->loader()->*function)(PolicyUse); +} + +void FrameLoaderClientWx::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest&, const String&) +{ + if (!m_frame) + return; + + notImplemented(); + (m_frame->loader()->*function)(PolicyUse); +} + +void FrameLoaderClientWx::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request) +{ + if (!m_frame) + return; + + wxWindow* target = m_frame->view()->nativeWindow(); + if (target) { + wxWebViewBeforeLoadEvent wkEvent(target); + wkEvent.SetNavigationType(wxNavTypeFromWebNavType(action.type())); + wkEvent.SetURL(request.url().string()); + + target->GetEventHandler()->ProcessEvent(wkEvent); + if (wkEvent.IsCancelled()) + (m_frame->loader()->*function)(PolicyIgnore); + else + (m_frame->loader()->*function)(PolicyUse); + + } +} + +void FrameLoaderClientWx::dispatchUnableToImplementPolicy(const ResourceError&) +{ + notImplemented(); +} + +void FrameLoaderClientWx::startDownload(const ResourceRequest&) +{ + notImplemented(); +} + +bool FrameLoaderClientWx::willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL&) const +{ + notImplemented(); + return false; +} + +PassRefPtr<Frame> FrameLoaderClientWx::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, + const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) +{ +/* + FIXME: Temporarily disabling code for loading subframes. While most + (i)frames load and are destroyed properly, the iframe created by + google.com in its new homepage does not get destroyed when + document()->detach() is called, as other (i)frames do. It is destroyed on + app shutdown, but until that point, this 'in limbo' frame will do things + like steal keyboard focus and crash when clicked on. (On some platforms, + it is actually a visible object, even though it's not in a valid state.) + + Since just about every user is probably going to test against Google at + some point, I'm disabling this functionality until I have time to track down + why it is not being destroyed. +*/ + +/* + wxWindow* parent = m_frame->view()->nativeWindow(); + + WebViewFrameData* data = new WebViewFrameData(); + data->name = name; + data->ownerElement = ownerElement; + data->url = url; + data->referrer = referrer; + data->marginWidth = marginWidth; + data->marginHeight = marginHeight; + + wxWebView* newWin = new wxWebView(parent, -1, wxDefaultPosition, wxDefaultSize, data); + + RefPtr<Frame> childFrame = newWin->m_impl->frame; + + // FIXME: All of the below should probably be moved over into WebCore + childFrame->tree()->setName(name); + m_frame->tree()->appendChild(childFrame); + // ### set override encoding if we have one + + FrameLoadType loadType = m_frame->loader()->loadType(); + FrameLoadType childLoadType = FrameLoadTypeInternal; + + childFrame->loader()->load(url, referrer, childLoadType, + String(), 0, 0); + + // The frame's onload handler may have removed it from the document. + if (!childFrame->tree()->parent()) + return 0; + + delete data; + + return childFrame.get(); +*/ + notImplemented(); + return 0; +} + +ObjectContentType FrameLoaderClientWx::objectContentType(const KURL& url, const String& mimeType) +{ + notImplemented(); + return ObjectContentType(); +} + +Widget* FrameLoaderClientWx::createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) +{ + notImplemented(); + return 0; +} + +void FrameLoaderClientWx::redirectDataToPlugin(Widget* pluginWidget) +{ + notImplemented(); + return; +} + +Widget* FrameLoaderClientWx::createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL, + const Vector<String>& paramNames, const Vector<String>& paramValues) +{ + notImplemented(); + return 0; +} + +String FrameLoaderClientWx::overrideMediaType() const +{ + notImplemented(); + return String(); +} + +void FrameLoaderClientWx::windowObjectCleared() +{ + notImplemented(); +} + +void FrameLoaderClientWx::didPerformFirstNavigation() const +{ + notImplemented(); +} + +void FrameLoaderClientWx::registerForIconNotification(bool listen) +{ + notImplemented(); +} + +void FrameLoaderClientWx::savePlatformDataToCachedPage(CachedPage*) +{ + notImplemented(); +} + +void FrameLoaderClientWx::transitionToCommittedFromCachedPage(CachedPage*) +{ + notImplemented(); +} + +void FrameLoaderClientWx::transitionToCommittedForNewPage() +{ + notImplemented(); +} + +} diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h new file mode 100644 index 0000000..60405c2 --- /dev/null +++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * 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 FrameLoaderClientWx_H +#define FrameLoaderClientWx_H + +#include "FrameLoaderClient.h" +#include "FrameLoader.h" +#include "KURL.h" +#include "RefCounted.h" +#include "ResourceResponse.h" + + +namespace WebCore { + + class AuthenticationChallenge; + class DocumentLoader; + class Element; + class FormState; + class NavigationAction; + class String; + class ResourceLoader; + + struct LoadErrorResetToken; + + class FrameLoaderClientWx : public FrameLoaderClient, public RefCounted<FrameLoaderClientWx> { + public: + FrameLoaderClientWx(); + ~FrameLoaderClientWx(); + void setFrame(Frame *frame); + virtual void detachFrameLoader(); + + virtual void ref(); + virtual void deref(); + + virtual bool hasWebView() const; // mainly for assertions + virtual bool hasFrameView() const; // ditto + + virtual bool hasBackForwardList() const; + virtual void resetBackForwardList(); + + virtual bool provisionalItemIsTarget() const; + + virtual void makeRepresentation(DocumentLoader*); + virtual void forceLayout(); + virtual void forceLayoutForNonHTML(); + + virtual void updateHistoryForCommit(); + + virtual void updateHistoryForBackForwardNavigation(); + virtual void updateHistoryForReload(); + virtual void updateHistoryForStandardLoad(); + virtual void updateHistoryForInternalLoad(); + + virtual void updateHistoryAfterClientRedirect(); + + virtual void setCopiesOnScroll(); + + virtual LoadErrorResetToken* tokenForLoadErrorReset(); + virtual void resetAfterLoadError(LoadErrorResetToken*); + virtual void doNotResetAfterLoadError(LoadErrorResetToken*); + + virtual void willCloseDocument(); + + virtual void detachedFromParent1(); + virtual void detachedFromParent2(); + virtual void detachedFromParent3(); + virtual void detachedFromParent4(); + + virtual void loadedFromCachedPage(); + + virtual void frameLoaderDestroyed(); + virtual bool canHandleRequest(const ResourceRequest&) const; + + virtual void dispatchDidHandleOnloadEvents(); + virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); + virtual void dispatchDidCancelClientRedirect(); + virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); + virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchWillClose(); + virtual void dispatchDidReceiveIcon(); + virtual void dispatchDidStartProvisionalLoad(); + virtual void dispatchDidReceiveTitle(const String& title); + virtual void dispatchDidCommitLoad(); + virtual void dispatchDidFinishDocumentLoad(); + virtual void dispatchDidFinishLoad(); + virtual void dispatchDidFirstLayout(); + + virtual void dispatchShow(); + virtual void cancelPolicyCheck(); + + virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>); + + virtual void dispatchDidLoadMainResource(DocumentLoader*); + virtual void revertToProvisionalState(DocumentLoader*); + virtual void clearUnarchivingState(DocumentLoader*); + + virtual void postProgressStartedNotification(); + virtual void postProgressEstimateChangedNotification(); + virtual void postProgressFinishedNotification(); + + virtual void progressStarted(); + virtual void progressCompleted(); + virtual void setMainFrameDocumentReady(bool); + virtual void willChangeTitle(DocumentLoader*); + virtual void didChangeTitle(DocumentLoader*); + virtual void finishedLoading(DocumentLoader*); + virtual void finalSetupForReplace(DocumentLoader*); + + virtual void setDefersLoading(bool); + virtual bool isArchiveLoadPending(ResourceLoader*) const; + virtual void cancelPendingArchiveLoad(ResourceLoader*); + virtual void clearArchivedResources(); + virtual bool canShowMIMEType(const String& MIMEType) const; + virtual bool representationExistsForURLScheme(const String& URLScheme) const; + virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const; + + virtual void frameLoadCompleted(); + virtual void saveViewStateToItem(HistoryItem*); + virtual void restoreViewState(); + virtual void restoreScrollPositionAndViewState(); + virtual void provisionalLoadStarted(); + virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const; + virtual void addHistoryItemForFragmentScroll(); + virtual void didFinishLoad(); + virtual void prepareForDataSourceReplacement(); + virtual void setTitle(const String& title, const KURL&); + + virtual String userAgent(const KURL&); + + virtual void savePlatformDataToCachedPage(WebCore::CachedPage*); + virtual void transitionToCommittedFromCachedPage(WebCore::CachedPage*); + virtual void transitionToCommittedForNewPage(); + + virtual void updateGlobalHistory(const KURL&); + virtual bool shouldGoToHistoryItem(HistoryItem*) const; + virtual void saveScrollPositionAndViewStateToItem(HistoryItem*); + virtual bool canCachePage() const; + + virtual void setMainDocumentError(DocumentLoader*, const ResourceError&); + virtual void committedLoad(DocumentLoader*, const char*, int); + virtual ResourceError cancelledError(const ResourceRequest&); + virtual ResourceError blockedError(const ResourceRequest&); + virtual ResourceError cannotShowURLError(const ResourceRequest&); + virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&); + virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&); + virtual ResourceError fileDoesNotExistError(const ResourceResponse&); + virtual bool shouldFallBack(const ResourceError&); + virtual WTF::PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&); + virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&); + + virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&); + + virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&); + virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&); + virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&); + virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&); + virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long, int); + virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long); + virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&); + + virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int); + virtual void dispatchDidFailProvisionalLoad(const ResourceError&); + virtual void dispatchDidFailLoad(const ResourceError&); + virtual Frame* dispatchCreatePage(); + virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String&, const ResourceRequest&); + virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest&, const String&); + virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest&); + virtual void dispatchUnableToImplementPolicy(const ResourceError&); + + virtual void startDownload(const ResourceRequest&); + virtual bool willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL&) const; + + // FIXME: This should probably not be here, but it's needed for the tests currently + virtual void partClearedInBegin(); + + virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, + const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); + virtual Widget* createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) ; + virtual void redirectDataToPlugin(Widget* pluginWidget); + + virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues); + + virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType); + virtual String overrideMediaType() const; + + virtual void windowObjectCleared(); + + virtual void didPerformFirstNavigation() const; + + virtual void registerForIconNotification(bool listen = true); + + private: + Frame *m_frame; + ResourceResponse m_response; + bool m_firstData; + }; + +} + +#endif diff --git a/WebKit/wx/WebKitSupport/InspectorClientWx.cpp b/WebKit/wx/WebKitSupport/InspectorClientWx.cpp new file mode 100644 index 0000000..e77a068 --- /dev/null +++ b/WebKit/wx/WebKitSupport/InspectorClientWx.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2007 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InspectorClientWx.h" + +#include "NotImplemented.h" +#include "Page.h" +#include "PlatformString.h" + +namespace WebCore { + +InspectorClientWx::InspectorClientWx() +{ + notImplemented(); +} + +InspectorClientWx::~InspectorClientWx() +{ + notImplemented(); +} + +void InspectorClientWx::inspectorDestroyed() +{ + notImplemented(); +} + +Page* InspectorClientWx::createPage() +{ + notImplemented(); + return 0; +} + +String InspectorClientWx::localizedStringsURL() +{ + notImplemented(); + return String(); +} + +void InspectorClientWx::showWindow() +{ + notImplemented(); +} + +void InspectorClientWx::closeWindow() +{ + notImplemented(); +} + +void InspectorClientWx::attachWindow() +{ + notImplemented(); +} + +void InspectorClientWx::detachWindow() +{ + notImplemented(); +} + +void InspectorClientWx::highlight(Node*) +{ + notImplemented(); +} + +void InspectorClientWx::hideHighlight() +{ + notImplemented(); +} + +void InspectorClientWx::inspectedURLChanged(const String& newURL) +{ + notImplemented(); +} + +}; diff --git a/WebKit/wx/WebKitSupport/InspectorClientWx.h b/WebKit/wx/WebKitSupport/InspectorClientWx.h new file mode 100644 index 0000000..5616278 --- /dev/null +++ b/WebKit/wx/WebKitSupport/InspectorClientWx.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) Kevin Ollivier 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 InspectorClientWx_h +#define InspectorClientWx_h + +#include "InspectorClient.h" + +namespace WebCore { + +class Node; +class Page; +class String; + +class InspectorClientWx : public InspectorClient { +public: + InspectorClientWx(); + ~InspectorClientWx(); + + virtual void inspectorDestroyed(); + + virtual Page* createPage(); + + virtual String localizedStringsURL(); + + virtual void showWindow(); + virtual void closeWindow(); + + virtual void attachWindow(); + virtual void detachWindow(); + + virtual void highlight(Node*); + virtual void hideHighlight(); + + virtual void inspectedURLChanged(const String& newURL); +}; + +} // namespace WebCore + +#endif // !defined(InspectorClient_h) diff --git a/WebKit/wx/WebView.cpp b/WebKit/wx/WebView.cpp new file mode 100644 index 0000000..f390017 --- /dev/null +++ b/WebKit/wx/WebView.cpp @@ -0,0 +1,577 @@ +/* + * Copyright (C) 2007 Kevin Ollivier All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CString.h" +#include "Document.h" +#include "Element.h" +#include "Editor.h" +#include "EventHandler.h" +#include "FocusController.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HTMLFrameOwnerElement.h" +#include "Logging.h" +#include "markup.h" +#include "Page.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformMouseEvent.h" +#include "PlatformString.h" +#include "PlatformWheelEvent.h" +#include "RenderObject.h" +#include "RenderTreeAsText.h" +#include "SelectionController.h" +#include "Settings.h" +#include "SubstituteData.h" + +#include "ChromeClientWx.h" +#include "ContextMenuClientWx.h" +#include "DragClientWx.h" +#include "EditorClientWx.h" +#include "FrameLoaderClientWx.h" +#include "InspectorClientWx.h" + +#include "kjs_proxy.h" +#include "kjs_binding.h" +#include <kjs/value.h> +#include <kjs/ustring.h> + +#include "wx/wxprec.h" +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "WebView.h" +#include "WebViewPrivate.h" + +#include <wx/defs.h> +#include <wx/dcbuffer.h> + +// Match Safari's min/max zoom sizes by default +#define MinimumTextSizeMultiplier 0.5f +#define MaximumTextSizeMultiplier 3.0f +#define TextSizeMultiplierRatio 1.2f + + +#if defined(_MSC_VER) +int rint(double val) +{ + return (int)(val < 0 ? val - 0.5 : val + 0.5); +} +#endif + +// ---------------------------------------------------------------------------- +// wxWebView Events +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxWebViewLoadEvent, wxCommandEvent) + +DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_LOAD) + +wxWebViewLoadEvent::wxWebViewLoadEvent(wxWindow* win) +{ + SetEventType( wxEVT_WEBVIEW_LOAD); + SetEventObject( win ); + SetId(win->GetId()); +} + +IMPLEMENT_DYNAMIC_CLASS(wxWebViewBeforeLoadEvent, wxCommandEvent) + +DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_BEFORE_LOAD) + +wxWebViewBeforeLoadEvent::wxWebViewBeforeLoadEvent(wxWindow* win) +{ + m_cancelled = false; + SetEventType(wxEVT_WEBVIEW_BEFORE_LOAD); + SetEventObject(win); + SetId(win->GetId()); +} + +IMPLEMENT_DYNAMIC_CLASS(wxWebViewNewWindowEvent, wxCommandEvent) + +DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_NEW_WINDOW) + +wxWebViewNewWindowEvent::wxWebViewNewWindowEvent(wxWindow* win) +{ + SetEventType(wxEVT_WEBVIEW_NEW_WINDOW); + SetEventObject(win); + SetId(win->GetId()); +} + +IMPLEMENT_DYNAMIC_CLASS(wxWebViewRightClickEvent, wxCommandEvent) + +DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_RIGHT_CLICK) + +wxWebViewRightClickEvent::wxWebViewRightClickEvent(wxWindow* win) +{ + SetEventType(wxEVT_WEBVIEW_RIGHT_CLICK); + SetEventObject(win); + SetId(win->GetId()); +} + +IMPLEMENT_DYNAMIC_CLASS(wxWebViewConsoleMessageEvent, wxCommandEvent) + +DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_CONSOLE_MESSAGE) + +wxWebViewConsoleMessageEvent::wxWebViewConsoleMessageEvent(wxWindow* win) +{ + SetEventType(wxEVT_WEBVIEW_CONSOLE_MESSAGE); + SetEventObject(win); + SetId(win->GetId()); +} + +//--------------------------------------------------------- +// DOM Element info data type +//--------------------------------------------------------- + +wxWebViewDOMElementInfo::wxWebViewDOMElementInfo() : + m_domElement(NULL), + m_isSelected(false), + m_text(wxEmptyString), + m_imageSrc(wxEmptyString), + m_link(wxEmptyString) +{ +} + +BEGIN_EVENT_TABLE(wxWebView, wxWindow) + EVT_PAINT(wxWebView::OnPaint) + EVT_SIZE(wxWebView::OnSize) + EVT_MOUSE_EVENTS(wxWebView::OnMouseEvents) + EVT_KEY_DOWN(wxWebView::OnKeyEvents) + EVT_KEY_UP(wxWebView::OnKeyEvents) + EVT_CHAR(wxWebView::OnKeyEvents) + EVT_SET_FOCUS(wxWebView::OnSetFocus) + EVT_KILL_FOCUS(wxWebView::OnKillFocus) + EVT_ACTIVATE(wxWebView::OnActivate) +END_EVENT_TABLE() + +wxWebView::wxWebView(wxWindow* parent, int id, const wxPoint& position, + const wxSize& size, WebViewFrameData* data) : + m_textMagnifier(1.0), + m_isEditable(false), + m_isInitialized(false), + m_beingDestroyed(false), + m_title(wxEmptyString) +{ + if (!wxWindow::Create(parent, id, position, size, wxBORDER_NONE | wxHSCROLL | wxVSCROLL)) + return; + +// This is necessary because we are using SharedTimerWin.cpp on Windows, +// due to a problem with exceptions getting eaten when using the callback +// approach to timers (which wx itself uses). +#if __WXMSW__ + WebCore::Page::setInstanceHandle(wxGetInstance()); +#endif + + // this helps reduce flicker on platforms like MSW + SetBackgroundStyle(wxBG_STYLE_CUSTOM); + + m_impl = new WebViewPrivate(); + + WebCore::InitializeLoggingChannelsIfNecessary(); + WebCore::HTMLFrameOwnerElement* parentFrame = 0; + + // FIXME: This cast is obviously not as safe as a dynamic + // cast, but this allows us to get around requiring RTTI + // support for the moment. This is only used for subframes + // in any case, which aren't currently supported. + wxWebView* parentWebView = static_cast<wxWebView*>(parent); + + if (data) { + parentFrame = data->ownerElement; + m_impl->page = parentWebView->m_impl->frame->page(); + } + else { + WebCore::EditorClientWx* editorClient = new WebCore::EditorClientWx(); + m_impl->page = new WebCore::Page(new WebCore::ChromeClientWx(this), new WebCore::ContextMenuClientWx(), editorClient, new WebCore::DragClientWx(), new WebCore::InspectorClientWx()); + editorClient->setPage(m_impl->page); + } + + WebCore::FrameLoaderClientWx* loaderClient = new WebCore::FrameLoaderClientWx(); + + m_impl->frame = new WebCore::Frame(m_impl->page, parentFrame, loaderClient); + m_impl->frame->deref(); + m_impl->frameView = new WebCore::FrameView(m_impl->frame.get()); + m_impl->frameView->deref(); + + m_impl->frame->setView(m_impl->frameView.get()); + m_impl->frame->init(); + + m_impl->frameView->setNativeWindow(this); + loaderClient->setFrame(m_impl->frame.get()); + + // Default settings - we should have wxWebViewSettings class for this + // eventually + WebCore::Settings* settings = m_impl->page->settings(); + settings->setLoadsImagesAutomatically(true); + settings->setDefaultFixedFontSize(13); + settings->setDefaultFontSize(16); + settings->setSerifFontFamily("Times New Roman"); + settings->setFixedFontFamily("Courier New"); + settings->setSansSerifFontFamily("Arial"); + settings->setStandardFontFamily("Times New Roman"); + settings->setJavaScriptEnabled(true); + + m_isInitialized = true; +} + +wxWebView::~wxWebView() +{ + m_beingDestroyed = true; + + m_impl->frame->loader()->detachFromParent(); + + delete m_impl->page; + m_impl->page = 0; + // Since frameView has the last reference to Frame, once it is + // destroyed the destructor for Frame will happen as well. + m_impl->frameView = 0; +} + +void wxWebView::Stop() +{ + if (m_impl->frame && m_impl->frame->loader()) + m_impl->frame->loader()->stop(); +} + +void wxWebView::Reload() +{ + if (m_impl->frame && m_impl->frame->loader()) + m_impl->frame->loader()->reload(); +} + +wxString wxWebView::GetPageSource() +{ + if (m_impl->frame) { + if (m_impl->frameView && m_impl->frameView->layoutPending()) + m_impl->frameView->layout(); + + WebCore::Document* doc = m_impl->frame->document(); + + if (doc) { + wxString source = doc->toString(); + return source; + } + } + return wxEmptyString; +} + +void wxWebView::SetPageSource(const wxString& source, const wxString& baseUrl) +{ + if (m_impl->frame && m_impl->frame->loader()) { + WebCore::FrameLoader* loader = m_impl->frame->loader(); + loader->begin(WebCore::KURL(static_cast<const char*>(baseUrl.mb_str(wxConvUTF8)))); + loader->write(source); + loader->end(); + } +} + +wxString wxWebView::GetInnerText() +{ + if (m_impl->frameView && m_impl->frameView->layoutPending()) + m_impl->frameView->layout(); + + WebCore::Element *documentElement = m_impl->frame->document()->documentElement(); + return documentElement->innerText(); +} + +wxString wxWebView::GetAsMarkup() +{ + if (!m_impl->frame || !m_impl->frame->document()) + return wxEmptyString; + + return createMarkup(m_impl->frame->document()); +} + +wxString wxWebView::GetExternalRepresentation() +{ + if (m_impl->frameView && m_impl->frameView->layoutPending()) + m_impl->frameView->layout(); + + return externalRepresentation(m_impl->frame->renderer()); +} + +wxString wxWebView::RunScript(const wxString& javascript) +{ + wxString returnValue = wxEmptyString; + if (m_impl->frame) { + KJS::JSValue* result = m_impl->frame->loader()->executeScript(javascript, true); + if (result) + returnValue = wxString(result->toString(m_impl->frame->scriptProxy()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8); + } + return returnValue; +} + +void wxWebView::LoadURL(wxString url) +{ + if (m_impl->frame && m_impl->frame->loader()) { + WebCore::KURL kurl = WebCore::KURL(static_cast<const char*>(url.mb_str(wxConvUTF8))); + // NB: This is an ugly fix, but CURL won't load sub-resources if the + // protocol is omitted; sadly, it will not emit an error, either, so + // there's no way for us to catch this problem the correct way yet. + if (kurl.protocol().isEmpty()) { + // is it a file on disk? + if (wxFileExists(url)) { + kurl.setProtocol("file"); + kurl.setPath("//" + kurl.path()); + } + else { + kurl.setProtocol("http"); + kurl.setPath("//" + kurl.path()); + } + } + m_impl->frame->loader()->load(kurl); + } +} + +bool wxWebView::GoBack() +{ + if (m_impl->frame && m_impl->frame->page()) { + return m_impl->frame->page()->goBack(); + } +} + +bool wxWebView::GoForward() +{ + if (m_impl->frame && m_impl->frame->page()) + return m_impl->frame->page()->goForward(); +} + +bool wxWebView::CanIncreaseTextSize() const +{ + if (m_impl->frame) { + if (m_textMagnifier*TextSizeMultiplierRatio <= MaximumTextSizeMultiplier) + return true; + } + return false; +} + +void wxWebView::IncreaseTextSize() +{ + if (CanIncreaseTextSize()) { + m_textMagnifier = m_textMagnifier*TextSizeMultiplierRatio; + m_impl->frame->setZoomFactor((int)rint(m_textMagnifier*100)); + } +} + +bool wxWebView::CanDecreaseTextSize() const +{ + if (m_impl->frame) { + if (m_textMagnifier/TextSizeMultiplierRatio >= MinimumTextSizeMultiplier) + return true; + } + return false; +} + +void wxWebView::DecreaseTextSize() +{ + if (CanDecreaseTextSize()) { + m_textMagnifier = m_textMagnifier/TextSizeMultiplierRatio; + m_impl->frame->setZoomFactor( (int)rint(m_textMagnifier*100)); + } +} + +void wxWebView::MakeEditable(bool enable) +{ + m_isEditable = enable; +} + + +/* + * Event forwarding functions to send events down to WebCore. + */ + +void wxWebView::OnPaint(wxPaintEvent& event) +{ + if (m_beingDestroyed || !m_impl->frameView || !m_impl->frame) + return; + + wxAutoBufferedPaintDC dc(this); + + if (IsShown() && m_impl->frame && m_impl->frame->document()) { +#if USE(WXGC) + wxGCDC gcdc(dc); +#endif + + if (dc.IsOk()) { + wxRect paintRect = GetUpdateRegion().GetBox(); + + WebCore::IntSize offset = m_impl->frameView->scrollOffset(); +#if USE(WXGC) + gcdc.SetDeviceOrigin(-offset.width(), -offset.height()); +#endif + dc.SetDeviceOrigin(-offset.width(), -offset.height()); + paintRect.Offset(offset.width(), offset.height()); + +#if USE(WXGC) + WebCore::GraphicsContext* gc = new WebCore::GraphicsContext(&gcdc); +#else + WebCore::GraphicsContext* gc = new WebCore::GraphicsContext((wxWindowDC*)&dc); +#endif + if (gc && m_impl->frame->renderer()) { + if (m_impl->frameView->needsLayout()) + m_impl->frameView->layout(); + + m_impl->frame->paint(gc, paintRect); + } + } + } +} + +void wxWebView::OnSize(wxSizeEvent& event) +{ + if (m_isInitialized && m_impl->frame && m_impl->frameView) { + m_impl->frame->sendResizeEvent(); + m_impl->frameView->layout(); + } + + event.Skip(); + +} + +void wxWebView::OnMouseEvents(wxMouseEvent& event) +{ + event.Skip(); + + if (!m_impl->frame && m_impl->frameView) + return; + + wxPoint globalPoint = ClientToScreen(event.GetPosition()); + + wxEventType type = event.GetEventType(); + + if (type == wxEVT_MOUSEWHEEL) { + WebCore::PlatformWheelEvent wkEvent(event, globalPoint); + m_impl->frame->eventHandler()->handleWheelEvent(wkEvent); + return; + } + + WebCore::PlatformMouseEvent wkEvent(event, globalPoint); + + if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN) + m_impl->frame->eventHandler()->handleMousePressEvent(wkEvent); + + else if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP || + type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK) + m_impl->frame->eventHandler()->handleMouseReleaseEvent(wkEvent); + + else if (type == wxEVT_MOTION) + m_impl->frame->eventHandler()->handleMouseMoveEvent(wkEvent); +} + +bool wxWebView::CanCopy() +{ + if (m_impl->frame && m_impl->frameView) + return (m_impl->frame->editor()->canCopy() || m_impl->frame->editor()->canDHTMLCopy()); + + return false; +} + +void wxWebView::Copy() +{ + if (CanCopy()) + m_impl->frame->editor()->copy(); +} + +bool wxWebView::CanCut() +{ + if (m_impl->frame && m_impl->frameView) + return (m_impl->frame->editor()->canCut() || m_impl->frame->editor()->canDHTMLCut()); + + return false; +} + +void wxWebView::Cut() +{ + if (CanCut()) + m_impl->frame->editor()->cut(); +} + +bool wxWebView::CanPaste() +{ + if (m_impl->frame && m_impl->frameView) + return (m_impl->frame->editor()->canPaste() || m_impl->frame->editor()->canDHTMLPaste()); + + return false; +} + +void wxWebView::Paste() +{ + if (CanPaste()) + m_impl->frame->editor()->paste(); + +} + +void wxWebView::OnKeyEvents(wxKeyEvent& event) +{ + if (m_impl->frame && m_impl->frameView) { + // WebCore doesn't handle these events itself, so we need to do + // it and not send the event down or else CTRL+C will erase the text + // and replace it with c. + if (event.CmdDown() && event.GetKeyCode() == static_cast<int>('C')) + Copy(); + else if (event.CmdDown() && event.GetKeyCode() == static_cast<int>('X')) + Cut(); + else if (event.CmdDown() && event.GetKeyCode() == static_cast<int>('V')) + Paste(); + else { + WebCore::PlatformKeyboardEvent wkEvent(event); + if (wkEvent.type() == WebCore::PlatformKeyboardEvent::Char && wkEvent.altKey()) + m_impl->frame->eventHandler()->handleAccessKey(wkEvent); + else + m_impl->frame->eventHandler()->keyEvent(wkEvent); + } + } + + // make sure we get the character event. + if (event.GetEventType() != wxEVT_CHAR) + event.Skip(); +} + +void wxWebView::OnSetFocus(wxFocusEvent& event) +{ + if (m_impl->frame) + m_impl->frame->selectionController()->setFocused(true); + + event.Skip(); +} + +void wxWebView::OnKillFocus(wxFocusEvent& event) +{ + if (m_impl->frame) + m_impl->frame->selectionController()->setFocused(false); + + event.Skip(); +} + +void wxWebView::OnActivate(wxActivateEvent& event) +{ + if (m_impl->page) + m_impl->page->focusController()->setActive(event.GetActive()); + + event.Skip(); +} diff --git a/WebKit/wx/WebView.h b/WebKit/wx/WebView.h new file mode 100644 index 0000000..5dff4e8 --- /dev/null +++ b/WebKit/wx/WebView.h @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + * + * 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 WXWEBVIEW_H +#define WXWEBVIEW_H + +#include "wx/wxprec.h" +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +class WebViewPrivate; +class WebViewFrameData; + +namespace WebCore { + class ChromeClientWx; + class FrameLoaderClientWx; +} + +#ifndef SWIG + +#if WXMAKINGDLL_WEBKIT +#define WXDLLIMPEXP_WEBKIT WXEXPORT +#elif defined(WXUSINGDLL_WEBKIT) +#define WXDLLIMPEXP_WEBKIT WXIMPORT +#else +#define WXDLLIMPEXP_WEBKIT +#endif + +#else +#define WXDLLIMPEXP_WEBKIT +#endif // SWIG + +class WXDLLIMPEXP_WEBKIT wxWebView : public wxWindow +{ + // ChromeClientWx needs to get the Page* stored by the wxWebView + // for the createWindow function. + friend class WebCore::ChromeClientWx; + friend class WebCore::FrameLoaderClientWx; + +public: + // ctor(s) +#if SWIG + %pythonAppend wxWebView "self._setOORInfo(self)" +#endif + wxWebView(wxWindow* parent, int id = wxID_ANY, + const wxPoint& point = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + WebViewFrameData* data = NULL); // For wxWebView internal data passing + +#ifndef SWIG + ~wxWebView(); +#endif + + void LoadURL(wxString url); + bool GoBack(); + bool GoForward(); + void Stop(); + void Reload(); + + bool CanCut(); + bool CanCopy(); + bool CanPaste(); + + void Cut(); + void Copy(); + void Paste(); + + //bool CanGetPageSource(); + wxString GetPageSource(); + void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString); + + wxString GetInnerText(); + wxString GetAsMarkup(); + wxString GetExternalRepresentation(); + + wxString RunScript(const wxString& javascript); + + bool CanIncreaseTextSize() const; + void IncreaseTextSize(); + bool CanDecreaseTextSize() const; + void DecreaseTextSize(); + void MakeEditable(bool enable); + bool IsEditable() const { return m_isEditable; } + + wxString GetPageTitle() const { return m_title; } + void SetPageTitle(const wxString& title) { m_title = title; } + +protected: + + // event handlers (these functions should _not_ be virtual) + void OnPaint(wxPaintEvent& event); + void OnSize(wxSizeEvent& event); + void OnMouseEvents(wxMouseEvent& event); + void OnKeyEvents(wxKeyEvent& event); + void OnSetFocus(wxFocusEvent& event); + void OnKillFocus(wxFocusEvent& event); + void OnActivate(wxActivateEvent& event); + +private: + // any class wishing to process wxWindows events must use this macro +#ifndef SWIG + DECLARE_EVENT_TABLE() +#endif + float m_textMagnifier; + bool m_isEditable; + bool m_isInitialized; + bool m_beingDestroyed; + WebViewPrivate* m_impl; + wxString m_title; + +}; + +// ---------------------------------------------------------------------------- +// Web Kit Events +// ---------------------------------------------------------------------------- + +enum { + wxWEBVIEW_LOAD_STARTED = 1, + wxWEBVIEW_LOAD_NEGOTIATING = 2, + wxWEBVIEW_LOAD_REDIRECTING = 4, + wxWEBVIEW_LOAD_TRANSFERRING = 8, + wxWEBVIEW_LOAD_STOPPED = 16, + wxWEBVIEW_LOAD_FAILED = 32, + wxWEBVIEW_LOAD_DL_COMPLETED = 64, + wxWEBVIEW_LOAD_DOC_COMPLETED = 128, + wxWEBVIEW_LOAD_ONLOAD_HANDLED = 256, + wxWEBVIEW_LOAD_WINDOW_OBJECT_CLEARED = 512 +}; + +enum { + wxWEBVIEW_NAV_LINK_CLICKED = 1, + wxWEBVIEW_NAV_BACK_NEXT = 2, + wxWEBVIEW_NAV_FORM_SUBMITTED = 4, + wxWEBVIEW_NAV_RELOAD = 8, + wxWEBVIEW_NAV_FORM_RESUBMITTED = 16, + wxWEBVIEW_NAV_OTHER = 32 +}; + +class WXDLLIMPEXP_WEBKIT wxWebViewDOMElementInfo +{ +public: + wxWebViewDOMElementInfo(); + + ~wxWebViewDOMElementInfo() { } + + wxString GetTagName() const { return m_tagName; } + void SetTagName(const wxString& name) { m_tagName = name; } + + bool IsSelected() const { return m_isSelected; } + void SetSelected(bool sel) { m_isSelected = sel; } + + wxString GetText() const { return m_text; } + void SetText(const wxString& text) { m_text = text; } + + wxString GetImageSrc() const { return m_imageSrc; } + void SetImageSrc(const wxString& src) { m_imageSrc = src; } + + wxString GetLink() const { return m_link; } + void SetLink(const wxString& link) { m_link = link; } + +private: + void* m_domElement; + bool m_isSelected; + wxString m_tagName; + wxString m_text; + wxString m_imageSrc; + wxString m_link; +}; + +class WXDLLIMPEXP_WEBKIT wxWebViewBeforeLoadEvent : public wxCommandEvent +{ +#ifndef SWIG + DECLARE_DYNAMIC_CLASS( wxWebViewBeforeLoadEvent ) +#endif + +public: + bool IsCancelled() const { return m_cancelled; } + void Cancel(bool cancel = true) { m_cancelled = cancel; } + wxString GetURL() const { return m_url; } + void SetURL(const wxString& url) { m_url = url; } + void SetNavigationType(int navType) { m_navType = navType; } + int GetNavigationType() const { return m_navType; } + + wxWebViewBeforeLoadEvent( wxWindow* win = (wxWindow*) NULL ); + wxEvent *Clone(void) const { return new wxWebViewBeforeLoadEvent(*this); } + +private: + bool m_cancelled; + wxString m_url; + int m_navType; +}; + +class WXDLLIMPEXP_WEBKIT wxWebViewLoadEvent : public wxCommandEvent +{ +#ifndef SWIG + DECLARE_DYNAMIC_CLASS( wxWebViewLoadEvent ) +#endif + +public: + int GetState() const { return m_state; } + void SetState(const int state) { m_state = state; } + wxString GetURL() const { return m_url; } + void SetURL(const wxString& url) { m_url = url; } + + wxWebViewLoadEvent( wxWindow* win = (wxWindow*) NULL ); + wxEvent *Clone(void) const { return new wxWebViewLoadEvent(*this); } + +private: + int m_state; + wxString m_url; +}; + +class WXDLLIMPEXP_WEBKIT wxWebViewNewWindowEvent : public wxCommandEvent +{ +#ifndef SWIG + DECLARE_DYNAMIC_CLASS( wxWebViewNewWindowEvent ) +#endif + +public: + wxString GetURL() const { return m_url; } + void SetURL(const wxString& url) { m_url = url; } + + wxWebViewNewWindowEvent( wxWindow* win = static_cast<wxWindow*>(NULL)); + wxEvent *Clone(void) const { return new wxWebViewNewWindowEvent(*this); } + +private: + wxString m_url; +}; + +class WXDLLIMPEXP_WEBKIT wxWebViewRightClickEvent : public wxCommandEvent +{ +#ifndef SWIG + DECLARE_DYNAMIC_CLASS( wxWebViewRightClickEvent ) +#endif + +public: + wxWebViewRightClickEvent( wxWindow* win = static_cast<wxWindow*>(NULL)); + wxEvent *Clone(void) const { return new wxWebViewRightClickEvent(*this); } + + wxWebViewDOMElementInfo GetInfo() const { return m_info; } + void SetInfo(wxWebViewDOMElementInfo info) { m_info = info; } + + wxPoint GetPosition() const { return m_position; } + void SetPosition(wxPoint pos) { m_position = pos; } + +private: + wxWebViewDOMElementInfo m_info; + wxPoint m_position; +}; + +class WXDLLIMPEXP_WEBKIT wxWebViewConsoleMessageEvent : public wxCommandEvent +{ +#ifndef SWIG + DECLARE_DYNAMIC_CLASS( wxWebViewConsoleMessageEvent ) +#endif + +public: + wxString GetMessage() const { return m_message; } + void SetMessage(const wxString& message) { m_message = message; } + + unsigned int GetLineNumber() const { return m_lineNumber; } + void SetLineNumber(unsigned int lineNumber) { m_lineNumber = lineNumber; } + + wxString GetSourceID() const { return m_sourceID; } + void SetSourceID(const wxString& sourceID) { m_sourceID = sourceID; } + + wxWebViewConsoleMessageEvent( wxWindow* win = (wxWindow*) NULL ); + wxEvent *Clone(void) const { return new wxWebViewConsoleMessageEvent(*this); } + +private: + unsigned int m_lineNumber; + wxString m_message; + wxString m_sourceID; +}; + +typedef void (wxEvtHandler::*wxWebViewLoadEventFunction)(wxWebViewLoadEvent&); +typedef void (wxEvtHandler::*wxWebViewBeforeLoadEventFunction)(wxWebViewBeforeLoadEvent&); +typedef void (wxEvtHandler::*wxWebViewNewWindowEventFunction)(wxWebViewNewWindowEvent&); +typedef void (wxEvtHandler::*wxWebViewRightClickEventFunction)(wxWebViewRightClickEvent&); +typedef void (wxEvtHandler::*wxWebViewConsoleMessageEventFunction)(wxWebViewConsoleMessageEvent&); + +#ifndef SWIG +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_BEFORE_LOAD, wxID_ANY) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_LOAD, wxID_ANY) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_NEW_WINDOW, wxID_ANY) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_RIGHT_CLICK, wxID_ANY) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_CONSOLE_MESSAGE, wxID_ANY) +END_DECLARE_EVENT_TYPES() +#endif + +#define EVT_WEBVIEW_LOAD(func) \ + DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_LOAD, \ + wxID_ANY, \ + wxID_ANY, \ + (wxObjectEventFunction) \ + (wxWebViewLoadEventFunction) & func, \ + static_cast<wxObject*>(NULL)), + +#define EVT_WEBVIEW_BEFORE_LOAD(func) \ + DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_BEFORE_LOAD, \ + wxID_ANY, \ + wxID_ANY, \ + (wxObjectEventFunction) \ + (wxWebViewBeforeLoadEventFunction) & func, \ + static_cast<wxObject*>(NULL)), + +#define EVT_WEBVIEW_NEW_WINDOW(func) \ + DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_NEW_WINDOW, \ + wxID_ANY, \ + wxID_ANY, \ + (wxObjectEventFunction) \ + (wxWebViewNewWindowEventFunction) & func, \ + static_cast<wxObject*>(NULL)), + +#define EVT_WEBVIEW_RIGHT_CLICK(func) \ + DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_RIGHT_CLICK, \ + wxID_ANY, \ + wxID_ANY, \ + (wxObjectEventFunction) \ + (wxWebViewRightClickEventFunction) & func, \ + static_cast<wxObject*>(NULL)), + +#define EVT_WEBVIEW_CONSOLE_MESSAGE(func) \ + DECLARE_EVENT_TABLE_ENTRY( wxEVT_WEBVIEW_CONSOLE_MESSAGE, \ + wxID_ANY, \ + wxID_ANY, \ + (wxObjectEventFunction) \ + (wxWebViewConsoleMessageEventFunction) & func, \ + static_cast<wxObject*>(NULL)), + +#endif // ifndef WXWEBVIEW_H diff --git a/WebKit/wx/WebViewPrivate.h b/WebKit/wx/WebViewPrivate.h new file mode 100644 index 0000000..1e8ffcf --- /dev/null +++ b/WebKit/wx/WebViewPrivate.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007 Kevin Ollivier. 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 WXWEBVIEWPRIVATE_H +#define WXWEBVIEWPRIVATE_H + + +#include "config.h" +#include "Frame.h" +#include "FrameView.h" +#include "wtf/RefPtr.h" +#include "KURL.h" + +class WebViewPrivate +{ +public: + WebViewPrivate() : + frame(0), + frameView(0), + page(0) + {} + + WTF::RefPtr<WebCore::Frame> frame; + WTF::RefPtr<WebCore::FrameView> frameView; + WebCore::Page* page; +}; + +class WebViewFrameData +{ +public: + WebCore::KURL url; + WebCore::String name; + WebCore::HTMLFrameOwnerElement* ownerElement; + + WebCore::String referrer; + bool allowsScrolling; + int marginWidth; + int marginHeight; +}; + +#endif diff --git a/WebKit/wx/bindings/python/samples/simple.py b/WebKit/wx/bindings/python/samples/simple.py new file mode 100644 index 0000000..2ebdf9c --- /dev/null +++ b/WebKit/wx/bindings/python/samples/simple.py @@ -0,0 +1,162 @@ +#!/usr/bin/python + +# Copyright (C) 2007 Kevin Ollivier 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. + + +import wx +import wx.webview + +class TestPanel(wx.Panel): + def __init__(self, parent, log, frame=None): + wx.Panel.__init__( + self, parent, -1, + style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE + ) + + self.log = log + self.current = "http://wxPython.org/" + self.frame = frame + + if frame: + self.titleBase = frame.GetTitle() + + sizer = wx.BoxSizer(wx.VERTICAL) + btnSizer = wx.BoxSizer(wx.HORIZONTAL) + + self.webview = wx.webview.WebView(self, -1) + + + btn = wx.Button(self, -1, "Open", style=wx.BU_EXACTFIT) + self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, -1, "<--", style=wx.BU_EXACTFIT) + self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, -1, "-->", style=wx.BU_EXACTFIT) + self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, -1, "Stop", style=wx.BU_EXACTFIT) + self.Bind(wx.EVT_BUTTON, self.OnStopButton, btn) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + btn = wx.Button(self, -1, "Refresh", style=wx.BU_EXACTFIT) + self.Bind(wx.EVT_BUTTON, self.OnRefreshPageButton, btn) + btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2) + + txt = wx.StaticText(self, -1, "Location:") + btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2) + + self.location = wx.ComboBox( + self, -1, "", style=wx.CB_DROPDOWN|wx.PROCESS_ENTER + ) + + self.Bind(wx.EVT_COMBOBOX, self.OnLocationSelect, self.location) + self.location.Bind(wx.EVT_KEY_UP, self.OnLocationKey) + self.location.Bind(wx.EVT_CHAR, self.IgnoreReturn) + btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2) + + sizer.Add(btnSizer, 0, wx.EXPAND) + sizer.Add(self.webview, 1, wx.EXPAND) + + self.webview.LoadURL(self.current) + self.location.Append(self.current) + + self.webview.Bind(wx.webview.EVT_WEBVIEW_STATE_CHANGED, self.OnStateChanged) + + self.SetSizer(sizer) + + def OnStateChanged(self, event): + statusbar = self.GetParent().GetStatusBar() + if statusbar: + if event.GetState() == wx.webview.WEBVIEW_STATE_NEGOTIATING: + statusbar.SetStatusText("Contacting " + event.GetURL()) + elif event.GetState() == wx.webview.WEBVIEW_STATE_TRANSFERRING: + statusbar.SetStatusText("Loading " + event.GetURL()) + elif event.GetState() == wx.webview.WEBVIEW_STATE_STOP: + statusbar.SetStatusText("") + self.location.SetValue(event.GetURL()) + self.GetParent().SetTitle("wxWebView - " + self.webview.GetPageTitle()) + + def OnLocationKey(self, evt): + if evt.GetKeyCode() == wx.WXK_RETURN: + URL = self.location.GetValue() + self.location.Append(URL) + self.webview.LoadURL(URL) + else: + evt.Skip() + + def IgnoreReturn(self, evt): + if evt.GetKeyCode() != wx.WXK_RETURN: + evt.Skip() + + def OnLocationSelect(self, evt): + url = self.location.GetStringSelection() + self.webview.LoadURL(url) + + def OnOpenButton(self, event): + dlg = wx.TextEntryDialog(self, "Open Location", + "Enter a full URL or local path", + self.current, wx.OK|wx.CANCEL) + dlg.CentreOnParent() + + if dlg.ShowModal() == wx.ID_OK: + self.current = dlg.GetValue() + self.webview.LoadURL(self.current) + + dlg.Destroy() + + def OnPrevPageButton(self, event): + self.webview.GoBack() + + def OnNextPageButton(self, event): + self.webview.GoForward() + + def OnStopButton(self, evt): + self.webview.Stop() + + def OnRefreshPageButton(self, evt): + self.webview.Reload() + + +class wkFrame(wx.Frame): + def __init__(self): + wx.Frame.__init__(self, None, -1, "WebKit in wxPython!") + + self.panel = TestPanel(self, -1) + self.panel.webview.LoadURL("http://www.wxwidgets.org/") + self.CreateStatusBar() + +class wkApp(wx.App): + def OnInit(self): + self.webFrame = wkFrame() + self.SetTopWindow(self.webFrame) + self.webFrame.Show() + + return True + +app = wkApp(redirect=False) +app.MainLoop() diff --git a/WebKit/wx/bindings/python/webview.i b/WebKit/wx/bindings/python/webview.i new file mode 100644 index 0000000..766169d --- /dev/null +++ b/WebKit/wx/bindings/python/webview.i @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2007 Kevin Ollivier 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. + */ + +%module(package="wx") webview + +%{ +#include "wx/wxPython/wxPython.h" +#include "wx/wxPython/pyclasses.h" +#include "WebView.h" +#include "WebFrame.h" +%} + +//--------------------------------------------------------------------------- + +%import core.i +%import windows.i + +MustHaveApp(wxWebView); +MustHaveApp(wxWebFrame); + +%include WebView.h +%include WebFrame.h + +%pythoncode { wx = _core } +%pythoncode { __docfilter__ = wx.__DocFilter(globals()) } + +%constant wxEventType wxEVT_WEBVIEW_BEFORE_LOAD; +%constant wxEventType wxEVT_WEBVIEW_LOAD; +%constant wxEventType wxEVT_WEBVIEW_NEW_WINDOW; +%constant wxEventType wxEVT_WEBVIEW_RIGHT_CLICK; + +%pythoncode { +EVT_WEBVIEW_BEFORE_LOAD = wx.PyEventBinder( wxEVT_WEBVIEW_BEFORE_LOAD ) +EVT_WEBVIEW_LOAD = wx.PyEventBinder( wxEVT_WEBVIEW_LOAD ) +EVT_WEBVIEW_NEW_WINDOW = wx.PyEventBinder( wxEVT_WEBVIEW_NEW_WINDOW ) +EVT_WEBVIEW_RIGHT_CLICK = wx.PyEventBinder( wxEVT_WEBVIEW_RIGHT_CLICK ) +} diff --git a/WebKit/wx/bindings/python/wxwebkit-py.bkl b/WebKit/wx/bindings/python/wxwebkit-py.bkl new file mode 100644 index 0000000..163d95d --- /dev/null +++ b/WebKit/wx/bindings/python/wxwebkit-py.bkl @@ -0,0 +1,118 @@ +<?xml version="1.0" ?> +<!-- +Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> + +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. + +Bakefile for wxWebKit Python bindings. +--> + +<makefile> + <set var="WX_UNICODE">1</set> + <set var="WX_SHARED">1</set> + <include file="../../wxwk-settings.bkl"/> + + <!-- the WX_PYTHON option was added to presets/wx.bkl in 2.8.5, so define + it in case the presets/wx.bkl doesn't define it for us. --> + <if cond="not isdefined('WX_PYTHON')"> + <set var="WX_PYTHON">1</set> + </if> + + <if cond="not isdefined('PYTHON_VERSION')"> + <option name="PYTHON_VERSION"> + <values>24,25</values> + <default-value>25</default-value> + <description> + Python version we're building against. + </description> + </option> + </if> + + <if cond="not isdefined('PYTHON_LIBDIR')"> + <option name="PYTHON_LIBDIR" category="path"> + <default-value>C:/Python25/Libs</default-value> + <description> + The directory containing the Python library to link against. + </description> + </option> + </if> + + <module id="wxwebkit-python" template="wxwk,webcore,xml2,iconv,xslt,icu,jscore,curl,sqlite3,gtk,pthreads"> + <!-- make sure we relink wxwebkit if either webcore or jscore change --> + <if cond="FORMAT=='gnu'"> + <depends-on-file>$(WKOUTPUTDIR)/libjscore.a</depends-on-file> + <depends-on-file>$(WKOUTPUTDIR)/libwebcore-wx.a</depends-on-file> + </if> + <if cond="FORMAT=='msvc'"> + <depends-on-file>$(WKOUTPUTDIR)/jscore.lib</depends-on-file> + <depends-on-file>$(WKOUTPUTDIR)/webcore-wx.lib</depends-on-file> + </if> + <runtime-libs>dynamic</runtime-libs> + <dllname>_webview</dllname> + + <set var="BUILDDIR">obj-$(FORMAT)</set> + + <include>$(WK_ROOT)/WebCore/platform/wx</include> + <include>$(WK_ROOT)/WebCore/bridge/wx</include> + <include>$(WK_ROOT)/WebCore/page/wx</include> + <include>$(WK_ROOT)/WebKit/wx</include> + <include>$(WK_ROOT)/WebKit/wx/WebKitSupport</include> + + <if cond="FORMAT=='gnu'"> + <sys-lib>png</sys-lib> + <set var="MAC_FLAGS"> + <if cond="WX_PORT=='mac'">-bundle</if> + </set> + + <ldflags>$(MAC_FLAGS) -undefined dynamic_lookup</ldflags> + </if> + <if cond="FORMAT in ['msvc','msvs2005prj']"> + <set var="PY_LIBNAME"> + <if cond="PYTHON_VERSION=='24'"> + python24 + </if> + <if cond="PYTHON_VERSION=='25'"> + python25 + </if> + </set> + <sys-lib>libpng</sys-lib> + <sys-lib>$(PY_LIBNAME)</sys-lib> + <lib-path>$(WK_ROOT)/libpng</lib-path> + <lib-path>$(PYTHON_LIBDIR)</lib-path> + </if> + + <sys-lib>wxwebkit</sys-lib> + <lib-path>$(WKOUTPUTDIR)</lib-path> + + <define>SWIG_TYPE_TABLE=_wxPython_table</define> + <define>WXP_USE_THREAD=1</define> + <define>SWIG_PYTHON_OUTPUT_TUPLE</define> + + <sources> + webview.cpp + </sources> + </module> + +</makefile> diff --git a/WebKit/wx/dependencies.bkl b/WebKit/wx/dependencies.bkl new file mode 100644 index 0000000..089d33f --- /dev/null +++ b/WebKit/wx/dependencies.bkl @@ -0,0 +1,172 @@ +<?xml version="1.0" ?> +<!-- + +Copyright (C) 2005, 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. +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. + +This file contains templates with settings for components used by JavaScriptCore +and WebCore. Include this file to use these settings. + +--> + + +<makefile> + + <option name="SQLITE3_LIBS"> + <default-value>$(DOLLAR)(shell pkg-config --libs sqlite3)</default-value> + </option> + + <option name="SQLITE3_CFLAGS"> + <default-value>$(DOLLAR)(shell pkg-config --cflags sqlite3)</default-value> + </option> + + <template id="sqlite3"> + <sys-lib>sqlite3</sys-lib> + <if cond="FORMAT=='gnu'"> + <ldflags>$(SQLITE3_LIBS)</ldflags> + <cxxflags>$(SQLITE3_CFLAGS)</cxxflags> + </if> + <if cond="FORMAT in ['msvc','msvs2005prj']"> + <include>$(WK_ROOT)/WebKitLibraries/win/include/SQLite</include> + </if> + </template> + + <option name="CURL_LIBS"> + <default-value>$(DOLLAR)(shell curl-config --libs)</default-value> + </option> + + <option name="CURL_CFLAGS"> + <default-value>$(DOLLAR)(shell curl-config --cflags)</default-value> + </option> + + <template id="curl"> + <if cond="FORMAT not in ['msvc', 'msvc2005prj']"> + <ldflags>$(CURL_LIBS)</ldflags> + <cxxflags>$(CURL_CFLAGS)</cxxflags> + </if> + <if cond="FORMAT in ['msvc', 'msvs2005prj']"> + <sys-lib>libcurl</sys-lib> + </if> + </template> + + <option name="GTK_LIBS"> + <default-value>$(DOLLAR)(shell pkg-config --libs gtk+-2.0)</default-value> + </option> + + <option name="GTK_CFLAGS"> + <default-value>$(DOLLAR)(shell pkg-config --cflags gtk+-2.0)</default-value> + </option> + + <!-- GTK settings, for GTK ports - wx doesn't use these --> + <template id="gtk"> + <if cond="FORMAT=='gnu'"> + <ldflags>$(GTK_LIBS)</ldflags> + <cxxflags>$(GTK_CFLAGS)</cxxflags> + </if> + + <!-- TODO: non-Cygwin Windows support for this? :) --> + </template> + + + <option name="XML2_LIBS"> + <default-value>$(DOLLAR)(shell xml2-config --libs)</default-value> + </option> + + <option name="XML2_CFLAGS"> + <default-value>$(DOLLAR)(shell xml2-config --cflags)</default-value> + </option> + + <!-- XML2 library settings --> + <template id="xml2"> + <if cond="FORMAT=='gnu'"> + <ldflags>$(XML2_LIBS)</ldflags> + <cxxflags>$(XML2_CFLAGS)</cxxflags> + </if> + + <if cond="PLATFORM_WIN32=='1'"> + <include>$(WK_ROOT)/WebKitLibraries/win/include/libxml</include> + <sys-lib>libxml2</sys-lib> + </if> + </template> + + + <option name="XSLT_LIBS"> + <default-value>$(DOLLAR)(shell xslt-config --libs)</default-value> + </option> + + <option name="XSLT_CFLAGS"> + <default-value>$(DOLLAR)(shell xslt-config --cflags)</default-value> + </option> + + <!-- XSLT library settings --> + <template id="xslt" template="xml2"> + <if cond="FORMAT=='gnu'"> + <ldflags>$(XSLT_LIBS)</ldflags> + <cxxflags>$(XSLT_CFLAGS)</cxxflags> + </if> + + <if cond="PLATFORM_WIN32=='1'"> + <include>$(WK_ROOT)/WebKitLibraries/win/include/libxslt</include> + <sys-lib>libxslt</sys-lib> + </if> + </template> + + <!-- IBM ICU settings --> + <template id="icu"> + <if cond="FORMAT=='gnu'"> + <!-- Mac includes ICU with the system, but doesn't include headers or + icu-config, so we have to hardcode settings there. --> + <set var="ICU_INCLUDE"><if cond="WX_PORT=='mac'">$(WK_ROOT)/JavaScriptCore/icu</if></set> + <set var="ICU_INCLUDE"><if cond="WX_PORT=='mac'">$(WK_ROOT)/WebCore/icu</if></set> + <set var="ICU_LIB"><if cond="WX_PORT=='mac'">icucore</if></set> + <set var="ICU_LDFLAGS"><if cond="WX_PORT=='gtk2'">$(DOLLAR)(shell icu-config --ldflags)</if></set> + <set var="ICU_CFLAGS"><if cond="WX_PORT=='gtk2'">$(DOLLAR)(shell icu-config --cppflags)</if></set> + + <include>$(ICU_INCLUDE)</include> + <sys-lib>$(ICU_LIB)</sys-lib> + <ldflags>$(ICU_LDFLAGS)</ldflags> + <cxxflags>$(ICU_CFLAGS)</cxxflags> + </if> + + <if cond="PLATFORM_WIN32=='1'"> + <sys-lib>icuuc</sys-lib> + <sys-lib>icuin</sys-lib> + </if> + </template> + + + <template id="iconv"> + </template> + + + <template id="pthreads"> + <if cond="PLATFORM_WIN32=='1'"> + <include>$(WK_ROOT)/WebKitLibraries/win/include/pthreads</include> + <sys-lib>pthreadVC2</sys-lib> + </if> + </template> + +</makefile> diff --git a/WebKit/wx/presets/wxwebkit.bkl b/WebKit/wx/presets/wxwebkit.bkl new file mode 100644 index 0000000..7fc59d2 --- /dev/null +++ b/WebKit/wx/presets/wxwebkit.bkl @@ -0,0 +1,128 @@ +<?xml version="1.0" ?> +<!-- + +Copyright (C) 2007 Kevin Ollivier. 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. + +This file contains templates with settings for components used by JavaScriptCore +and WebCore. Include this file to use these settings. + +--> + + +<makefile> + <if cond="not isdefined('WK_ROOT')"> + <option name="WK_ROOT" category="path"> + <default-value>$(DOLLAR)(WEBKIT_ROOT)</default-value> + <description> + The root directory containing WebKit sources + </description> + </option> + </if> + <if cond="not isdefined('WKOUTPUTDIR')"> + <option name="WKOUTPUTDIR" category="path"> + <default-value>$(DOLLAR)(WEBKITOUTPUTDIR)</default-value> + <description> + The root directory containing WebKit products + </description> + </option> + </if> + + <if cond="not isdefined('WX_PORT')"> + <if cond="FORMAT in ['msvc','msvs2005prj']"> + <set var="WX_PORT_DEFAULT" overwrite="0"> + msw + </set> + </if> + <if cond="not FORMAT in ['msvc','msvs2005prj']"> + <set var="WX_PORT_DEFAULT" overwrite="0"> + $(DOLLAR)(shell $(WX_CONFIG) --selected-config | cut -d '-' -f 1) + </set> + </if> + <option name="WX_PORT"> + <values>gtk2,msw,mac</values> + <default-value force="1">$(WX_PORT_DEFAULT)</default-value> + <description> + Port of the wx library to build against + </description> + </option> + </if> + + <template id="jscore"> + <if cond="FORMAT in ['msvc', 'msvs2005prj']"> + <!-- MSVC chokes on #import, so don't use ForwardingHeaders... --> + <include>$(WK_ROOT)/JavaScriptCore/os-win32</include><!-- stdint.h is here --> + </if> + </template> + + <template id="webcore"> + <if cond="FORMAT=='gnu'"> + <!-- FIXME: we need proper configure checks --> + <define>HAVE_FUNC_ISNAN</define> + </if> + + <if cond="PLATFORM_WIN32=='1'"> + <include>$(WK_ROOT)/os-win32</include> + <define>HAVE_SYS_TIMEB_H=1</define> + <define>HAVE_FLOAT_H=1</define> + <define>HAVE_FUNC__FINITE=1</define> + </if> + + <include>$(WK_ROOT)/WebCore</include> + <include>$(WK_ROOT)/WebCore/DerivedSources/WebCore</include> + <include>$(WK_ROOT)/WebCore/bindings/js</include> + <include>$(WK_ROOT)/WebCore/bridge</include> + <include>$(WK_ROOT)/WebCore/editing</include> + <include>$(WK_ROOT)/WebCore/history</include> + <include>$(WK_ROOT)/WebCore/html</include> + <include>$(WK_ROOT)/WebCore/css</include> + <include>$(WK_ROOT)/WebCore/dom</include> + <include>$(WK_ROOT)/WebCore/kwq</include> + <include>$(WK_ROOT)/WebCore/loader</include> + <include>$(WK_ROOT)/WebCore/loader/icon</include> + <include>$(WK_ROOT)/WebCore/page</include> + <include>$(WK_ROOT)/WebCore/platform</include> + <include>$(WK_ROOT)/WebCore/platform/graphics</include> + <include>$(WK_ROOT)/WebCore/platform/image-decoders</include> + <include>$(WK_ROOT)/WebCore/platform/image-decoders/gif</include> + <include>$(WK_ROOT)/WebCore/platform/image-decoders/jpeg</include> + <include>$(WK_ROOT)/WebCore/platform/image-decoders/png</include> + <include>$(WK_ROOT)/WebCore/platform/image-decoders/zlib</include> + <include>$(WK_ROOT)/WebCore/platform/network</include> + <include>$(WK_ROOT)/WebCore/platform/network/curl</include> + <include>$(WK_ROOT)/WebCore/platform/sql</include> + <include>$(WK_ROOT)/WebCore/platform/text</include> + <include>$(WK_ROOT)/WebCore/rendering</include> + <include>$(WK_ROOT)/WebCore/storage</include> + <include>$(WK_ROOT)/WebCore/xml</include> + + <include>$(WK_ROOT)/JavaScriptCore</include> + <include>$(WK_ROOT)/JavaScriptCore/kjs</include> + <include>$(WK_ROOT)/JavaScriptCore/pcre</include> + <include>$(WK_ROOT)/JavaScriptCore/wtf</include> + </template> + +</makefile> diff --git a/WebKit/wx/wxwebkit.bkl b/WebKit/wx/wxwebkit.bkl new file mode 100644 index 0000000..dfe3d1b --- /dev/null +++ b/WebKit/wx/wxwebkit.bkl @@ -0,0 +1,90 @@ +<?xml version="1.0" ?> +<!-- + +Copyright (C) 2007 Kevin Ollivier. 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. + +This file builds the wxWebKit library. + +--> + +<makefile> + <include file="wxwk-settings.bkl"/> + + <set var="BUILDDIR">obj-$(FORMAT)</set> + + <dll id="wxwebkit-dynamic" template="wxwk,jscore,webcore,xml2,iconv,xslt,icu,curl,sqlite3,gtk,pthreads"> + <!-- make sure we relink wxwebkit if either webcore or jscore change --> + <if cond="FORMAT=='gnu'"> + <depends-on-file>$(WKOUTPUTDIR)/libjscore.a</depends-on-file> + <depends-on-file>$(WKOUTPUTDIR)/libwebcore-wx.a</depends-on-file> + </if> + <if cond="FORMAT=='msvc'"> + <depends-on-file>$(WKOUTPUTDIR)/jscore.lib</depends-on-file> + <depends-on-file>$(WKOUTPUTDIR)/webcore-wx.lib</depends-on-file> + </if> + <runtime-libs>dynamic</runtime-libs> + <dllname>wxwebkit</dllname> + <libname>wxwebkit</libname> + + <set var="BUILDDIR">obj-$(FORMAT)</set> + + <include>$(WK_ROOT)/WebCore/platform/graphics/wx</include> + <include>$(WK_ROOT)/WebCore/platform/wx</include> + <include>$(WK_ROOT)/WebCore/bridge/wx</include> + <include>$(WK_ROOT)/WebCore/page/wx</include> + <include>$(WK_ROOT)/WebKit/wx</include> + <include>$(WK_ROOT)/WebKit/wx/WebKitSupport</include> + + <lib-path>$(WKOUTPUTDIR)</lib-path> + <sys-lib>webcore-wx</sys-lib> + <sys-lib>jscore</sys-lib> + + <if cond="FORMAT=='gnu'"> + <sys-lib>png</sys-lib> + <sys-lib>jpeg</sys-lib> + </if> + <if cond="FORMAT in ['msvc','msvs2005prj']"> + <sys-lib>winmm</sys-lib> <!-- for timeGetTime --> + <sys-lib>gdiplus</sys-lib> + <sys-lib>libpng</sys-lib> + <sys-lib>libjpeg</sys-lib> + </if> + + <sources> + WebKitSupport/ChromeClientWx.cpp + WebKitSupport/ContextMenuClientWx.cpp + WebKitSupport/DragClientWx.cpp + WebKitSupport/EditorClientWx.cpp + WebKitSupport/FrameLoaderClientWx.cpp + WebKitSupport/InspectorClientWx.cpp + + WebView.cpp + WebFrame.cpp + </sources> + </dll> + +</makefile> diff --git a/WebKit/wx/wxwk-settings.bkl b/WebKit/wx/wxwk-settings.bkl new file mode 100644 index 0000000..e312c05 --- /dev/null +++ b/WebKit/wx/wxwk-settings.bkl @@ -0,0 +1,82 @@ +<?xml version="1.0" ?> +<!-- +Copyright (C) 2007 Kevin Ollivier 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. + +JavaScriptCore Bakefile project file. +--> + +<makefile> + <set var="WX_UNICODE">1</set> + <set var="WX_SHARED">1</set> + + <include file="presets/wx.bkl"/> + <include file="presets/wxwebkit.bkl"/> + <include file="dependencies.bkl"/> + + <!-- the WX_PYTHON option was added to presets/wx.bkl in 2.8.5, so define + it in case the presets/wx.bkl doesn't define it for us. --> + + <if cond="not isdefined('WX_PYTHON')"> + <set var="WX_PYTHON">0</set> + </if> + + <template id="wxwk_build_settings"> + <dirname>$(WKOUTPUTDIR)</dirname> + <warnings>default</warnings> + <cxx-rtti>on</cxx-rtti> + <cxx-exceptions>on</cxx-exceptions> + <define>BUILDING_WX__=1</define> + <debug-info>on</debug-info> + <if cond="FORMAT in ['msvc', 'msvs2005prj']"> + <set var="DEBUG_RUNTIME"> + <if cond="WX_PYTHON=='1' and WX_DEBUG=='0'">off</if> + <if cond="WX_PYTHON=='0' and WX_DEBUG=='0'">off</if> + <if cond="WX_PYTHON=='1' and WX_DEBUG=='1'">off</if> + <if cond="WX_PYTHON=='0' and WX_DEBUG=='1'">on</if> + </set> + <debug-runtime-libs> + $(DEBUG_RUNTIME) + </debug-runtime-libs> + </if> + <if cond="FORMAT=='gnu'"> + <include>$(WK_ROOT)/WebKitLibraries/unix/include</include> + <lib-path>$(WK_ROOT)/WebKitLibraries/unix/lib</lib-path> + </if> + <if cond="FORMAT in ['msvc', 'msvs2005prj']"> + <include>$(WK_ROOT)/WebKitLibraries/win/include</include> + <lib-path>$(WK_ROOT)/WebKitLibraries/win/lib</lib-path> + </if> + </template> + <template id="wxwk" template="wxwk_build_settings,wx"> + <wx-lib>core</wx-lib> + <wx-lib>base</wx-lib> + <if cond="PLATFORM_WIN32=='1'"> + <define>WXUSINGDLL=1</define> + </if> + </template> + +</makefile> |
