Codebase list mozc / 8db8182
Remove an obsolete migration logic This CL deprecates an obsolete migration logic when Mozc renderer needs to talk to Mozc IMM32 clients version 0.13.521.0 or prior. REF_BUG=20474448,3200425 REF_CL=107569253 Yohei Yukawa 8 years ago
4 changed file(s) with 138 addition(s) and 183 deletion(s). Raw diff Collapse all Expand all
00 MAJOR=2
11 MINOR=17
2 BUILD=2379
2 BUILD=2380
33 REVISION=102
44 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
55 # downloaded by NaCl Mozc.
8989 // An equivalent to COMPOSITIONFORM in IMM32. (For Windows only)
9090 // TODO(yukawa): make a common composition form format for all platforms.
9191 message CompositionForm {
92 reserved 1; // Deprecated style
93 optional Point current_position = 2;
94 optional Rectangle area = 3;
95 // Used as bit flags in |style_bits|.
9296 // These constants correspond to CFS_* in Imm.h
9397 enum Style {
9498 DEFAULT = 0; // CFS_DEFAULT
96100 POINT = 2; // CFS_POINT
97101 FORCE_POSITION = 32; // CFS_FORCE_POSITION
98102 };
99 // Use |style_bits| instead because there are some applications which
100 // specify a combination of style bits like CFS_RECT + CFS_POINT.
101 optional Style DEPRECATED_style = 1;
102 optional Point current_position = 2;
103 optional Rectangle area = 3;
104103 optional uint32 style_bits = 4 [ default = 0 ]; // 0 means Style::DEFAULT
105104 };
106105
107106 // An equivalent to CANDIDATEFORM in IMM32. (For Windows only)
108107 // TODO(yukawa): make a common candidate form format for all platforms.
109108 message CandidateForm {
109 reserved 1; // Deprecated style
110 optional Point current_position = 2;
111 optional Rectangle area = 3;
112 // Used as bit flags in |style_bits|.
110113 // These constants correspond to CFS_* in Imm.h
111114 enum Style {
112115 DEFAULT = 0; // CFS_DEFAULT
113116 CANDIDATEPOS = 64; // CFS_CANDIDATEPOS
114117 EXCLUDE = 128; // CFS_EXCLUDE
115118 };
116 // Use |style_bits| instead in case there is an applications which
117 // specifies a combination of style bits.
118 optional Style DEPRECATED_style = 1;
119 optional Point current_position = 2;
120 optional Rectangle area = 3;
121119 optional uint32 style_bits = 4 [ default = 0 ]; // 0 means Style::DEFAULT
122120 };
123121
190190 return true;
191191 }
192192
193 // TODO(yukawa): Stop supporting |deprecated_style()|.
194 const uint32 style_bits =
195 (form.has_deprecated_style() ? form.deprecated_style()
196 : form.style_bits());
197
198193 // Note that CompositionForm::DEFAULT is defined as 0.
199 if (style_bits != CompositionForm::DEFAULT) {
194 if (form.style_bits() != CompositionForm::DEFAULT) {
200195 return true;
201196 }
202197
286281 const commands::RendererCommand::CandidateForm &form =
287282 app_info.candidate_form();
288283
289 // TODO(yukawa): Stop supporting |deprecated_style()|.
290 const uint32 candidate_style_bits =
291 (form.has_deprecated_style() ? form.deprecated_style()
292 : form.style_bits());
284 const uint32 candidate_style_bits = form.style_bits();
293285
294286 const bool has_candidate_pos_style_bit =
295287 ((candidate_style_bits & CandidateForm::CANDIDATEPOS) ==
18351827 }
18361828 }
18371829
1838 // TODO(yukawa): Stop supporting |deprecated_style()|.
1839 const uint32 style_bits =
1840 (composition_form.has_deprecated_style()
1841 ? composition_form.deprecated_style()
1842 : composition_form.style_bits());
1830 const uint32 style_bits = composition_form.style_bits();
18431831
18441832 // Check the availability of optional fields.
18451833 // Note that currently we always use |current_position| field even when
822822 use_proportional_font, is_vertical, cursor_offset, hwnd, command);
823823 }
824824
825 // Verification of changes for b/3200425.
826 static void VerifyCompositionStyleBitsCompatibilityForIssue3200425(
827 bool use_deprecated_style, CompositionForm::Style style,
828 bool use_new_style, uint32 style_bits) {
829 const int kCursorOffsetX = 0;
830
831 RendererCommand command;
832
833 HWND hwnd = nullptr;
834 LayoutManager layout_mgr(CreateDefaultGUIFontEmulator(),
835 CreateWindowEmulatorWithDPIScaling(1.0, &hwnd));
836 vector<CompositionWindowLayout> layouts;
837 CandidateWindowLayout candidate_layout;
838
839 CLogFont logfont;
840
841 bool result = false;
842
843 // w/ candidates, monospaced, horizontal
844 SetRenderereCommandForTest(
845 false, true, false, kCursorOffsetX, hwnd, &command);
846
847 if (use_deprecated_style) {
848 command.mutable_application_info()->mutable_composition_form()
849 ->set_deprecated_style(style);
850 } else {
851 command.mutable_application_info()->mutable_composition_form()
852 ->clear_deprecated_style();
853 }
854 if (use_new_style) {
855 command.mutable_application_info()->mutable_composition_form()
856 ->set_style_bits(style_bits);
857 } else {
858 command.mutable_application_info()->mutable_composition_form()
859 ->clear_style_bits();
860 }
861
862 EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
863 command.application_info().composition_font(), &logfont));
864 layouts.clear();
865 candidate_layout.Clear();
866 result = layout_mgr.LayoutCompositionWindow(
867 command, &layouts, &candidate_layout);
868 EXPECT_TRUE(result);
869
870 ASSERT_EQ(2, layouts.size());
871
872 // The first line
873 {
874 const CompositionWindowLayout &layout = layouts.at(0);
875 EXPECT_COMPOSITION_WINDOW_LAYOUT(1868, 599, 2003, 648, 0, 0, 135, 49,
876 0, 0, 0, 0, 0, 0, logfont, layout);
877 {
878 // "これは"
879 const char kMsg[] = "\343\201\223\343\202\214\343\201\257";
880 wstring msg;
881 mozc::Util::UTF8ToWide(kMsg, &msg);
882 EXPECT_EQ(msg, layout.text);
883 }
884 ASSERT_EQ(1, layout.marker_layouts.size());
885
886 EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
887 EXPECT_EQ(CPoint(126, 48), layout.marker_layouts[0].to);
888 EXPECT_FALSE(layout.marker_layouts[0].highlighted);
889 }
890
891 // The second line
892 {
893 const CompositionWindowLayout &layout = layouts.at(1);
894 EXPECT_COMPOSITION_WINDOW_LAYOUT(1193, 648, 1840, 697, 0, 0, 646, 49,
895 0, 0, 646, 0, 647, 49, logfont, layout);
896 {
897 // "、Google日本語入力のTestです"
898 const char kMsg[] =
899 "\343\200\201Google\346\227\245\346\234\254\350\252\236\345\205\245"
900 "\345\212\233\343\201\256Test\343\201\247\343\201\231";
901 wstring msg;
902 mozc::Util::UTF8ToWide(kMsg, &msg);
903 EXPECT_EQ(msg, layout.text);
904 }
905 ASSERT_EQ(4, layout.marker_layouts.size());
906
907 EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
908 EXPECT_EQ(CPoint(36, 48), layout.marker_layouts[0].to);
909 EXPECT_FALSE(layout.marker_layouts[0].highlighted);
910 EXPECT_EQ(CPoint(45, 48), layout.marker_layouts[1].from);
911 EXPECT_EQ(CPoint(190, 48), layout.marker_layouts[1].to);
912 EXPECT_TRUE(layout.marker_layouts[1].highlighted);
913 EXPECT_EQ(CPoint(196, 48), layout.marker_layouts[2].from);
914 EXPECT_EQ(CPoint(457, 48), layout.marker_layouts[2].to);
915 EXPECT_FALSE(layout.marker_layouts[2].highlighted);
916 EXPECT_EQ(CPoint(466, 48), layout.marker_layouts[3].from);
917 EXPECT_EQ(CPoint(646, 48), layout.marker_layouts[3].to);
918 EXPECT_FALSE(layout.marker_layouts[3].highlighted);
919 }
920 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
921 1238, 697, 1238, 648, 1839, 697, candidate_layout);
922
923 // Check other candidate positions.
924 command.mutable_output()->mutable_candidates()->set_position(0);
925 layouts.clear();
926 candidate_layout.Clear();
927 result = layout_mgr.LayoutCompositionWindow(
928 command, &layouts, &candidate_layout);
929 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
930 1868, 648, 1868, 599, 2003, 648, candidate_layout);
931
932 command.mutable_output()->mutable_candidates()->set_position(3);
933 layouts.clear();
934 candidate_layout.Clear();
935 result = layout_mgr.LayoutCompositionWindow(
936 command, &layouts, &candidate_layout);
937 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
938 1193, 697, 1193, 648, 1839, 697, candidate_layout);
939
940 command.mutable_output()->mutable_candidates()->set_position(10);
941 layouts.clear();
942 candidate_layout.Clear();
943 result = layout_mgr.LayoutCompositionWindow(
944 command, &layouts, &candidate_layout);
945 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
946 1389, 697, 1389, 648, 1839, 697, candidate_layout);
947
948 command.mutable_output()->mutable_candidates()->set_position(16);
949 layouts.clear();
950 candidate_layout.Clear();
951 result = layout_mgr.LayoutCompositionWindow(
952 command, &layouts, &candidate_layout);
953 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
954 1659, 697, 1659, 648, 1839, 697, candidate_layout);
955
956 // w/o candidates, monospaced, horizontal
957 SetRenderereCommandForTest(false, false, false, 0, hwnd, &command);
958 EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
959 command.application_info().composition_font(), &logfont));
960 layouts.clear();
961 candidate_layout.Clear();
962 result = layout_mgr.LayoutCompositionWindow(
963 command, &layouts, &candidate_layout);
964 EXPECT_TRUE(result);
965 EXPECT_FALSE(candidate_layout.initialized());
966 }
967
968825 protected:
969826 static void SetUpTestCase() {
970827 // On Windows XP, the availability of typical Japanese fonts such are as
34863343 // We should consider the case where two or more style bits are specified
34873344 // at the same time.
34883345 TEST_F(Win32RendererUtilTest, CompositionFormRECTAsBitFlag_Issue3200425) {
3489 // Check the backward compatibility.
3490 VerifyCompositionStyleBitsCompatibilityForIssue3200425(
3491 true, CompositionForm::RECT,
3492 false, CompositionForm::DEFAULT);
3493
3494 // Set CompositionForm::RECT and CompositionForm::POINT at the same time.
3495 VerifyCompositionStyleBitsCompatibilityForIssue3200425(
3496 false, CompositionForm::DEFAULT,
3497 true, CompositionForm::RECT | CompositionForm::POINT);
3498
3499 // If both of them are specified, the legacy one is used.
3500 VerifyCompositionStyleBitsCompatibilityForIssue3200425(
3501 true, CompositionForm::RECT,
3502 true, CompositionForm::POINT);
3346 const uint32 kStyleBit = CompositionForm::RECT | CompositionForm::POINT;
3347
3348 const int kCursorOffsetX = 0;
3349
3350 RendererCommand command;
3351
3352 HWND hwnd = nullptr;
3353 LayoutManager layout_mgr(CreateDefaultGUIFontEmulator(),
3354 CreateWindowEmulatorWithDPIScaling(1.0, &hwnd));
3355 vector<CompositionWindowLayout> layouts;
3356 CandidateWindowLayout candidate_layout;
3357
3358 CLogFont logfont;
3359
3360 bool result = false;
3361
3362 // w/ candidates, monospaced, horizontal
3363 SetRenderereCommandForTest(
3364 false, true, false, kCursorOffsetX, hwnd, &command);
3365 command.mutable_application_info()->mutable_composition_form()
3366 ->set_style_bits(kStyleBit);
3367
3368 EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
3369 command.application_info().composition_font(), &logfont));
3370 layouts.clear();
3371 candidate_layout.Clear();
3372 result = layout_mgr.LayoutCompositionWindow(
3373 command, &layouts, &candidate_layout);
3374 EXPECT_TRUE(result);
3375
3376 ASSERT_EQ(2, layouts.size());
3377
3378 // The first line
3379 {
3380 const CompositionWindowLayout &layout = layouts.at(0);
3381 EXPECT_COMPOSITION_WINDOW_LAYOUT(1868, 599, 2003, 648, 0, 0, 135, 49,
3382 0, 0, 0, 0, 0, 0, logfont, layout);
3383 {
3384 // "これは"
3385 const char kMsg[] = "\343\201\223\343\202\214\343\201\257";
3386 wstring msg;
3387 mozc::Util::UTF8ToWide(kMsg, &msg);
3388 EXPECT_EQ(msg, layout.text);
3389 }
3390 ASSERT_EQ(1, layout.marker_layouts.size());
3391
3392 EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
3393 EXPECT_EQ(CPoint(126, 48), layout.marker_layouts[0].to);
3394 EXPECT_FALSE(layout.marker_layouts[0].highlighted);
3395 }
3396
3397 // The second line
3398 {
3399 const CompositionWindowLayout &layout = layouts.at(1);
3400 EXPECT_COMPOSITION_WINDOW_LAYOUT(1193, 648, 1840, 697, 0, 0, 646, 49,
3401 0, 0, 646, 0, 647, 49, logfont, layout);
3402 {
3403 // "、Google日本語入力のTestです"
3404 const char kMsg[] =
3405 "\343\200\201Google\346\227\245\346\234\254\350\252\236\345\205\245"
3406 "\345\212\233\343\201\256Test\343\201\247\343\201\231";
3407 wstring msg;
3408 mozc::Util::UTF8ToWide(kMsg, &msg);
3409 EXPECT_EQ(msg, layout.text);
3410 }
3411 ASSERT_EQ(4, layout.marker_layouts.size());
3412
3413 EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
3414 EXPECT_EQ(CPoint(36, 48), layout.marker_layouts[0].to);
3415 EXPECT_FALSE(layout.marker_layouts[0].highlighted);
3416 EXPECT_EQ(CPoint(45, 48), layout.marker_layouts[1].from);
3417 EXPECT_EQ(CPoint(190, 48), layout.marker_layouts[1].to);
3418 EXPECT_TRUE(layout.marker_layouts[1].highlighted);
3419 EXPECT_EQ(CPoint(196, 48), layout.marker_layouts[2].from);
3420 EXPECT_EQ(CPoint(457, 48), layout.marker_layouts[2].to);
3421 EXPECT_FALSE(layout.marker_layouts[2].highlighted);
3422 EXPECT_EQ(CPoint(466, 48), layout.marker_layouts[3].from);
3423 EXPECT_EQ(CPoint(646, 48), layout.marker_layouts[3].to);
3424 EXPECT_FALSE(layout.marker_layouts[3].highlighted);
3425 }
3426 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
3427 1238, 697, 1238, 648, 1839, 697, candidate_layout);
3428
3429 // Check other candidate positions.
3430 command.mutable_output()->mutable_candidates()->set_position(0);
3431 layouts.clear();
3432 candidate_layout.Clear();
3433 result = layout_mgr.LayoutCompositionWindow(
3434 command, &layouts, &candidate_layout);
3435 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
3436 1868, 648, 1868, 599, 2003, 648, candidate_layout);
3437
3438 command.mutable_output()->mutable_candidates()->set_position(3);
3439 layouts.clear();
3440 candidate_layout.Clear();
3441 result = layout_mgr.LayoutCompositionWindow(
3442 command, &layouts, &candidate_layout);
3443 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
3444 1193, 697, 1193, 648, 1839, 697, candidate_layout);
3445
3446 command.mutable_output()->mutable_candidates()->set_position(10);
3447 layouts.clear();
3448 candidate_layout.Clear();
3449 result = layout_mgr.LayoutCompositionWindow(
3450 command, &layouts, &candidate_layout);
3451 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
3452 1389, 697, 1389, 648, 1839, 697, candidate_layout);
3453
3454 command.mutable_output()->mutable_candidates()->set_position(16);
3455 layouts.clear();
3456 candidate_layout.Clear();
3457 result = layout_mgr.LayoutCompositionWindow(
3458 command, &layouts, &candidate_layout);
3459 EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
3460 1659, 697, 1659, 648, 1839, 697, candidate_layout);
3461
3462 // w/o candidates, monospaced, horizontal
3463 SetRenderereCommandForTest(false, false, false, 0, hwnd, &command);
3464 EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
3465 command.application_info().composition_font(), &logfont));
3466 layouts.clear();
3467 candidate_layout.Clear();
3468 result = layout_mgr.LayoutCompositionWindow(
3469 command, &layouts, &candidate_layout);
3470 EXPECT_TRUE(result);
3471 EXPECT_FALSE(candidate_layout.initialized());
35033472 }
35043473
35053474 // Evernote Windows Client 4.0.0.2880 (107102) / Editor component