+2008-08-06 Kevin Watters <kevinwatters@gmail.com>
+
+ Reviewed by Kevin Ollivier.
+
+ Create a wxWebFrame API to match other ports and to prepare for frames support.
+ Also fixes a frame leak in wx port on trunk.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19041
+
+ * WebFrame.cpp: Added.
+ (wxWebFrame::wxWebFrame):
+ (wxWebFrame::~wxWebFrame):
+ (wxWebFrame::GetFrame):
+ (wxWebFrame::Stop):
+ (wxWebFrame::Reload):
+ (wxWebFrame::GetPageSource):
+ (wxWebFrame::SetPageSource):
+ (wxWebFrame::GetInnerText):
+ (wxWebFrame::GetAsMarkup):
+ (wxWebFrame::GetExternalRepresentation):
+ (wxWebFrame::RunScript):
+ (wxWebFrame::LoadURL):
+ (wxWebFrame::GoBack):
+ (wxWebFrame::GoForward):
+ (wxWebFrame::CanGoBack):
+ (wxWebFrame::CanGoForward):
+ (wxWebFrame::CanIncreaseTextSize):
+ (wxWebFrame::IncreaseTextSize):
+ (wxWebFrame::CanDecreaseTextSize):
+ (wxWebFrame::DecreaseTextSize):
+ (wxWebFrame::MakeEditable):
+ (wxWebFrame::CanCopy):
+ (wxWebFrame::Copy):
+ (wxWebFrame::CanCut):
+ (wxWebFrame::Cut):
+ (wxWebFrame::CanPaste):
+ (wxWebFrame::Paste):
+ * WebFrame.h: Added.
+ * WebView.cpp:
+ (wxWebView::wxWebView):
+ (wxWebView::Create):
+ (wxWebView::~wxWebView):
+ (wxWebView::Stop):
+ (wxWebView::Reload):
+ (wxWebView::GetPageSource):
+ (wxWebView::SetPageSource):
+ (wxWebView::GetInnerText):
+ (wxWebView::GetAsMarkup):
+ (wxWebView::GetExternalRepresentation):
+ (wxWebView::RunScript):
+ (wxWebView::LoadURL):
+ (wxWebView::GoBack):
+ (wxWebView::GoForward):
+ (wxWebView::CanGoBack):
+ (wxWebView::CanGoForward):
+ (wxWebView::CanIncreaseTextSize):
+ (wxWebView::IncreaseTextSize):
+ (wxWebView::CanDecreaseTextSize):
+ (wxWebView::DecreaseTextSize):
+ (wxWebView::OnPaint):
+ (wxWebView::OnSize):
+ (wxWebView::OnMouseEvents):
+ (wxWebView::CanCopy):
+ (wxWebView::Copy):
+ (wxWebView::CanCut):
+ (wxWebView::Cut):
+ (wxWebView::CanPaste):
+ (wxWebView::Paste):
+ (wxWebView::OnKeyEvents):
+ (wxWebView::OnSetFocus):
+ (wxWebView::OnKillFocus):
+ * WebView.h:
+ * wxwebkit.bkl:
+
2008-07-27 Kevin Watters <kevinwatters@gmail.com>
Reviewed by Sam Weinig.
--- /dev/null
+/*
+ * 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 "Editor.h"
+#include "Element.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameView.h"
+#include "HTMLFrameOwnerElement.h"
+#include "markup.h"
+#include "Page.h"
+#include "RenderTreeAsText.h"
+#include "RenderObject.h"
+#include "RenderView.h"
+
+#include "EditorClientWx.h"
+#include "FrameLoaderClientWx.h"
+
+#include "ScriptController.h"
+#include "JSDOMBinding.h"
+#include <kjs/JSValue.h>
+#include <kjs/ustring.h>
+
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include "WebFrame.h"
+#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
+
+wxWebFrame::wxWebFrame(wxWebView* container, wxWebFrame* parent, WebViewFrameData* data) :
+ m_textMagnifier(1.0),
+ m_isEditable(false),
+ m_isInitialized(false),
+ m_beingDestroyed(false),
+ m_title(wxEmptyString)
+{
+
+ m_impl = new WebViewPrivate();
+
+ WebCore::HTMLFrameOwnerElement* parentFrame = 0;
+
+ if (data) {
+ parentFrame = data->ownerElement;
+ }
+
+ WebCore::FrameLoaderClientWx* loaderClient = new WebCore::FrameLoaderClientWx();
+
+ m_impl->frame = WebCore::Frame::create(container->m_impl->page, parentFrame, loaderClient);
+ m_impl->frame->deref();
+
+ loaderClient->setFrame(m_impl->frame.get());
+ loaderClient->setWebView(container);
+
+ m_impl->frame->init();
+
+ m_isInitialized = true;
+}
+
+wxWebFrame::~wxWebFrame()
+{
+ m_impl->frame->loader()->detachFromParent();
+}
+
+WebCore::Frame* wxWebFrame::GetFrame()
+{
+ if (m_impl)
+ return m_impl->frame.get();
+
+ return 0;
+}
+
+void wxWebFrame::Stop()
+{
+ if (m_impl->frame && m_impl->frame->loader())
+ m_impl->frame->loader()->stop();
+}
+
+void wxWebFrame::Reload()
+{
+ if (m_impl->frame && m_impl->frame->loader())
+ m_impl->frame->loader()->reload();
+}
+
+wxString wxWebFrame::GetPageSource()
+{
+ if (m_impl->frame) {
+ if (m_impl->frame->view() && m_impl->frame->view()->layoutPending())
+ m_impl->frame->view()->layout();
+
+ WebCore::Document* doc = m_impl->frame->document();
+
+ if (doc) {
+ wxString source = createMarkup(doc);
+ return source;
+ }
+ }
+ return wxEmptyString;
+}
+
+void wxWebFrame::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 wxWebFrame::GetInnerText()
+{
+ if (m_impl->frame->view() && m_impl->frame->view()->layoutPending())
+ m_impl->frame->view()->layout();
+
+ WebCore::Element *documentElement = m_impl->frame->document()->documentElement();
+ return documentElement->innerText();
+}
+
+wxString wxWebFrame::GetAsMarkup()
+{
+ if (!m_impl->frame || !m_impl->frame->document())
+ return wxEmptyString;
+
+ return createMarkup(m_impl->frame->document());
+}
+
+wxString wxWebFrame::GetExternalRepresentation()
+{
+ if (m_impl->frame->view() && m_impl->frame->view()->layoutPending())
+ m_impl->frame->view()->layout();
+
+ return externalRepresentation(m_impl->frame->contentRenderer());
+}
+
+wxString wxWebFrame::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->script()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8);
+ }
+ return returnValue;
+}
+
+void wxWebFrame::LoadURL(const 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 wxWebFrame::GoBack()
+{
+ if (m_impl->frame && m_impl->frame->page())
+ return m_impl->frame->page()->goBack();
+
+ return false;
+}
+
+bool wxWebFrame::GoForward()
+{
+ if (m_impl->frame && m_impl->frame->page())
+ return m_impl->frame->page()->goForward();
+
+ return false;
+}
+
+bool wxWebFrame::CanGoBack()
+{
+ if (m_impl->frame && m_impl->frame->page() && m_impl->frame->page()->backForwardList())
+ return m_impl->frame->page()->backForwardList()->backItem() != NULL;
+
+ return false;
+}
+
+bool wxWebFrame::CanGoForward()
+{
+ if (m_impl->frame && m_impl->frame->page() && m_impl->frame->page()->backForwardList())
+ return m_impl->frame->page()->backForwardList()->forwardItem() != NULL;
+
+ return false;
+}
+bool wxWebFrame::CanIncreaseTextSize() const
+{
+ if (m_impl->frame) {
+ if (m_textMagnifier*TextSizeMultiplierRatio <= MaximumTextSizeMultiplier)
+ return true;
+ }
+ return false;
+}
+
+void wxWebFrame::IncreaseTextSize()
+{
+ if (CanIncreaseTextSize()) {
+ m_textMagnifier = m_textMagnifier*TextSizeMultiplierRatio;
+ m_impl->frame->setZoomFactor(m_textMagnifier, true);
+ }
+}
+
+bool wxWebFrame::CanDecreaseTextSize() const
+{
+ if (m_impl->frame) {
+ if (m_textMagnifier/TextSizeMultiplierRatio >= MinimumTextSizeMultiplier)
+ return true;
+ }
+ return false;
+}
+
+void wxWebFrame::DecreaseTextSize()
+{
+ if (CanDecreaseTextSize()) {
+ m_textMagnifier = m_textMagnifier/TextSizeMultiplierRatio;
+ m_impl->frame->setZoomFactor(m_textMagnifier, true);
+ }
+}
+
+void wxWebFrame::MakeEditable(bool enable)
+{
+ m_isEditable = enable;
+}
+
+
+
+bool wxWebFrame::CanCopy()
+{
+ if (m_impl->frame && m_impl->frame->view())
+ return (m_impl->frame->editor()->canCopy() || m_impl->frame->editor()->canDHTMLCopy());
+
+ return false;
+}
+
+void wxWebFrame::Copy()
+{
+ if (CanCopy())
+ m_impl->frame->editor()->copy();
+}
+
+bool wxWebFrame::CanCut()
+{
+ if (m_impl->frame && m_impl->frame->view())
+ return (m_impl->frame->editor()->canCut() || m_impl->frame->editor()->canDHTMLCut());
+
+ return false;
+}
+
+void wxWebFrame::Cut()
+{
+ if (CanCut())
+ m_impl->frame->editor()->cut();
+}
+
+bool wxWebFrame::CanPaste()
+{
+ if (m_impl->frame && m_impl->frame->view())
+ return (m_impl->frame->editor()->canPaste() || m_impl->frame->editor()->canDHTMLPaste());
+
+ return false;
+}
+
+void wxWebFrame::Paste()
+{
+ if (CanPaste())
+ m_impl->frame->editor()->paste();
+
+}
--- /dev/null
+/*
+ * 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
+
+class WebViewPrivate;
+class WebViewFrameData;
+class wxWebView;
+
+namespace WebCore {
+ class ChromeClientWx;
+ class FrameLoaderClientWx;
+ class Frame;
+}
+
+#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 wxWebFrame
+{
+ // ChromeClientWx needs to get the Page* stored by the wxWebView
+ // for the createWindow function.
+ friend class WebCore::ChromeClientWx;
+ friend class WebCore::FrameLoaderClientWx;
+ friend class wxWebView;
+
+ wxWebFrame(wxWebView* container, wxWebFrame* parent = NULL, WebViewFrameData* data = NULL);
+
+ ~wxWebFrame();
+
+ void LoadURL(const wxString& url);
+ bool GoBack();
+ bool GoForward();
+ void Stop();
+ void Reload();
+
+ bool CanGoBack();
+ bool CanGoForward();
+
+ bool CanCut();
+ bool CanCopy();
+ bool CanPaste();
+
+ void Cut();
+ void Copy();
+ void Paste();
+
+ 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; }
+
+ WebCore::Frame* GetFrame();
+
+private:
+ float m_textMagnifier;
+ bool m_isEditable;
+ bool m_isInitialized;
+ bool m_beingDestroyed;
+ WebViewPrivate* m_impl;
+ wxString m_title;
+
+};
+
+#endif // ifndef WXWEBFRAME_H
#include "FrameLoader.h"
#include "FrameView.h"
#include "GraphicsContext.h"
-#include "HTMLFrameOwnerElement.h"
#include "Logging.h"
#include "markup.h"
#include "Page.h"
#include "PlatformString.h"
#include "PlatformWheelEvent.h"
#include "RenderObject.h"
-#include "RenderTreeAsText.h"
#include "RenderView.h"
#include "SelectionController.h"
#include "Settings.h"
#include "wx/wx.h"
#endif
+#include "WebFrame.h"
#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)
{
}
wxWebView::wxWebView(wxWindow* parent, int id, const wxPoint& position,
- const wxSize& size, long style, const wxString& name,
- WebViewFrameData* data) :
+ const wxSize& size, long style, const wxString& name) :
m_textMagnifier(1.0),
m_isEditable(false),
m_isInitialized(false),
m_beingDestroyed(false),
m_title(wxEmptyString)
{
- Create(parent, id, position, size, style, name, data);
+ Create(parent, id, position, size, style, name);
}
bool wxWebView::Create(wxWindow* parent, int id, const wxPoint& position,
- const wxSize& size, long style, const wxString& name,
- WebViewFrameData* data)
+ const wxSize& size, long style, const wxString& name)
{
if ( (style & wxBORDER_MASK) == 0)
style |= wxBORDER_NONE;
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();
+ 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);
- m_impl->frame = WebCore::Frame::create(m_impl->page, parentFrame, loaderClient);
+ m_mainFrame = new wxWebFrame(this);
- loaderClient->setFrame(m_impl->frame.get());
- loaderClient->setWebView(this);
-
- m_impl->frame->init();
-
// Default settings - we should have wxWebViewSettings class for this
// eventually
WebCore::Settings* settings = m_impl->page->settings();
{
m_beingDestroyed = true;
- m_impl->frame->loader()->detachFromParent();
+ delete m_mainFrame;
delete m_impl->page;
m_impl->page = 0;
void wxWebView::Stop()
{
- if (m_impl->frame && m_impl->frame->loader())
- m_impl->frame->loader()->stop();
+ if (m_mainFrame)
+ m_mainFrame->Stop();
}
void wxWebView::Reload()
{
- if (m_impl->frame && m_impl->frame->loader())
- m_impl->frame->loader()->reload();
+ if (m_mainFrame)
+ m_mainFrame->Reload();
}
wxString wxWebView::GetPageSource()
{
- if (m_impl->frame) {
- if (m_impl->frame->view() && m_impl->frame->view()->layoutPending())
- m_impl->frame->view()->layout();
-
- WebCore::Document* doc = m_impl->frame->document();
-
- if (doc) {
- wxString source = createMarkup(doc);
- return source;
- }
- }
+ if (m_mainFrame)
+ return m_mainFrame->GetPageSource();
+
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();
- }
+ if (m_mainFrame)
+ m_mainFrame->SetPageSource(source, baseUrl);
}
wxString wxWebView::GetInnerText()
{
- if (m_impl->frame->view() && m_impl->frame->view()->layoutPending())
- m_impl->frame->view()->layout();
+ if (m_mainFrame)
+ return m_mainFrame->GetInnerText();
- WebCore::Element *documentElement = m_impl->frame->document()->documentElement();
- return documentElement->innerText();
+ return wxEmptyString;
}
wxString wxWebView::GetAsMarkup()
{
- if (!m_impl->frame || !m_impl->frame->document())
- return wxEmptyString;
-
- return createMarkup(m_impl->frame->document());
+ if (m_mainFrame)
+ return m_mainFrame->GetAsMarkup();
+
+ return wxEmptyString;
}
wxString wxWebView::GetExternalRepresentation()
{
- if (m_impl->frame->view() && m_impl->frame->view()->layoutPending())
- m_impl->frame->view()->layout();
-
- return externalRepresentation(m_impl->frame->contentRenderer());
+ if (m_mainFrame)
+ return m_mainFrame->GetExternalRepresentation();
+
+ return wxEmptyString;
}
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->script()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8);
- }
- return returnValue;
+ if (m_mainFrame)
+ return m_mainFrame->RunScript(javascript);
+
+ return wxEmptyString;
}
void wxWebView::LoadURL(const 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);
- }
+ if (m_mainFrame)
+ m_mainFrame->LoadURL(url);
}
bool wxWebView::GoBack()
{
- if (m_impl->frame && m_impl->frame->page())
- return m_impl->frame->page()->goBack();
+ if (m_mainFrame)
+ return m_mainFrame->GoBack();
return false;
}
bool wxWebView::GoForward()
{
- if (m_impl->frame && m_impl->frame->page())
- return m_impl->frame->page()->goForward();
+ if (m_mainFrame)
+ return m_mainFrame->GoForward();
return false;
}
bool wxWebView::CanGoBack()
{
- if (m_impl->frame && m_impl->frame->page() && m_impl->frame->page()->backForwardList())
- return m_impl->frame->page()->backForwardList()->backItem() != NULL;
+ if (m_mainFrame)
+ return m_mainFrame->CanGoBack();
return false;
}
bool wxWebView::CanGoForward()
{
- if (m_impl->frame && m_impl->frame->page() && m_impl->frame->page()->backForwardList())
- return m_impl->frame->page()->backForwardList()->forwardItem() != NULL;
+ if (m_mainFrame)
+ return m_mainFrame->CanGoForward();
return false;
}
bool wxWebView::CanIncreaseTextSize() const
{
- if (m_impl->frame) {
- if (m_textMagnifier*TextSizeMultiplierRatio <= MaximumTextSizeMultiplier)
- return true;
- }
+ if (m_mainFrame)
+ return m_mainFrame->CanIncreaseTextSize();
+
return false;
}
void wxWebView::IncreaseTextSize()
{
- if (CanIncreaseTextSize()) {
- m_textMagnifier = m_textMagnifier*TextSizeMultiplierRatio;
- m_impl->frame->setZoomFactor(m_textMagnifier, true);
- }
+ if (m_mainFrame)
+ m_mainFrame->IncreaseTextSize();
}
bool wxWebView::CanDecreaseTextSize() const
{
- if (m_impl->frame) {
- if (m_textMagnifier/TextSizeMultiplierRatio >= MinimumTextSizeMultiplier)
- return true;
- }
+ if (m_mainFrame)
+ m_mainFrame->CanDecreaseTextSize();
+
return false;
}
void wxWebView::DecreaseTextSize()
{
- if (CanDecreaseTextSize()) {
- m_textMagnifier = m_textMagnifier/TextSizeMultiplierRatio;
- m_impl->frame->setZoomFactor(m_textMagnifier, true);
- }
+ if (m_mainFrame)
+ m_mainFrame->DecreaseTextSize();
}
void wxWebView::MakeEditable(bool enable)
void wxWebView::OnPaint(wxPaintEvent& event)
{
- if (m_beingDestroyed || !m_impl->frame->view() || !m_impl->frame)
+
+ if (m_beingDestroyed || !m_mainFrame)
+ return;
+
+ WebCore::Frame* frame = m_mainFrame->GetFrame();
+ if (!frame || !frame->view())
return;
wxAutoBufferedPaintDC dc(this);
- if (IsShown() && m_impl->frame && m_impl->frame->document()) {
+ if (IsShown() && frame->document()) {
#if USE(WXGC)
wxGCDC gcdc(dc);
#endif
if (dc.IsOk()) {
wxRect paintRect = GetUpdateRegion().GetBox();
- WebCore::IntSize offset = m_impl->frame->view()->scrollOffset();
+ WebCore::IntSize offset = frame->view()->scrollOffset();
#if USE(WXGC)
gcdc.SetDeviceOrigin(-offset.width(), -offset.height());
#endif
#else
WebCore::GraphicsContext* gc = new WebCore::GraphicsContext((wxWindowDC*)&dc);
#endif
- if (gc && m_impl->frame->contentRenderer()) {
- if (m_impl->frame->view()->needsLayout())
- m_impl->frame->view()->layout();
+ if (gc && frame->contentRenderer()) {
+ if (frame->view()->needsLayout())
+ frame->view()->layout();
- m_impl->frame->paint(gc, paintRect);
+ frame->paint(gc, paintRect);
}
}
}
void wxWebView::OnSize(wxSizeEvent& event)
{
- if (m_isInitialized && m_impl->frame && m_impl->frame->view()) {
- m_impl->frame->sendResizeEvent();
- m_impl->frame->view()->layout();
+ if (m_isInitialized && m_mainFrame) {
+ WebCore::Frame* frame = m_mainFrame->GetFrame();
+ frame->sendResizeEvent();
+ frame->view()->layout();
}
-
+
event.Skip();
-
}
void wxWebView::OnMouseEvents(wxMouseEvent& event)
{
event.Skip();
- if (!m_impl->frame && m_impl->frame->view())
+ if (!m_mainFrame)
return;
+ WebCore::Frame* frame = m_mainFrame->GetFrame();
+ if (!frame || !frame->view())
+ 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);
+ 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);
+ 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);
+ frame->eventHandler()->handleMouseReleaseEvent(wkEvent);
else if (type == wxEVT_MOTION)
- m_impl->frame->eventHandler()->mouseMoved(wkEvent);
+ frame->eventHandler()->mouseMoved(wkEvent);
}
bool wxWebView::CanCopy()
{
- if (m_impl->frame && m_impl->frame->view())
- return (m_impl->frame->editor()->canCopy() || m_impl->frame->editor()->canDHTMLCopy());
+ if (m_mainFrame)
+ return m_mainFrame->CanCopy();
return false;
}
void wxWebView::Copy()
{
- if (CanCopy())
- m_impl->frame->editor()->copy();
+ if (m_mainFrame)
+ m_mainFrame->Copy();
}
bool wxWebView::CanCut()
{
- if (m_impl->frame && m_impl->frame->view())
- return (m_impl->frame->editor()->canCut() || m_impl->frame->editor()->canDHTMLCut());
+ if (m_mainFrame)
+ m_mainFrame->CanCut();
return false;
}
void wxWebView::Cut()
{
- if (CanCut())
- m_impl->frame->editor()->cut();
+ if (m_mainFrame)
+ m_mainFrame->Cut();
}
bool wxWebView::CanPaste()
{
- if (m_impl->frame && m_impl->frame->view())
- return (m_impl->frame->editor()->canPaste() || m_impl->frame->editor()->canDHTMLPaste());
+ if (m_mainFrame)
+ m_mainFrame->CanPaste();
return false;
}
void wxWebView::Paste()
{
- if (CanPaste())
- m_impl->frame->editor()->paste();
+ if (m_mainFrame)
+ m_mainFrame->Paste();
}
void wxWebView::OnKeyEvents(wxKeyEvent& event)
{
- if (m_impl->frame && m_impl->frame->view()) {
+ WebCore::Frame* frame = 0;
+ if (m_mainFrame)
+ frame = m_mainFrame->GetFrame();
+
+ if (frame && frame->view()) {
// 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.
else {
WebCore::PlatformKeyboardEvent wkEvent(event);
if (wkEvent.type() == WebCore::PlatformKeyboardEvent::Char && wkEvent.altKey())
- m_impl->frame->eventHandler()->handleAccessKey(wkEvent);
+ frame->eventHandler()->handleAccessKey(wkEvent);
else
- m_impl->frame->eventHandler()->keyEvent(wkEvent);
+ frame->eventHandler()->keyEvent(wkEvent);
}
}
void wxWebView::OnSetFocus(wxFocusEvent& event)
{
- if (m_impl->frame)
- m_impl->frame->selection()->setFocused(true);
+ WebCore::Frame* frame = 0;
+ if (m_mainFrame)
+ frame = m_mainFrame->GetFrame();
+
+ if (frame)
+ frame->selection()->setFocused(true);
event.Skip();
}
void wxWebView::OnKillFocus(wxFocusEvent& event)
{
- if (m_impl->frame)
- m_impl->frame->selection()->setFocused(false);
+ WebCore::Frame* frame = 0;
+ if (m_mainFrame)
+ frame = m_mainFrame->GetFrame();
+
+ if (frame)
+ frame->selection()->setFocused(false);
event.Skip();
}
class WebViewPrivate;
class WebViewFrameData;
+class wxWebFrame;
namespace WebCore {
class ChromeClientWx;
const wxPoint& point = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
- const wxString& name = wxWebViewNameStr,
- WebViewFrameData* data = NULL); // For wxWebView internal data passing
+ const wxString& name = wxWebViewNameStr); // For wxWebView internal data passing
#if SWIG
%rename(PreWebView) wxWebView();
#else
const wxPoint& point = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
- const wxString& name = wxWebViewNameStr,
- WebViewFrameData* data = NULL); // For wxWebView internal data passing
+ const wxString& name = wxWebViewNameStr); // For wxWebView internal data passing
#ifndef SWIG
~wxWebView();
wxString GetPageTitle() const { return m_title; }
void SetPageTitle(const wxString& title) { m_title = title; }
+
+ wxWebFrame* GetMainFrame() { return m_mainFrame; }
protected:
bool m_isInitialized;
bool m_beingDestroyed;
WebViewPrivate* m_impl;
+ wxWebFrame* m_mainFrame;
wxString m_title;
};
WebKitSupport/FrameLoaderClientWx.cpp
WebKitSupport/InspectorClientWx.cpp
+ WebFrame.cpp
WebView.cpp
WebBrowserShell.cpp
</sources>