Commit 661549ee authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Make sure to trace WebInputMethodController.

This class contains GC pointers and should be traced. Due to
a bug in the GC plugin, this wasn't being enforced. This also
changes the class to be a part object to clarify lifetimes.

Bug: 724418
Change-Id: I46d037d7f5040bc942b6bdf54d8d8a134914134b
Reviewed-on: https://chromium-review.googlesource.com/509149Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#473763}
parent b704484b
......@@ -26,21 +26,20 @@
namespace blink {
WebInputMethodControllerImpl::WebInputMethodControllerImpl(
WebLocalFrameImpl* web_local_frame)
: web_local_frame_(web_local_frame) {}
WebLocalFrameImpl& web_frame)
: web_frame_(&web_frame) {}
WebInputMethodControllerImpl::~WebInputMethodControllerImpl() {}
// static
WebInputMethodControllerImpl* WebInputMethodControllerImpl::FromFrame(
LocalFrame* frame) {
WebLocalFrameImpl* web_local_frame_impl = WebLocalFrameImpl::FromFrame(frame);
return web_local_frame_impl ? web_local_frame_impl->GetInputMethodController()
: nullptr;
WebLocalFrameImpl* web_frame_impl = WebLocalFrameImpl::FromFrame(frame);
return web_frame_impl ? web_frame_impl->GetInputMethodController() : nullptr;
}
DEFINE_TRACE(WebInputMethodControllerImpl) {
visitor->Trace(web_local_frame_);
visitor->Trace(web_frame_);
}
bool WebInputMethodControllerImpl::SetComposition(
......@@ -62,7 +61,7 @@ bool WebInputMethodControllerImpl::SetComposition(
// Select the range to be replaced with the composition later.
if (!replacement_range.IsNull())
web_local_frame_->SelectRange(replacement_range);
web_frame_->SelectRange(replacement_range);
// We should verify the parent node of this IME composition node are
// editable because JavaScript may delete a parent node of the composition
......@@ -128,7 +127,7 @@ bool WebInputMethodControllerImpl::CommitText(
// Select the range to be replaced with the composition later.
if (!replacement_range.IsNull())
web_local_frame_->SelectRange(replacement_range);
web_frame_->SelectRange(replacement_range);
// TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
......@@ -148,7 +147,7 @@ WebTextInputType WebInputMethodControllerImpl::TextInputType() {
}
LocalFrame* WebInputMethodControllerImpl::GetFrame() const {
return web_local_frame_->GetFrame();
return web_frame_->GetFrame();
}
InputMethodController& WebInputMethodControllerImpl::GetInputMethodController()
......
......@@ -6,6 +6,7 @@
#define WebInputMethodControllerImpl_h
#include "platform/heap/Handle.h"
#include "platform/wtf/Allocator.h"
#include "public/web/WebCompositionUnderline.h"
#include "public/web/WebInputMethodController.h"
......@@ -20,9 +21,10 @@ class WebString;
class WebInputMethodControllerImpl : public WebInputMethodController {
WTF_MAKE_NONCOPYABLE(WebInputMethodControllerImpl);
DISALLOW_NEW();
public:
explicit WebInputMethodControllerImpl(WebLocalFrameImpl* owner_frame);
explicit WebInputMethodControllerImpl(WebLocalFrameImpl& web_frame);
~WebInputMethodControllerImpl() override;
static WebInputMethodControllerImpl* FromFrame(LocalFrame*);
......@@ -49,7 +51,7 @@ class WebInputMethodControllerImpl : public WebInputMethodController {
InputMethodController& GetInputMethodController() const;
WebPlugin* FocusedPluginIfInputMethodSupported() const;
WeakMember<WebLocalFrameImpl> web_local_frame_;
const Member<WebLocalFrameImpl> web_frame_;
};
} // namespace blink
......
......@@ -1599,7 +1599,7 @@ WebLocalFrameImpl::WebLocalFrameImpl(
interface_provider_(interface_provider),
interface_registry_(interface_registry),
web_dev_tools_frontend_(0),
input_method_controller_(new WebInputMethodControllerImpl(this)),
input_method_controller_(*this),
text_checker_client_(new TextCheckerClientImpl(this)),
self_keep_alive_(this) {
DCHECK(client_);
......@@ -1631,6 +1631,7 @@ DEFINE_TRACE(WebLocalFrameImpl) {
visitor->Trace(text_finder_);
visitor->Trace(print_context_);
visitor->Trace(context_menu_node_);
visitor->Trace(input_method_controller_);
visitor->Trace(text_checker_client_);
WebLocalFrameBase::Trace(visitor);
// TODO(slangley): Call this from WebLocalFrameBase, once WebFrame is in core.
......@@ -2563,9 +2564,8 @@ base::SingleThreadTaskRunner* WebLocalFrameImpl::UnthrottledTaskRunner() {
->ToSingleThreadTaskRunner();
}
WebInputMethodControllerImpl* WebLocalFrameImpl::GetInputMethodController()
const {
return input_method_controller_.get();
WebInputMethodControllerImpl* WebLocalFrameImpl::GetInputMethodController() {
return &input_method_controller_;
}
void WebLocalFrameImpl::ExtractSmartClipData(WebRect rect_in_viewport,
......
......@@ -313,7 +313,7 @@ class WEB_EXPORT WebLocalFrameImpl final
base::SingleThreadTaskRunner* TimerTaskRunner() override;
base::SingleThreadTaskRunner* LoadingTaskRunner() override;
base::SingleThreadTaskRunner* UnthrottledTaskRunner() override;
WebInputMethodControllerImpl* GetInputMethodController() const override;
WebInputMethodControllerImpl* GetInputMethodController() override;
void ExtractSmartClipData(WebRect rect_in_viewport,
WebString& clip_text,
......@@ -514,7 +514,7 @@ class WEB_EXPORT WebLocalFrameImpl final
Member<Node> context_menu_node_;
std::unique_ptr<WebInputMethodControllerImpl> input_method_controller_;
WebInputMethodControllerImpl input_method_controller_;
// Stores the TextCheckerClient to bridge SpellChecker and WebTextCheckClient.
Member<TextCheckerClientImpl> text_checker_client_;
......
......@@ -551,7 +551,7 @@ class WebLocalFrame : public WebFrame {
virtual base::SingleThreadTaskRunner* UnthrottledTaskRunner() = 0;
// Returns the WebInputMethodController associated with this local frame.
virtual WebInputMethodController* GetInputMethodController() const = 0;
virtual WebInputMethodController* GetInputMethodController() = 0;
// Loading ------------------------------------------------------------------
// Creates and returns a loader. This function can be called only when this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment