OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 webViewImpl->resize(WebSize(640, 480)); | 722 webViewImpl->resize(WebSize(640, 480)); |
723 webViewImpl->layout(); | 723 webViewImpl->layout(); |
724 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 724 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
725 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 725 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
726 | 726 |
727 // Make the page scale and scroll with the given paremeters. | 727 // Make the page scale and scroll with the given paremeters. |
728 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); | 728 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); |
729 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 729 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
730 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 730 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
731 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 731 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
732 webViewImpl->page()->mainFrame()->loader().history()->saveDocumentAndScrollS
tate(); | 732 webViewImpl->page()->history()->saveDocumentAndScrollState(webViewImpl->page
()->mainFrame()); |
733 | 733 |
734 // Confirm that restoring the page state restores the parameters. | 734 // Confirm that restoring the page state restores the parameters. |
735 webViewImpl->setPageScaleFactor(1.5f, WebPoint(16, 24)); | 735 webViewImpl->setPageScaleFactor(1.5f, WebPoint(16, 24)); |
736 EXPECT_EQ(1.5f, webViewImpl->pageScaleFactor()); | 736 EXPECT_EQ(1.5f, webViewImpl->pageScaleFactor()); |
737 EXPECT_EQ(16, webViewImpl->mainFrame()->scrollOffset().width); | 737 EXPECT_EQ(16, webViewImpl->mainFrame()->scrollOffset().width); |
738 EXPECT_EQ(24, webViewImpl->mainFrame()->scrollOffset().height); | 738 EXPECT_EQ(24, webViewImpl->mainFrame()->scrollOffset().height); |
739 // WebViewImpl::setPageScaleFactor is performing user scrolls, which will se
t the | 739 // WebViewImpl::setPageScaleFactor is performing user scrolls, which will se
t the |
740 // wasScrolledByUser flag on the main frame, and prevent restoreScrollPositi
onAndViewState | 740 // wasScrolledByUser flag on the main frame, and prevent restoreScrollPositi
onAndViewState |
741 // from restoring the scrolling position. | 741 // from restoring the scrolling position. |
742 webViewImpl->page()->mainFrame()->view()->setWasScrolledByUser(false); | 742 webViewImpl->page()->mainFrame()->view()->setWasScrolledByUser(false); |
743 webViewImpl->page()->mainFrame()->loader().history()->restoreScrollPositionA
ndViewState(); | 743 webViewImpl->page()->history()->restoreScrollPositionAndViewState(webViewImp
l->page()->mainFrame()); |
744 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 744 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
745 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 745 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
746 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 746 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
747 webViewImpl->page()->mainFrame()->loader().history()->saveDocumentAndScrollS
tate(); | 747 webViewImpl->page()->history()->saveDocumentAndScrollState(webViewImpl->page
()->mainFrame()); |
748 | 748 |
749 // Confirm that resetting the page state resets the saved scroll position. | 749 // Confirm that resetting the page state resets the saved scroll position. |
750 // The HistoryController treats a page scale factor of 0.0f as special and a
voids | 750 // The HistoryController treats a page scale factor of 0.0f as special and a
voids |
751 // restoring it to the WebView. | 751 // restoring it to the WebView. |
752 webViewImpl->resetScrollAndScaleState(); | 752 webViewImpl->resetScrollAndScaleState(); |
753 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 753 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
754 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 754 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
755 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 755 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
756 webViewImpl->page()->mainFrame()->loader().history()->restoreScrollPositionA
ndViewState(); | 756 webViewImpl->page()->history()->restoreScrollPositionAndViewState(webViewImp
l->page()->mainFrame()); |
757 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 757 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
758 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 758 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
759 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 759 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
760 } | 760 } |
761 | 761 |
762 class EnterFullscreenWebViewClient : public WebViewClient { | 762 class EnterFullscreenWebViewClient : public WebViewClient { |
763 public: | 763 public: |
764 // WebViewClient methods | 764 // WebViewClient methods |
765 virtual bool enterFullScreen() { return true; } | 765 virtual bool enterFullScreen() { return true; } |
766 virtual void exitFullScreen() { } | 766 virtual void exitFullScreen() { } |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 | 1231 |
1232 webView->setFocus(true); | 1232 webView->setFocus(true); |
1233 webView->setFocus(false); | 1233 webView->setFocus(false); |
1234 webView->setFocus(true); | 1234 webView->setFocus(true); |
1235 | 1235 |
1236 WebElement element = webView->mainFrame()->document().getElementById("messag
e"); | 1236 WebElement element = webView->mainFrame()->document().getElementById("messag
e"); |
1237 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); | 1237 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); |
1238 } | 1238 } |
1239 | 1239 |
1240 } | 1240 } |
OLD | NEW |