OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2831 // Zoom out slightly. | 2831 // Zoom out slightly. |
2832 const float withinToleranceScale = scale * 0.9f; | 2832 const float withinToleranceScale = scale * 0.9f; |
2833 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, withinTolera
nceScale); | 2833 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, withinTolera
nceScale); |
2834 // Move focus back to the second edit box. | 2834 // Move focus back to the second edit box. |
2835 webViewHelper.webView()->advanceFocus(false); | 2835 webViewHelper.webView()->advanceFocus(false); |
2836 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2836 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
2837 // The scale should not be adjusted as the zoomed out scale was sufficiently
close to the previously focused scale. | 2837 // The scale should not be adjusted as the zoomed out scale was sufficiently
close to the previously focused scale. |
2838 EXPECT_FALSE(needAnimation); | 2838 EXPECT_FALSE(needAnimation); |
2839 } | 2839 } |
2840 | 2840 |
| 2841 TEST_F(WebFrameTest, CharacterIndexAtPointWithPinchZoom) |
| 2842 { |
| 2843 registerMockedHttpURLLoad("sometext.html"); |
| 2844 |
| 2845 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2846 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); |
| 2847 webViewHelper.webViewImpl()->resize(WebSize(640, 480)); |
| 2848 webViewHelper.webViewImpl()->layout(); |
| 2849 |
| 2850 |
| 2851 webViewHelper.webViewImpl()->setPageScaleFactor(2); |
| 2852 webViewHelper.webViewImpl()->setPinchViewportOffset(WebFloatPoint(50, 60)); |
| 2853 |
| 2854 WebRect baseRect; |
| 2855 WebRect extentRect; |
| 2856 |
| 2857 WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame(); |
| 2858 size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388)); |
| 2859 |
| 2860 EXPECT_EQ(2ul, ix); |
| 2861 } |
| 2862 |
| 2863 TEST_F(WebFrameTest, FirstRectForCharacterRangeWithPinchZoom) |
| 2864 { |
| 2865 registerMockedHttpURLLoad("textbox.html"); |
| 2866 |
| 2867 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2868 webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true); |
| 2869 webViewHelper.webViewImpl()->resize(WebSize(640, 480)); |
| 2870 |
| 2871 WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame(); |
| 2872 mainFrame->executeScript(WebScriptSource("selectRange();")); |
| 2873 |
| 2874 WebRect oldRect; |
| 2875 mainFrame->firstRectForCharacterRange(0, 5, oldRect); |
| 2876 |
| 2877 WebFloatPoint pinchOffset(100, 130); |
| 2878 float scale = 2; |
| 2879 webViewHelper.webViewImpl()->setPageScaleFactor(scale); |
| 2880 webViewHelper.webViewImpl()->setPinchViewportOffset(pinchOffset); |
| 2881 |
| 2882 WebRect baseRect; |
| 2883 WebRect extentRect; |
| 2884 |
| 2885 WebRect rect; |
| 2886 mainFrame->firstRectForCharacterRange(0, 5, rect); |
| 2887 |
| 2888 EXPECT_EQ((oldRect.x - pinchOffset.x) * scale, rect.x); |
| 2889 EXPECT_EQ((oldRect.y - pinchOffset.y) * scale, rect.y); |
| 2890 EXPECT_EQ(oldRect.width*scale, rect.width); |
| 2891 EXPECT_EQ(oldRect.height*scale, rect.height); |
| 2892 } |
| 2893 |
2841 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) | 2894 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) |
2842 { | 2895 { |
2843 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 2896 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
2844 | 2897 |
2845 const int viewportWidth = 450; | 2898 const int viewportWidth = 450; |
2846 const int viewportHeight = 300; | 2899 const int viewportHeight = 300; |
2847 const float minReadableCaretHeight = 16.0f; | 2900 const float minReadableCaretHeight = 16.0f; |
2848 FrameTestHelpers::WebViewHelper webViewHelper; | 2901 FrameTestHelpers::WebViewHelper webViewHelper; |
2849 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); | 2902 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); |
2850 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); | 2903 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); |
(...skipping 4276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7127 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7180 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7128 WebView* view = WebView::create(&viewClient); | 7181 WebView* view = WebView::create(&viewClient); |
7129 view->setMainFrame(remoteClient.frame()); | 7182 view->setMainFrame(remoteClient.frame()); |
7130 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; | 7183 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; |
7131 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", WebSandboxFlags::None, &childFrameClient); | 7184 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", WebSandboxFlags::None, &childFrameClient); |
7132 childFrame->detach(); | 7185 childFrame->detach(); |
7133 view->close(); | 7186 view->close(); |
7134 } | 7187 } |
7135 | 7188 |
7136 } // namespace blink | 7189 } // namespace blink |
OLD | NEW |