Skip to content
Permalink
Browse files

Remove dead code from mozc_server.

This is a follow up for 9fbcdd5,
with which we stopped working around a limitation in GTK IM-module
and removed the ibus-mozc side logic.

This CL removes the backend logic implemented in mozc_server.  This
should not have any user-visible behavior change because that logic
in question is no longer used.

BUG=#243
TEST=unittest
REF_BUG=19395322
REF_CL=91766128
  • Loading branch information...
yukawa committed Dec 19, 2015
1 parent 5d423b0 commit 7a129e6590297380dccd8b997cbbd821f54403a2
@@ -316,7 +316,7 @@ SendCommand_SwitchInputFieldType
SendCommand_UsageStatsEvent
SendCommand_UndoOrRewind
SendCommand_ExpandSuggestion
SendCommand_SendCaretLocation
SendCommand_ObsoleteSendCaretLocation
SendCommand_ObsoleteSendLanguageBarCommand
SendCommand_ObsoleteGetAsyncResult
SendCommand_CommitRawText
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
BUILD=2244
BUILD=2245
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
@@ -86,8 +86,8 @@ enum DisplayType {
CASCADE = 1;
};

// TODO(nona): merge to RendererCommand::Rectangle
message Rectangle {
// Obsolete. Used only in old IBus client.
message DeprecatedRectangle {
required int32 x = 1;
required int32 y = 2;
required int32 width = 3;
@@ -206,19 +206,20 @@ message Candidates {
};
optional Direction direction = 14 [ default = VERTICAL ];

// This position is used for suggest window position.
optional Rectangle composition_rectangle = 15;
optional Rectangle caret_rectangle = 16;
// Obsolete. Used only in old IBus client.
optional DeprecatedRectangle deprecated_composition_rectangle = 15;
optional DeprecatedRectangle deprecated_caret_rectangle = 16;

enum CandidateWindowLocation{
// Obsolete. Used only in old IBus client.
enum DeprecatedCandidateWindowLocation {
// Shows candidate window under the caret. This is used for prediction and
// conversion
CARET = 0;
DEPRECATED_CARET = 0;
// Shows candidate window aligned with composition area. This is used for
// suggestion.
COMPOSITION = 1;
DEPRECATED_COMPOSITION = 1;
}
optional CandidateWindowLocation window_location = 17;
optional DeprecatedCandidateWindowLocation deprecated_window_location = 17;

// The number of candidates per page.
optional uint32 page_size = 18 [ default = 9 ];
@@ -403,11 +403,8 @@ message SessionCommand {
// thing but it changes IME state to prediction).
EXPAND_SUGGESTION = 15;

// The client can send the current caret position whenever the caret
// position is changed. The caret position is used for suggest window
// position calculation. This is an optional message. If client can show
// suggest window on the correct position, this message can be ignored.
SEND_CARET_LOCATION = 16;
// Obsolete command. Used only in old IBus client.
OBSOLETE_SEND_CARET_LOCATION = 16;

// Obsolete command. Don't simply remove this command for NUM_OF_COMMANDS.
// TODO(team): Replace this command by useful one.
@@ -489,9 +486,8 @@ message SessionCommand {
optional UsageStatsEvent usage_stats_event = 7;
optional int32 usage_stats_event_int_value = 9;

// Specify the current caret location, this is used for suggest window
// position calculation. Used with SEND_CARET_LOCATION.
optional Rectangle caret_rectangle = 8;
// Obsolete command. Used only in old IBus client.
optional DeprecatedRectangle deprecated_caret_rectangle = 8;
};

message Context {
@@ -100,8 +100,6 @@ void ImeContext::CopyContext(const ImeContext &src, ImeContext *dest) {

dest->mutable_client_capability()->CopyFrom(src.client_capability());
dest->mutable_application_info()->CopyFrom(src.application_info());
dest->mutable_composition_rectangle()->CopyFrom(src.composition_rectangle());
dest->mutable_caret_rectangle()->CopyFrom(src.caret_rectangle());
dest->mutable_output()->CopyFrom(src.output());
}

@@ -124,20 +124,6 @@ class ImeContext {
return &client_context_;
}

const commands::Rectangle &composition_rectangle() const {
return composition_rectangle_;
}
commands::Rectangle *mutable_composition_rectangle() {
return &composition_rectangle_;
}

const commands::Rectangle &caret_rectangle() const {
return caret_rectangle_;
}
commands::Rectangle *mutable_caret_rectangle() {
return &caret_rectangle_;
}

const commands::Output &output() const {
return output_;
}
@@ -174,11 +160,6 @@ class ImeContext {

commands::Context client_context_;

// TODO(nona): remove these fields by moving the rectangle calculation logic
// to the Linux client.
commands::Rectangle composition_rectangle_;
commands::Rectangle caret_rectangle_;

// Storing the last output consisting of the last result and the
// last performed command.
commands::Output output_;
@@ -145,14 +145,6 @@ void SetSessionState(const ImeContext::State state, ImeContext *context) {
break;
case ImeContext::COMPOSITION:
if (prev_state == ImeContext::PRECOMPOSITION) {
// NOTE: In case of state change including commitment, state change
// doesn't happen directly at once from CONVERSION to COMPOSITION.
// Actual state change is CONVERSION to PRECOMPOSITION at first,
// followed by PRECOMPOSITION to COMPOSITION.
// However in this case we can only get one SendCaretRectangle
// because the state change is executed atomically.
context->mutable_composition_rectangle()->CopyFrom(
context->caret_rectangle());
// Notify the start of composition to the converter so that internal
// state can be refreshed by the client context (especially by
// preceding text).
@@ -353,9 +345,6 @@ bool Session::SendCommand(commands::Command *command) {
case commands::SessionCommand::UNDO_OR_REWIND:
result = UndoOrRewind(command);
break;
case commands::SessionCommand::SEND_CARET_LOCATION:
result = SetCaretLocation(command);
break;
case commands::SessionCommand::COMMIT_RAW_TEXT:
result = CommitRawText(command);
break;
@@ -2675,33 +2664,6 @@ void Session::Output(commands::Command *command) {
OutputMode(command);
context_->mutable_converter()->PopOutput(
context_->composer(), command->mutable_output());
OutputWindowLocation(command);
}

void Session::OutputWindowLocation(commands::Command *command) const {
if (!(command->output().has_candidates() &&
context_->caret_rectangle().IsInitialized() &&
context_->composition_rectangle().IsInitialized())) {
return;
}

DCHECK(command->output().candidates().has_category());

commands::Candidates *candidates =
command->mutable_output()->mutable_candidates();

candidates->mutable_caret_rectangle()->CopyFrom(
context_->caret_rectangle());

candidates->mutable_composition_rectangle()->CopyFrom(
context_->composition_rectangle());

if (command->output().candidates().category() == commands::SUGGESTION ||
command->output().candidates().category() == commands::PREDICTION) {
candidates->set_window_location(commands::Candidates::COMPOSITION);
} else {
candidates->set_window_location(commands::Candidates::CARET);
}
}

void Session::OutputMode(commands::Command *command) const {
@@ -2864,41 +2826,6 @@ bool Session::SwitchInputFieldType(commands::Command *command) {
return true;
}

bool Session::SetCaretLocation(commands::Command *command) {
if (!command->input().has_command()) {
return false;
}

const commands::SessionCommand &session_command = command->input().command();
if (!session_command.has_caret_rectangle()) {
context_->mutable_caret_rectangle()->Clear();
return false;
}

if (!context_->caret_rectangle().IsInitialized()) {
context_->mutable_caret_rectangle()->CopyFrom(
session_command.caret_rectangle());
return true;
}

const int caret_delta_y = abs(
context_->caret_rectangle().y() - session_command.caret_rectangle().y());

context_->mutable_caret_rectangle()->CopyFrom(
session_command.caret_rectangle());

const int kJumpThreshold = 30;

// If caret is jumped, assume the text field is also jumped and reset the
// rectangle of composition text.
if (caret_delta_y > kJumpThreshold) {
context_->mutable_composition_rectangle()->CopyFrom(
context_->caret_rectangle());
}

return true;
}

bool Session::HandleIndirectImeOnOff(commands::Command *command) {
const commands::KeyEvent &key = command->input().key();
if (!key.has_activated()) {
@@ -35,7 +35,6 @@
#include <memory>
#include <string>

#include "base/coordinates.h"
#include "base/port.h"
#include "composer/composer.h"
#include "session/session_interface.h"
@@ -60,7 +59,6 @@ class EngineInterface;

namespace session {
class ImeContext;
class SessionCursorManageTest;

class Session : public SessionInterface {
public:
@@ -362,7 +360,6 @@ class Session : public SessionInterface {
void OutputMode(mozc::commands::Command *command) const;
void OutputComposition(mozc::commands::Command *command) const;
void OutputKey(mozc::commands::Command *command) const;
void OutputWindowLocation(mozc::commands::Command *command) const;

bool SendKeyDirectInputState(mozc::commands::Command *command);
bool SendKeyPrecompositionState(mozc::commands::Command *command);
@@ -386,9 +383,6 @@ class Session : public SessionInterface {
// AutoIMEConversion.
bool CanStartAutoConversion(const mozc::commands::KeyEvent &key_event) const;

// Stores received caret location into caret_rectangle_.
bool SetCaretLocation(mozc::commands::Command *command);

// Handles KeyEvent::activated to support indirect IME on/off.
bool HandleIndirectImeOnOff(mozc::commands::Command *command);

0 comments on commit 7a129e6

Please sign in to comment.
You can’t perform that action at this time.