]> git.saurik.com Git - wxWidgets.git/commitdiff
Derive wxWebViewEvent from wxNotifyEvent.
authorSteve Lamerton <steve.lamerton@gmail.com>
Wed, 17 Aug 2011 11:19:29 +0000 (11:19 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Wed, 17 Aug 2011 11:19:29 +0000 (11:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/webview.h
interface/wx/webview.h
src/gtk/webview_webkit.cpp
src/msw/webview_ie.cpp
src/osx/webview_webkit.mm

index e58cf881f9f07257f9b6cb737ec8b2a771a7841d..7c9c4e8276492931dc050079b1c16e8165fe6aea 100644 (file)
@@ -171,36 +171,23 @@ public:
     wxDECLARE_ABSTRACT_CLASS(wxWebView);
 };
 
-class WXDLLIMPEXP_WEB wxWebViewEvent : public wxCommandEvent
+class WXDLLIMPEXP_WEB wxWebViewEvent : public wxNotifyEvent
 {
 public:
     wxWebViewEvent() {}
     wxWebViewEvent(wxEventType type, int id, const wxString url,
-                   const wxString target, bool canVeto)
-        : wxCommandEvent(type, id)
-    {
-        m_url = url;
-        m_target = target;
-        m_vetoed = false;
-        m_canVeto = canVeto;
-    }
+                   const wxString target)
+        : wxNotifyEvent(type, id), m_url(url), m_target(target)
+    {}
 
 
     const wxString& GetURL() const { return m_url; }
     const wxString& GetTarget() const { return m_target; }
 
     virtual wxEvent* Clone() const { return new wxWebViewEvent(*this); }
-
-    bool CanVeto() const { return m_canVeto; }
-    bool IsVetoed() const { return m_vetoed; }
-
-    void Veto() { wxASSERT(m_canVeto); m_vetoed = true; }
-
 private:
     wxString m_url;
     wxString m_target;
-    bool m_canVeto;
-    bool m_vetoed;
 
     wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWebViewEvent);
 };
index 1b266bb013c799a8a17746ed3aa8325349520734..1eaacdcaa1024f4bf501827506fc79bf92b22985 100644 (file)
@@ -243,7 +243,7 @@ public:
    
     @library{wxweb}
     @category{ctrl,web}
-    @see wxWebHandler, wxWebViewEvent
+    @see wxWebViewHandler, wxWebViewEvent
  */
 class wxWebView : public wxControl
 {
@@ -626,12 +626,12 @@ public:
 
     @see wxWebView
 */
-class wxWebViewEvent : public wxCommandEvent
+class wxWebViewEvent : public wxNotifyEvent
 {
 public:
     wxWebViewEvent();
     wxWebViewEvent(wxEventType type, int id, const wxString href,
-                   const wxString target, bool canVeto);
+                   const wxString target);
 
     /**
         Get the name of the target frame which the url of this event
@@ -644,24 +644,4 @@ public:
         Get the URL being visited
     */
     const wxString& GetURL() const;
-
-    virtual wxEvent* Clone() const;
-
-    /** 
-        Get whether this event may be vetoed (stopped/prevented). Only
-        meaningful for events fired before navigation takes place.
-     */
-    bool CanVeto() const;
-
-    /** 
-        Whether this event was vetoed (stopped/prevented). Only meaningful for
-        events fired before navigation takes place or new window events.
-     */
-    bool IsVetoed() const;
-
-    /** 
-        Veto (prevent/stop) this event. Only meaningful for events fired
-        before navigation takes place. Only valid if CanVeto() returned true.
-     */
-    void Veto();
 };
\ No newline at end of file
index 5ac7a88fda62a464c567f157ecf82187747b67ba..91973b1d5f52c9b73111a33dbaacfcefc10d4538 100644 (file)
@@ -46,7 +46,7 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget,
         webKitCtrl->m_busy = false;
         wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED,
                              webKitCtrl->GetId(),
-                             url, target, false);
+                             url, target);
 
         if (webKitCtrl && webKitCtrl->GetEventHandler())
             webKitCtrl->GetEventHandler()->ProcessEvent(event);
@@ -56,7 +56,7 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget,
         webKitCtrl->m_busy = true;
         wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
                              webKitCtrl->GetId(),
-                             url, target, false);
+                             url, target);
 
         if (webKitCtrl && webKitCtrl->GetEventHandler())
             webKitCtrl->GetEventHandler()->ProcessEvent(event);
@@ -89,13 +89,12 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
     wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
                          webKitCtrl->GetId(),
                          wxString( uri, wxConvUTF8 ),
-                         target,
-                         true);
+                         target);
 
     if (webKitCtrl && webKitCtrl->GetEventHandler())
         webKitCtrl->GetEventHandler()->ProcessEvent(event);
 
-    if (event.IsVetoed())
+    if (!event.IsAllowed())
     {
         webKitCtrl->m_busy = false;
         webkit_web_policy_decision_ignore(policy_decision);
@@ -262,7 +261,7 @@ wxgtk_webview_webkit_error(WebKitWebView*,
 
     wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR,
                          webKitWindow->GetId(),
-                         uri, "", false);
+                         uri, "");
     event.SetString(description);
     event.SetInt(type);
 
@@ -288,8 +287,7 @@ wxgtk_webview_webkit_new_window(WebKitWebView*,
     wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
                                        webKitCtrl->GetId(),
                                        wxString( uri, wxConvUTF8 ),
-                                       target,
-                                       true);
+                                       target);
 
     if (webKitCtrl && webKitCtrl->GetEventHandler())
         webKitCtrl->GetEventHandler()->ProcessEvent(event);
@@ -308,7 +306,7 @@ wxgtk_webview_webkit_title_changed(WebKitWebView*,
     wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
                          webKitCtrl->GetId(),
                          webKitCtrl->GetCurrentURL(),
-                         "", true);
+                         "");
     event.SetString(wxString(title, wxConvUTF8));
 
     if (webKitCtrl && webKitCtrl->GetEventHandler())
index 57b75b296c5512d7d6f7f8e5727b5e74b5240c1d..92edb4ecd5e8a1d86f7faa0c35036bad56cc1344 100644 (file)
@@ -110,7 +110,7 @@ void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
         //We send the events when we are done to mimic webkit
         //Navigated event
         wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
-                             GetId(), baseUrl, "", false);
+                             GetId(), baseUrl, "");
         event.SetEventObject(this);
         HandleWindowEvent(event);
 
@@ -723,11 +723,11 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
             wxString target = evt[3].GetString();
 
             wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
-                                 GetId(), url, target, true);
+                                 GetId(), url, target);
             event.SetEventObject(this);
             HandleWindowEvent(event);
 
-            if (event.IsVetoed())
+            if (!event.IsAllowed())
             {
                 wxActiveXEventNativeMSW* nativeParams =
                     evt.GetNativeParameters();
@@ -749,7 +749,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
             // TODO: set target parameter if possible
             wxString target = wxEmptyString;
             wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
-                                 GetId(), url, target, false);
+                                 GetId(), url, target);
             event.SetEventObject(this);
             HandleWindowEvent(event);
             break;
@@ -798,7 +798,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
             // TODO: set target parameter if possible
             wxString target = wxEmptyString;
             wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED, GetId(),
-                                 url, target, false);
+                                 url, target);
             event.SetEventObject(this);
             HandleWindowEvent(event);
             break;
@@ -814,7 +814,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
             wxString title = evt[0].GetString();
 
             wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
-                                 GetId(), GetCurrentURL(), wxEmptyString, true);
+                                 GetId(), GetCurrentURL(), "");
             event.SetString(title);
             event.SetEventObject(this);
             HandleWindowEvent(event);
@@ -938,7 +938,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
             wxString url = evt[1].GetString();
             wxString target = evt[2].GetString();
             wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR, GetId(),
-                                 url, target, false);
+                                 url, target);
             event.SetEventObject(this);
             event.SetInt(errorType);
             event.SetString(errorCode);
@@ -950,7 +950,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
             wxString url = evt[4].GetString();
 
             wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
-                                 GetId(), url, wxEmptyString, true);
+                                 GetId(), url, wxEmptyString);
             event.SetEventObject(this);
             HandleWindowEvent(event);
 
index 745f0194e9f08be910458c227b4169a86c44dd1d..f0175d48ab5f60ef6c3c624ebfbba741f22244df 100644 (file)
@@ -1018,13 +1018,13 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
     if (webKitWindow && frame == [sender mainFrame]){
         NSString *url = [[[[frame dataSource] request] URL] absoluteString];
         wxString target = wxStringWithNSString([frame name]);
-        wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
-                                           webKitWindow->GetId(),
-                                           wxStringWithNSString( url ),
-                                           target, false);
+        wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
+                             webKitWindow->GetId(),
+                             wxStringWithNSString( url ),
+                             target);
 
         if (webKitWindow && webKitWindow->GetEventHandler())
-            webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+            webKitWindow->GetEventHandler()->ProcessEvent(event);
     }
 }
 
@@ -1036,13 +1036,13 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
         NSString *url = [[[[frame dataSource] request] URL] absoluteString];
 
         wxString target = wxStringWithNSString([frame name]);
-        wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_LOADED,
-                                           webKitWindow->GetId(),
-                                           wxStringWithNSString( url ),
-                                           target, false);
+        wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED,
+                             webKitWindow->GetId(),
+                             wxStringWithNSString( url ),
+                             target);
 
         if (webKitWindow && webKitWindow->GetEventHandler())
-            webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+            webKitWindow->GetEventHandler()->ProcessEvent(event);
     }
 }
 
@@ -1130,16 +1130,16 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
 
         wxWebViewNavigationError type;
         wxString description = nsErrorToWxHtmlError(error, &type);
-               wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR,
-                                                  webKitWindow->GetId(),
-                                           wxStringWithNSString( url ),
-                                           wxEmptyString, false);
-               thisEvent.SetString(description);
-               thisEvent.SetInt(type);
+               wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR,
+                                    webKitWindow->GetId(),
+                             wxStringWithNSString( url ),
+                             wxEmptyString);
+               event.SetString(description);
+               event.SetInt(type);
 
                if (webKitWindow && webKitWindow->GetEventHandler())
                {
-                       webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+                       webKitWindow->GetEventHandler()->ProcessEvent(event);
                }
     }
 }
@@ -1156,15 +1156,15 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
 
                wxWebViewNavigationError type;
         wxString description = nsErrorToWxHtmlError(error, &type);
-               wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR,
-                                                  webKitWindow->GetId(),
-                                           wxStringWithNSString( url ),
-                                           wxEmptyString, false);
-               thisEvent.SetString(description);
-               thisEvent.SetInt(type);
+               wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR,
+                                    webKitWindow->GetId(),
+                             wxStringWithNSString( url ),
+                             wxEmptyString);
+               event.SetString(description);
+               event.SetInt(type);
 
                if (webKitWindow && webKitWindow->GetEventHandler())
-                       webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+                       webKitWindow->GetEventHandler()->ProcessEvent(event);
     }
 }
 
@@ -1172,15 +1172,15 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
                                          forFrame:(WebFrame *)frame
 {
     wxString target = wxStringWithNSString([frame name]);
-    wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
-                                       webKitWindow->GetId(),
-                                       webKitWindow->GetCurrentURL(),
-                                       target, true);
+    wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
+                         webKitWindow->GetId(),
+                         webKitWindow->GetCurrentURL(),
+                         target);
                                    
-    thisEvent.SetString(wxStringWithNSString(title));
+    event.SetString(wxStringWithNSString(title));
 
     if (webKitWindow && webKitWindow->GetEventHandler())
-        webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+        webKitWindow->GetEventHandler()->ProcessEvent(event);
 }
 @end
 
@@ -1204,14 +1204,14 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
     webKitWindow->m_busy = true;
     NSString *url = [[request URL] absoluteString];
     wxString target = wxStringWithNSString([frame name]);
-    wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
-                                       webKitWindow->GetId(),
-                                       wxStringWithNSString( url ), target, true);
+    wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
+                         webKitWindow->GetId(),
+                         wxStringWithNSString( url ), target);
 
     if (webKitWindow && webKitWindow->GetEventHandler())
-        webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+        webKitWindow->GetEventHandler()->ProcessEvent(event);
 
-    if (thisEvent.IsVetoed())
+    if (!event.IsAllowed())
     {
         webKitWindow->m_busy = false;
         [listener ignore];
@@ -1231,12 +1231,12 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
     wxUnusedVar(actionInformation);
 
     NSString *url = [[request URL] absoluteString];
-    wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
-                                       webKitWindow->GetId(),
-                                       wxStringWithNSString( url ), "", true);
+    wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
+                         webKitWindow->GetId(),
+                         wxStringWithNSString( url ), "");
 
     if (webKitWindow && webKitWindow->GetEventHandler())
-        webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+        webKitWindow->GetEventHandler()->ProcessEvent(event);
 
     [listener ignore];
 }