| 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 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 base::WideToUTF16(ime_message->ime_string), | 1311 base::WideToUTF16(ime_message->ime_string), |
| 1312 std::vector<blink::WebCompositionUnderline>(), | 1312 std::vector<blink::WebCompositionUnderline>(), |
| 1313 gfx::Range::InvalidRange(), | 1313 gfx::Range::InvalidRange(), |
| 1314 ime_message->selection_start, | 1314 ime_message->selection_start, |
| 1315 ime_message->selection_end); | 1315 ime_message->selection_end); |
| 1316 break; | 1316 break; |
| 1317 | 1317 |
| 1318 case IME_CONFIRMCOMPOSITION: | 1318 case IME_CONFIRMCOMPOSITION: |
| 1319 view()->OnImeConfirmComposition( | 1319 view()->OnImeConfirmComposition( |
| 1320 base::WideToUTF16(ime_message->ime_string), | 1320 base::WideToUTF16(ime_message->ime_string), |
| 1321 gfx::Range::InvalidRange(), | 1321 gfx::Range::InvalidRange(), false, 1); |
| 1322 false); | |
| 1323 break; | 1322 break; |
| 1324 | 1323 |
| 1325 case IME_CANCELCOMPOSITION: | 1324 case IME_CANCELCOMPOSITION: |
| 1326 view()->OnImeSetComposition( | 1325 view()->OnImeSetComposition( |
| 1327 base::string16(), | 1326 base::string16(), |
| 1328 std::vector<blink::WebCompositionUnderline>(), | 1327 std::vector<blink::WebCompositionUnderline>(), |
| 1329 gfx::Range::InvalidRange(), | 1328 gfx::Range::InvalidRange(), |
| 1330 0, 0); | 1329 0, 0); |
| 1331 break; | 1330 break; |
| 1332 } | 1331 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 | 1567 |
| 1569 // ASCII composition | 1568 // ASCII composition |
| 1570 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); | 1569 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); |
| 1571 view()->OnImeSetComposition(ascii_composition, empty_underline, | 1570 view()->OnImeSetComposition(ascii_composition, empty_underline, |
| 1572 gfx::Range::InvalidRange(), 0, 0); | 1571 gfx::Range::InvalidRange(), 0, 0); |
| 1573 view()->GetCompositionCharacterBounds(&bounds); | 1572 view()->GetCompositionCharacterBounds(&bounds); |
| 1574 ASSERT_EQ(ascii_composition.size(), bounds.size()); | 1573 ASSERT_EQ(ascii_composition.size(), bounds.size()); |
| 1575 | 1574 |
| 1576 for (size_t i = 0; i < bounds.size(); ++i) | 1575 for (size_t i = 0; i < bounds.size(); ++i) |
| 1577 EXPECT_LT(0, bounds[i].width()); | 1576 EXPECT_LT(0, bounds[i].width()); |
| 1578 view()->OnImeConfirmComposition( | 1577 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
| 1579 empty_string, gfx::Range::InvalidRange(), false); | 1578 false, 1); |
| 1580 | 1579 |
| 1581 // Non surrogate pair unicode character. | 1580 // Non surrogate pair unicode character. |
| 1582 const base::string16 unicode_composition = base::UTF8ToUTF16( | 1581 const base::string16 unicode_composition = base::UTF8ToUTF16( |
| 1583 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); | 1582 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); |
| 1584 view()->OnImeSetComposition(unicode_composition, empty_underline, | 1583 view()->OnImeSetComposition(unicode_composition, empty_underline, |
| 1585 gfx::Range::InvalidRange(), 0, 0); | 1584 gfx::Range::InvalidRange(), 0, 0); |
| 1586 view()->GetCompositionCharacterBounds(&bounds); | 1585 view()->GetCompositionCharacterBounds(&bounds); |
| 1587 ASSERT_EQ(unicode_composition.size(), bounds.size()); | 1586 ASSERT_EQ(unicode_composition.size(), bounds.size()); |
| 1588 for (size_t i = 0; i < bounds.size(); ++i) | 1587 for (size_t i = 0; i < bounds.size(); ++i) |
| 1589 EXPECT_LT(0, bounds[i].width()); | 1588 EXPECT_LT(0, bounds[i].width()); |
| 1590 view()->OnImeConfirmComposition( | 1589 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
| 1591 empty_string, gfx::Range::InvalidRange(), false); | 1590 false, 1); |
| 1592 | 1591 |
| 1593 // Surrogate pair character. | 1592 // Surrogate pair character. |
| 1594 const base::string16 surrogate_pair_char = | 1593 const base::string16 surrogate_pair_char = |
| 1595 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); | 1594 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); |
| 1596 view()->OnImeSetComposition(surrogate_pair_char, | 1595 view()->OnImeSetComposition(surrogate_pair_char, |
| 1597 empty_underline, | 1596 empty_underline, |
| 1598 gfx::Range::InvalidRange(), | 1597 gfx::Range::InvalidRange(), |
| 1599 0, | 1598 0, |
| 1600 0); | 1599 0); |
| 1601 view()->GetCompositionCharacterBounds(&bounds); | 1600 view()->GetCompositionCharacterBounds(&bounds); |
| 1602 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); | 1601 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); |
| 1603 EXPECT_LT(0, bounds[0].width()); | 1602 EXPECT_LT(0, bounds[0].width()); |
| 1604 EXPECT_EQ(0, bounds[1].width()); | 1603 EXPECT_EQ(0, bounds[1].width()); |
| 1605 view()->OnImeConfirmComposition( | 1604 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
| 1606 empty_string, gfx::Range::InvalidRange(), false); | 1605 false, 1); |
| 1607 | 1606 |
| 1608 // Mixed string. | 1607 // Mixed string. |
| 1609 const base::string16 surrogate_pair_mixed_composition = | 1608 const base::string16 surrogate_pair_mixed_composition = |
| 1610 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + | 1609 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + |
| 1611 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; | 1610 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; |
| 1612 const size_t utf16_length = 8UL; | 1611 const size_t utf16_length = 8UL; |
| 1613 const bool is_surrogate_pair_empty_rect[8] = { | 1612 const bool is_surrogate_pair_empty_rect[8] = { |
| 1614 false, true, false, false, true, false, false, true }; | 1613 false, true, false, false, true, false, false, true }; |
| 1615 view()->OnImeSetComposition(surrogate_pair_mixed_composition, | 1614 view()->OnImeSetComposition(surrogate_pair_mixed_composition, |
| 1616 empty_underline, | 1615 empty_underline, |
| 1617 gfx::Range::InvalidRange(), | 1616 gfx::Range::InvalidRange(), |
| 1618 0, | 1617 0, |
| 1619 0); | 1618 0); |
| 1620 view()->GetCompositionCharacterBounds(&bounds); | 1619 view()->GetCompositionCharacterBounds(&bounds); |
| 1621 ASSERT_EQ(utf16_length, bounds.size()); | 1620 ASSERT_EQ(utf16_length, bounds.size()); |
| 1622 for (size_t i = 0; i < utf16_length; ++i) { | 1621 for (size_t i = 0; i < utf16_length; ++i) { |
| 1623 if (is_surrogate_pair_empty_rect[i]) { | 1622 if (is_surrogate_pair_empty_rect[i]) { |
| 1624 EXPECT_EQ(0, bounds[i].width()); | 1623 EXPECT_EQ(0, bounds[i].width()); |
| 1625 } else { | 1624 } else { |
| 1626 EXPECT_LT(0, bounds[i].width()); | 1625 EXPECT_LT(0, bounds[i].width()); |
| 1627 } | 1626 } |
| 1628 } | 1627 } |
| 1629 view()->OnImeConfirmComposition( | 1628 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
| 1630 empty_string, gfx::Range::InvalidRange(), false); | 1629 false, 1); |
| 1631 } | 1630 } |
| 1632 #endif | 1631 #endif |
| 1633 | 1632 |
| 1634 TEST_F(RenderViewImplTest, ZoomLimit) { | 1633 TEST_F(RenderViewImplTest, ZoomLimit) { |
| 1635 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1634 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 1636 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1635 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 1637 | 1636 |
| 1638 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 1637 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
| 1639 // Regression test for http://crbug.com/139559, where the level was not | 1638 // Regression test for http://crbug.com/139559, where the level was not |
| 1640 // properly set when it is out of the default zoom limits of WebView. | 1639 // properly set when it is out of the default zoom limits of WebView. |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 ExpectPauseAndResume(3); | 2482 ExpectPauseAndResume(3); |
| 2484 blink::WebScriptSource source2( | 2483 blink::WebScriptSource source2( |
| 2485 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2484 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2486 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2485 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
| 2487 | 2486 |
| 2488 EXPECT_FALSE(IsPaused()); | 2487 EXPECT_FALSE(IsPaused()); |
| 2489 Detach(); | 2488 Detach(); |
| 2490 } | 2489 } |
| 2491 | 2490 |
| 2492 } // namespace content | 2491 } // namespace content |
| OLD | NEW |