Reviewed by Kevin Ollivier.
authorkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jul 2010 20:51:21 +0000 (20:51 +0000)
committerkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jul 2010 20:51:21 +0000 (20:51 +0000)
Add DOM bindings support for wx port.

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

25 files changed:
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/bindings/scripts/CodeGeneratorCPP.pm
WebCore/platform/graphics/wx/FontPlatformDataWx.cpp
WebCore/platform/wx/MouseEventWx.cpp
WebCore/wscript
WebKit/wx/ChangeLog
WebKit/wx/WebBrowserShell.cpp
WebKit/wx/WebBrowserShell.h
WebKit/wx/WebDOMSelection.cpp [new file with mode: 0644]
WebKit/wx/WebDOMSelection.h [new file with mode: 0644]
WebKit/wx/WebFrame.cpp
WebKit/wx/WebFrame.h
WebKit/wx/WebKitDefines.h
WebKit/wx/WebKitSupport/EditorClientWx.cpp
WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
WebKit/wx/WebView.cpp
WebKit/wx/WebView.h
WebKit/wx/bindings/python/webview.i
WebKit/wx/bindings/python/wscript
WebKit/wx/wscript
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/wscript
WebKitTools/wx/browser/wscript
WebKitTools/wx/build/settings.py

index d5fed82f43e8c761e89d645bd17fbcfd25de463c..f1cfb671209106b8ed1a47af2c7eff3ddfe6c174 100644 (file)
@@ -1,3 +1,17 @@
+2010-07-28  Robin Dunn  <robin@alldunn.com>
+
+        Reviewed by Kevin Ollivier.
+
+        Add DOM bindings support for wx port.
+
+        * DerivedSources.make:
+        * bindings/scripts/CodeGeneratorCPP.pm:
+        * platform/graphics/wx/FontPlatformDataWx.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+        * platform/wx/MouseEventWx.cpp:
+        (WebCore::PlatformMouseEvent::PlatformMouseEvent):
+        * wscript:
+
 2010-07-28  Stephen White  <senorblanco@chromium.org>
 
         Reviewed by Darin Fisher.
index 8cecc2b568bda0595dcf8673fe543705a730a6cb..3b0f38d14ceb5519c45b74d765ad48f4465bcd2a 100644 (file)
@@ -476,10 +476,16 @@ INSPECTOR_CLASSES = Inspector
 
 JS_DOM_HEADERS=$(filter-out JSEventListener.h JSEventTarget.h,$(DOM_CLASSES:%=JS%.h) $(INSPECTOR_CLASSES:%=Remote%Frontend.h))
 
+WEB_DOM_HEADERS :=
+ifeq ($(findstring BUILDING_WX,$(FEATURE_DEFINES)), BUILDING_WX)
+WEB_DOM_HEADERS := $(filter-out WebDOMXSLTProcessor.h,$(DOM_CLASSES:%=WebDOM%.h))
+endif # BUILDING_WX
+
 all : \
     remove-stray-plugin-and-mime-type-files \
     \
     $(JS_DOM_HEADERS) \
+    $(WEB_DOM_HEADERS) \
     \
     JSJavaScriptCallFrame.h \
     \
@@ -812,6 +818,13 @@ Remote%Frontend.h : %.idl $(INSPECTOR_GENERATOR_SCRIPTS)
 
 -include $(JS_DOM_HEADERS:.h=.dep)
 
+ifeq ($(findstring BUILDING_WX,$(FEATURE_DEFINES)), BUILDING_WX)
+CPP_BINDINGS_SCRIPTS = $(GENERATE_SCRIPTS) bindings/scripts/CodeGeneratorCPP.pm
+
+WebDOM%.h : %.idl $(CPP_BINDINGS_SCRIPTS)
+       $(call generator_script, $(CPP_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_CPP" --generator CPP $<
+endif # BUILDING_WX
+
 # ------------------------
 
 # Mac-specific rules
index 9e254af3f3edc17f98da4eb6ef887a157ff8343b..27cf854e2aa6fc7d3df7c87610905e4aca1a1647 100644 (file)
@@ -281,7 +281,7 @@ sub AddIncludesForType
     my $type = $codeGenerator->StripModule(shift);
 
     return if $codeGenerator->IsNonPointerType($type);
-    return if $type =~ /cconstructor/;
+    return if $type =~ /Constructor/;
 
     if ($codeGenerator->IsStringType($type)) {
         $implIncludes{"AtomicString.h"} = 1;
index 29512233a27ab288b33c1abb3ec1c0712be69dc5..b77a03bf90cc5b867965509d1ed141d1f6329341 100644 (file)
@@ -81,23 +81,23 @@ FontPlatformData::FontPlatformData(const FontDescription& desc, const AtomicStri
 // this is a moot issue on Linux and Mac as they only accept the point argument. So,
 // we use the pixel size constructor on Windows, but we use point size on Linux and Mac.
 #if __WXMSW__
-    m_font = new FontHolder(new wxFont(   wxSize(0, -desc.computedPixelSize()), 
+    m_font = adoptRef(new FontHolder(new wxFont(   wxSize(0, -desc.computedPixelSize()), 
                                 fontFamilyToWxFontFamily(desc.genericFamily()), 
                                 italicToWxFontStyle(desc.italic()),
                                 fontWeightToWxFontWeight(desc.weight()),
                                 false,
                                 family.string()
                             )
-                        ); 
+                        ))
 #else
-    m_font = new FontHolder(new wxFont(   desc.computedPixelSize(), 
+    m_font = adoptRef(new FontHolder(new wxFont(   desc.computedPixelSize(), 
                                 fontFamilyToWxFontFamily(desc.genericFamily()), 
                                 italicToWxFontStyle(desc.italic()),
                                 fontWeightToWxFontWeight(desc.weight()),
                                 false,
                                 family.string()
                             )
-                        ); 
+                        ))
 #endif
 #if OS(DARWIN) && !defined(wxOSX_USE_CORE_TEXT)
 #if wxCHECK_VERSION(2,9,0)
index 4f39598d5dd57de07eddd7c0c7f7965932351216..8591ef57a0142ab51f30c44b607cc0fbe41000f5 100644 (file)
@@ -37,7 +37,7 @@ PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint&
     : m_position(event.GetPosition())
     , m_globalPosition(globalPoint)
     , m_shiftKey(event.ShiftDown())
-    , m_ctrlKey(event.CmdDown())
+    , m_ctrlKey(event.CmdDown() || event.ControlDown())
     , m_altKey(event.AltDown())
     , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers
 {
index f923e87234861ec0243dbda81f2b86219ac6fe62..bd058e494d577167488ad7a39eebedee19ef0313 100644 (file)
@@ -30,7 +30,8 @@ from settings import *
 webcore_sources = {}
 
 if build_port == "wx":
-    webcore_sources['wx'] = ['platform/KillRingNone.cpp']
+    webcore_sources['wx'] = ['platform/KillRingNone.cpp']  
+
     if building_on_win32:
         # make sure platform/wx comes after this so we get the right
         # FontPlatformData.h
@@ -125,7 +126,9 @@ def build(bld):
     wk_includes = ['.', '..', 'DerivedSources',
                 wk_root, 
                 os.path.join(wk_root, 'JavaScriptCore'),
+                os.path.join(wk_root, 'JavaScriptCore', 'wtf', 'text'),
                 os.path.join(wk_root, 'WebCore'),
+                os.path.join(wk_root, 'WebKit/wx'),
                 'platform/image-decoders',
                 'platform/win',
                 'platform/wx/wxcode',
@@ -135,7 +138,7 @@ def build(bld):
     features = [build_port]
     exclude_patterns = ['*AllInOne.cpp', '*Brew.cpp', '*CFNet.cpp', '*Chromium*.cpp', 
             '*Gtk.cpp', '*Mac.cpp', '*None.cpp', '*Qt.cpp', '*Safari.cpp',
-            'test*bindings.*', '*Wince.cpp']
+            'test*bindings.*', '*Wince.cpp', "WebDOMSVG*.cpp"]
     if build_port == 'wx':
         features.append('curl')
         if not building_on_win32:
@@ -172,6 +175,7 @@ def build(bld):
         includes = ' '.join(wk_includes),
         source = ' '.join(flattenSources(webcore_sources.values())),
         cxxflags = cxxflags,
+        defines = ['WXMAKINGDLL_WEBKIT'],
         target = 'webcore',
         uselib = 'WX ICU XML XSLT CURL SQLITE3 ' + get_config(),
         uselib_local = '',
@@ -218,6 +222,15 @@ def build(bld):
         excludes.append('JSSVGTransformable.cpp')
         excludes.append('JSSVGURIReference.cpp')
         
+        excludes.append('WebDOMAbstractView.cpp')
+        excludes.append('WebDOMBlobBuilder.cpp')
+        excludes.append('WebDOMEventListenerCustom.cpp')
+        excludes.append('WebDOMElementTimeControl.cpp')
+        excludes.append('WebDOMImageData.cpp')
+        excludes.append('WebDOMScriptProfile.cpp')
+        excludes.append('WebDOMScriptProfileNode.cpp')
+        excludes.append('WebNativeEventListener.cpp')
+        
         if building_on_win32:
             excludes.append('SharedTimerWx.cpp')
             excludes.append('RenderThemeWin.cpp')
index 5e373d1903db63c78508795a3755ac322d1254ee..1bf295acde11c46e78c02b437f28e25b03cda3fb 100644 (file)
@@ -1,3 +1,53 @@
+2010-07-28  Robin Dunn  <robin@alldunn.com>
+
+        Reviewed by Kevin Ollivier.
+
+        Add DOM bindings support for wx port.
+
+        * WebBrowserShell.cpp:
+        (wxWebBrowserShell::wxWebBrowserShell):
+        (wxWebBrowserShell::OnEditCommand):
+        (wxWebBrowserShell::OnGetEditCommandState):
+        * WebBrowserShell.h:
+        * WebDOMSelection.cpp: Added.
+        (wxWebKitSelection::wxWebKitSelection):
+        (wxWebKitSelection::GetRootEditableElement):
+        (wxWebKitSelection::GetAsRange):
+        * WebDOMSelection.h: Added.
+        * WebFrame.cpp:
+        (wxWebFrame::GetSelectionAsHTML):
+        (wxWebFrame::GetSelectionAsText):
+        (wxWebFrame::GetSelection):
+        (wxWebFrame::ExecuteEditCommand):
+        (wxWebFrame::GetEditCommandState):
+        (wxWebFrame::GetEditCommandValue):
+        (wxWebFrame::HitTest):
+        * WebFrame.h:
+        * WebKitDefines.h:
+        * WebKitSupport/EditorClientWx.cpp:
+        (WebCore::):
+        (WebCore::EditorClientWx::redo):
+        * WebKitSupport/FrameLoaderClientWx.cpp:
+        (WebCore::FrameLoaderClientWx::finishedLoading):
+        (WebCore::FrameLoaderClientWx::setMainDocumentError):
+        (WebCore::FrameLoaderClientWx::dispatchDidFailLoading):
+        * WebView.cpp:
+        (wxWebViewDOMElementInfo::wxWebViewDOMElementInfo):
+        (wxWebViewDOMElementInfo::~wxWebViewDOMElementInfo):
+        (wxWebView::Create):
+        (wxWebView::GetSelection):
+        (wxWebView::GetSelectionAsHTML):
+        (wxWebView::GetSelectionAsText):
+        (wxWebView::ExecuteEditCommand):
+        (wxWebView::GetEditCommandState):
+        (wxWebView::GetEditCommandValue):
+        (wxWebView::MakeEditable):
+        (wxWebView::IsEditable):
+        * WebView.h:
+        * bindings/python/webview.i:
+        * bindings/python/wscript:
+        * wscript:
+
 2010-07-26  Steve Block  <steveblock@google.com>
 
         Reviewed by Jeremy Orlow.
index 8853051acd73f0254121cbbec0246e19a838a0b9..b1ff578bbc1741d54d8d5bf3754f7497d716d3f8 100644 (file)
@@ -35,8 +35,9 @@
 
 #include "wx/artprov.h"
 
-#include "WebView.h"
 #include "WebBrowserShell.h"
+#include "WebFrame.h"
+#include "WebView.h"
 #include "WebViewPrivate.h"
 
 wxPageSourceViewFrame::wxPageSourceViewFrame(const wxString& source)
@@ -63,7 +64,9 @@ enum {
     ID_BROWSE = wxID_HIGHEST + 15,
     ID_EDIT = wxID_HIGHEST + 16,
     ID_RUN_SCRIPT = wxID_HIGHEST + 17,
-    ID_WEBVIEW = wxID_HIGHEST + 18
+    ID_WEBVIEW = wxID_HIGHEST + 18,
+    ID_EDIT_COMMAND = wxID_HIGHEST + 19,
+    ID_GET_EDIT_COMMAND_STATE = wxID_HIGHEST + 20
 };
 
 BEGIN_EVENT_TABLE(wxWebBrowserShell, wxFrame)
@@ -88,6 +91,8 @@ BEGIN_EVENT_TABLE(wxWebBrowserShell, wxFrame)
     EVT_MENU(ID_BROWSE, wxWebBrowserShell::OnBrowse)
     EVT_MENU(ID_EDIT, wxWebBrowserShell::OnEdit)
     EVT_MENU(ID_RUN_SCRIPT, wxWebBrowserShell::OnRunScript)
+    EVT_MENU(ID_EDIT_COMMAND, wxWebBrowserShell::OnEditCommand)
+    EVT_MENU(ID_GET_EDIT_COMMAND_STATE, wxWebBrowserShell::OnGetEditCommandState)
 END_EVENT_TABLE()
 
 
@@ -123,6 +128,8 @@ wxWebBrowserShell::wxWebBrowserShell(const wxString& title) :
     m_debugMenu = new wxMenu;
     m_debugMenu->Append(ID_SET_SOURCE, _("Test SetPageSource"));
     m_debugMenu->Append(ID_RUN_SCRIPT, _("Test RunScript"));
+    m_debugMenu->Append(ID_EDIT_COMMAND, _("Test EditCommand::Execute"));
+    m_debugMenu->Append(ID_GET_EDIT_COMMAND_STATE, _("Test EditCommand::GetState"));
 
     // the "About" item should be in the help menu
     wxMenu *helpMenu = new wxMenu;
@@ -339,7 +346,8 @@ void wxWebBrowserShell::OnEdit(wxCommandEvent& event)
         webview->MakeEditable(event.IsChecked());
 }
 
-void wxWebBrowserShell::OnRunScript(wxCommandEvent& myEvent){
+void wxWebBrowserShell::OnRunScript(wxCommandEvent& myEvent)
+{
     if (webview) {
         wxTextEntryDialog* dialog = new wxTextEntryDialog(this, _("Type in a JavaScript to exectute."));
         if (dialog->ShowModal() == wxID_OK)
@@ -348,3 +356,43 @@ void wxWebBrowserShell::OnRunScript(wxCommandEvent& myEvent){
         dialog->Destroy();
     }
 }
+
+void wxWebBrowserShell::OnEditCommand(wxCommandEvent& myEvent)
+{
+    if (webview) {
+        if (!webview->IsEditable()) {
+            wxMessageBox(wxT("Please enable editing before running editing commands."));
+            return;
+        }
+        
+        wxTextEntryDialog* dialog = new wxTextEntryDialog(this, _("Type in a editing command to exectute."));
+        if (dialog->ShowModal() == wxID_OK) {
+            bool result = webview->ExecuteEditCommand(dialog->GetValue());
+            if (!result)
+                wxMessageBox(wxT("Editing command failed."));
+        }
+        dialog->Destroy();
+    }
+}
+
+void wxWebBrowserShell::OnGetEditCommandState(wxCommandEvent& myEvent)
+{
+    if (webview) {
+        if (!webview->IsEditable()) {
+            wxMessageBox(wxT("Please enable editing before running editing commands."));
+            return;
+        }
+        
+        wxTextEntryDialog* dialog = new wxTextEntryDialog(this, _("Type in a editing command whose state you want to get."));
+        if (dialog->ShowModal() == wxID_OK) {
+            EditState result = webview->GetEditCommandState(dialog->GetValue());
+            if (result == EditStateTrue)
+                wxMessageBox(wxT("State is true."));
+            else if (result == EditStateFalse)
+                wxMessageBox(wxT("State is false."));
+            else if (result == EditStateMixed)
+                wxMessageBox(wxT("State is mixed."));
+        }
+        dialog->Destroy();
+    }
+}
index 2f43ffb1ab09c2860ba477878ea3aa50686447ad..4fe9c037d582200e58ae369531784be46631c076 100644 (file)
@@ -80,6 +80,8 @@ protected:
     // debug menu items
     void OnSetSource(wxCommandEvent& event);
     void OnRunScript(wxCommandEvent& myEvent);
+    void OnEditCommand(wxCommandEvent& myEvent);
+    void OnGetEditCommandState(wxCommandEvent& myEvent);
 
 private:
     wxTextCtrl* addressBar;
diff --git a/WebKit/wx/WebDOMSelection.cpp b/WebKit/wx/WebDOMSelection.cpp
new file mode 100644 (file)
index 0000000..ce35ea4
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2008 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 "WebDOMSelection.h"
+
+#include "Element.h"
+#include "SelectionController.h"
+#include "WebDOMElement.h"
+#include "WebDOMRange.h"
+
+#include <wtf/RefPtr.h>
+
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+IMPLEMENT_DYNAMIC_CLASS(wxWebKitSelection, wxObject)
+
+wxWebKitSelection::wxWebKitSelection(const wxWebKitSelection& other)
+{
+    m_selection = other.m_selection;
+}
+
+WebDOMElement* wxWebKitSelection::GetRootEditableElement() const
+{
+    if (m_selection)
+        return new WebDOMElement(m_selection->rootEditableElement());
+        
+    return 0;
+}
+
+WebDOMRange* wxWebKitSelection::GetAsRange()
+{
+    if (m_selection) {
+        WTF::RefPtr<WebCore::Range> range = m_selection->toNormalizedRange();
+        // keep it alive until it reaches wxWebKitDOMRange, which takes ownership
+        
+        if (range) {
+            range->ref();
+            return new WebDOMRange(range.get());
+        }
+    }
+        
+    return 0;
+}
diff --git a/WebKit/wx/WebDOMSelection.h b/WebKit/wx/WebDOMSelection.h
new file mode 100644 (file)
index 0000000..f9a2aa5
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2008 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 WebDOMSelection_h
+#define WebDOMSelection_h
+
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+#include "WebKitDefines.h"
+
+class WebDOMElement;
+class WebDOMRange;
+
+namespace WebCore {
+
+class SelectionController;
+
+}
+
+class WXDLLIMPEXP_WEBKIT wxWebKitSelection : public wxObject {
+#ifndef SWIG
+DECLARE_DYNAMIC_CLASS(wxWebKitDOMSelection)
+#endif
+
+public:
+    wxWebKitSelection() {}
+    wxWebKitSelection(WebCore::SelectionController* selection)
+        : m_selection(selection) 
+        { }
+        
+    wxWebKitSelection(const wxWebKitSelection&);
+    ~wxWebKitSelection() { m_selection = 0; }
+
+    WebDOMElement* GetRootEditableElement() const;
+    WebDOMRange* GetAsRange();
+
+private:
+    WebCore::SelectionController* m_selection;
+
+};
+
+#endif
index e1f7ecc65dd44872c44bc482a6cf23a225bb636b..b8d2ac2a810a9021579b714216ee9063afa02cd3 100644 (file)
@@ -59,6 +59,9 @@
     #include "wx/wx.h"
 #endif
 
+#include "WebDOMNode.h"
+
+#include "WebDOMSelection.h"
 #include "WebFrame.h"
 #include "WebView.h"
 #include "WebFramePrivate.h"
@@ -193,6 +196,30 @@ wxString wxWebFrame::GetExternalRepresentation()
     return externalRepresentation(m_impl->frame);
 }
 
+wxString wxWebFrame::GetSelectionAsHTML()
+{
+    if (m_impl->frame)
+        return m_impl->frame->selection()->toNormalizedRange()->toHTML();
+        
+    return wxEmptyString;
+}
+
+wxString wxWebFrame::GetSelectionAsText()
+{
+    if (m_impl->frame)
+        return m_impl->frame->selection()->toNormalizedRange()->text();
+        
+    return wxEmptyString;
+}
+
+wxWebKitSelection wxWebFrame::GetSelection()
+{
+    if (m_impl->frame)
+        return wxWebKitSelection(m_impl->frame->selection());
+        
+    return 0;
+}
+
 wxString wxWebFrame::RunScript(const wxString& javascript)
 {
     wxString returnValue = wxEmptyString;
@@ -213,6 +240,36 @@ wxString wxWebFrame::RunScript(const wxString& javascript)
     return returnValue;
 }
 
+bool wxWebFrame::ExecuteEditCommand(const wxString& command, const wxString& parameter)
+{
+    if (m_impl->frame && IsEditable())
+        return m_impl->frame->editor()->command(command).execute(parameter);
+}
+
+EditState wxWebFrame::GetEditCommandState(const wxString& command) const
+{
+    if (m_impl->frame && IsEditable()) { 
+        WebCore::TriState state = m_impl->frame->editor()->command(command).state();
+        if (state == WebCore::TrueTriState)
+            return EditStateTrue;
+        if (state == WebCore::FalseTriState)
+            return EditStateFalse;
+
+        return EditStateMixed;
+    }
+        
+    return EditStateFalse;
+}
+
+wxString wxWebFrame::GetEditCommandValue(const wxString& command) const
+{
+    if (m_impl->frame && IsEditable())
+        return m_impl->frame->editor()->command(command).value();
+        
+    return wxEmptyString;
+}
+
+
 bool wxWebFrame::FindString(const wxString& string, bool forward, bool caseSensitive, bool wrapSelection, bool startInSelection)
 {
     if (m_impl->frame)
@@ -401,6 +458,7 @@ wxWebViewDOMElementInfo wxWebFrame::HitTest(const wxPoint& pos) const
     if (m_impl->frame->view()) {
         WebCore::HitTestResult result = m_impl->frame->eventHandler()->hitTestResultAtPoint(m_impl->frame->view()->windowToContents(pos), false);
         if (result.innerNode()) {
+            domInfo.SetInnerNode(new WebDOMNode(result.innerNode()));
             domInfo.SetLink(result.absoluteLinkURL().string());
             domInfo.SetText(result.textContent());
             domInfo.SetImageSrc(result.absoluteImageURL().string());
index fec625715ebe9739fa462583fb66ca67489c02af..f09c8842775a28b2b65dab70d68b9c8c7e4712ff 100644 (file)
 
 #include "WebKitDefines.h"
 
+class WebDOMElement;
+class WebDOMNode;
+
+#include "WebDOMSelection.h"
+
+class Element;
+
 class WebFramePrivate;
 class WebViewFrameData;
 class wxWebView;
 
 namespace WebCore {
     class ChromeClientWx;
-    class FrameLoaderClientWx;
     class EditorClientWx;
-    class Frame;
+    class FrameLoaderClientWx;
+    class Frame;    
 }
 
 class WXDLLIMPEXP_WEBKIT wxWebViewDOMElementInfo
 {
 public:
     wxWebViewDOMElementInfo();
+    wxWebViewDOMElementInfo(const wxWebViewDOMElementInfo& other);
 
-    ~wxWebViewDOMElementInfo() { }
+    ~wxWebViewDOMElementInfo();
 
     wxString GetTagName() const { return m_tagName; }
     void SetTagName(const wxString& name) { m_tagName = name; }
@@ -67,9 +75,16 @@ public:
 
     wxString GetLink() const { return m_link; }
     void SetLink(const wxString& link) { m_link = link; }
+    
+    WebDOMNode* GetInnerNode() { return m_innerNode; }
+    void SetInnerNode(WebDOMNode* node) { m_innerNode = node; }
+    
+    WebDOMElement* GetURLElement() { return m_urlElement; }
+    void SetURLElement(WebDOMElement* url) { m_urlElement = url; }
 
 private:
-    void* m_domElement;
+    WebDOMNode* m_innerNode;
+    WebDOMElement* m_urlElement;
     bool m_isSelected;
     wxString m_tagName;
     wxString m_text;
@@ -82,6 +97,7 @@ enum wxWebKitParseMode { Compat, AlmostStrict, Strict, NoDocument };
 
 class WXDLLIMPEXP_WEBKIT wxWebFrame
 {
+public:
     // ChromeClientWx needs to get the Page* stored by the wxWebView
     // for the createWindow function. 
     friend class WebCore::ChromeClientWx;
@@ -124,7 +140,14 @@ public:
     wxString GetAsMarkup();
     wxString GetExternalRepresentation();
     
+    wxWebKitSelection GetSelection();
+    wxString GetSelectionAsHTML();
+    wxString GetSelectionAsText();
+    
     wxString RunScript(const wxString& javascript);
+    bool ExecuteEditCommand(const wxString& command, const wxString& parameter = wxEmptyString);
+    EditState GetEditCommandState(const wxString& command) const;
+    wxString GetEditCommandValue(const wxString& command) const;
     
     bool FindString(const wxString& string, bool forward = true,
         bool caseSensitive = false, bool wrapSelection = true,
index d973063ad6e5fe8cc4156cf89b0b7f6b3f3be739..67ad8681187c3ea8fd9195fbe51bf974670ebccc 100644 (file)
@@ -42,4 +42,7 @@
 #define WXDLLIMPEXP_WEBKIT
 #endif // SWIG
 
+// enums
+enum EditState { EditStateTrue, EditStateFalse, EditStateMixed };
+
 #endif // WebKitDefines_h
index 23551413a5ca7a5e0d21576aa997a9216c59af3a..64bfd06c781441d0b733ebe2dbaff7597a4f7c20 100644 (file)
@@ -109,7 +109,7 @@ static const KeyDownEntry keyDownEntries[] = {
     { VK_RETURN, 0,                  "InsertNewline"                               },
     { VK_RETURN, CtrlKey,            "InsertNewline"                               },
     { VK_RETURN, AltKey,             "InsertNewline"                               },
-    { VK_RETURN, AltKey | ShiftKey,  "InsertNewline"                               },
+    { VK_RETURN, ShiftKey,           "InsertLineBreak"                               },
     { 'A',       CtrlKey,            "SelectAll"                                   },
     { 'Z',       CtrlKey,            "Undo"                                        },
     { 'Z',       CtrlKey | ShiftKey, "Redo"                                        },
@@ -363,8 +363,8 @@ void EditorClientWx::redo()
     if (frame) {    
         wxWebView* webKitWin = dynamic_cast<wxWebView*>(frame->view()->hostWindow()->platformPageClient());
         if (webKitWin) {
-            webKitWin->m_impl->redoStack.first().editCommand()->reapply();
-            webKitWin->m_impl->redoStack.remove(0);
+            webKitWin->m_impl->redoStack.last().editCommand()->reapply();
+            webKitWin->m_impl->redoStack.removeLast();
         }
     }
 }
index a163727637c6871ec299909ebb6bb6438ad57c14..5b708c2ba57dc1c871397594919f643727ddbd8d 100644 (file)
@@ -430,9 +430,15 @@ void FrameLoaderClientWx::didChangeTitle(DocumentLoader *l)
 }
 
 
-void FrameLoaderClientWx::finishedLoading(DocumentLoader*)
+void FrameLoaderClientWx::finishedLoading(DocumentLoader* loader)
 {
-    if (m_pluginView) {
+    if (!m_pluginView) {
+        if (m_firstData) {
+            FrameLoader* fl = loader->frameLoader();
+            fl->writer()->setEncoding(m_response.textEncodingName(), false);
+            m_firstData = false;
+        }
+    } else {
         m_pluginView->didFinishLoading();
         m_pluginView = 0;
         m_hasSentResponseToPlugin = false;
@@ -598,9 +604,12 @@ bool FrameLoaderClientWx::canCachePage() const
     return false;
 }
 
-void FrameLoaderClientWx::setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&)
+void FrameLoaderClientWx::setMainDocumentError(WebCore::DocumentLoader* loader, const WebCore::ResourceError&)
 {
-    notImplemented();
+    if (m_firstData) {
+        loader->frameLoader()->writer()->setEncoding(m_response.textEncodingName(), false);
+        m_firstData = false;
+    }
 }
 
 void FrameLoaderClientWx::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length)
@@ -722,8 +731,13 @@ void FrameLoaderClientWx::dispatchDidFinishLoading(DocumentLoader*, unsigned lon
     notImplemented();
 }
 
-void FrameLoaderClientWx::dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&)
+void FrameLoaderClientWx::dispatchDidFailLoading(DocumentLoader* loader, unsigned long, const ResourceError&)
 {
+    if (m_firstData) {
+        FrameLoader* fl = loader->frameLoader();
+        fl->writer()->setEncoding(m_response.textEncodingName(), false);
+        m_firstData = false;
+    }
     if (m_webView) {
         wxWebViewLoadEvent wkEvent(m_webView);
         wkEvent.SetState(wxWEBVIEW_LOAD_FAILED);
index cd16662d4d796be7e739fa95b4de672e4e925e23..88d0ad9610d46de6816e00a55c225b505ea252a4 100644 (file)
@@ -83,6 +83,9 @@
     #include "wx/wx.h"
 #endif
 
+#include "WebDOMElement.h"
+#include "WebDOMNode.h"
+
 #include "WebFrame.h"
 #include "WebView.h"
 #include "WebViewPrivate.h"
@@ -229,7 +232,6 @@ wxWebViewWindowObjectClearedEvent::wxWebViewWindowObjectClearedEvent(wxWindow* w
 //---------------------------------------------------------
 
 wxWebViewDOMElementInfo::wxWebViewDOMElementInfo() :
-    m_domElement(NULL),
     m_isSelected(false),
     m_text(wxEmptyString),
     m_imageSrc(wxEmptyString),
@@ -257,6 +259,25 @@ wxWebViewCachePolicy wxWebView::GetCachePolicy()
     return gs_cachePolicy;
 }
 
+wxWebViewDOMElementInfo::wxWebViewDOMElementInfo(const wxWebViewDOMElementInfo& other)
+{
+    m_isSelected = other.m_isSelected;
+    m_text = other.m_text;
+    m_imageSrc = other.m_imageSrc;
+    m_link = other.m_link;
+    m_innerNode = other.m_innerNode;
+    m_urlElement = other.m_urlElement;
+}
+
+wxWebViewDOMElementInfo::~wxWebViewDOMElementInfo() 
+{
+    if (m_innerNode)
+        delete m_innerNode;
+        
+    if (m_urlElement)
+        delete m_urlElement;
+}
+
 #if OS(DARWIN)
 // prototype - function is in WebSystemInterface.mm
 void InitWebCoreSystemInterface(void);
@@ -364,9 +385,6 @@ bool wxWebView::Create(wxWindow* parent, int id, const wxPoint& position,
     // initialized so that the activate handler is run properly.
     LoadURL(wxT("about:blank"));
     
-    wxWindow* tlw = wxGetTopLevelParent(this);
-    tlw->Connect(-1, wxEVT_ACTIVATE, wxActivateEventHandler(wxWebView::OnTLWActivated));
-
     m_isInitialized = true;
 
     return true;
@@ -386,6 +404,9 @@ wxWebView::~wxWebView()
     m_impl->page = 0;   
 }
 
+// NOTE: binding to this event in the wxWebView constructor is too early in 
+// some cases, but leave the event handler here so that users can bind to it
+// at a later time if they have activation state problems.
 void wxWebView::OnTLWActivated(wxActivateEvent& event)
 {        
     if (m_impl && m_impl->page && m_impl->page->focusController())
@@ -445,6 +466,30 @@ wxString wxWebView::GetExternalRepresentation()
     return wxEmptyString;
 }
 
+wxWebKitSelection wxWebView::GetSelection()
+{
+    if (m_mainFrame)
+        return m_mainFrame->GetSelection();
+        
+    return 0;
+}
+
+wxString wxWebView::GetSelectionAsHTML()
+{
+    if (m_mainFrame)
+        return m_mainFrame->GetSelectionAsHTML();
+        
+    return wxEmptyString;
+}
+
+wxString wxWebView::GetSelectionAsText()
+{
+    if (m_mainFrame)
+        return m_mainFrame->GetSelectionAsText();
+        
+    return wxEmptyString;
+}
+
 void wxWebView::SetTransparent(bool transparent)
 {
     WebCore::Frame* frame = 0;
@@ -477,6 +522,26 @@ wxString wxWebView::RunScript(const wxString& javascript)
     return wxEmptyString;
 }
 
+bool wxWebView::ExecuteEditCommand(const wxString& command, const wxString& parameter)
+{
+    if (m_mainFrame)
+        return m_mainFrame->ExecuteEditCommand(command, parameter);
+}
+
+EditState wxWebView::GetEditCommandState(const wxString& command) const
+{
+    if (m_mainFrame)
+        return m_mainFrame->GetEditCommandState(command);
+}
+
+wxString wxWebView::GetEditCommandValue(const wxString& command) const
+{
+    if (m_mainFrame)
+        return m_mainFrame->GetEditCommandValue(command);
+    return wxEmptyString;
+}
+
 void wxWebView::LoadURL(const wxString& url)
 {
     if (m_mainFrame)
@@ -551,9 +616,19 @@ void wxWebView::ResetTextSize()
 
 void wxWebView::MakeEditable(bool enable)
 {
-    m_isEditable = enable;
+    if (m_mainFrame)
+        m_mainFrame->MakeEditable(enable);
 }
 
+bool wxWebView::IsEditable() const
+{
+    if (m_mainFrame)
+        return m_mainFrame->IsEditable();
+    
+    return false;
+}
+
+
 
 /* 
  * Event forwarding functions to send events down to WebCore.
index 075deaf451f4fa007ce6e12320036164853baca9..d7f23b6ab49e817b8361633a15f4f1502e4487e5 100644 (file)
@@ -33,8 +33,9 @@
     #include "wx/wx.h"
 #endif
 
-#include "WebFrame.h"
 #include "WebKitDefines.h"
+#include "WebDOMSelection.h"
+#include "WebFrame.h"
 #include "WebSettings.h"
 
 class WebViewPrivate;
@@ -161,10 +162,17 @@ public:
     wxString GetAsMarkup();
     wxString GetExternalRepresentation();
     
+    wxWebKitSelection GetSelection();
+    wxString GetSelectionAsHTML();
+    wxString GetSelectionAsText();
+    
     void SetTransparent(bool transparent);
     bool IsTransparent() const;
     
     wxString RunScript(const wxString& javascript);
+    bool ExecuteEditCommand(const wxString& command, const wxString& parameter = wxEmptyString);
+    EditState GetEditCommandState(const wxString& command) const;
+    wxString GetEditCommandValue(const wxString& command) const;
 
     bool FindString(const wxString& string, bool forward = true,
         bool caseSensitive = false, bool wrapSelection = true,
@@ -176,7 +184,7 @@ public:
     void DecreaseTextSize();
     void ResetTextSize();
     void MakeEditable(bool enable);
-    bool IsEditable() const { return m_isEditable; }
+    bool IsEditable() const;
 
     wxString GetPageTitle() const { return m_title; }
     void SetPageTitle(const wxString& title) { m_title = title; }
index bdc55618b28d1ae8aa2fbdcf099f2e95064b4a0b..95a6ff8e7cab7335a67908853e4c0153682dc9d6 100644 (file)
  * (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 webview
 
 %{
 #include "wx/wxPython/wxPython.h"
 #include "wx/wxPython/pyclasses.h"
-
 #include "WebBrowserShell.h"
+#include "WebDOMSelection.h"
+#include "WebEdit.h"
 #include "WebFrame.h"
-#include "WebKitDefines.h"
+#include "WebDOMDefines.h"
 #include "WebSettings.h"
 #include "WebView.h"
+
+#include "WebDOMAttr.h"
+#include "WebDOMCSSStyleDeclaration.h"
+#include "WebDOMDocument.h"
+#include "WebDOMDocumentFragment.h"
+#include "WebDOMDOMSelection.h"
+#include "WebDOMElement.h"
+#include "WebDOMEventListener.h"
+#include "WebDOMNamedNodeMap.h"
+#include "WebDOMNode.h"
+#include "WebDOMNodeList.h"
+#include "WebDOMObject.h"
+#include "WebDOMRange.h"
+
+PyObject* createDOMNodeSubtype(WebDOMNode* ptr, bool setThisOwn)
+{
+    //static wxPyTypeInfoHashMap* typeInfoCache = NULL;
+
+    //if (typeInfoCache == NULL)
+    //    typeInfoCache = new wxPyTypeInfoHashMap;
+
+    swig_type_info* swigType = 0; //(*typeInfoCache)[name];
+    char* name = 0;
+    if (ptr) {
+        // it wasn't in the cache, so look it up from SWIG
+        switch (ptr->nodeType()) {
+            case WebDOMNode::WEBDOM_ELEMENT_NODE:
+                name = "WebDOMElement*";
+                break;
+            case WebDOMNode::WEBDOM_ATTRIBUTE_NODE:
+                name = "WebDOMAttr*";
+                break;
+            default:
+                name = "WebDOMNode*";
+        }
+        swigType = SWIG_TypeQuery(name);
+        if (swigType)
+            return SWIG_Python_NewPointerObj(ptr, swigType, setThisOwn);
+        
+        // if it still wasn't found, try looking for a mapped name
+        //if (swigType) {
+            // and add it to the map if found
+        //    (*typeInfoCache)[className] = swigType;
+        //}
+    }
+    
+    Py_INCREF(Py_None);
+    
+    return Py_None;
+}
+
 %}
 //---------------------------------------------------------------------------
 
 %import core.i
 %import windows.i
 
+%typemap(out) WebDOMNode*             { $result = createDOMNodeSubtype($1, (bool)$owner); }
+%typemap(out) WebDOMElement*             { $result = createDOMNodeSubtype($1, (bool)$owner); }
+
 MAKE_CONST_WXSTRING(WebViewNameStr);
 
 MustHaveApp(wxWebBrowserShell);
 MustHaveApp(wxWebFrame);
 MustHaveApp(wxWebView);
 
+%include WebDOMDefines.h
 %include WebKitDefines.h
 
+%include WebDOMObject.h
+%include WebDOMNode.h
+
+%include WebDOMAttr.h
+%include WebDOMDOMSelection.h
+%include WebDOMElement.h
+%include WebDOMNodeList.h
+%include WebDOMRange.h
+
 %include WebBrowserShell.h
+%include WebDOMSelection.h
+%include WebEdit.h
 %include WebFrame.h
 %include WebSettings.h
 %include WebView.h
index 41e5d41fbd9790bd611442de6c270f194b9d1850..617a839d1fc609514c9933c903cf23bf638c6add 100644 (file)
@@ -30,6 +30,9 @@ import Logs
 import Options
 
 include_paths = [
+            os.path.join(wk_root, 'JavaScriptCore'),
+            os.path.join(wk_root, 'WebCore', 'bindings', 'cpp'),
+            os.path.join(wk_root, 'WebCore', 'DerivedSources'),
             os.path.join(wk_root, 'WebKit', 'wx'),
             os.path.join(wx_root, 'wxPython', 'include'),
             os.path.join(wx_root, '..', 'wxPython', 'include'),
@@ -95,4 +98,5 @@ def build(bld):
             
             libpath = [output_dir],
             uselib_local = '',
-            install_path = output_dir)
+            install_path = output_dir
+            )
index d0594b3c5c8b1f36d34ec23e99931c3aa35c0be3..fa3e06f95ec0a992c0ddca67bd0f949287e29dfa 100644 (file)
@@ -32,6 +32,8 @@ include_paths = webkit_dirs + common_includes + ['.', '..',
                 wk_root,
                 os.path.join(wk_root, 'JavaScriptCore'),
                 os.path.join(wk_root, 'WebCore'),
+                os.path.join(wk_root, 'WebCore', 'bindings', 'wx'),
+                os.path.join(wk_root, 'WebCore', 'DerivedSources'),
                 os.path.join(output_dir),
                 os.path.join(wk_root, 'WebCore', 'page', 'wx'),
                 os.path.join(wk_root, 'WebCore', 'platform', 'network', 'curl'),
index 0238ac0a668346773e5a4afe5445346eaf99b473..b73d12fff699e5e7cd65265be82c56239519d3b8 100644 (file)
@@ -1,3 +1,13 @@
+2010-07-28  Robin Dunn  <robin@alldunn.com>
+
+        Reviewed by Kevin Ollivier.
+
+        Add DOM bindings support for wx port.
+
+        * DumpRenderTree/wscript:
+        * wx/browser/wscript:
+        * wx/build/settings.py:
+
 2010-07-28  Tony Chang  <tony@chromium.org>
 
         Reviewed by Kent Tamura.
index 5e6c5971568cd92f18d901dbab2321b76dd5a224..75d208f126557bc54a164e8f630178c42f1db41f 100644 (file)
@@ -33,6 +33,7 @@ include_paths = [
                 os.path.join(output_dir),
                 os.path.join(wk_root, 'JavaScriptCore'),
                 os.path.join(wk_root, 'WebCore'),
+                os.path.join(wk_root, 'WebCore', 'bindings', 'wx'),
                 os.path.join(wk_root, 'WebKit', 'wx'), 
                 '.', 
                 'wx'
index a2a24e05778251a1f18e88508402267dd3b1a8fb..bd2640c269cae35c113f8eaa080551713bea688a 100644 (file)
@@ -29,7 +29,8 @@ import sys
 
 from settings import *
 
-include_paths = [os.path.join(wk_root, 'WebKit', 'wx')]
+include_paths = [os.path.join(wk_root, 'WebCore', 'bindings', 'wx'),
+                os.path.join(wk_root, 'WebKit', 'wx')]
 
 def set_options(opt):
     common_set_options(opt)
index b703967f667dd4ef11a378436923c2dc934a1125..2d144f65912e4f228ffd0981442f2a8bbd42d31c 100644 (file)
@@ -99,6 +99,7 @@ jscore_dirs = [
 webcore_dirs = [
     'accessibility',
     'bindings',
+    'bindings/cpp',
     'bindings/generic',
     'bindings/js',
     'bridge', 
@@ -168,7 +169,7 @@ def get_config():
             waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL'
         else:
             waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL_DBG'
-            
+
     return waf_configname
 
 create_hash_table = wk_root + "/JavaScriptCore/create_hash_table"
@@ -176,7 +177,10 @@ if building_on_win32:
     create_hash_table = get_output('cygpath --unix "%s"' % create_hash_table)
 os.environ['CREATE_HASH_TABLE'] = create_hash_table
 
-feature_defines = ['ENABLE_DATABASE', 'ENABLE_XSLT', 'ENABLE_JAVASCRIPT_DEBUGGER', 'ENABLE_SVG', 'ENABLE_SVG_USE', 'ENABLE_FILTERS', 'ENABLE_SVG_FONTS', 'ENABLE_SVG_ANIMATION', 'ENABLE_SVG_AS_IMAGE', 'ENABLE_SVG_FOREIGN_OBJECT', 'EXECUTABLE_ALLOCATOR_DEMAND']
+feature_defines = ['ENABLE_DATABASE', 'ENABLE_XSLT', 'ENABLE_JAVASCRIPT_DEBUGGER',
+                    'ENABLE_SVG', 'ENABLE_SVG_USE', 'ENABLE_FILTERS', 'ENABLE_SVG_FONTS',
+                    'ENABLE_SVG_ANIMATION', 'ENABLE_SVG_AS_IMAGE', 'ENABLE_SVG_FOREIGN_OBJECT',
+                    'ENABLE_JIT', 'ENABLE_EXECUTABLE_ALLOCATOR_DEMAND', 'BUILDING_%s' % build_port.upper()]
 
 msvc_version = 'msvc2008'