Skip to content

Commit

Permalink
Remove dead code from mozc_server.
Browse files Browse the repository at this point in the history
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 20, 2015
1 parent 5d423b0 commit 7a129e6
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 506 deletions.
2 changes: 1 addition & 1 deletion src/data/usage_stats/stats.def
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ SendCommand_SwitchInputFieldType
SendCommand_UsageStatsEvent
SendCommand_UndoOrRewind
SendCommand_ExpandSuggestion
SendCommand_SendCaretLocation
SendCommand_ObsoleteSendCaretLocation
SendCommand_ObsoleteSendLanguageBarCommand
SendCommand_ObsoleteGetAsyncResult
SendCommand_CommitRawText
Expand Down
2 changes: 1 addition & 1 deletion src/mozc_version_template.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
19 changes: 10 additions & 9 deletions src/protocol/candidates.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ];
Expand Down
12 changes: 4 additions & 8 deletions src/protocol/commands.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/session/internal/ime_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
19 changes: 0 additions & 19 deletions src/session/internal/ime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand Down Expand Up @@ -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_;
Expand Down
73 changes: 0 additions & 73 deletions src/session/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()) {
Expand Down
6 changes: 0 additions & 6 deletions src/session/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -60,7 +59,6 @@ class EngineInterface;

namespace session {
class ImeContext;
class SessionCursorManageTest;

class Session : public SessionInterface {
public:
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down
Loading

0 comments on commit 7a129e6

Please sign in to comment.