| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/common/ssl_status_serialization.h" | 10 #include "content/common/ssl_status_serialization.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "third_party/WebKit/public/platform/WebString.h" | 31 #include "third_party/WebKit/public/platform/WebString.h" |
| 32 #include "third_party/WebKit/public/platform/WebURLError.h" | 32 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 33 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 33 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 34 #include "third_party/WebKit/public/web/WebDataSource.h" | 34 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 35 #include "third_party/WebKit/public/web/WebFrame.h" | 35 #include "third_party/WebKit/public/web/WebFrame.h" |
| 36 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 36 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 37 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 37 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 38 #include "third_party/WebKit/public/web/WebView.h" | 38 #include "third_party/WebKit/public/web/WebView.h" |
| 39 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 39 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 40 #include "ui/base/keycodes/keyboard_codes.h" | 40 #include "ui/base/keycodes/keyboard_codes.h" |
| 41 #include "ui/base/range/range.h" | |
| 42 #include "ui/gfx/codec/jpeg_codec.h" | 41 #include "ui/gfx/codec/jpeg_codec.h" |
| 42 #include "ui/gfx/range/range.h" |
| 43 | 43 |
| 44 #if defined(OS_LINUX) && !defined(USE_AURA) | 44 #if defined(OS_LINUX) && !defined(USE_AURA) |
| 45 #include "ui/base/gtk/event_synthesis_gtk.h" | 45 #include "ui/base/gtk/event_synthesis_gtk.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if defined(USE_AURA) | 48 #if defined(USE_AURA) |
| 49 #include "ui/base/events/event.h" | 49 #include "ui/base/events/event.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 #if defined(USE_AURA) && defined(USE_X11) | 52 #if defined(USE_AURA) && defined(USE_X11) |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 view()->OnImeSetComposition( | 1007 view()->OnImeSetComposition( |
| 1008 WideToUTF16Hack(ime_message->ime_string), | 1008 WideToUTF16Hack(ime_message->ime_string), |
| 1009 std::vector<WebKit::WebCompositionUnderline>(), | 1009 std::vector<WebKit::WebCompositionUnderline>(), |
| 1010 ime_message->selection_start, | 1010 ime_message->selection_start, |
| 1011 ime_message->selection_end); | 1011 ime_message->selection_end); |
| 1012 break; | 1012 break; |
| 1013 | 1013 |
| 1014 case IME_CONFIRMCOMPOSITION: | 1014 case IME_CONFIRMCOMPOSITION: |
| 1015 view()->OnImeConfirmComposition( | 1015 view()->OnImeConfirmComposition( |
| 1016 WideToUTF16Hack(ime_message->ime_string), | 1016 WideToUTF16Hack(ime_message->ime_string), |
| 1017 ui::Range::InvalidRange(), | 1017 gfx::Range::InvalidRange(), |
| 1018 false); | 1018 false); |
| 1019 break; | 1019 break; |
| 1020 | 1020 |
| 1021 case IME_CANCELCOMPOSITION: | 1021 case IME_CANCELCOMPOSITION: |
| 1022 view()->OnImeSetComposition( | 1022 view()->OnImeSetComposition( |
| 1023 string16(), | 1023 string16(), |
| 1024 std::vector<WebKit::WebCompositionUnderline>(), | 1024 std::vector<WebKit::WebCompositionUnderline>(), |
| 1025 0, 0); | 1025 0, 0); |
| 1026 break; | 1026 break; |
| 1027 } | 1027 } |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 view()->OnSetInputMethodActive(true); | 1770 view()->OnSetInputMethodActive(true); |
| 1771 | 1771 |
| 1772 // ASCII composition | 1772 // ASCII composition |
| 1773 const string16 ascii_composition = UTF8ToUTF16("aiueo"); | 1773 const string16 ascii_composition = UTF8ToUTF16("aiueo"); |
| 1774 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); | 1774 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); |
| 1775 view()->GetCompositionCharacterBounds(&bounds); | 1775 view()->GetCompositionCharacterBounds(&bounds); |
| 1776 ASSERT_EQ(ascii_composition.size(), bounds.size()); | 1776 ASSERT_EQ(ascii_composition.size(), bounds.size()); |
| 1777 for (size_t i = 0; i < bounds.size(); ++i) | 1777 for (size_t i = 0; i < bounds.size(); ++i) |
| 1778 EXPECT_LT(0, bounds[i].width()); | 1778 EXPECT_LT(0, bounds[i].width()); |
| 1779 view()->OnImeConfirmComposition( | 1779 view()->OnImeConfirmComposition( |
| 1780 empty_string, ui::Range::InvalidRange(), false); | 1780 empty_string, gfx::Range::InvalidRange(), false); |
| 1781 | 1781 |
| 1782 // Non surrogate pair unicode character. | 1782 // Non surrogate pair unicode character. |
| 1783 const string16 unicode_composition = UTF8ToUTF16( | 1783 const string16 unicode_composition = UTF8ToUTF16( |
| 1784 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); | 1784 "\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"); |
| 1785 view()->OnImeSetComposition(unicode_composition, empty_underline, 0, 0); | 1785 view()->OnImeSetComposition(unicode_composition, empty_underline, 0, 0); |
| 1786 view()->GetCompositionCharacterBounds(&bounds); | 1786 view()->GetCompositionCharacterBounds(&bounds); |
| 1787 ASSERT_EQ(unicode_composition.size(), bounds.size()); | 1787 ASSERT_EQ(unicode_composition.size(), bounds.size()); |
| 1788 for (size_t i = 0; i < bounds.size(); ++i) | 1788 for (size_t i = 0; i < bounds.size(); ++i) |
| 1789 EXPECT_LT(0, bounds[i].width()); | 1789 EXPECT_LT(0, bounds[i].width()); |
| 1790 view()->OnImeConfirmComposition( | 1790 view()->OnImeConfirmComposition( |
| 1791 empty_string, ui::Range::InvalidRange(), false); | 1791 empty_string, gfx::Range::InvalidRange(), false); |
| 1792 | 1792 |
| 1793 // Surrogate pair character. | 1793 // Surrogate pair character. |
| 1794 const string16 surrogate_pair_char = UTF8ToUTF16("\xF0\xA0\xAE\x9F"); | 1794 const string16 surrogate_pair_char = UTF8ToUTF16("\xF0\xA0\xAE\x9F"); |
| 1795 view()->OnImeSetComposition(surrogate_pair_char, | 1795 view()->OnImeSetComposition(surrogate_pair_char, |
| 1796 empty_underline, | 1796 empty_underline, |
| 1797 0, | 1797 0, |
| 1798 0); | 1798 0); |
| 1799 view()->GetCompositionCharacterBounds(&bounds); | 1799 view()->GetCompositionCharacterBounds(&bounds); |
| 1800 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); | 1800 ASSERT_EQ(surrogate_pair_char.size(), bounds.size()); |
| 1801 EXPECT_LT(0, bounds[0].width()); | 1801 EXPECT_LT(0, bounds[0].width()); |
| 1802 EXPECT_EQ(0, bounds[1].width()); | 1802 EXPECT_EQ(0, bounds[1].width()); |
| 1803 view()->OnImeConfirmComposition( | 1803 view()->OnImeConfirmComposition( |
| 1804 empty_string, ui::Range::InvalidRange(), false); | 1804 empty_string, gfx::Range::InvalidRange(), false); |
| 1805 | 1805 |
| 1806 // Mixed string. | 1806 // Mixed string. |
| 1807 const string16 surrogate_pair_mixed_composition = | 1807 const string16 surrogate_pair_mixed_composition = |
| 1808 surrogate_pair_char + UTF8ToUTF16("\xE3\x81\x82") + surrogate_pair_char + | 1808 surrogate_pair_char + UTF8ToUTF16("\xE3\x81\x82") + surrogate_pair_char + |
| 1809 UTF8ToUTF16("b") + surrogate_pair_char; | 1809 UTF8ToUTF16("b") + surrogate_pair_char; |
| 1810 const size_t utf16_length = 8UL; | 1810 const size_t utf16_length = 8UL; |
| 1811 const bool is_surrogate_pair_empty_rect[8] = { | 1811 const bool is_surrogate_pair_empty_rect[8] = { |
| 1812 false, true, false, false, true, false, false, true }; | 1812 false, true, false, false, true, false, false, true }; |
| 1813 view()->OnImeSetComposition(surrogate_pair_mixed_composition, | 1813 view()->OnImeSetComposition(surrogate_pair_mixed_composition, |
| 1814 empty_underline, | 1814 empty_underline, |
| 1815 0, | 1815 0, |
| 1816 0); | 1816 0); |
| 1817 view()->GetCompositionCharacterBounds(&bounds); | 1817 view()->GetCompositionCharacterBounds(&bounds); |
| 1818 ASSERT_EQ(utf16_length, bounds.size()); | 1818 ASSERT_EQ(utf16_length, bounds.size()); |
| 1819 for (size_t i = 0; i < utf16_length; ++i) { | 1819 for (size_t i = 0; i < utf16_length; ++i) { |
| 1820 if (is_surrogate_pair_empty_rect[i]) { | 1820 if (is_surrogate_pair_empty_rect[i]) { |
| 1821 EXPECT_EQ(0, bounds[i].width()); | 1821 EXPECT_EQ(0, bounds[i].width()); |
| 1822 } else { | 1822 } else { |
| 1823 EXPECT_LT(0, bounds[i].width()); | 1823 EXPECT_LT(0, bounds[i].width()); |
| 1824 } | 1824 } |
| 1825 } | 1825 } |
| 1826 view()->OnImeConfirmComposition( | 1826 view()->OnImeConfirmComposition( |
| 1827 empty_string, ui::Range::InvalidRange(), false); | 1827 empty_string, gfx::Range::InvalidRange(), false); |
| 1828 } | 1828 } |
| 1829 #endif | 1829 #endif |
| 1830 | 1830 |
| 1831 TEST_F(RenderViewImplTest, ZoomLimit) { | 1831 TEST_F(RenderViewImplTest, ZoomLimit) { |
| 1832 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); | 1832 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 1833 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); | 1833 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 1834 | 1834 |
| 1835 ViewMsg_Navigate_Params params; | 1835 ViewMsg_Navigate_Params params; |
| 1836 params.page_id = -1; | 1836 params.page_id = -1; |
| 1837 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 1837 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1944 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); | 1944 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); |
| 1945 | 1945 |
| 1946 const_cast<WebKit::WebURLResponse&>(frame->dataSource()->response()). | 1946 const_cast<WebKit::WebURLResponse&>(frame->dataSource()->response()). |
| 1947 setSecurityInfo( | 1947 setSecurityInfo( |
| 1948 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0)); | 1948 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0)); |
| 1949 ssl_status = view()->GetSSLStatusOfFrame(frame); | 1949 ssl_status = view()->GetSSLStatusOfFrame(frame); |
| 1950 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); | 1950 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); |
| 1951 } | 1951 } |
| 1952 | 1952 |
| 1953 } // namespace content | 1953 } // namespace content |
| OLD | NEW |