| 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 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); | 2270 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
| 2271 EXPECT_TRUE(view->layoutView()->compositor()->layerForHorizontalScrollbar())
; | 2271 EXPECT_TRUE(view->layoutView()->compositor()->layerForHorizontalScrollbar())
; |
| 2272 EXPECT_TRUE(view->layoutView()->compositor()->layerForVerticalScrollbar()); | 2272 EXPECT_TRUE(view->layoutView()->compositor()->layerForVerticalScrollbar()); |
| 2273 | 2273 |
| 2274 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); | 2274 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); |
| 2275 webViewHelper.webView()->layout(); | 2275 webViewHelper.webView()->layout(); |
| 2276 EXPECT_FALSE(view->layoutView()->compositor()->layerForHorizontalScrollbar()
); | 2276 EXPECT_FALSE(view->layoutView()->compositor()->layerForHorizontalScrollbar()
); |
| 2277 EXPECT_FALSE(view->layoutView()->compositor()->layerForVerticalScrollbar()); | 2277 EXPECT_FALSE(view->layoutView()->compositor()->layerForVerticalScrollbar()); |
| 2278 } | 2278 } |
| 2279 | 2279 |
| 2280 void setScaleAndScrollAndLayout(WebView* webView, WebPoint scroll, float scale) | 2280 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca
le) |
| 2281 { | 2281 { |
| 2282 webView->setPageScaleFactor(scale); | 2282 webView->setPageScaleFactor(scale); |
| 2283 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); | 2283 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); |
| 2284 webView->layout(); | 2284 webView->layout(); |
| 2285 } | 2285 } |
| 2286 | 2286 |
| 2287 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2287 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
| 2288 { | 2288 { |
| 2289 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 2289 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 2290 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | 2290 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 2777 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2778 | 2778 |
| 2779 WebRect editBoxWithText(200, 200, 250, 20); | 2779 WebRect editBoxWithText(200, 200, 250, 20); |
| 2780 WebRect editBoxWithNoText(200, 250, 250, 20); | 2780 WebRect editBoxWithNoText(200, 250, 250, 20); |
| 2781 | 2781 |
| 2782 // Test scrolling the focused node | 2782 // Test scrolling the focused node |
| 2783 // The edit box is shorter and narrower than the viewport when legible. | 2783 // The edit box is shorter and narrower than the viewport when legible. |
| 2784 webViewHelper.webView()->advanceFocus(false); | 2784 webViewHelper.webView()->advanceFocus(false); |
| 2785 // Set the caret to the end of the input box. | 2785 // Set the caret to the end of the input box. |
| 2786 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); | 2786 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(1000, 1000); |
| 2787 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); | 2787 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); |
| 2788 WebRect rect, caret; | 2788 WebRect rect, caret; |
| 2789 webViewHelper.webViewImpl()->selectionBounds(caret, rect); | 2789 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 2790 | 2790 |
| 2791 // Set the page scale to be smaller than the minimal readable scale. | 2791 // Set the page scale to be smaller than the minimal readable scale. |
| 2792 float initialScale = minReadableCaretHeight / caret.height * 0.5f; | 2792 float initialScale = minReadableCaretHeight / caret.height * 0.5f; |
| 2793 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS
cale); | 2793 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 2794 | 2794 |
| 2795 float scale; | 2795 float scale; |
| 2796 IntPoint scroll; | 2796 IntPoint scroll; |
| 2797 bool needAnimation; | 2797 bool needAnimation; |
| 2798 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2798 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2799 EXPECT_TRUE(needAnimation); | 2799 EXPECT_TRUE(needAnimation); |
| 2800 // The edit box should be left aligned with a margin for possible label. | 2800 // The edit box should be left aligned with a margin for possible label. |
| 2801 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; | 2801 int hScroll = editBoxWithText.x - leftBoxRatio * viewportWidth / scale; |
| 2802 EXPECT_NEAR(hScroll, scroll.x(), 2); | 2802 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 2803 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; | 2803 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
| 2804 EXPECT_NEAR(vScroll, scroll.y(), 2); | 2804 EXPECT_NEAR(vScroll, scroll.y(), 2); |
| 2805 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2805 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| 2806 | 2806 |
| 2807 // The edit box is wider than the viewport when legible. | 2807 // The edit box is wider than the viewport when legible. |
| 2808 viewportWidth = 200; | 2808 viewportWidth = 200; |
| 2809 viewportHeight = 150; | 2809 viewportHeight = 150; |
| 2810 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 2810 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 2811 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS
cale); | 2811 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 2812 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2812 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2813 EXPECT_TRUE(needAnimation); | 2813 EXPECT_TRUE(needAnimation); |
| 2814 // The caret should be right aligned since the caret would be offscreen when
the edit box is left aligned. | 2814 // The caret should be right aligned since the caret would be offscreen when
the edit box is left aligned. |
| 2815 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; | 2815 hScroll = caret.x + caret.width + caretPadding - viewportWidth / scale; |
| 2816 EXPECT_NEAR(hScroll, scroll.x(), 2); | 2816 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 2817 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2817 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| 2818 | 2818 |
| 2819 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), initialS
cale); | 2819 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), init
ialScale); |
| 2820 // Move focus to edit box with text. | 2820 // Move focus to edit box with text. |
| 2821 webViewHelper.webView()->advanceFocus(false); | 2821 webViewHelper.webView()->advanceFocus(false); |
| 2822 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2822 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2823 EXPECT_TRUE(needAnimation); | 2823 EXPECT_TRUE(needAnimation); |
| 2824 // The edit box should be left aligned. | 2824 // The edit box should be left aligned. |
| 2825 hScroll = editBoxWithNoText.x; | 2825 hScroll = editBoxWithNoText.x; |
| 2826 EXPECT_NEAR(hScroll, scroll.x(), 2); | 2826 EXPECT_NEAR(hScroll, scroll.x(), 2); |
| 2827 vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoText.
height) / 2; | 2827 vScroll = editBoxWithNoText.y - (viewportHeight / scale - editBoxWithNoText.
height) / 2; |
| 2828 EXPECT_NEAR(vScroll, scroll.y(), 2); | 2828 EXPECT_NEAR(vScroll, scroll.y(), 2); |
| 2829 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); | 2829 EXPECT_NEAR(minReadableCaretHeight / caret.height, scale, 0.1); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2907 webViewHelper.webView()->setDeviceScaleFactor(1.5f); | 2907 webViewHelper.webView()->setDeviceScaleFactor(1.5f); |
| 2908 webViewHelper.webView()->layout(); | 2908 webViewHelper.webView()->layout(); |
| 2909 webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(tr
ue); | 2909 webViewHelper.webView()->settings()->setAutoZoomFocusedNodeToLegibleScale(tr
ue); |
| 2910 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); | 2910 webViewHelper.webViewImpl()->enableFakePageScaleAnimationForTesting(true); |
| 2911 | 2911 |
| 2912 const WebRect editBoxWithText(200, 200, 250, 20); | 2912 const WebRect editBoxWithText(200, 200, 250, 20); |
| 2913 | 2913 |
| 2914 webViewHelper.webView()->advanceFocus(false); | 2914 webViewHelper.webView()->advanceFocus(false); |
| 2915 // Set the caret to the begining of the input box. | 2915 // Set the caret to the begining of the input box. |
| 2916 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(0, 0); | 2916 webViewHelper.webView()->mainFrame()->document().getElementById("EditBoxWith
Text").to<WebInputElement>().setSelectionRange(0, 0); |
| 2917 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), 1); | 2917 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), 1); |
| 2918 WebRect rect, caret; | 2918 WebRect rect, caret; |
| 2919 webViewHelper.webViewImpl()->selectionBounds(caret, rect); | 2919 webViewHelper.webViewImpl()->selectionBounds(caret, rect); |
| 2920 | 2920 |
| 2921 // Set the page scale to be twice as large as the minimal readable scale. | 2921 // Set the page scale to be twice as large as the minimal readable scale. |
| 2922 float newScale = minReadableCaretHeight / caret.height * 2.0; | 2922 float newScale = minReadableCaretHeight / caret.height * 2.0; |
| 2923 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(0, 0), newScale
); | 2923 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(0, 0), newS
cale); |
| 2924 | 2924 |
| 2925 float scale; | 2925 float scale; |
| 2926 IntPoint scroll; | 2926 IntPoint scroll; |
| 2927 bool needAnimation; | 2927 bool needAnimation; |
| 2928 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2928 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2929 EXPECT_TRUE(needAnimation); | 2929 EXPECT_TRUE(needAnimation); |
| 2930 // Edit box and caret should be left alinged | 2930 // Edit box and caret should be left alinged |
| 2931 int hScroll = editBoxWithText.x; | 2931 int hScroll = editBoxWithText.x; |
| 2932 EXPECT_NEAR(hScroll, scroll.x(), 1); | 2932 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2933 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; | 2933 int vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.
height) / 2; |
| 2934 EXPECT_NEAR(vScroll, scroll.y(), 1); | 2934 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2935 // Page scale have to be unchanged | 2935 // Page scale have to be unchanged |
| 2936 EXPECT_EQ(newScale, scale); | 2936 EXPECT_EQ(newScale, scale); |
| 2937 | 2937 |
| 2938 // Set page scale and scroll such that edit box will be under the screen | 2938 // Set page scale and scroll such that edit box will be under the screen |
| 2939 newScale = 3.0; | 2939 newScale = 3.0; |
| 2940 hScroll = 200; | 2940 hScroll = 200; |
| 2941 setScaleAndScrollAndLayout(webViewHelper.webView(), WebPoint(hScroll, 0), ne
wScale); | 2941 setScaleAndScrollAndLayout(webViewHelper.webViewImpl(), WebPoint(hScroll, 0)
, newScale); |
| 2942 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2942 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
| 2943 EXPECT_TRUE(needAnimation); | 2943 EXPECT_TRUE(needAnimation); |
| 2944 // Horizontal scroll have to be the same | 2944 // Horizontal scroll have to be the same |
| 2945 EXPECT_NEAR(hScroll, scroll.x(), 1); | 2945 EXPECT_NEAR(hScroll, scroll.x(), 1); |
| 2946 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig
ht) / 2; | 2946 vScroll = editBoxWithText.y - (viewportHeight / scale - editBoxWithText.heig
ht) / 2; |
| 2947 EXPECT_NEAR(vScroll, scroll.y(), 1); | 2947 EXPECT_NEAR(vScroll, scroll.y(), 1); |
| 2948 // Page scale have to be unchanged | 2948 // Page scale have to be unchanged |
| 2949 EXPECT_EQ(newScale, scale); | 2949 EXPECT_EQ(newScale, scale); |
| 2950 } | 2950 } |
| 2951 | 2951 |
| (...skipping 4383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7335 | 7335 |
| 7336 EXPECT_EQ(parent, firstFrame->parent()); | 7336 EXPECT_EQ(parent, firstFrame->parent()); |
| 7337 EXPECT_EQ(parent, secondFrame->parent()); | 7337 EXPECT_EQ(parent, secondFrame->parent()); |
| 7338 EXPECT_EQ(parent, thirdFrame->parent()); | 7338 EXPECT_EQ(parent, thirdFrame->parent()); |
| 7339 EXPECT_EQ(parent, fourthFrame->parent()); | 7339 EXPECT_EQ(parent, fourthFrame->parent()); |
| 7340 | 7340 |
| 7341 view->close(); | 7341 view->close(); |
| 7342 } | 7342 } |
| 7343 | 7343 |
| 7344 } // namespace blink | 7344 } // namespace blink |
| OLD | NEW |