Commit 8b71af91 authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

imf: Don't use unique_ptr for CandidateWindow.

For some reason we use unique_ptr to store CandidateWindow. There's not
much benefit apart from saving 1 ptr size.

Bug: 1005619
Change-Id: Icd0305135257af3762f67798ab3b04d64c9aa2ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815806
Commit-Queue: Darren Shen <shend@chromium.org>
Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699624}
parent ce5064e0
......@@ -66,11 +66,7 @@ InputMethodEngine::CandidateWindowProperty::CandidateWindowProperty()
InputMethodEngine::CandidateWindowProperty::~CandidateWindowProperty() =
default;
InputMethodEngine::InputMethodEngine()
: candidate_window_(new ui::CandidateWindow()),
window_visible_(false),
is_mirroring_(false),
is_casting_(false) {}
InputMethodEngine::InputMethodEngine() = default;
InputMethodEngine::~InputMethodEngine() = default;
......@@ -127,18 +123,18 @@ void InputMethodEngine::SetCandidateWindowProperty(
dest_property.show_window_at_composition =
property.show_window_at_composition;
dest_property.cursor_position =
candidate_window_->GetProperty().cursor_position;
candidate_window_.GetProperty().cursor_position;
dest_property.auxiliary_text = property.auxiliary_text;
dest_property.is_auxiliary_text_visible = property.is_auxiliary_text_visible;
candidate_window_->SetProperty(dest_property);
candidate_window_.SetProperty(dest_property);
candidate_window_property_ = property;
if (IsActive()) {
IMECandidateWindowHandlerInterface* cw_handler =
ui::IMEBridge::Get()->GetCandidateWindowHandler();
if (cw_handler)
cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
cw_handler->UpdateLookupTable(candidate_window_, window_visible_);
}
}
......@@ -153,7 +149,7 @@ bool InputMethodEngine::SetCandidateWindowVisible(bool visible,
IMECandidateWindowHandlerInterface* cw_handler =
ui::IMEBridge::Get()->GetCandidateWindowHandler();
if (cw_handler)
cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
cw_handler->UpdateLookupTable(candidate_window_, window_visible_);
return true;
}
......@@ -173,7 +169,7 @@ bool InputMethodEngine::SetCandidates(
// TODO: Nested candidates
candidate_ids_.clear();
candidate_indexes_.clear();
candidate_window_->mutable_candidates()->clear();
candidate_window_.mutable_candidates()->clear();
for (const auto& candidate : candidates) {
ui::CandidateWindow::Entry entry;
entry.value = base::UTF8ToUTF16(candidate.value);
......@@ -186,13 +182,13 @@ bool InputMethodEngine::SetCandidates(
candidate_indexes_[candidate.id] = candidate_ids_.size();
candidate_ids_.push_back(candidate.id);
candidate_window_->mutable_candidates()->push_back(entry);
candidate_window_.mutable_candidates()->push_back(entry);
}
if (IsActive()) {
IMECandidateWindowHandlerInterface* cw_handler =
ui::IMEBridge::Get()->GetCandidateWindowHandler();
if (cw_handler)
cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
cw_handler->UpdateLookupTable(candidate_window_, window_visible_);
}
return true;
}
......@@ -216,11 +212,11 @@ bool InputMethodEngine::SetCursorPosition(int context_id,
return false;
}
candidate_window_->set_cursor_position(position->second);
candidate_window_.set_cursor_position(position->second);
IMECandidateWindowHandlerInterface* cw_handler =
ui::IMEBridge::Get()->GetCandidateWindowHandler();
if (cw_handler)
cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
cw_handler->UpdateLookupTable(candidate_window_, window_visible_);
return true;
}
......
......@@ -13,13 +13,13 @@
#include <vector>
#include "chrome/browser/ui/input_method/input_method_engine_base.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/base/ime/chromeos/input_method_descriptor.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/ime_engine_handler_interface.h"
#include "url/gurl.h"
namespace ui {
class CandidateWindow;
struct CompositionText;
class KeyEvent;
......@@ -150,13 +150,13 @@ class InputMethodEngine : public ::input_method::InputMethodEngineBase {
ui::ime::InputMethodMenuItem* property);
// The current candidate window.
std::unique_ptr<ui::CandidateWindow> candidate_window_;
ui::CandidateWindow candidate_window_;
// The current candidate window property.
CandidateWindowProperty candidate_window_property_;
// Indicates whether the candidate window is visible.
bool window_visible_;
bool window_visible_ = false;
// Mapping of candidate index to candidate id.
std::vector<int> candidate_ids_;
......@@ -165,10 +165,10 @@ class InputMethodEngine : public ::input_method::InputMethodEngineBase {
std::map<int, int> candidate_indexes_;
// Whether the screen is in mirroring mode.
bool is_mirroring_;
bool is_mirroring_ = false;
// Whether the desktop is being casted.
bool is_casting_;
bool is_casting_ = false;
DISALLOW_COPY_AND_ASSIGN(InputMethodEngine);
};
......
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