| 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 2826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2837 EXPECT_FLOAT_EQ(1, scale); | 2837 EXPECT_FLOAT_EQ(1, scale); |
| 2838 webViewHelper.webViewImpl()->setPageScaleFactor(webViewHelper.webViewImpl()-
>minimumPageScaleFactor()); | 2838 webViewHelper.webViewImpl()->setPageScaleFactor(webViewHelper.webViewImpl()-
>minimumPageScaleFactor()); |
| 2839 simulateMultiTargetZoom(webViewHelper.webViewImpl(), topDiv, scale); | 2839 simulateMultiTargetZoom(webViewHelper.webViewImpl(), topDiv, scale); |
| 2840 EXPECT_FLOAT_EQ(1, scale); | 2840 EXPECT_FLOAT_EQ(1, scale); |
| 2841 } | 2841 } |
| 2842 | 2842 |
| 2843 TEST_F(WebFrameTest, DivScrollIntoEditableTest) | 2843 TEST_F(WebFrameTest, DivScrollIntoEditableTest) |
| 2844 { | 2844 { |
| 2845 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 2845 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
| 2846 | 2846 |
| 2847 const bool autoZoomToLegibleScale = true; |
| 2847 int viewportWidth = 450; | 2848 int viewportWidth = 450; |
| 2848 int viewportHeight = 300; | 2849 int viewportHeight = 300; |
| 2849 float leftBoxRatio = 0.3f; | 2850 float leftBoxRatio = 0.3f; |
| 2850 int caretPadding = 10; | 2851 int caretPadding = 10; |
| 2851 float minReadableCaretHeight = 16.0f; | 2852 float minReadableCaretHeight = 16.0f; |
| 2852 FrameTestHelpers::WebViewHelper webViewHelper; | 2853 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2853 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); | 2854 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); |
| 2854 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); | 2855 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); |
| 2855 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2856 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2856 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); | 2857 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); |
| 2857 webViewHelper.webView()->setDeviceScaleFactor(1.5f); | |
| 2858 webViewHelper.webView()->layout(); | |
| 2859 webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(tr
ue); | |
| 2860 | 2858 |
| 2861 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 2859 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2862 | 2860 |
| 2863 WebRect editBoxWithText(200, 200, 250, 20); | 2861 WebRect editBoxWithText(200, 200, 250, 20); |
| 2864 WebRect editBoxWithNoText(200, 250, 250, 20); | 2862 WebRect editBoxWithNoText(200, 250, 250, 20); |
| 2865 | 2863 |
| 2866 // Test scrolling the focused node | 2864 // Test scrolling the focused node |
| 2867 // The edit box is shorter and narrower than the viewport when legible. | 2865 // The edit box is shorter and narrower than the viewport when legible. |
| 2868 webViewHelper.webView()->advanceFocus(false); | 2866 webViewHelper.webView()->advanceFocus(false); |
| 2869 // Set the caret to the end of the input box. | 2867 // Set the caret to the end of the input box. |
| 2870 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); | 2868 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); |
| 2871 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); | 2869 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); |
| 2872 WebRect rect, caret; | 2870 WebRect rect, caret; |
| 2873 webViewHelper.webViewImpl()->selectionBounds(caret, rect); | 2871 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 2874 | 2872 |
| 2875 // Set the page scale to be smaller than the minimal readable scale. | 2873 // Set the page scale to be smaller than the minimal readable scale. |
| 2876 float initialScale = minReadableCaretHeight / caret.height * 0.5f; | 2874 float initialScale = minReadableCaretHeight / caret.height * 0.5f; |
| 2877 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); | 2875 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 2878 | 2876 |
| 2879 float scale; | 2877 float scale; |
| 2880 IntPoint scroll; | 2878 IntPoint scroll; |
| 2881 bool needAnimation; | 2879 bool needAnimation; |
| 2882 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2880 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 2883 EXPECT_TRUE(needAnimation); | 2881 EXPECT_TRUE(needAnimation); |
| 2884 // The edit box should be left aligned with a margin for possible label. | 2882 // The edit box should be left aligned with a margin for possible label. |
| 2885 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; | 2883 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; |
| 2886 EXPECT_NEAR(hScroll, scroll.x(), 2); | 2884 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 2887 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; | 2885 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
| 2888 EXPECT_NEAR(vScroll, scroll.y(), 2); | 2886 EXPECT_NEAR(vScroll, scroll.y(), 2); |
| 2889 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2887 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| 2890 | 2888 |
| 2891 // The edit box is wider than the viewport when legible. | 2889 // The edit box is wider than the viewport when legible. |
| 2892 viewportWidth = 200; | 2890 viewportWidth = 200; |
| 2893 viewportHeight = 150; | 2891 viewportHeight = 150; |
| 2894 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2892 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2895 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); | 2893 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 2896 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2894 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 2897 EXPECT_TRUE(needAnimation); | 2895 EXPECT_TRUE(needAnimation); |
| 2898 // The caret should be right aligned since the caret would be offscreen when
the edit box is left aligned. | 2896 // The caret should be right aligned since the caret would be offscreen when
the edit box is left aligned. |
| 2899 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; | 2897 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; |
| 2900 EXPECT_NEAR(hScroll, scroll.x(), 2); | 2898 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 2901 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2899 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| 2902 | 2900 |
| 2903 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); | 2901 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 2904 // Move focus to edit box with text. | 2902 // Move focus to edit box with text. |
| 2905 webViewHelper.webView()->advanceFocus(false); | 2903 webViewHelper.webView()->advanceFocus(false); |
| 2906 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2904 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 2907 EXPECT_TRUE(needAnimation); | 2905 EXPECT_TRUE(needAnimation); |
| 2908 // The edit box should be left aligned. | 2906 // The edit box should be left aligned. |
| 2909 hScroll = editBoxWithNoText.x; | 2907 hScroll = editBoxWithNoText.x; |
| 2910 EXPECT_NEAR(hScroll, scroll.x(), 2); | 2908 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 2911 vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoText.
height) / 2; | 2909 vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoText.
height) / 2; |
| 2912 EXPECT_NEAR(vScroll, scroll.y(), 2); | 2910 EXPECT_NEAR(vScroll, scroll.y(), 2); |
| 2913 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2911 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| 2914 | 2912 |
| 2915 // Move focus back to the first edit box. | 2913 // Move focus back to the first edit box. |
| 2916 webViewHelper.webView()->advanceFocus(true); | 2914 webViewHelper.webView()->advanceFocus(true); |
| 2917 // Zoom out slightly. | 2915 // Zoom out slightly. |
| 2918 const float withinToleranceScale = scale * 0.9f; | 2916 const float withinToleranceScale = scale * 0.9f; |
| 2919 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, withinTolera
nceScale); | 2917 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, withinTolera
nceScale); |
| 2920 // Move focus back to the second edit box. | 2918 // Move focus back to the second edit box. |
| 2921 webViewHelper.webView()->advanceFocus(false); | 2919 webViewHelper.webView()->advanceFocus(false); |
| 2922 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2920 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 2923 // The scale should not be adjusted as the zoomed out scale was sufficiently
close to the previously focused scale. | 2921 // The scale should not be adjusted as the zoomed out scale was sufficiently
close to the previously focused scale. |
| 2924 EXPECT_FALSE(needAnimation); | 2922 EXPECT_FALSE(needAnimation); |
| 2925 } | 2923 } |
| 2926 | 2924 |
| 2925 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) |
| 2926 { |
| 2927 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
| 2928 |
| 2929 const bool autoZoomToLegibleScale = true; |
| 2930 const int viewportWidth = 450; |
| 2931 const int viewportHeight = 300; |
| 2932 const float minReadableCaretHeight = 16.0f; |
| 2933 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2934 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); |
| 2935 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); |
| 2936 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2937 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2938 |
| 2939 const WebRect editBoxWithText(200, 200, 250, 20); |
| 2940 |
| 2941 webViewHelper.webView()->advanceFocus(false); |
| 2942 // Set the caret to the begining of the input box. |
| 2943 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(0, 0); |
| 2944 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); |
| 2945 WebRect rect, caret; |
| 2946 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 2947 |
| 2948 // Set the page scale to be twice as large as the minimal readable scale. |
| 2949 float newScale = minReadableCaretHeight / caret.height * 2.0; |
| 2950 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), newS
cale); |
| 2951 |
| 2952 float scale; |
| 2953 IntPoint scroll; |
| 2954 bool needAnimation; |
| 2955 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 2956 EXPECT_TRUE(needAnimation); |
| 2957 // Edit box and caret should be left alinged |
| 2958 int hScroll = editBoxWithText.x; |
| 2959 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2960 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
| 2961 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2962 // Page scale have to be unchanged |
| 2963 EXPECT_EQ(newScale, scale); |
| 2964 |
| 2965 // Set page scale and scroll such that edit box will be under the screen |
| 2966 newScale = 3.0; |
| 2967 hScroll = 200; |
| 2968 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(hScroll, 0)
, newScale); |
| 2969 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 2970 EXPECT_TRUE(needAnimation); |
| 2971 // Horizontal scroll have to be the same |
| 2972 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2973 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig
ht) / 2; |
| 2974 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2975 // Page scale have to be unchanged |
| 2976 EXPECT_EQ(newScale, scale); |
| 2977 } |
| 2978 |
| 2979 // Tests the scroll into view functionality when autoZoomeFocusedNodeToLegibleSc
ale set |
| 2980 // to false. i.e. The path non-Android platforms take. |
| 2981 TEST_F(WebFrameTest, DivScrollIntoEditableTestZoomToLegibleScaleDisabled) |
| 2982 { |
| 2983 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
| 2984 |
| 2985 const bool autoZoomToLegibleScale = false; |
| 2986 int viewportWidth = 100; |
| 2987 int viewportHeight = 100; |
| 2988 float leftBoxRatio = 0.3f; |
| 2989 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2990 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); |
| 2991 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); |
| 2992 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2993 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 4); |
| 2994 |
| 2995 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2996 |
| 2997 WebRect editBoxWithText(200, 200, 250, 20); |
| 2998 WebRect editBoxWithNoText(200, 250, 250, 20); |
| 2999 |
| 3000 // Test scrolling the focused node |
| 3001 // Since we're zoomed out, the caret is considered too small to be legible a
nd so we'd |
| 3002 // normally zoom in. Make sure we don't change scale since the auto-zoom set
ting is off. |
| 3003 |
| 3004 // Focus the second empty textbox. |
| 3005 webViewHelper.webView()->advanceFocus(false); |
| 3006 webViewHelper.webView()->advanceFocus(false); |
| 3007 |
| 3008 // Set the page scale to be smaller than the minimal readable scale. |
| 3009 float initialScale = 0.25f; |
| 3010 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 3011 |
| 3012 float scale; |
| 3013 IntPoint scroll; |
| 3014 bool needAnimation; |
| 3015 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 3016 |
| 3017 // There should be no change in page scale. |
| 3018 EXPECT_EQ(initialScale, scale); |
| 3019 // The edit box should be left aligned with a margin for possible label. |
| 3020 EXPECT_TRUE(needAnimation); |
| 3021 int hScroll = editBoxWithNoText.x - leftBoxRatio * viewportWidth / scale; |
| 3022 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 3023 int vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoT
ext.height) / 2; |
| 3024 EXPECT_NEAR(vScroll, scroll.y(), 2); |
| 3025 |
| 3026 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), scroll, scale); |
| 3027 |
| 3028 // Select the first textbox. |
| 3029 webViewHelper.webView()->advanceFocus(true); |
| 3030 WebRect rect, caret; |
| 3031 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 3032 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), autoZoomToLegibleScale, scale, scroll, needA
nimation); |
| 3033 |
| 3034 // There should be no change at all since the textbox is fully visible alrea
dy. |
| 3035 EXPECT_EQ(initialScale, scale); |
| 3036 EXPECT_FALSE(needAnimation); |
| 3037 } |
| 3038 |
| 2927 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) | 3039 TEST_P(ParameterizedWebFrameTest, CharacterIndexAtPointWithPinchZoom) |
| 2928 { | 3040 { |
| 2929 registerMockedHttpURLLoad("sometext.html"); | 3041 registerMockedHttpURLLoad("sometext.html"); |
| 2930 | 3042 |
| 2931 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3043 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 2932 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); | 3044 webViewHelper.initializeAndLoad(m_baseURL + "sometext.html"); |
| 2933 webViewHelper.webViewImpl()->resize(WebSize(640, 480)); | 3045 webViewHelper.webViewImpl()->resize(WebSize(640, 480)); |
| 2934 webViewHelper.webViewImpl()->layout(); | 3046 webViewHelper.webViewImpl()->layout(); |
| 2935 | 3047 |
| 2936 | 3048 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 WebRect extentRect; | 3081 WebRect extentRect; |
| 2970 | 3082 |
| 2971 WebRect rect; | 3083 WebRect rect; |
| 2972 mainFrame->firstRectForCharacterRange(0, 5, rect); | 3084 mainFrame->firstRectForCharacterRange(0, 5, rect); |
| 2973 | 3085 |
| 2974 EXPECT_EQ((oldRect.x - pinchOffset.x) * scale, rect.x); | 3086 EXPECT_EQ((oldRect.x - pinchOffset.x) * scale, rect.x); |
| 2975 EXPECT_EQ((oldRect.y - pinchOffset.y) * scale, rect.y); | 3087 EXPECT_EQ((oldRect.y - pinchOffset.y) * scale, rect.y); |
| 2976 EXPECT_EQ(oldRect.width*scale, rect.width); | 3088 EXPECT_EQ(oldRect.width*scale, rect.width); |
| 2977 EXPECT_EQ(oldRect.height*scale, rect.height); | 3089 EXPECT_EQ(oldRect.height*scale, rect.height); |
| 2978 } | 3090 } |
| 2979 | |
| 2980 TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest) | |
| 2981 { | |
| 2982 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | |
| 2983 | |
| 2984 const int viewportWidth = 450; | |
| 2985 const int viewportHeight = 300; | |
| 2986 const float minReadableCaretHeight = 16.0f; | |
| 2987 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 2988 webViewHelper.initializeAndLoad(m_baseURL + "get_scale_for_zoom_into_editabl
e_test.html"); | |
| 2989 webViewHelper.webViewImpl()->page()->settings().setTextAutosizingEnabled(fal
se); | |
| 2990 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | |
| 2991 webViewHelper.webView()->setDeviceScaleFactor(1.5f); | |
| 2992 webViewHelper.webView()->layout(); | |
| 2993 webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(tr
ue); | |
| 2994 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); | |
| 2995 | |
| 2996 const WebRect editBoxWithText(200, 200, 250, 20); | |
| 2997 | |
| 2998 webViewHelper.webView()->advanceFocus(false); | |
| 2999 // Set the caret to the begining of the input box. | |
| 3000 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(0, 0); | |
| 3001 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); | |
| 3002 WebRect rect, caret; | |
| 3003 webViewHelper.webViewImpl()->selectionBounds(caret, rect); | |
| 3004 | |
| 3005 // Set the page scale to be twice as large as the minimal readable scale. | |
| 3006 float newScale = minReadableCaretHeight / caret.height * 2.0; | |
| 3007 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), newS
cale); | |
| 3008 | |
| 3009 float scale; | |
| 3010 IntPoint scroll; | |
| 3011 bool needAnimation; | |
| 3012 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | |
| 3013 EXPECT_TRUE(needAnimation); | |
| 3014 // Edit box and caret should be left alinged | |
| 3015 int hScroll = editBoxWithText.x; | |
| 3016 EXPECT_NEAR(hScroll, scroll.x(), 1); | |
| 3017 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; | |
| 3018 EXPECT_NEAR(vScroll, scroll.y(), 1); | |
| 3019 // Page scale have to be unchanged | |
| 3020 EXPECT_EQ(newScale, scale); | |
| 3021 | |
| 3022 // Set page scale and scroll such that edit box will be under the screen | |
| 3023 newScale = 3.0; | |
| 3024 hScroll = 200; | |
| 3025 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(hScroll, 0)
, newScale); | |
| 3026 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | |
| 3027 EXPECT_TRUE(needAnimation); | |
| 3028 // Horizontal scroll have to be the same | |
| 3029 EXPECT_NEAR(hScroll, scroll.x(), 1); | |
| 3030 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig
ht) / 2; | |
| 3031 EXPECT_NEAR(vScroll, scroll.y(), 1); | |
| 3032 // Page scale have to be unchanged | |
| 3033 EXPECT_EQ(newScale, scale); | |
| 3034 } | |
| 3035 | |
| 3036 class TestReloadDoesntRedirectWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { | 3091 class TestReloadDoesntRedirectWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { |
| 3037 public: | 3092 public: |
| 3038 virtual WebNavigationPolicy decidePolicyForNavigation(const NavigationPolicy
Info& info) override | 3093 virtual WebNavigationPolicy decidePolicyForNavigation(const NavigationPolicy
Info& info) override |
| 3039 { | 3094 { |
| 3040 EXPECT_FALSE(info.isRedirect); | 3095 EXPECT_FALSE(info.isRedirect); |
| 3041 return WebNavigationPolicyCurrentTab; | 3096 return WebNavigationPolicyCurrentTab; |
| 3042 } | 3097 } |
| 3043 }; | 3098 }; |
| 3044 | 3099 |
| 3045 TEST_P(ParameterizedWebFrameTest, ReloadDoesntSetRedirect) | 3100 TEST_P(ParameterizedWebFrameTest, ReloadDoesntSetRedirect) |
| (...skipping 4689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7735 | 7790 |
| 7736 TEST_F(WebFrameTest, MaxFramesDetach) | 7791 TEST_F(WebFrameTest, MaxFramesDetach) |
| 7737 { | 7792 { |
| 7738 registerMockedHttpURLLoad("max-frames-detach.html"); | 7793 registerMockedHttpURLLoad("max-frames-detach.html"); |
| 7739 FrameTestHelpers::WebViewHelper webViewHelper; | 7794 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7740 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); | 7795 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); |
| 7741 webViewImpl->mainFrameImpl()->collectGarbage(); | 7796 webViewImpl->mainFrameImpl()->collectGarbage(); |
| 7742 } | 7797 } |
| 7743 | 7798 |
| 7744 } // namespace blink | 7799 } // namespace blink |
| OLD | NEW |