| 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 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 static WebRect ExpectedRootBounds(WebCore::Document* document, float scaleFactor
) | 1657 static WebRect ExpectedRootBounds(WebCore::Document* document, float scaleFactor
) |
| 1658 { | 1658 { |
| 1659 WebCore::Element* element = document->getElementById("root"); | 1659 WebCore::Element* element = document->getElementById("root"); |
| 1660 if (!element) | 1660 if (!element) |
| 1661 element = document->getElementById("target"); | 1661 element = document->getElementById("target"); |
| 1662 if (element->hasTagName(WebCore::HTMLNames::iframeTag)) | 1662 if (element->hasTagName(WebCore::HTMLNames::iframeTag)) |
| 1663 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument(
), scaleFactor); | 1663 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument(
), scaleFactor); |
| 1664 | 1664 |
| 1665 WebCore::IntRect boundingBox = element->pixelSnappedBoundingBox(); | 1665 WebCore::IntRect boundingBox; |
| 1666 if (element->hasTagName(WebCore::HTMLNames::htmlTag)) |
| 1667 boundingBox = WebCore::IntRect(WebCore::IntPoint(0, 0), document->frame(
)->view()->contentsSize()); |
| 1668 else |
| 1669 boundingBox = element->pixelSnappedBoundingBox(); |
| 1666 boundingBox = document->frame()->view()->contentsToWindow(boundingBox); | 1670 boundingBox = document->frame()->view()->contentsToWindow(boundingBox); |
| 1667 boundingBox.scale(scaleFactor); | 1671 boundingBox.scale(scaleFactor); |
| 1668 return boundingBox; | 1672 return boundingBox; |
| 1669 } | 1673 } |
| 1670 | 1674 |
| 1671 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
actor) | 1675 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
actor) |
| 1672 { | 1676 { |
| 1673 std::string url = m_baseURL + htmlFile; | 1677 std::string url = m_baseURL + htmlFile; |
| 1674 | 1678 |
| 1675 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 1679 WebView* webView = m_webViewHelper.initializeAndLoad(url, true); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 testSelectionRootBounds("select_range_iframe_textarea.html", 1.0f); | 1739 testSelectionRootBounds("select_range_iframe_textarea.html", 1.0f); |
| 1736 testSelectionRootBounds("select_range_iframe_textarea_overflow.html", 1.0f); | 1740 testSelectionRootBounds("select_range_iframe_textarea_overflow.html", 1.0f); |
| 1737 | 1741 |
| 1738 // Basic page with scale factor. | 1742 // Basic page with scale factor. |
| 1739 testSelectionRootBounds("select_range_basic.html", 0.0f); | 1743 testSelectionRootBounds("select_range_basic.html", 0.0f); |
| 1740 testSelectionRootBounds("select_range_basic.html", 0.1f); | 1744 testSelectionRootBounds("select_range_basic.html", 0.1f); |
| 1741 testSelectionRootBounds("select_range_basic.html", 1.5f); | 1745 testSelectionRootBounds("select_range_basic.html", 1.5f); |
| 1742 testSelectionRootBounds("select_range_basic.html", 2.0f); | 1746 testSelectionRootBounds("select_range_basic.html", 2.0f); |
| 1743 } | 1747 } |
| 1744 | 1748 |
| 1749 TEST_F(WebViewTest, GetSelectionRootBoundsBrokenHeight) |
| 1750 { |
| 1751 WebSize contentSize = WebSize(640, 480); |
| 1752 |
| 1753 registerMockedHttpURLLoad("select_range_basic_broken_height.html"); |
| 1754 |
| 1755 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "select_ran
ge_basic_broken_height.html", true); |
| 1756 webView->resize(contentSize); |
| 1757 webView->setPageScaleFactor(1.0f, WebPoint(0, 0)); |
| 1758 webView->layout(); |
| 1759 runPendingTasks(); |
| 1760 |
| 1761 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 1762 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); |
| 1763 |
| 1764 WebRect expectedRootBounds = WebRect(0, 0, contentSize.width, contentSize.he
ight); |
| 1765 WebRect actualRootBounds; |
| 1766 webView->getSelectionRootBounds(actualRootBounds); |
| 1767 ASSERT_EQ(expectedRootBounds, actualRootBounds); |
| 1768 } |
| 1769 |
| 1745 class NonUserInputTextUpdateWebViewClient : public WebViewClient { | 1770 class NonUserInputTextUpdateWebViewClient : public WebViewClient { |
| 1746 public: | 1771 public: |
| 1747 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } | 1772 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } |
| 1748 | 1773 |
| 1749 // WebWidgetClient methods | 1774 // WebWidgetClient methods |
| 1750 virtual void didUpdateTextOfFocusedElementByNonUserInput() OVERRIDE | 1775 virtual void didUpdateTextOfFocusedElementByNonUserInput() OVERRIDE |
| 1751 { | 1776 { |
| 1752 m_textIsUpdated = true; | 1777 m_textIsUpdated = true; |
| 1753 } | 1778 } |
| 1754 | 1779 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 client.reset(); | 1865 client.reset(); |
| 1841 EXPECT_FALSE(client.textIsUpdated()); | 1866 EXPECT_FALSE(client.textIsUpdated()); |
| 1842 document->setFocusedElement(nullptr); | 1867 document->setFocusedElement(nullptr); |
| 1843 webViewImpl->setFocus(false); | 1868 webViewImpl->setFocus(false); |
| 1844 EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
aElement)); | 1869 EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
aElement)); |
| 1845 inputElement->setValue("testB3"); | 1870 inputElement->setValue("testB3"); |
| 1846 EXPECT_FALSE(client.textIsUpdated()); | 1871 EXPECT_FALSE(client.textIsUpdated()); |
| 1847 } | 1872 } |
| 1848 | 1873 |
| 1849 } // namespace | 1874 } // namespace |
| OLD | NEW |