| OLD | NEW |
| 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 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 view()->OnImeSetComposition( | 1249 view()->OnImeSetComposition( |
| 1250 base::WideToUTF16(ime_message->ime_string), | 1250 base::WideToUTF16(ime_message->ime_string), |
| 1251 std::vector<blink::WebCompositionUnderline>(), | 1251 std::vector<blink::WebCompositionUnderline>(), |
| 1252 gfx::Range::InvalidRange(), | 1252 gfx::Range::InvalidRange(), |
| 1253 ime_message->selection_start, | 1253 ime_message->selection_start, |
| 1254 ime_message->selection_end); | 1254 ime_message->selection_end); |
| 1255 break; | 1255 break; |
| 1256 | 1256 |
| 1257 case IME_COMMITTEXT: | 1257 case IME_COMMITTEXT: |
| 1258 view()->OnImeCommitText(base::WideToUTF16(ime_message->ime_string), | 1258 view()->OnImeCommitText(base::WideToUTF16(ime_message->ime_string), |
| 1259 std::vector<blink::WebCompositionUnderline>(), |
| 1259 gfx::Range::InvalidRange(), 0); | 1260 gfx::Range::InvalidRange(), 0); |
| 1260 break; | 1261 break; |
| 1261 | 1262 |
| 1262 case IME_FINISHCOMPOSINGTEXT: | 1263 case IME_FINISHCOMPOSINGTEXT: |
| 1263 view()->OnImeFinishComposingText(false); | 1264 view()->OnImeFinishComposingText(false); |
| 1264 break; | 1265 break; |
| 1265 | 1266 |
| 1266 case IME_CANCELCOMPOSITION: | 1267 case IME_CANCELCOMPOSITION: |
| 1267 view()->OnImeSetComposition( | 1268 view()->OnImeSetComposition( |
| 1268 base::string16(), | 1269 base::string16(), |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 | 1510 |
| 1510 // ASCII composition | 1511 // ASCII composition |
| 1511 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); | 1512 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); |
| 1512 view()->OnImeSetComposition(ascii_composition, empty_underline, | 1513 view()->OnImeSetComposition(ascii_composition, empty_underline, |
| 1513 gfx::Range::InvalidRange(), 0, 0); | 1514 gfx::Range::InvalidRange(), 0, 0); |
| 1514 view()->GetCompositionCharacterBounds(&bounds); | 1515 view()->GetCompositionCharacterBounds(&bounds); |
| 1515 ASSERT_EQ(ascii_composition.size(), bounds.size()); | 1516 ASSERT_EQ(ascii_composition.size(), bounds.size()); |
| 1516 | 1517 |
| 1517 for (size_t i = 0; i < bounds.size(); ++i) | 1518 for (size_t i = 0; i < bounds.size(); ++i) |
| 1518 EXPECT_LT(0, bounds[i].width()); | 1519 EXPECT_LT(0, bounds[i].width()); |
| 1519 view()->OnImeCommitText(empty_string, gfx::Range::InvalidRange(), 0); | 1520 view()->OnImeCommitText(empty_string, |
| 1521 std::vector<blink::WebCompositionUnderline>(), |
| 1522 gfx::Range::InvalidRange(), 0); |
| 1520 | 1523 |
| 1521 // Non surrogate pair unicode character. | 1524 // Non surrogate pair unicode character. |
| 1522 const base::string16 unicode_composition = base::UTF8ToUTF16( | 1525 const base::string16 unicode_composition = base::UTF8ToUTF16( |
| 1523 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); | 1526 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); |
| 1524 view()->OnImeSetComposition(unicode_composition, empty_underline, | 1527 view()->OnImeSetComposition(unicode_composition, empty_underline, |
| 1525 gfx::Range::InvalidRange(), 0, 0); | 1528 gfx::Range::InvalidRange(), 0, 0); |
| 1526 view()->GetCompositionCharacterBounds(&bounds); | 1529 view()->GetCompositionCharacterBounds(&bounds); |
| 1527 ASSERT_EQ(unicode_composition.size(), bounds.size()); | 1530 ASSERT_EQ(unicode_composition.size(), bounds.size()); |
| 1528 for (size_t i = 0; i < bounds.size(); ++i) | 1531 for (size_t i = 0; i < bounds.size(); ++i) |
| 1529 EXPECT_LT(0, bounds[i].width()); | 1532 EXPECT_LT(0, bounds[i].width()); |
| 1530 view()->OnImeCommitText(empty_string, gfx::Range::InvalidRange(), 0); | 1533 view()->OnImeCommitText(empty_string, empty_underline, |
| 1534 gfx::Range::InvalidRange(), 0); |
| 1531 | 1535 |
| 1532 // Surrogate pair character. | 1536 // Surrogate pair character. |
| 1533 const base::string16 surrogate_pair_char = | 1537 const base::string16 surrogate_pair_char = |
| 1534 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); | 1538 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); |
| 1535 view()->OnImeSetComposition(surrogate_pair_char, | 1539 view()->OnImeSetComposition(surrogate_pair_char, |
| 1536 empty_underline, | 1540 empty_underline, |
| 1537 gfx::Range::InvalidRange(), | 1541 gfx::Range::InvalidRange(), |
| 1538 0, | 1542 0, |
| 1539 0); | 1543 0); |
| 1540 view()->GetCompositionCharacterBounds(&bounds); | 1544 view()->GetCompositionCharacterBounds(&bounds); |
| 1541 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); | 1545 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); |
| 1542 EXPECT_LT(0, bounds[0].width()); | 1546 EXPECT_LT(0, bounds[0].width()); |
| 1543 EXPECT_EQ(0, bounds[1].width()); | 1547 EXPECT_EQ(0, bounds[1].width()); |
| 1544 view()->OnImeCommitText(empty_string, gfx::Range::InvalidRange(), 0); | 1548 view()->OnImeCommitText(empty_string, empty_underline, |
| 1549 gfx::Range::InvalidRange(), 0); |
| 1545 | 1550 |
| 1546 // Mixed string. | 1551 // Mixed string. |
| 1547 const base::string16 surrogate_pair_mixed_composition = | 1552 const base::string16 surrogate_pair_mixed_composition = |
| 1548 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + | 1553 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + |
| 1549 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; | 1554 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; |
| 1550 const size_t utf16_length = 8UL; | 1555 const size_t utf16_length = 8UL; |
| 1551 const bool is_surrogate_pair_empty_rect[8] = { | 1556 const bool is_surrogate_pair_empty_rect[8] = { |
| 1552 false, true, false, false, true, false, false, true }; | 1557 false, true, false, false, true, false, false, true }; |
| 1553 view()->OnImeSetComposition(surrogate_pair_mixed_composition, | 1558 view()->OnImeSetComposition(surrogate_pair_mixed_composition, |
| 1554 empty_underline, | 1559 empty_underline, |
| 1555 gfx::Range::InvalidRange(), | 1560 gfx::Range::InvalidRange(), |
| 1556 0, | 1561 0, |
| 1557 0); | 1562 0); |
| 1558 view()->GetCompositionCharacterBounds(&bounds); | 1563 view()->GetCompositionCharacterBounds(&bounds); |
| 1559 ASSERT_EQ(utf16_length, bounds.size()); | 1564 ASSERT_EQ(utf16_length, bounds.size()); |
| 1560 for (size_t i = 0; i < utf16_length; ++i) { | 1565 for (size_t i = 0; i < utf16_length; ++i) { |
| 1561 if (is_surrogate_pair_empty_rect[i]) { | 1566 if (is_surrogate_pair_empty_rect[i]) { |
| 1562 EXPECT_EQ(0, bounds[i].width()); | 1567 EXPECT_EQ(0, bounds[i].width()); |
| 1563 } else { | 1568 } else { |
| 1564 EXPECT_LT(0, bounds[i].width()); | 1569 EXPECT_LT(0, bounds[i].width()); |
| 1565 } | 1570 } |
| 1566 } | 1571 } |
| 1567 view()->OnImeCommitText(empty_string, gfx::Range::InvalidRange(), 0); | 1572 view()->OnImeCommitText(empty_string, empty_underline, |
| 1573 gfx::Range::InvalidRange(), 0); |
| 1568 } | 1574 } |
| 1569 #endif | 1575 #endif |
| 1570 | 1576 |
| 1571 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1577 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
| 1572 // Load an HTML page consisting of an input field. | 1578 // Load an HTML page consisting of an input field. |
| 1573 LoadHTML("<html>" | 1579 LoadHTML("<html>" |
| 1574 "<head>" | 1580 "<head>" |
| 1575 "</head>" | 1581 "</head>" |
| 1576 "<body>" | 1582 "<body>" |
| 1577 "<input id=\"test1\" value=\"some test text hello\"></input>" | 1583 "<input id=\"test1\" value=\"some test text hello\"></input>" |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2550 ExpectPauseAndResume(3); | 2556 ExpectPauseAndResume(3); |
| 2551 blink::WebScriptSource source2( | 2557 blink::WebScriptSource source2( |
| 2552 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2558 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2553 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2559 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
| 2554 | 2560 |
| 2555 EXPECT_FALSE(IsPaused()); | 2561 EXPECT_FALSE(IsPaused()); |
| 2556 Detach(); | 2562 Detach(); |
| 2557 } | 2563 } |
| 2558 | 2564 |
| 2559 } // namespace content | 2565 } // namespace content |
| OLD | NEW |