Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1422)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1635953002: Added replacement_range to ImeSetComposition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: erikchen's review Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 1315
1316 case IME_SETFOCUS: 1316 case IME_SETFOCUS:
1317 // Update the window focus. 1317 // Update the window focus.
1318 view()->OnSetFocus(ime_message->enable); 1318 view()->OnSetFocus(ime_message->enable);
1319 break; 1319 break;
1320 1320
1321 case IME_SETCOMPOSITION: 1321 case IME_SETCOMPOSITION:
1322 view()->OnImeSetComposition( 1322 view()->OnImeSetComposition(
1323 base::WideToUTF16(ime_message->ime_string), 1323 base::WideToUTF16(ime_message->ime_string),
1324 std::vector<blink::WebCompositionUnderline>(), 1324 std::vector<blink::WebCompositionUnderline>(),
1325 gfx::Range::InvalidRange(),
1325 ime_message->selection_start, 1326 ime_message->selection_start,
1326 ime_message->selection_end); 1327 ime_message->selection_end);
1327 break; 1328 break;
1328 1329
1329 case IME_CONFIRMCOMPOSITION: 1330 case IME_CONFIRMCOMPOSITION:
1330 view()->OnImeConfirmComposition( 1331 view()->OnImeConfirmComposition(
1331 base::WideToUTF16(ime_message->ime_string), 1332 base::WideToUTF16(ime_message->ime_string),
1332 gfx::Range::InvalidRange(), 1333 gfx::Range::InvalidRange(),
1333 false); 1334 false);
1334 break; 1335 break;
1335 1336
1336 case IME_CANCELCOMPOSITION: 1337 case IME_CANCELCOMPOSITION:
1337 view()->OnImeSetComposition( 1338 view()->OnImeSetComposition(
1338 base::string16(), 1339 base::string16(),
1339 std::vector<blink::WebCompositionUnderline>(), 1340 std::vector<blink::WebCompositionUnderline>(),
1341 gfx::Range::InvalidRange(),
1340 0, 0); 1342 0, 0);
1341 break; 1343 break;
1342 } 1344 }
1343 1345
1344 // Update the status of our IME back-end. 1346 // Update the status of our IME back-end.
1345 // TODO(hbono): we should verify messages to be sent from the back-end. 1347 // TODO(hbono): we should verify messages to be sent from the back-end.
1346 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 1348 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
1347 ProcessPendingMessages(); 1349 ProcessPendingMessages();
1348 render_thread_->sink().ClearMessages(); 1350 render_thread_->sink().ClearMessages();
1349 1351
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 LoadHTML("<textarea id=\"test\"></textarea>"); 1939 LoadHTML("<textarea id=\"test\"></textarea>");
1938 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); 1940 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1939 1941
1940 const base::string16 empty_string; 1942 const base::string16 empty_string;
1941 const std::vector<blink::WebCompositionUnderline> empty_underline; 1943 const std::vector<blink::WebCompositionUnderline> empty_underline;
1942 std::vector<gfx::Rect> bounds; 1944 std::vector<gfx::Rect> bounds;
1943 view()->OnSetFocus(true); 1945 view()->OnSetFocus(true);
1944 1946
1945 // ASCII composition 1947 // ASCII composition
1946 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); 1948 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo");
1947 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); 1949 view()->OnImeSetComposition(ascii_composition, empty_underline,
1950 gfx::Range::InvalidRange(), 0, 0);
1948 view()->GetCompositionCharacterBounds(&bounds); 1951 view()->GetCompositionCharacterBounds(&bounds);
1949 ASSERT_EQ(ascii_composition.size(), bounds.size()); 1952 ASSERT_EQ(ascii_composition.size(), bounds.size());
1950 1953
1951 for (size_t i = 0; i < bounds.size(); ++i) 1954 for (size_t i = 0; i < bounds.size(); ++i)
1952 EXPECT_LT(0, bounds[i].width()); 1955 EXPECT_LT(0, bounds[i].width());
1953 view()->OnImeConfirmComposition( 1956 view()->OnImeConfirmComposition(
1954 empty_string, gfx::Range::InvalidRange(), false); 1957 empty_string, gfx::Range::InvalidRange(), false);
1955 1958
1956 // Non surrogate pair unicode character. 1959 // Non surrogate pair unicode character.
1957 const base::string16 unicode_composition = base::UTF8ToUTF16( 1960 const base::string16 unicode_composition = base::UTF8ToUTF16(
1958 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); 1961 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A");
1959 view()->OnImeSetComposition(unicode_composition, empty_underline, 0, 0); 1962 view()->OnImeSetComposition(unicode_composition, empty_underline,
1963 gfx::Range::InvalidRange(), 0, 0);
1960 view()->GetCompositionCharacterBounds(&bounds); 1964 view()->GetCompositionCharacterBounds(&bounds);
1961 ASSERT_EQ(unicode_composition.size(), bounds.size()); 1965 ASSERT_EQ(unicode_composition.size(), bounds.size());
1962 for (size_t i = 0; i < bounds.size(); ++i) 1966 for (size_t i = 0; i < bounds.size(); ++i)
1963 EXPECT_LT(0, bounds[i].width()); 1967 EXPECT_LT(0, bounds[i].width());
1964 view()->OnImeConfirmComposition( 1968 view()->OnImeConfirmComposition(
1965 empty_string, gfx::Range::InvalidRange(), false); 1969 empty_string, gfx::Range::InvalidRange(), false);
1966 1970
1967 // Surrogate pair character. 1971 // Surrogate pair character.
1968 const base::string16 surrogate_pair_char = 1972 const base::string16 surrogate_pair_char =
1969 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); 1973 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F");
1970 view()->OnImeSetComposition(surrogate_pair_char, 1974 view()->OnImeSetComposition(surrogate_pair_char,
1971 empty_underline, 1975 empty_underline,
1976 gfx::Range::InvalidRange(),
1972 0, 1977 0,
1973 0); 1978 0);
1974 view()->GetCompositionCharacterBounds(&bounds); 1979 view()->GetCompositionCharacterBounds(&bounds);
1975 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); 1980 ASSERT_EQ(surrogate_pair_char.size(), bounds.size());
1976 EXPECT_LT(0, bounds[0].width()); 1981 EXPECT_LT(0, bounds[0].width());
1977 EXPECT_EQ(0, bounds[1].width()); 1982 EXPECT_EQ(0, bounds[1].width());
1978 view()->OnImeConfirmComposition( 1983 view()->OnImeConfirmComposition(
1979 empty_string, gfx::Range::InvalidRange(), false); 1984 empty_string, gfx::Range::InvalidRange(), false);
1980 1985
1981 // Mixed string. 1986 // Mixed string.
1982 const base::string16 surrogate_pair_mixed_composition = 1987 const base::string16 surrogate_pair_mixed_composition =
1983 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + 1988 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") +
1984 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; 1989 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char;
1985 const size_t utf16_length = 8UL; 1990 const size_t utf16_length = 8UL;
1986 const bool is_surrogate_pair_empty_rect[8] = { 1991 const bool is_surrogate_pair_empty_rect[8] = {
1987 false, true, false, false, true, false, false, true }; 1992 false, true, false, false, true, false, false, true };
1988 view()->OnImeSetComposition(surrogate_pair_mixed_composition, 1993 view()->OnImeSetComposition(surrogate_pair_mixed_composition,
1989 empty_underline, 1994 empty_underline,
1995 gfx::Range::InvalidRange(),
1990 0, 1996 0,
1991 0); 1997 0);
1992 view()->GetCompositionCharacterBounds(&bounds); 1998 view()->GetCompositionCharacterBounds(&bounds);
1993 ASSERT_EQ(utf16_length, bounds.size()); 1999 ASSERT_EQ(utf16_length, bounds.size());
1994 for (size_t i = 0; i < utf16_length; ++i) { 2000 for (size_t i = 0; i < utf16_length; ++i) {
1995 if (is_surrogate_pair_empty_rect[i]) { 2001 if (is_surrogate_pair_empty_rect[i]) {
1996 EXPECT_EQ(0, bounds[i].width()); 2002 EXPECT_EQ(0, bounds[i].width());
1997 } else { 2003 } else {
1998 EXPECT_LT(0, bounds[i].width()); 2004 EXPECT_LT(0, bounds[i].width());
1999 } 2005 }
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 LoadHTML("<textarea id=\"test\"></textarea>"); 2666 LoadHTML("<textarea id=\"test\"></textarea>");
2661 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); 2667 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
2662 2668
2663 const base::string16 empty_string; 2669 const base::string16 empty_string;
2664 const std::vector<blink::WebCompositionUnderline> empty_underline; 2670 const std::vector<blink::WebCompositionUnderline> empty_underline;
2665 std::vector<gfx::Rect> bounds_at_1x; 2671 std::vector<gfx::Rect> bounds_at_1x;
2666 view()->OnSetFocus(true); 2672 view()->OnSetFocus(true);
2667 2673
2668 // ASCII composition 2674 // ASCII composition
2669 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); 2675 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo");
2670 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); 2676 view()->OnImeSetComposition(ascii_composition, empty_underline,
2677 gfx::Range::InvalidRange(), 0, 0);
2671 view()->GetCompositionCharacterBounds(&bounds_at_1x); 2678 view()->GetCompositionCharacterBounds(&bounds_at_1x);
2672 ASSERT_EQ(ascii_composition.size(), bounds_at_1x.size()); 2679 ASSERT_EQ(ascii_composition.size(), bounds_at_1x.size());
2673 2680
2674 SetDeviceScaleFactor(2.f); 2681 SetDeviceScaleFactor(2.f);
2675 std::vector<gfx::Rect> bounds_at_2x; 2682 std::vector<gfx::Rect> bounds_at_2x;
2676 view()->GetCompositionCharacterBounds(&bounds_at_2x); 2683 view()->GetCompositionCharacterBounds(&bounds_at_2x);
2677 ASSERT_EQ(bounds_at_1x.size(), bounds_at_2x.size()); 2684 ASSERT_EQ(bounds_at_1x.size(), bounds_at_2x.size());
2678 for (size_t i = 0; i < bounds_at_1x.size(); i++) { 2685 for (size_t i = 0; i < bounds_at_1x.size(); i++) {
2679 const gfx::Rect& b1 = bounds_at_1x[i]; 2686 const gfx::Rect& b1 = bounds_at_1x[i];
2680 const gfx::Rect& b2 = bounds_at_2x[i]; 2687 const gfx::Rect& b2 = bounds_at_2x[i];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 FROM_HERE, 2749 FROM_HERE,
2743 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2750 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2744 ExecuteJavaScriptForTests("debugger;"); 2751 ExecuteJavaScriptForTests("debugger;");
2745 2752
2746 // CloseWhilePaused should resume execution and continue here. 2753 // CloseWhilePaused should resume execution and continue here.
2747 EXPECT_FALSE(IsPaused()); 2754 EXPECT_FALSE(IsPaused());
2748 Detach(); 2755 Detach();
2749 } 2756 }
2750 2757
2751 } // namespace content 2758 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698