Chromium Code Reviews| Index: chrome/renderer/render_view.cc |
| diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc |
| index a94e122cd62dcc9f8da0cc1643b49e1f41675d17..9bf253bf0b0697d30cacf32e8cd14886b4704281 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" |
| @@ -621,6 +622,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()); |
| @@ -2233,18 +2240,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(); |
|
James Su
2011/03/03 04:10:31
IMHO we should use the same code path regardless o
Robert Sesek
2011/03/18 21:33:16
Done.
|
| 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) |
| } |