]> git.saurik.com Git - wxWidgets.git/commitdiff
Add ClearSelection for msw ie and gtk webkit, with a stub for osx webkit. Document...
authorSteve Lamerton <steve.lamerton@gmail.com>
Fri, 15 Jul 2011 09:36:08 +0000 (09:36 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Fri, 15 Jul 2011 09:36:08 +0000 (09:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68274 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/webview_webkit.h
include/wx/msw/webview_ie.h
include/wx/osx/webview_webkit.h
include/wx/webview.h
interface/wx/webview.h
src/gtk/webview_webkit.cpp
src/msw/webview_ie.cpp
tests/controls/webtest.cpp

index 15b919374c58fff887035806529cb55944a29016..e675d5d98adc5655ddf75983d32fc71f82800c95 100644 (file)
@@ -147,6 +147,7 @@ public:
     virtual void SelectAll();
     virtual wxString GetSelectedText();
     virtual wxString GetSelectedSource();
+    virtual void ClearSelection();
 
     /** FIXME: hack to work around signals being received too early */
     bool m_ready;
index efc13b61ed02867414ef3d71c679685501e648cd..5d854abd9ddfeb291aa090dae8ff90239d97a4ae 100644 (file)
@@ -104,6 +104,7 @@ public:
     virtual void DeleteSelection();
     virtual wxString GetSelectedText();
     virtual wxString GetSelectedSource();
+    virtual void ClearSelection();
 
 
     // ---- IE-specific methods
index cbf0af285126e218298fc62e7394d0ea224843a1..a30f95cccb195b18b3912d8015151b5b897bea36 100644 (file)
@@ -109,6 +109,7 @@ public:
     virtual void SelectAll() {};
     virtual wxString GetSelectedText();
     virtual wxString GetSelectedSource() { return ""; }
+    virtual void ClearSelection() {}
 
     // ---- methods not from the parent (common) interface
     wxString RunScript(const wxString& javascript);
index 5d846a1d9a49c7c44149e245f5debe7a1909b400..22d9a2cbbc1a92e3d0fc3d7d48775d1068c1471d 100644 (file)
@@ -290,6 +290,7 @@ public:
     virtual void DeleteSelection() = 0;
     virtual wxString GetSelectedText() = 0;
     virtual wxString GetSelectedSource() = 0;
+    virtual void ClearSelection() = 0;
 
     // TODO:
     //     void EnableJavascript(bool enabled);             // maybe?
index 85e9a235eb2270cc353b520b504d55ab10a438e2..2ee38446881a1111045f5bc114ca67626074d9e2 100644 (file)
@@ -391,6 +391,11 @@ public:
         @name Selection
     */
     
+    /**
+        Clears the current selection. 
+    */
+    virtual void ClearSelection() = 0;
+    
     /**
         Deletes the current selection. Note that for @c wxWEB_VIEW_BACKEND_WEBKIT
         the selection must be editable, either through SetEditable or the 
index 4305f30675b7383608eb7a338e6d32389776136d..11304653d6d100f807fee8e617df1c098d3efb73 100644 (file)
@@ -768,6 +768,19 @@ wxString wxWebViewWebKit::GetSelectedSource()
                     wxConvUTF8);
 }
 
+void wxWebViewWebKit::ClearSelection()
+{
+    WebKitDOMDocument* doc; 
+    WebKitDOMDOMWindow* win;
+    WebKitDOMDOMSelection* sel;
+
+    doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view));
+    win = webkit_dom_document_get_default_view(WEBKIT_DOM_DOCUMENT(doc));
+    sel = webkit_dom_dom_window_get_selection(WEBKIT_DOM_DOM_WINDOW(win));
+    webkit_dom_dom_selection_remove_all_ranges(WEBKIT_DOM_DOM_SELECTION(sel));
+
+}
+
 wxString wxWebViewWebKit::GetPageText()
 {
     WebKitDOMDocument* doc; 
index 343699581c848678167abb6ad2296c0417467b1f..01d00611462dc2b535343ca451cfff45f2b3a7aa 100644 (file)
@@ -655,6 +655,20 @@ wxString wxWebViewIE::GetSelectedSource()
     return selected;
 }
 
+void wxWebViewIE::ClearSelection()
+{
+    IHTMLDocument2* document = GetDocument();
+    IHTMLSelectionObject* selection;
+    wxString selected;
+    HRESULT hr = document->get_selection(&selection);
+    if(SUCCEEDED(hr))
+    {
+        selection->empty();
+        selection->Release();
+    }
+    document->Release();
+}
+
 wxString wxWebViewIE::GetPageText()
 {
     IHTMLDocument2* document = GetDocument();
index 3e3b4cafda0b8590296e72717184543a4e9ee2e3..8154a9032b9a48f2fe28e83a909b4ac2700ee343 100644 (file)
@@ -207,6 +207,9 @@ void WebTestCase::Selection()
     //We lower case the result as ie returns tags in uppercase
     CPPUNIT_ASSERT_EQUAL("some <strong>strong</strong> text", 
                          m_browser->GetSelectedSource().Lower());
+
+    m_browser->ClearSelection();
+    CPPUNIT_ASSERT(!m_browser->HasSelection());  
 }
 
 void WebTestCase::Zoom()