Index: chrome/renderer/render_view.cc |
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc |
index 65004f26e04f8945752f727abe5d74cff65e0f72..4ae4af4f77106fb180410ca1dc2c2f764e6de42a 100644 |
--- a/chrome/renderer/render_view.cc |
+++ b/chrome/renderer/render_view.cc |
@@ -93,6 +93,7 @@ |
#include "chrome/renderer/speech_input_dispatcher.h" |
#include "chrome/renderer/spellchecker/spellcheck_provider.h" |
#include "chrome/renderer/spellchecker/spellcheck.h" |
+#include "chrome/renderer/text_input_client_observer.h" |
#include "chrome/renderer/translate_helper.h" |
#include "chrome/renderer/user_script_idle_scheduler.h" |
#include "chrome/renderer/user_script_slave.h" |
@@ -620,6 +621,12 @@ RenderView::RenderView(RenderThreadBase* render_thread, |
AutoFillAgent* autofill_agent = new AutoFillAgent(this, |
password_autofill_manager); |
+#if defined(OS_MACOSX) |
+ // Create the message filter for the TextInputClient. |
+ TextInputClientObserver* input_client = new TextInputClientObserver(this); |
+ input_client->render_view(); // Avoid unused variable warning. |
+#endif // defined(OS_MACOSX) |
+ |
webwidget_ = WebView::create(this, devtools_agent_, autofill_agent); |
g_view_map.Get().insert(std::make_pair(webview(), this)); |
webkit_preferences_.Apply(webview()); |
@@ -2222,18 +2229,25 @@ void RenderView::didChangeSelection(bool is_empty_selection) { |
// Sometimes we get repeated didChangeSelection calls from webkit when |
// the selection hasn't actually changed. We don't want to report these |
// because it will cause us to continually claim the X clipboard. |
- const std::string& this_selection = |
- webview()->focusedFrame()->selectionAsText().utf8(); |
+ WebFrame* frame = webview()->focusedFrame(); |
+ const std::string& this_selection = frame->selectionAsText().utf8(); |
if (this_selection == last_selection_) |
return; |
+ WebRange range = frame->selectionRange(); |
Send(new ViewHostMsg_SelectionChanged(routing_id_, |
- this_selection)); |
+ this_selection, range.startOffset(), range.endOffset())); |
last_selection_ = this_selection; |
} else { |
last_selection_.clear(); |
- Send(new ViewHostMsg_SelectionChanged(routing_id_, |
- last_selection_)); |
+ WebRange range = webwidget_->caretOrSelectionRange(); |
+ if (!range.isNull()) { |
+ Send(new ViewHostMsg_SelectionChanged(routing_id_, |
+ last_selection_, range.startOffset(), range.endOffset())); |
+ } else { |
+ Send(new ViewHostMsg_SelectionChanged(routing_id_, |
+ last_selection_, 0, 0)); |
+ } |
} |
#endif // defined(OS_POSIX) |
} |