Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3135)

Unified Diff: content/renderer/text_input_client_observer.cc

Issue 2278283002: Implement Mac Pop-up Dictionary for OOPIF. (Closed)
Patch Set: Added Tests and Modified DEPS Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/text_input_client_observer.cc
diff --git a/content/renderer/text_input_client_observer.cc b/content/renderer/text_input_client_observer.cc
index c18d1273294100df05dd1827ba804b91051524ba..2695d2bf9030b13e7996a2707988afaab39fa38c 100644
--- a/content/renderer/text_input_client_observer.cc
+++ b/content/renderer/text_input_client_observer.cc
@@ -11,7 +11,8 @@
#include "build/build_config.h"
#include "content/common/text_input_client_messages.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
-#include "content/renderer/render_view_impl.h"
+#include "content/renderer/render_widget.h"
+#include "ipc/ipc_message.h"
#include "third_party/WebKit/public/platform/WebPoint.h"
#include "third_party/WebKit/public/platform/WebRect.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -22,13 +23,10 @@
namespace content {
-TextInputClientObserver::TextInputClientObserver(RenderViewImpl* render_view)
-#if defined(ENABLE_PLUGINS)
- : RenderViewObserver(render_view), render_view_impl_(render_view) {
-#else
- : RenderViewObserver(render_view) {
-#endif
-}
+TextInputClientObserver::TextInputClientObserver(
+ scoped_refptr<RenderWidget> render_widget,
+ blink::WebView* web_view)
+ : render_widget_(render_widget), web_view_(web_view) {}
TextInputClientObserver::~TextInputClientObserver() {
}
@@ -48,24 +46,30 @@ bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void TextInputClientObserver::OnDestruct() {
- delete this;
+bool TextInputClientObserver::Send(IPC::Message* message) {
+ DCHECK(render_widget_);
+ return render_widget_->Send(message);
}
blink::WebView* TextInputClientObserver::webview() {
- return render_view()->GetWebView();
+ return web_view_;
+}
+
+int32_t TextInputClientObserver::GetRoutingID() {
+ DCHECK(render_widget_);
+ return render_widget_->routing_id();
}
void TextInputClientObserver::OnStringAtPoint(gfx::Point point) {
#if defined(OS_MACOSX)
blink::WebPoint baselinePoint;
NSAttributedString* string = blink::WebSubstringUtil::attributedWordAtPoint(
- webview(), point, baselinePoint);
+ webview(), render_widget_->webwidget(), point, baselinePoint);
std::unique_ptr<const mac::AttributedStringCoder::EncodedString> encoded(
mac::AttributedStringCoder::Encode(string));
Send(new TextInputClientReplyMsg_GotStringAtPoint(
- routing_id(), *encoded.get(), baselinePoint));
+ GetRoutingID(), *encoded.get(), baselinePoint));
#else
NOTIMPLEMENTED();
#endif
@@ -75,15 +79,15 @@ void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) {
blink::WebPoint web_point(point);
uint32_t index = static_cast<uint32_t>(
webview()->focusedFrame()->characterIndexForPoint(web_point));
- Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint(routing_id(),
- index));
+ Send(new TextInputClientReplyMsg_GotCharacterIndexForPoint(GetRoutingID(),
+ index));
}
void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) {
gfx::Rect rect;
#if defined(ENABLE_PLUGINS)
- if (render_view_impl_->GetFocusedPepperPlugin()) {
- rect = render_view_impl_->GetFocusedPepperPlugin()->GetCaretBounds();
+ if (render_widget_->focused_pepper_plugin()) {
+ rect = render_widget_->focused_pepper_plugin()->GetCaretBounds();
} else
#endif
{
@@ -97,7 +101,7 @@ void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) {
rect = web_rect;
}
}
- Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect));
+ Send(new TextInputClientReplyMsg_GotFirstRectForRange(GetRoutingID(), rect));
}
void TextInputClientObserver::OnStringForRange(gfx::Range range) {
@@ -113,8 +117,8 @@ void TextInputClientObserver::OnStringForRange(gfx::Range range) {
}
std::unique_ptr<const mac::AttributedStringCoder::EncodedString> encoded(
mac::AttributedStringCoder::Encode(string));
- Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(),
- *encoded.get(), baselinePoint));
+ Send(new TextInputClientReplyMsg_GotStringForRange(
+ GetRoutingID(), *encoded.get(), baselinePoint));
#else
NOTIMPLEMENTED();
#endif

Powered by Google App Engine
This is Rietveld 408576698