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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 base::WideToUTF16(ime_message->ime_string), | 1329 base::WideToUTF16(ime_message->ime_string), |
1330 std::vector<blink::WebCompositionUnderline>(), | 1330 std::vector<blink::WebCompositionUnderline>(), |
1331 gfx::Range::InvalidRange(), | 1331 gfx::Range::InvalidRange(), |
1332 ime_message->selection_start, | 1332 ime_message->selection_start, |
1333 ime_message->selection_end); | 1333 ime_message->selection_end); |
1334 break; | 1334 break; |
1335 | 1335 |
1336 case IME_CONFIRMCOMPOSITION: | 1336 case IME_CONFIRMCOMPOSITION: |
1337 view()->OnImeConfirmComposition( | 1337 view()->OnImeConfirmComposition( |
1338 base::WideToUTF16(ime_message->ime_string), | 1338 base::WideToUTF16(ime_message->ime_string), |
1339 gfx::Range::InvalidRange(), | 1339 gfx::Range::InvalidRange(), false, 0); |
1340 false); | |
1341 break; | 1340 break; |
1342 | 1341 |
1343 case IME_CANCELCOMPOSITION: | 1342 case IME_CANCELCOMPOSITION: |
1344 view()->OnImeSetComposition( | 1343 view()->OnImeSetComposition( |
1345 base::string16(), | 1344 base::string16(), |
1346 std::vector<blink::WebCompositionUnderline>(), | 1345 std::vector<blink::WebCompositionUnderline>(), |
1347 gfx::Range::InvalidRange(), | 1346 gfx::Range::InvalidRange(), |
1348 0, 0); | 1347 0, 0); |
1349 break; | 1348 break; |
1350 } | 1349 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 | 1585 |
1587 // ASCII composition | 1586 // ASCII composition |
1588 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); | 1587 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); |
1589 view()->OnImeSetComposition(ascii_composition, empty_underline, | 1588 view()->OnImeSetComposition(ascii_composition, empty_underline, |
1590 gfx::Range::InvalidRange(), 0, 0); | 1589 gfx::Range::InvalidRange(), 0, 0); |
1591 view()->GetCompositionCharacterBounds(&bounds); | 1590 view()->GetCompositionCharacterBounds(&bounds); |
1592 ASSERT_EQ(ascii_composition.size(), bounds.size()); | 1591 ASSERT_EQ(ascii_composition.size(), bounds.size()); |
1593 | 1592 |
1594 for (size_t i = 0; i < bounds.size(); ++i) | 1593 for (size_t i = 0; i < bounds.size(); ++i) |
1595 EXPECT_LT(0, bounds[i].width()); | 1594 EXPECT_LT(0, bounds[i].width()); |
1596 view()->OnImeConfirmComposition( | 1595 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
1597 empty_string, gfx::Range::InvalidRange(), false); | 1596 false, 0); |
1598 | 1597 |
1599 // Non surrogate pair unicode character. | 1598 // Non surrogate pair unicode character. |
1600 const base::string16 unicode_composition = base::UTF8ToUTF16( | 1599 const base::string16 unicode_composition = base::UTF8ToUTF16( |
1601 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); | 1600 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); |
1602 view()->OnImeSetComposition(unicode_composition, empty_underline, | 1601 view()->OnImeSetComposition(unicode_composition, empty_underline, |
1603 gfx::Range::InvalidRange(), 0, 0); | 1602 gfx::Range::InvalidRange(), 0, 0); |
1604 view()->GetCompositionCharacterBounds(&bounds); | 1603 view()->GetCompositionCharacterBounds(&bounds); |
1605 ASSERT_EQ(unicode_composition.size(), bounds.size()); | 1604 ASSERT_EQ(unicode_composition.size(), bounds.size()); |
1606 for (size_t i = 0; i < bounds.size(); ++i) | 1605 for (size_t i = 0; i < bounds.size(); ++i) |
1607 EXPECT_LT(0, bounds[i].width()); | 1606 EXPECT_LT(0, bounds[i].width()); |
1608 view()->OnImeConfirmComposition( | 1607 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
1609 empty_string, gfx::Range::InvalidRange(), false); | 1608 false, 0); |
1610 | 1609 |
1611 // Surrogate pair character. | 1610 // Surrogate pair character. |
1612 const base::string16 surrogate_pair_char = | 1611 const base::string16 surrogate_pair_char = |
1613 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); | 1612 base::UTF8ToUTF16("\xF0\xA0\xAE\x9F"); |
1614 view()->OnImeSetComposition(surrogate_pair_char, | 1613 view()->OnImeSetComposition(surrogate_pair_char, |
1615 empty_underline, | 1614 empty_underline, |
1616 gfx::Range::InvalidRange(), | 1615 gfx::Range::InvalidRange(), |
1617 0, | 1616 0, |
1618 0); | 1617 0); |
1619 view()->GetCompositionCharacterBounds(&bounds); | 1618 view()->GetCompositionCharacterBounds(&bounds); |
1620 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); | 1619 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); |
1621 EXPECT_LT(0, bounds[0].width()); | 1620 EXPECT_LT(0, bounds[0].width()); |
1622 EXPECT_EQ(0, bounds[1].width()); | 1621 EXPECT_EQ(0, bounds[1].width()); |
1623 view()->OnImeConfirmComposition( | 1622 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
1624 empty_string, gfx::Range::InvalidRange(), false); | 1623 false, 0); |
1625 | 1624 |
1626 // Mixed string. | 1625 // Mixed string. |
1627 const base::string16 surrogate_pair_mixed_composition = | 1626 const base::string16 surrogate_pair_mixed_composition = |
1628 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + | 1627 surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") + |
1629 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; | 1628 surrogate_pair_char + base::UTF8ToUTF16("b") + surrogate_pair_char; |
1630 const size_t utf16_length = 8UL; | 1629 const size_t utf16_length = 8UL; |
1631 const bool is_surrogate_pair_empty_rect[8] = { | 1630 const bool is_surrogate_pair_empty_rect[8] = { |
1632 false, true, false, false, true, false, false, true }; | 1631 false, true, false, false, true, false, false, true }; |
1633 view()->OnImeSetComposition(surrogate_pair_mixed_composition, | 1632 view()->OnImeSetComposition(surrogate_pair_mixed_composition, |
1634 empty_underline, | 1633 empty_underline, |
1635 gfx::Range::InvalidRange(), | 1634 gfx::Range::InvalidRange(), |
1636 0, | 1635 0, |
1637 0); | 1636 0); |
1638 view()->GetCompositionCharacterBounds(&bounds); | 1637 view()->GetCompositionCharacterBounds(&bounds); |
1639 ASSERT_EQ(utf16_length, bounds.size()); | 1638 ASSERT_EQ(utf16_length, bounds.size()); |
1640 for (size_t i = 0; i < utf16_length; ++i) { | 1639 for (size_t i = 0; i < utf16_length; ++i) { |
1641 if (is_surrogate_pair_empty_rect[i]) { | 1640 if (is_surrogate_pair_empty_rect[i]) { |
1642 EXPECT_EQ(0, bounds[i].width()); | 1641 EXPECT_EQ(0, bounds[i].width()); |
1643 } else { | 1642 } else { |
1644 EXPECT_LT(0, bounds[i].width()); | 1643 EXPECT_LT(0, bounds[i].width()); |
1645 } | 1644 } |
1646 } | 1645 } |
1647 view()->OnImeConfirmComposition( | 1646 view()->OnImeConfirmComposition(empty_string, gfx::Range::InvalidRange(), |
1648 empty_string, gfx::Range::InvalidRange(), false); | 1647 false, 0); |
1649 } | 1648 } |
1650 #endif | 1649 #endif |
1651 | 1650 |
1652 TEST_F(RenderViewImplTest, ZoomLimit) { | 1651 TEST_F(RenderViewImplTest, ZoomLimit) { |
1653 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1652 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
1654 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1653 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
1655 | 1654 |
1656 // Verifies navigation to a URL with preset zoom level indeed sets the level. | 1655 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
1657 // Regression test for http://crbug.com/139559, where the level was not | 1656 // Regression test for http://crbug.com/139559, where the level was not |
1658 // properly set when it is out of the default zoom limits of WebView. | 1657 // properly set when it is out of the default zoom limits of WebView. |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 ExpectPauseAndResume(3); | 2555 ExpectPauseAndResume(3); |
2557 blink::WebScriptSource source2( | 2556 blink::WebScriptSource source2( |
2558 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2557 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
2559 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2558 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
2560 | 2559 |
2561 EXPECT_FALSE(IsPaused()); | 2560 EXPECT_FALSE(IsPaused()); |
2562 Detach(); | 2561 Detach(); |
2563 } | 2562 } |
2564 | 2563 |
2565 } // namespace content | 2564 } // namespace content |
OLD | NEW |