| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 348     webView->resize(WebSize(100, 100)); | 348     webView->resize(WebSize(100, 100)); | 
| 349     WebPoint hitPoint(75, 75); | 349     WebPoint hitPoint(75, 75); | 
| 350 | 350 | 
| 351     // Image is at top left quandrant, so should not hit it. | 351     // Image is at top left quandrant, so should not hit it. | 
| 352     WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); | 352     WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); | 
| 353     ASSERT_EQ(WebNode::ElementNode, negativeResult.node().nodeType()); | 353     ASSERT_EQ(WebNode::ElementNode, negativeResult.node().nodeType()); | 
| 354     EXPECT_FALSE(negativeResult.node().to<WebElement>().hasTagName("img")); | 354     EXPECT_FALSE(negativeResult.node().to<WebElement>().hasTagName("img")); | 
| 355     negativeResult.reset(); | 355     negativeResult.reset(); | 
| 356 | 356 | 
| 357     // Scale page up 2x so image should occupy the whole viewport. | 357     // Scale page up 2x so image should occupy the whole viewport. | 
| 358     webView->setPageScaleFactor(2.0f, WebPoint(0, 0)); | 358     webView->setPinchViewportScaleFactor(2.0f); | 
| 359     WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); | 359     WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); | 
| 360     ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); | 360     ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); | 
| 361     EXPECT_TRUE(positiveResult.node().to<WebElement>().hasTagName("img")); | 361     EXPECT_TRUE(positiveResult.node().to<WebElement>().hasTagName("img")); | 
| 362     positiveResult.reset(); | 362     positiveResult.reset(); | 
| 363 } | 363 } | 
| 364 | 364 | 
| 365 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
      xAutoResize, | 365 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
      xAutoResize, | 
| 366                                  const std::string& pageWidth, const std::string
      & pageHeight, | 366                                  const std::string& pageWidth, const std::string
      & pageHeight, | 
| 367                                  int expectedWidth, int expectedHeight, | 367                                  int expectedWidth, int expectedHeight, | 
| 368                                  HorizontalScrollbarState expectedHorizontalStat
      e, VerticalScrollbarState expectedVerticalState) | 368                                  HorizontalScrollbarState expectedHorizontalStat
      e, VerticalScrollbarState expectedVerticalState) | 
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 774 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) | 774 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) | 
| 775 { | 775 { | 
| 776     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 776     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 
| 777     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html"); | 777     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html"); | 
| 778     webViewImpl->resize(WebSize(640, 480)); | 778     webViewImpl->resize(WebSize(640, 480)); | 
| 779     webViewImpl->layout(); | 779     webViewImpl->layout(); | 
| 780     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 780     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 
| 781     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 781     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 
| 782 | 782 | 
| 783     // Make the page scale and scroll with the given paremeters. | 783     // Make the page scale and scroll with the given paremeters. | 
| 784     webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); | 784     webViewImpl->setPinchViewportScaleFactor(2.0f); | 
|  | 785     webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); | 
| 785     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 786     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 
| 786     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 787     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 
| 787     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 788     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 
| 788     webViewImpl->page()->mainFrame()->loader().saveScrollState(); | 789     webViewImpl->page()->mainFrame()->loader().saveScrollState(); | 
| 789     EXPECT_EQ(2.0f, webViewImpl->page()->mainFrame()->loader().currentItem()->pa
      geScaleFactor()); | 790     EXPECT_EQ(2.0f, webViewImpl->page()->mainFrame()->loader().currentItem()->pa
      geScaleFactor()); | 
| 790     EXPECT_EQ(116, webViewImpl->page()->mainFrame()->loader().currentItem()->scr
      ollPoint().x()); | 791     EXPECT_EQ(116, webViewImpl->page()->mainFrame()->loader().currentItem()->scr
      ollPoint().x()); | 
| 791     EXPECT_EQ(84, webViewImpl->page()->mainFrame()->loader().currentItem()->scro
      llPoint().y()); | 792     EXPECT_EQ(84, webViewImpl->page()->mainFrame()->loader().currentItem()->scro
      llPoint().y()); | 
| 792 | 793 | 
| 793     // Confirm that resetting the page state resets the saved scroll position. | 794     // Confirm that resetting the page state resets the saved scroll position. | 
| 794     // The HistoryController treats a page scale factor of 0.0f as special and a
      voids | 795     // The HistoryController treats a page scale factor of 0.0f as special and a
      voids | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 814 { | 815 { | 
| 815     EnterFullscreenWebViewClient client; | 816     EnterFullscreenWebViewClient client; | 
| 816     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 817     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 
| 817     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html", true, 0, &client); | 818     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html", true, 0, &client); | 
| 818     webViewImpl->resize(WebSize(640, 480)); | 819     webViewImpl->resize(WebSize(640, 480)); | 
| 819     webViewImpl->layout(); | 820     webViewImpl->layout(); | 
| 820     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 821     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 
| 821     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 822     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 
| 822 | 823 | 
| 823     // Make the page scale and scroll with the given paremeters. | 824     // Make the page scale and scroll with the given paremeters. | 
| 824     webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); | 825     webViewImpl->setPinchViewportScaleFactor(2.0f); | 
|  | 826     webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); | 
| 825     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 827     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 
| 826     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 828     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 
| 827     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 829     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 
| 828 | 830 | 
| 829     RefPtr<WebCore::Element> element = static_cast<PassRefPtr<WebCore::Element> 
      >(webViewImpl->mainFrame()->document().body()); | 831     RefPtr<WebCore::Element> element = static_cast<PassRefPtr<WebCore::Element> 
      >(webViewImpl->mainFrame()->document().body()); | 
| 830     webViewImpl->enterFullScreenForElement(element.get()); | 832     webViewImpl->enterFullScreenForElement(element.get()); | 
| 831     webViewImpl->willEnterFullScreen(); | 833     webViewImpl->willEnterFullScreen(); | 
| 832     webViewImpl->didEnterFullScreen(); | 834     webViewImpl->didEnterFullScreen(); | 
| 833 | 835 | 
| 834     // Page scale factor must be 1.0 during fullscreen for elements to be sized | 836     // Page scale factor must be 1.0 during fullscreen for elements to be sized | 
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1667     boundingBox.scale(scaleFactor); | 1669     boundingBox.scale(scaleFactor); | 
| 1668     return boundingBox; | 1670     return boundingBox; | 
| 1669 } | 1671 } | 
| 1670 | 1672 | 
| 1671 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
      actor) | 1673 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
      actor) | 
| 1672 { | 1674 { | 
| 1673     std::string url = m_baseURL + htmlFile; | 1675     std::string url = m_baseURL + htmlFile; | 
| 1674 | 1676 | 
| 1675     WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 1677     WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 
| 1676     webView->resize(WebSize(640, 480)); | 1678     webView->resize(WebSize(640, 480)); | 
| 1677     webView->setPageScaleFactor(pageScaleFactor, WebPoint(0, 0)); | 1679     webView->setPinchViewportScaleFactor(pageScaleFactor); | 
| 1678     webView->layout(); | 1680     webView->layout(); | 
| 1679     runPendingTasks(); | 1681     runPendingTasks(); | 
| 1680 | 1682 | 
| 1681     WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); | 1683     WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); | 
| 1682     EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 1684     EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 
| 1683     WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
      cument()); | 1685     WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
      cument()); | 
| 1684 | 1686 | 
| 1685     WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
      Factor()); | 1687     WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
      Factor()); | 
| 1686     WebRect actualRootBounds; | 1688     WebRect actualRootBounds; | 
| 1687     webView->getSelectionRootBounds(actualRootBounds); | 1689     webView->getSelectionRootBounds(actualRootBounds); | 
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1840     client.reset(); | 1842     client.reset(); | 
| 1841     EXPECT_FALSE(client.textIsUpdated()); | 1843     EXPECT_FALSE(client.textIsUpdated()); | 
| 1842     document->setFocusedElement(nullptr); | 1844     document->setFocusedElement(nullptr); | 
| 1843     webViewImpl->setFocus(false); | 1845     webViewImpl->setFocus(false); | 
| 1844     EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
      aElement)); | 1846     EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
      aElement)); | 
| 1845     inputElement->setValue("testB3"); | 1847     inputElement->setValue("testB3"); | 
| 1846     EXPECT_FALSE(client.textIsUpdated()); | 1848     EXPECT_FALSE(client.textIsUpdated()); | 
| 1847 } | 1849 } | 
| 1848 | 1850 | 
| 1849 } // namespace | 1851 } // namespace | 
| OLD | NEW | 
|---|