Index: chrome/renderer/render_view.cc |
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc |
index fe84d68780a8203ff26f63d97d937200da52ed97..44e3b801c1c9d448e5d307b3caf82ed4e93de8d3 100644 |
--- a/chrome/renderer/render_view.cc |
+++ b/chrome/renderer/render_view.cc |
@@ -195,6 +195,7 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.h" |
#elif defined(OS_MACOSX) |
#include "skia/ext/skia_utils_mac.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebTextHelper.h" |
#endif |
using WebKit::WebAccessibilityCache; |
@@ -1070,6 +1071,11 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) { |
IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionConfirmed, |
OnPluginImeCompositionConfirmed) |
+ IPC_MESSAGE_HANDLER(ViewMsg_CharacterIndexForPoint, |
+ OnCharacterIndexForPoint) |
+ IPC_MESSAGE_HANDLER(ViewMsg_FirstRectForCharacterRange, |
+ OnFirstRectForCharacterRange) |
+ IPC_MESSAGE_HANDLER(ViewMsg_StringForRange, OnStringForRange) |
#endif |
IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
OnSetEditCommandsForNextKeyEvent) |
@@ -2241,18 +2247,19 @@ 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_)); |
+ last_selection_, 0, 0)); |
James Su
2011/01/20 23:46:06
As caretRect_ in RWHVM is not used anymore. We nee
|
} |
#endif // defined(OS_POSIX) |
} |
@@ -5657,6 +5664,24 @@ void RenderView::OnSelectPopupMenuItem(int selected_index) { |
external_popup_menu_->DidSelectItem(selected_index); |
external_popup_menu_.reset(); |
} |
+ |
+void RenderView::OnCharacterIndexForPoint(gfx::Point point) { |
+ WebKit::WebTextHelper helper(webview()->mainFrame()); |
+ uint index = helper.characterIndexForPoint(point.x(), point.y()); |
+ Send(new ViewHostMsg_GotCharacterIndexForPoint(routing_id(), index)); |
+} |
+ |
+void RenderView::OnFirstRectForCharacterRange(uint location, uint length) { |
+ WebKit::WebTextHelper helper(webview()->mainFrame()); |
+ gfx::Rect rect(helper.firstRectForRange(location, length)); |
+ Send(new ViewHostMsg_GotFirstRectForRange(routing_id(), rect)); |
+} |
+ |
+void RenderView::OnStringForRange(uint location, uint length) { |
+ WebKit::WebTextHelper helper(webview()->mainFrame()); |
+ WebKit::WebString webstring(helper.substringInRange(location, length)); |
+ Send(new ViewHostMsg_GotStringForRange(routing_id(), webstring)); |
+} |
#endif |
void RenderView::AddErrorToRootConsole(const string16& message) { |