diff options
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/editor_client_impl.cc | 9 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 4 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 10 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 1 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 2 |
5 files changed, 22 insertions, 4 deletions
diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index 4bea274..d6b2e2c 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -15,6 +15,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "Editor.h" #include "EventHandler.h" #include "EventNames.h" +#include "Frame.h" #include "KeyboardCodes.h" #include "HTMLInputElement.h" #include "HTMLNames.h" @@ -235,8 +236,11 @@ void EditorClientImpl::didBeginEditing() { void EditorClientImpl::respondToChangedSelection() { if (use_editor_delegate_) { WebViewDelegate* d = web_view_->delegate(); - if (d) - d->DidChangeSelection(); + if (d) { + WebCore::Frame* frame = web_view_->GetFocusedWebCoreFrame(); + if (frame) + d->DidChangeSelection(!frame->selection()->isRange()); + } } } @@ -844,4 +848,3 @@ std::wstring EditorClientImpl::Describe(WebCore::CSSStyleDeclaration* style) { // an example. But because none of them use it, it's not yet important. return std::wstring(); } - diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index 05fd9327..7c6c1fc 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -272,6 +272,10 @@ class WebFrame : public base::RefCounted<WebFrame> { // Clear any text selection in the frame. virtual void ClearSelection() = 0; + // Returns the selected text if there is any. If |as_html| is true, returns + // the selection as HTML. The return value is encoded in utf-8. + virtual std::string GetSelection(bool as_html) = 0; + // Paints the contents of this web view in a bitmapped image. This image // will not have plugins drawn. Devices are cheap to copy because the data is // internally refcounted so we allocate and return a new copy diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 70cbc61..78ac3d4 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -1340,6 +1340,16 @@ void WebFrameImpl::ClearSelection() { frame()->selection()->clear(); } +std::string WebFrameImpl::GetSelection(bool as_html) { + RefPtr<Range> range = frame()->selection()->toRange(); + if (as_html) { + String markup = WebCore::createMarkup(range.get(), 0); + return webkit_glue::StringToStdString(markup); + } else { + return webkit_glue::StringToStdString(range->text()); + } +} + void WebFrameImpl::CreateFrameView() { ASSERT(frame_); // If frame_ doesn't exist, we probably didn't init properly. diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 320a114..61c9851 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -140,6 +140,7 @@ class WebFrameImpl : public WebFrame { virtual void Undo(); virtual void Redo(); virtual void ClearSelection(); + virtual std::string GetSelection(bool as_html); virtual void SetInViewSourceMode(bool enable); diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index dd6ba52..1987999 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -634,7 +634,7 @@ class WebViewDelegate : virtual public WebWidgetDelegate { return false; } virtual void DidBeginEditing() { } - virtual void DidChangeSelection() { } + virtual void DidChangeSelection(bool is_empty_selection) { } virtual void DidChangeContents() { } virtual void DidEndEditing() { } |