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