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