Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fcitx
Browse files Browse the repository at this point in the history
  • Loading branch information
Fcitx Bot committed Aug 28, 2024
2 parents 99ff944 + 78c45a7 commit f8cf9ea
Show file tree
Hide file tree
Showing 33 changed files with 225 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: build
working-directory: ./src
run: |
bazel build --config oss_android package -c opt
bazel build --config oss_android package --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: bazel build
working-directory: ./src
run: |
bazel build --config oss_linux package -c opt
bazel build --config oss_linux package --config release_build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: bazel build
working-directory: ./src
run: |
bazel build --config oss_macos package --macos_cpus=arm64 -c opt
bazel build --config oss_macos package --macos_cpus=arm64 --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
- name: bazel build
working-directory: ./src
run: |
bazel build --config oss_macos package --macos_cpus=x86_64 -c opt
bazel build --config oss_macos package --macos_cpus=x86_64 --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
- name: bazel build
working-directory: ./src
run: |
bazel build --config oss_macos package --macos_cpus=x86_64,arm64 -c opt
bazel build --config oss_macos package --macos_cpus=x86_64,arm64 --config release_build
- name: upload artifacts
uses: actions/upload-artifact@v4
Expand Down
6 changes: 3 additions & 3 deletions docs/build_mozc_in_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docker build --rm --tag mozc_ubuntu22.04 .
docker create --interactive --tty --name mozc_build mozc_ubuntu22.04
docker start mozc_build
docker exec mozc_build bazel build package --config oss_linux -c opt
docker exec mozc_build bazel build package --config oss_linux --config release_build
docker cp mozc_build:/home/mozc_builder/work/mozc/src/bazel-bin/unix/mozc.zip .
```

Expand Down Expand Up @@ -48,7 +48,7 @@ Notes

```
docker start mozc_build
docker exec mozc_build bazel build package --config oss_linux -c opt
docker exec mozc_build bazel build package --config oss_linux --config release_build
docker cp mozc_build:/home/mozc_builder/work/mozc/src/bazel-bin/unix/mozc.zip .
```

Expand All @@ -63,7 +63,7 @@ Notes
## Build Mozc for Linux Desktop

```
bazel build package --config oss_linux -c opt
bazel build package --config oss_linux --config release_build
```

Note: You might want to execute `docker start --interactive mozc_build`
Expand Down
8 changes: 4 additions & 4 deletions docs/build_mozc_in_osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python3 build_tools/update_deps.py
# CMake is also required to build Qt.
python3 build_tools/build_qt.py --release --confirm_license
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build
open bazel-bin/mac/Mozc.pkg
```

Expand Down Expand Up @@ -133,7 +133,7 @@ brew install cmake
### Build installer

```
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build
open bazel-bin/mac/Mozc.pkg
```

Expand All @@ -142,14 +142,14 @@ open bazel-bin/mac/Mozc.pkg
To build an Intel64 macOS binary regardless of the host CPU architecture.
```
python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x64_64
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt --macos_cpus=x64_64
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build --macos_cpus=x64_64
open bazel-bin/mac/Mozc.pkg
```

To build a Universal macOS Binary both x86_64 and arm64.
```
python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x86_64,arm64
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt --macos_cpus=x86_64,arm64
MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos --config release_build --macos_cpus=x86_64,arm64
open bazel-bin/mac/Mozc.pkg
```

Expand Down
4 changes: 4 additions & 0 deletions src/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ common:workspace --noenable_bzlmod
## Dev channel
build:dev_channel --define CHANNEL=dev

## Release build
build:release_build --compilation_mode=opt
build:release_build --copt=-DABSL_MIN_LOG_LEVEL=100

## Compiler options
common:linux_env --config=compiler_gcc_like
common:android_env --config=compiler_gcc_like
Expand Down
7 changes: 3 additions & 4 deletions src/base/mmap_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@

namespace mozc {
namespace {
using SharedBitGen = absl::random_internal::PoolURBG<uint32_t, 8>;

std::vector<char> GetRandomContents(size_t size) {
std::vector<char> data(size);
absl::c_generate(data, []() -> char {
return absl::Uniform<unsigned char>(SharedBitGen());
});
absl::BitGen gen;
absl::c_generate(
data, [&gen]() -> char { return absl::Uniform<unsigned char>(gen); });
return data;
}

Expand Down
15 changes: 15 additions & 0 deletions src/converter/converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,21 @@ void Converter::RevertConversion(Segments *segments) const {
segments->clear_revert_entries();
}

bool Converter::DeleteCandidateFromHistory(const Segments &segments,
size_t segment_index,
int candidate_index) const {
DCHECK_LT(segment_index, segments.segments_size());
const Segment &segment = segments.segment(segment_index);
DCHECK(segment.is_valid_index(candidate_index));
const Segment::Candidate &candidate = segment.candidate(candidate_index);
bool result = false;
result |=
rewriter_->ClearHistoryEntry(segments, segment_index, candidate_index);
result |= predictor_->ClearHistoryEntry(candidate.key, candidate.value);

return result;
}

bool Converter::ReconstructHistory(
Segments *segments, const absl::string_view preceding_text) const {
segments->Clear();
Expand Down
5 changes: 5 additions & 0 deletions src/converter/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ class Converter final : public ConverterInterface {
void ResetConversion(Segments *segments) const override;
void RevertConversion(Segments *segments) const override;

ABSL_MUST_USE_RESULT
bool DeleteCandidateFromHistory(const Segments &segments,
size_t segment_index,
int candidate_index) const override;

ABSL_MUST_USE_RESULT
bool ReconstructHistory(Segments *segments,
absl::string_view preceding_text) const override;
Expand Down
9 changes: 9 additions & 0 deletions src/converter/converter_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ class ConverterInterface {
// Revert last Finish operation
virtual void RevertConversion(Segments *segments) const = 0;

// Delete candidate from user input history.
// Returns false if the candidate was not found or deletion failed.
// Note: |segment_index| is the index for all segments, not the index of
// conversion_segments.
ABSL_MUST_USE_RESULT
virtual bool DeleteCandidateFromHistory(const Segments &segments,
size_t segment_index,
int candidate_index) const = 0;

// Reconstruct history segments from given preceding text.
ABSL_MUST_USE_RESULT
virtual bool ReconstructHistory(Segments *segments,
Expand Down
2 changes: 2 additions & 0 deletions src/converter/converter_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class StrictMockConverter : public ConverterInterface {
MOCK_METHOD(void, CancelConversion, (Segments * segments), (const, override));
MOCK_METHOD(void, ResetConversion, (Segments * segments), (const, override));
MOCK_METHOD(void, RevertConversion, (Segments * segments), (const, override));
MOCK_METHOD(bool, DeleteCandidateFromHistory, (const Segments &, size_t, int),
(const));
MOCK_METHOD(bool, ReconstructHistory,
(Segments * segments, absl::string_view preceding_text),
(const, override));
Expand Down
31 changes: 31 additions & 0 deletions src/data/test/session/scenario/mobile_delete_history.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# History should be removed
# 1. A user inputs 京 for きょう
# 2. 京 appears in candidates list
# 3. 京 is deleted from the history.
# 4. After deletion, 京 shouldn't be the top candidate

SEND_KEY ON
UPDATE_MOBILE_KEYBOARD FLICK_TO_HIRAGANA SPACE_OR_CONVERT_KEEPING_COMPOSITION
SWITCH_INPUT_MODE HIRAGANA

SEND_KEYS a^*;
EXPECT_PREEDIT きょう

EXPECT_CANDIDATE 0 今日
EXPECT_IN_ALL_CANDIDATE_WORDS 京

SUBMIT_CANDIDATE_BY_VALUE 京
EXPECT_RESULT 京

SEND_KEYS a^*;
EXPECT_PREEDIT きょう
EXPECT_CANDIDATE 0 京

# Emulate DELETE_SELECTED_CANDIDATE command
# Delete 京 from the input history.
DELETE_CANDIDATE_FROM_HISTORY 0
EXPECT_CANDIDATE 0 今日

# Make sure that 京 is not the top for CONVERSION
SEND_KEY SPACE
EXPECT_CANDIDATE 0 今日
1 change: 0 additions & 1 deletion src/engine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ mozc_cc_library(
deps = [
":user_data_manager_interface",
"//testing:gunit",
"@com_google_absl//absl/strings",
],
)

Expand Down
7 changes: 0 additions & 7 deletions src/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class UserDataManager final : public UserDataManagerInterface {
bool ClearUserHistory() override;
bool ClearUserPrediction() override;
bool ClearUnusedUserPrediction() override;
bool ClearUserPredictionEntry(absl::string_view key,
absl::string_view value) override;
bool Wait() override;

private:
Expand Down Expand Up @@ -109,11 +107,6 @@ bool UserDataManager::ClearUnusedUserPrediction() {
return true;
}

bool UserDataManager::ClearUserPredictionEntry(const absl::string_view key,
const absl::string_view value) {
return predictor_->ClearHistoryEntry(key, value);
}

bool UserDataManager::Wait() { return predictor_->Wait(); }

} // namespace
Expand Down
10 changes: 6 additions & 4 deletions src/engine/minimal_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ class UserDataManagerStub : public UserDataManagerInterface {
bool ClearUserHistory() override { return true; }
bool ClearUserPrediction() override { return true; }
bool ClearUnusedUserPrediction() override { return true; }
bool ClearUserPredictionEntry(const absl::string_view key,
const absl::string_view value) override {
return true;
}
bool Wait() override { return true; }
};

Expand Down Expand Up @@ -169,6 +165,12 @@ class MinimalConverter : public ConverterInterface {

void RevertConversion(Segments *segments) const override {}

bool DeleteCandidateFromHistory(const Segments &segments,
size_t segment_index,
int candidate_index) const {
return true;
}

bool ReconstructHistory(
Segments *segments,
const absl::string_view preceding_text) const override {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/supplemental_model_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SupplementalModelInterface {

// Returns true if the final typing correct result is not confident.
virtual bool ShouldRevertTypingCorrection(
const commands::Request &request, const Segments &segments,
const ConversionRequest &request, const Segments &segments,
absl::Span<const prediction::Result> literal_results,
absl::Span<const prediction::Result> typing_corrected_results) const {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/supplemental_model_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MockSupplementalModel : public SupplementalModelInterface {
(const ConversionRequest &request, absl::string_view context),
(const, override));
MOCK_METHOD(bool, ShouldRevertTypingCorrection,
(const commands::Request &request, const Segments &segments,
(const ConversionRequest &request, const Segments &segments,
absl::Span<const prediction::Result> literal_results,
absl::Span<const prediction::Result> typing_corrected_results),
(const, override));
Expand Down
4 changes: 0 additions & 4 deletions src/engine/user_data_manager_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ class UserDataManagerInterface {
// Clears unused user prediction data.
virtual bool ClearUnusedUserPrediction() = 0;

// Clears a specific user prediction history.
virtual bool ClearUserPredictionEntry(absl::string_view key,
absl::string_view value) = 0;

// Waits for syncer thread to complete.
virtual bool Wait() = 0;
};
Expand Down
3 changes: 0 additions & 3 deletions src/engine/user_data_manager_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#ifndef MOZC_ENGINE_USER_DATA_MANAGER_MOCK_H_
#define MOZC_ENGINE_USER_DATA_MANAGER_MOCK_H_

#include "absl/strings/string_view.h"
#include "engine/user_data_manager_interface.h"
#include "testing/gmock.h"

Expand All @@ -46,8 +45,6 @@ class MockUserDataManager : public UserDataManagerInterface {
MOCK_METHOD(bool, ClearUserHistory, (), (override));
MOCK_METHOD(bool, ClearUserPrediction, (), (override));
MOCK_METHOD(bool, ClearUnusedUserPrediction, (), (override));
MOCK_METHOD(bool, ClearUserPredictionEntry,
(absl::string_view key, absl::string_view value), (override));
MOCK_METHOD(bool, Wait, (), (override));
};

Expand Down
3 changes: 1 addition & 2 deletions src/prediction/dictionary_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,7 @@ DictionaryPredictor::GetTypingCorrectionMixingParams(
if (supplemental_model) {
typing_correction_mixing_params.literal_on_top =
supplemental_model->ShouldRevertTypingCorrection(
request.request(), segments, literal_results,
typing_corrected_results);
request, segments, literal_results, typing_corrected_results);
}

return typing_correction_mixing_params;
Expand Down
2 changes: 2 additions & 0 deletions src/protocol/commands.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ message KeyEvent {
HENKAN = 13;
MUHENKAN = 14;
// VK_DBE_HIRAGANA(Win), kVK_JIS_Kana(Mac)
// The "Katakana Hiragana Romaji" key (w/o modifiers) returns this key code.
KANA = 15; // GUI label is "Hiragana".
HOME = 16;
END = 17;
Expand Down Expand Up @@ -135,6 +136,7 @@ message KeyEvent {
TEXT_INPUT = 64; // Meta key event representing any text input.
HANKAKU = 65; // GUI label is "Hankaku/Zenkaku".
KANJI = 66;
// The "Katakana Hiragana Romaji" key with Shift returns this key code.
KATAKANA = 67; // VK_DBE_KATAKANA(Win)
CAPS_LOCK = 68;
// Unsupported keys (e.g. PrtSc, Pause) fall back to UNDEFINED_KEY.
Expand Down
10 changes: 10 additions & 0 deletions src/rewriter/merger_rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ class MergerRewriter : public RewriterInterface {
}
}

bool ClearHistoryEntry(const Segments &segments, size_t segment_index,
int candidate_index) override {
bool result = false;
for (const std::unique_ptr<RewriterInterface> &rewriter : rewriters_) {
result |=
rewriter->ClearHistoryEntry(segments, segment_index, candidate_index);
}
return result;
}

// Syncs internal data to local file system.
bool Sync() override {
bool result = false;
Expand Down
10 changes: 10 additions & 0 deletions src/rewriter/rewriter_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ class RewriterInterface {
// Reverts the last Finish operation.
virtual void Revert(Segments *segments) {}

// Delete the user history based entry corresponding to the specified
// candidate.
// Returns true when at least one deletion operation succeeded
// |segment_index| is the index for all segments, not the index of
// conversion_segments.
virtual bool ClearHistoryEntry(const Segments &segments, size_t segment_index,
int candidate_index) {
return false;
}

// Synchronizes internal data to local file system. This method is called
// when the server received SYNC_DATA command from the client. Currently,
// this event happens, e.g., when user moves to another text area.
Expand Down
Loading

0 comments on commit f8cf9ea

Please sign in to comment.