[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kevino at webkit.org kevino at webkit.org
Wed Dec 22 12:38:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 8d011abe558b1457af7079acb1fd256c9c5ea40a
Author: kevino at webkit.org <kevino at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 26 15:59:59 2010 +0000

    Reviewed by Kevin Ollivier.
    
    A few tweaks to the wxWebView editing APIs after addition of DOM bindings.
    https://bugs.webkit.org/show_bug.cgi?id=44656
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66107 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog
index 342edea..6efdd42 100644
--- a/WebKit/wx/ChangeLog
+++ b/WebKit/wx/ChangeLog
@@ -1,3 +1,38 @@
+2010-08-26  Robin Dunn  <robin at alldunn.com>
+
+        Reviewed by Kevin Ollivier.
+
+        A few tweaks to the wxWebView editing APIs after addition of DOM bindings.
+        https://bugs.webkit.org/show_bug.cgi?id=44656
+        
+        1. adoptRef fix for WebCore::EditCommand wrapper API.
+        2. Add the mimetype as an argument to SetPageSource to allow XHTML documents to be loaded.
+        3. Add notification events for contents / selection changed editing events.
+        4. Improved wxPython binding typemaps support for DOM APIs.
+        
+        * WebEdit.cpp:
+        (WebCoreEditCommandPrivate::WebCoreEditCommandPrivate):
+        (WebCoreEditCommandPrivate::~WebCoreEditCommandPrivate):
+        (WebCoreEditCommandPrivate::command):
+        (wxWebEditCommand::wxWebEditCommand):
+        (wxWebEditCommand::~wxWebEditCommand):
+        (wxWebEditCommand::SetNodeAttribute):
+        (wxWebEditCommand::Apply):
+        * WebEdit.h:
+        * WebFrame.cpp:
+        (wxWebFrame::SetPageSource):
+        * WebFrame.h:
+        * WebKitSupport/EditorClientWx.cpp:
+        (WebCore::EditorClientWx::respondToChangedContents):
+        (WebCore::EditorClientWx::respondToChangedSelection):
+        * WebSettings.h:
+        * WebView.cpp:
+        (wxWebViewContentsChangedEvent::wxWebViewContentsChangedEvent):
+        (wxWebViewSelectionChangedEvent::wxWebViewSelectionChangedEvent):
+        (wxWebView::SetPageSource):
+        * WebView.h:
+        * bindings/python/webview.i:
+
 2010-08-16  Kevin Ollivier  <kevino at theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
diff --git a/WebKit/wx/WebEdit.cpp b/WebKit/wx/WebEdit.cpp
index 503e2ed..33b4c86 100644
--- a/WebKit/wx/WebEdit.cpp
+++ b/WebKit/wx/WebEdit.cpp
@@ -34,32 +34,47 @@ public:
 
 }
 
+class WebCoreEditCommandPrivate {
+public:
+    WebCoreEditCommandPrivate()
+        : m_ptr(0)
+    { }
+    
+    WebCoreEditCommandPrivate(WebCore::WebCoreEditCommand* ptr)
+        : m_ptr(adoptRef(ptr))
+    { }
+    
+    ~WebCoreEditCommandPrivate() { }
+    
+    WebCore::WebCoreEditCommand* command() { return m_ptr.get(); }
+        
+    RefPtr<WebCore::WebCoreEditCommand> m_ptr;
+};
+
 wxWebEditCommand::wxWebEditCommand(wxWebFrame* webframe)
 {
     if (webframe) {
         WebCore::Frame* frame = webframe->GetFrame();
         if (frame && frame->document())
-            m_impl = new WebCore::WebCoreEditCommand(frame->document());
-            m_impl->ref();
+            m_impl = new WebCoreEditCommandPrivate(new WebCore::WebCoreEditCommand(frame->document()));
     }
 }
 
 wxWebEditCommand::~wxWebEditCommand()
 {
     // the impl. is ref-counted, so don't delete it as it may be in an undo/redo stack
-    if (m_impl)
-        m_impl->deref();
+    delete m_impl;
     m_impl = 0;
 }
 
 void wxWebEditCommand::SetNodeAttribute(WebDOMElement* element, const wxString& name, const wxString& value)
 {
-    if (m_impl)
-        m_impl->setElementAttribute(element->impl(), WebCore::QualifiedName(WTF::nullAtom, WTF::String(name), WTF::nullAtom), WTF::String(value));
+    if (m_impl && m_impl->command())
+        m_impl->command()->setElementAttribute(element->impl(), WebCore::QualifiedName(WTF::nullAtom, WTF::String(name), WTF::nullAtom), WTF::String(value));
 }
 
 void wxWebEditCommand::Apply()
 {
-    if (m_impl)
-        m_impl->apply();
-}
\ No newline at end of file
+    if (m_impl && m_impl->command())
+        m_impl->command()->apply();
+}
diff --git a/WebKit/wx/WebEdit.h b/WebKit/wx/WebEdit.h
index 7099088..e4bba91 100644
--- a/WebKit/wx/WebEdit.h
+++ b/WebKit/wx/WebEdit.h
@@ -41,6 +41,7 @@ namespace WebCore {
 }
 
 class WebDOMElement;
+class WebCoreEditCommandPrivate;
 class wxWebFrame;
 
 class WXDLLIMPEXP_WEBKIT wxWebEditCommand
@@ -56,7 +57,7 @@ public:
     void Apply();
     
 private:
-    WebCore::WebCoreEditCommand* m_impl;
+    WebCoreEditCommandPrivate* m_impl;
 };
 
 #endif
diff --git a/WebKit/wx/WebFrame.cpp b/WebKit/wx/WebFrame.cpp
index f9be56f..da3bfe2 100644
--- a/WebKit/wx/WebFrame.cpp
+++ b/WebKit/wx/WebFrame.cpp
@@ -155,7 +155,7 @@ wxString wxWebFrame::GetPageSource()
     return wxEmptyString;
 }
 
-void wxWebFrame::SetPageSource(const wxString& source, const wxString& baseUrl)
+void wxWebFrame::SetPageSource(const wxString& source, const wxString& baseUrl, const wxString& mimetype)
 {
     if (m_impl->frame && m_impl->frame->loader()) {
         WebCore::KURL url(WebCore::KURL(), baseUrl);
@@ -164,7 +164,7 @@ void wxWebFrame::SetPageSource(const wxString& source, const wxString& baseUrl)
         const char* contents = charBuffer;
 
         WTF::PassRefPtr<WebCore::SharedBuffer> sharedBuffer = WebCore::SharedBuffer::create(contents, strlen(contents));
-        WebCore::SubstituteData substituteData(sharedBuffer, WTF::String("text/html"), WTF::String("UTF-8"), WebCore::blankURL(), url);
+        WebCore::SubstituteData substituteData(sharedBuffer, mimetype, WTF::String("UTF-8"), WebCore::blankURL(), url);
 
         m_impl->frame->loader()->stop();
         m_impl->frame->loader()->load(WebCore::ResourceRequest(url), substituteData, false);
diff --git a/WebKit/wx/WebFrame.h b/WebKit/wx/WebFrame.h
index f09c884..ba30022 100644
--- a/WebKit/wx/WebFrame.h
+++ b/WebKit/wx/WebFrame.h
@@ -134,7 +134,7 @@ public:
     void Redo();
     
     wxString GetPageSource();
-    void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
+    void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString, const wxString& mimetype = wxT("text/html"));
     
     wxString GetInnerText();
     wxString GetAsMarkup();
diff --git a/WebKit/wx/WebKitSupport/EditorClientWx.cpp b/WebKit/wx/WebKitSupport/EditorClientWx.cpp
index 99afec8..59e2fd4 100644
--- a/WebKit/wx/WebKitSupport/EditorClientWx.cpp
+++ b/WebKit/wx/WebKitSupport/EditorClientWx.cpp
@@ -262,7 +262,15 @@ void EditorClientWx::didBeginEditing()
 
 void EditorClientWx::respondToChangedContents()
 {
-    notImplemented();
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    
+    if (frame) {
+        wxWebView* webKitWin = dynamic_cast<wxWebView*>(frame->view()->hostWindow()->platformPageClient());
+        if (webKitWin) {
+            wxWebViewContentsChangedEvent wkEvent(webKitWin);
+            webKitWin->GetEventHandler()->ProcessEvent(wkEvent);
+        }
+    }
 }
 
 void EditorClientWx::didEndEditing()
@@ -483,7 +491,14 @@ void EditorClientWx::textDidChangeInTextArea(Element*)
 
 void EditorClientWx::respondToChangedSelection()
 {
-    notImplemented();
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    if (frame) {
+        wxWebView* webKitWin = dynamic_cast<wxWebView*>(frame->view()->hostWindow()->platformPageClient());
+        if (webKitWin) {
+            wxWebViewSelectionChangedEvent wkEvent(webKitWin);
+            webKitWin->GetEventHandler()->ProcessEvent(wkEvent);
+        }
+    }
 }
 
 void EditorClientWx::ignoreWordInSpellDocument(const String&) 
diff --git a/WebKit/wx/WebSettings.h b/WebKit/wx/WebSettings.h
index 148755a..9ab5502 100644
--- a/WebKit/wx/WebSettings.h
+++ b/WebKit/wx/WebSettings.h
@@ -66,6 +66,8 @@ public:
     {}
     
     wxWebSettings() : wxObject() {}
+    
+    virtual ~wxWebSettings() { }
 
     /**
         Sets the default font size for fixed fonts.
diff --git a/WebKit/wx/WebView.cpp b/WebKit/wx/WebView.cpp
index 3b0bcb0..92488dd 100644
--- a/WebKit/wx/WebView.cpp
+++ b/WebKit/wx/WebView.cpp
@@ -226,6 +226,29 @@ wxWebViewWindowObjectClearedEvent::wxWebViewWindowObjectClearedEvent(wxWindow* w
         SetId(win->GetId());
 }
 
+IMPLEMENT_DYNAMIC_CLASS(wxWebViewContentsChangedEvent, wxCommandEvent)
+
+DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_CONTENTS_CHANGED)
+
+wxWebViewContentsChangedEvent::wxWebViewContentsChangedEvent(wxWindow* win)
+{
+    SetEventType(wxEVT_WEBVIEW_CONTENTS_CHANGED);
+    SetEventObject(win);
+    if (win)
+        SetId(win->GetId());
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxWebViewSelectionChangedEvent, wxCommandEvent)
+
+DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_SELECTION_CHANGED)
+
+wxWebViewSelectionChangedEvent::wxWebViewSelectionChangedEvent(wxWindow* win)
+{
+    SetEventType(wxEVT_WEBVIEW_SELECTION_CHANGED);
+    SetEventObject(win);
+    if (win)
+        SetId(win->GetId());
+}
 
 //---------------------------------------------------------
 // DOM Element info data type
@@ -438,10 +461,10 @@ wxString wxWebView::GetPageSource()
     return wxEmptyString;
 }
 
-void wxWebView::SetPageSource(const wxString& source, const wxString& baseUrl)
+void wxWebView::SetPageSource(const wxString& source, const wxString& baseUrl, const wxString& mimetype)
 {
     if (m_mainFrame)
-        m_mainFrame->SetPageSource(source, baseUrl);
+        m_mainFrame->SetPageSource(source, baseUrl, mimetype);
 }
 
 wxString wxWebView::GetInnerText()
diff --git a/WebKit/wx/WebView.h b/WebKit/wx/WebView.h
index d7f23b6..8f70408 100644
--- a/WebKit/wx/WebView.h
+++ b/WebKit/wx/WebView.h
@@ -156,7 +156,7 @@ public:
     
     //bool CanGetPageSource();
     wxString GetPageSource();
-    void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
+    void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString, const wxString& mimetype = wxT("text/html"));
     
     wxString GetInnerText();
     wxString GetAsMarkup();
@@ -525,6 +525,26 @@ private:
     JSObjectRef m_windowObject;
 };
 
+class WXDLLIMPEXP_WEBKIT wxWebViewContentsChangedEvent : public wxCommandEvent {
+#ifndef SWIG
+    DECLARE_DYNAMIC_CLASS(wxWebViewContentsChangedEvent)
+#endif
+
+public:
+    wxWebViewContentsChangedEvent(wxWindow* win = static_cast<wxWindow*>(0));
+    wxEvent *Clone(void) const { return new wxWebViewContentsChangedEvent(*this); }
+};
+
+class WXDLLIMPEXP_WEBKIT wxWebViewSelectionChangedEvent : public wxCommandEvent {
+#ifndef SWIG
+    DECLARE_DYNAMIC_CLASS(wxWebViewSelectionChangedEvent)
+#endif
+
+public:
+    wxWebViewSelectionChangedEvent(wxWindow* win = static_cast<wxWindow*>(0));
+    wxEvent *Clone(void) const { return new wxWebViewSelectionChangedEvent(*this); }
+};
+
 typedef void (wxEvtHandler::*wxWebViewLoadEventFunction)(wxWebViewLoadEvent&);
 typedef void (wxEvtHandler::*wxWebViewBeforeLoadEventFunction)(wxWebViewBeforeLoadEvent&);
 typedef void (wxEvtHandler::*wxWebViewNewWindowEventFunction)(wxWebViewNewWindowEvent&);
@@ -535,6 +555,8 @@ typedef void (wxEvtHandler::*wxWebViewConfirmEventFunction)(wxWebViewConfirmEven
 typedef void (wxEvtHandler::*wxWebViewPromptEventFunction)(wxWebViewPromptEvent&);
 typedef void (wxEvtHandler::*wxWebViewReceivedTitleEventFunction)(wxWebViewReceivedTitleEvent&);
 typedef void (wxEvtHandler::*wxWebViewWindowObjectClearedFunction)(wxWebViewWindowObjectClearedEvent&);
+typedef void (wxEvtHandler::*wxWebViewContentsChangedFunction)(wxWebViewContentsChangedEvent&);
+typedef void (wxEvtHandler::*wxWebViewSelectionChangedFunction)(wxWebViewSelectionChangedEvent&);
 
 #define wxWebViewLoadEventHandler(func) \
     (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewLoadEventFunction, &func)
@@ -556,7 +578,11 @@ typedef void (wxEvtHandler::*wxWebViewWindowObjectClearedFunction)(wxWebViewWind
     (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewReceivedTitleEventFunction, &func)
 #define wxWebViewWindowObjectClearedEventHandler(func) \
     (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewWindowObjectClearedFunction, &func)
-
+#define wxWebViewContentsChangedEventHandler(func) \
+    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewContentsChangedEventFunction, &func)
+#define wxWebViewSelectionChangedEventHandler(func) \
+    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewSelectionChangedEventFunction, &func)
+    
 #ifndef SWIG
 BEGIN_DECLARE_EVENT_TYPES()
     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_BEFORE_LOAD, wxID_ANY)
@@ -569,6 +595,8 @@ BEGIN_DECLARE_EVENT_TYPES()
     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_JS_PROMPT, wxID_ANY)
     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_RECEIVED_TITLE, wxID_ANY)
     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_WINDOW_OBJECT_CLEARED, wxID_ANY)
+    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_CONTENTS_CHANGED, wxID_ANY)
+    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_SELECTION_CHANGED, wxID_ANY)
 END_DECLARE_EVENT_TYPES()
 #endif
 
@@ -652,4 +680,21 @@ END_DECLARE_EVENT_TYPES()
                             (wxWebViewWindowObjectClearedFunction) & func, \
                             static_cast<wxObject*>(NULL)),
 
+#define EVT_WEBVIEW_CONTENTS_CHANGED(winid, func)                       \
+            DECLARE_EVENT_TABLE_ENTRY(wxEVT_WEBVIEW_CONTENTS_CHANGED, \
+                            winid, \
+                            wxID_ANY, \
+                            (wxObjectEventFunction)   \
+                            (wxWebViewContentsChangedEventFunction) & func, \
+                            static_cast<wxObject*>(0)),
+                            
+#define EVT_WEBVIEW_SELECTION_CHANGED(winid, func)                       \
+            DECLARE_EVENT_TABLE_ENTRY(wxEVT_WEBVIEW_SELECTION_CHANGED, \
+                            winid, \
+                            wxID_ANY, \
+                            (wxObjectEventFunction)   \
+                            (wxWebViewSelectionChangedEventFunction) & func, \
+                            static_cast<wxObject*>(0)),
+                            
+                            
 #endif // ifndef WXWEBVIEW_H
diff --git a/WebKit/wx/bindings/python/webview.i b/WebKit/wx/bindings/python/webview.i
index 8e3c808..f1621b0 100644
--- a/WebKit/wx/bindings/python/webview.i
+++ b/WebKit/wx/bindings/python/webview.i
@@ -51,7 +51,7 @@
 #include "WebDOMRange.h"
 
 #ifndef __WXMSW__
-PyObject* createDOMNodeSubtype(WebDOMNode* ptr, bool setThisOwn)
+PyObject* createDOMNodeSubtype(WebDOMNode* ptr, bool setThisOwn, bool isValueObject)
 {
     //static wxPyTypeInfoHashMap* typeInfoCache = NULL;
 
@@ -73,9 +73,13 @@ PyObject* createDOMNodeSubtype(WebDOMNode* ptr, bool setThisOwn)
                 name = "WebDOMNode*";
         }
         swigType = SWIG_TypeQuery(name);
-        if (swigType)
+        if (swigType) {
+            if (isValueObject) {
+                return SWIG_Python_NewPointerObj(new WebDOMNode(*ptr), swigType, setThisOwn);
+            }
+            
             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
@@ -87,8 +91,34 @@ PyObject* createDOMNodeSubtype(WebDOMNode* ptr, bool setThisOwn)
     
     return Py_None;
 }
+
+WebDOMString* createWebDOMString(PyObject* source)
+{
+    if (!PyString_Check(source) && !PyUnicode_Check(source)) {
+        PyErr_SetString(PyExc_TypeError, "String or Unicode type required");
+        return new WebDOMString();
+    }
+    
+    char* tmpPtr;
+    Py_ssize_t tmpSize;
+    
+    if (PyString_Check(source))
+        PyString_AsStringAndSize(source, &tmpPtr, &tmpSize);
+    else {
+        PyObject* str = PyUnicode_AsUTF8String(source);
+        PyString_AsStringAndSize(str, &tmpPtr, &tmpSize);
+        Py_DECREF(str);
+    }
+    
+    WebDOMString temp = WebDOMString::fromUTF8(tmpPtr);
+    
+    return new WebDOMString(temp);
+}
+
 #endif
 
+
+
 %}
 //---------------------------------------------------------------------------
 
@@ -96,10 +126,13 @@ PyObject* createDOMNodeSubtype(WebDOMNode* ptr, bool setThisOwn)
 %import windows.i
 
 #ifndef __WXMSW__
-%typemap(out) WebDOMNode*             { $result = createDOMNodeSubtype($1, (bool)$owner); }
-%typemap(out) WebDOMElement*             { $result = createDOMNodeSubtype($1, (bool)$owner); }
-%typemap(out) WebDOMNode             { $result = createDOMNodeSubtype(&$1, (bool)$owner); }
-%typemap(out) WebDOMElement             { $result = createDOMNodeSubtype(&$1, (bool)$owner); }
+%typemap(out) WebDOMNode*             { $result = createDOMNodeSubtype($1, (bool)$owner, 0); }
+%typemap(out) WebDOMElement*             { $result = createDOMNodeSubtype($1, (bool)$owner, 0); }
+%typemap(out) WebDOMNode             { $result = createDOMNodeSubtype(&$1, (bool)$owner, 1); }
+%typemap(out) WebDOMElement             { $result = createDOMNodeSubtype(&$1, (bool)$owner, 1); }
+%typemap(in) WebDOMString&            { $1 = createWebDOMString($input); }
+%typemap(out) WebDOMString           { $result = PyUnicode_DecodeUTF8($1.utf8().data(), $1.utf8().length(), NULL); }
+%typemap(out) WebDOMString&           { $result = PyUnicode_DecodeUTF8($1.utf8().data(), $1.utf8().length(), NULL); }
 #endif
 
 MAKE_CONST_WXSTRING(WebViewNameStr);
@@ -134,6 +167,8 @@ MustHaveApp(wxWebView);
 %constant wxEventType wxEVT_WEBVIEW_RIGHT_CLICK;
 %constant wxEventType wxEVT_WEBVIEW_CONSOLE_MESSAGE;
 %constant wxEventType wxEVT_WEBVIEW_RECEIVED_TITLE;
+%constant wxEventType wxEVT_WEBVIEW_CONTENTS_CHANGED;
+%constant wxEventType wxEVT_WEBVIEW_SELECTION_CHANGED;
 
 %pythoncode {
 EVT_WEBVIEW_BEFORE_LOAD = wx.PyEventBinder( wxEVT_WEBVIEW_BEFORE_LOAD, 1 )
@@ -141,5 +176,7 @@ EVT_WEBVIEW_LOAD = wx.PyEventBinder( wxEVT_WEBVIEW_LOAD, 1 )
 EVT_WEBVIEW_NEW_WINDOW = wx.PyEventBinder( wxEVT_WEBVIEW_NEW_WINDOW, 1 )
 EVT_WEBVIEW_RIGHT_CLICK = wx.PyEventBinder( wxEVT_WEBVIEW_RIGHT_CLICK, 1 )
 EVT_WEBVIEW_CONSOLE_MESSAGE = wx.PyEventBinder( wxEVT_WEBVIEW_CONSOLE_MESSAGE, 1 )
-EVT_WEBVIEW_RECEIVED_TITLE = wx.PyEventBinder( wxEVT_WEBVIEW_RECEIVED_TITLE, 1 )    
+EVT_WEBVIEW_RECEIVED_TITLE = wx.PyEventBinder( wxEVT_WEBVIEW_RECEIVED_TITLE, 1 )
+EVT_WEBVIEW_CONTENTS_CHANGED = wx.PyEventBinder( wxEVT_WEBVIEW_CONTENTS_CHANGED, 1 )
+EVT_WEBVIEW_SELECTION_CHANGED = wx.PyEventBinder( wxEVT_WEBVIEW_SELECTION_CHANGED, 1 )
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list