Chromium Code Reviews| 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 10815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10826 document->frame()->eventHandler().handleMouseMoveEvent( | 10826 document->frame()->eventHandler().handleMouseMoveEvent( | 
| 10827 mouseMoveEvent, Vector<WebMouseEvent>()); | 10827 mouseMoveEvent, Vector<WebMouseEvent>()); | 
| 10828 | 10828 | 
| 10829 EXPECT_EQ(document->hoverNode(), | 10829 EXPECT_EQ(document->hoverNode(), | 
| 10830 document->frame()->chromeClient().lastSetTooltipNodeForTesting()); | 10830 document->frame()->chromeClient().lastSetTooltipNodeForTesting()); | 
| 10831 EXPECT_EQ(div2Tag, | 10831 EXPECT_EQ(div2Tag, | 
| 10832 document->frame()->chromeClient().lastSetTooltipNodeForTesting()); | 10832 document->frame()->chromeClient().lastSetTooltipNodeForTesting()); | 
| 10833 } | 10833 } | 
| 10834 | 10834 | 
| 10835 // Makes sure that mouse hover over an overlay scrollbar doesn't activate | 10835 // Makes sure that mouse hover over an overlay scrollbar doesn't activate | 
| 10836 // elements below unless the scrollbar is faded out. | 10836 // elements below(except the Element that owns the scrollbar) unless the | 
| 10837 // scrollbar is faded out. | |
| 10837 TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { | 10838 TEST_F(WebFrameTest, MouseOverLinkAndOverlayScrollbar) { | 
| 10838 FrameTestHelpers::WebViewHelper webViewHelper; | 10839 FrameTestHelpers::WebViewHelper webViewHelper; | 
| 10839 webViewHelper.initialize(true, nullptr, nullptr, nullptr, | 10840 webViewHelper.initialize(true, nullptr, nullptr, nullptr, | 
| 10840 [](WebSettings* settings) {}); | 10841 [](WebSettings* settings) {}); | 
| 10841 webViewHelper.resize(WebSize(20, 20)); | 10842 webViewHelper.resize(WebSize(20, 20)); | 
| 10842 WebViewImpl* webView = webViewHelper.webView(); | 10843 WebViewImpl* webView = webViewHelper.webView(); | 
| 10843 | 10844 | 
| 10844 initializeWithHTML(*webView->mainFrameImpl()->frame(), | 10845 initializeWithHTML(*webView->mainFrameImpl()->frame(), | 
| 10845 "<!DOCTYPE html>" | 10846 "<!DOCTYPE html>" | 
| 10846 "<a id='a' href='javascript:void(0);'>" | 10847 "<a id='a' href='javascript:void(0);'>" | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10988 TimeTicks::Now().InSeconds()); | 10989 TimeTicks::Now().InSeconds()); | 
| 10989 mouseMoveOverDivAndScrollbar.setFrameScale(1); | 10990 mouseMoveOverDivAndScrollbar.setFrameScale(1); | 
| 10990 document->frame()->eventHandler().handleMouseMoveEvent( | 10991 document->frame()->eventHandler().handleMouseMoveEvent( | 
| 10991 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); | 10992 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); | 
| 10992 | 10993 | 
| 10993 // Custom not change the DIV :hover | 10994 // Custom not change the DIV :hover | 
| 10994 EXPECT_EQ(document->hoverNode(), scrollbarDiv); | 10995 EXPECT_EQ(document->hoverNode(), scrollbarDiv); | 
| 10995 EXPECT_EQ(hitTestResult.scrollbar()->hoveredPart(), ScrollbarPart::ThumbPart); | 10996 EXPECT_EQ(hitTestResult.scrollbar()->hoveredPart(), ScrollbarPart::ThumbPart); | 
| 10996 } | 10997 } | 
| 10997 | 10998 | 
| 10999 // Makes sure that mouse hover over a scrollbar also hover the element owns the | |
| 11000 // scrollbar. | |
| 11001 TEST_F(WebFrameTest, MouseOverScrollbarAndParentElement) { | |
| 11002 registerMockedHttpURLLoad("scrollbar-and-element-hover.html"); | |
| 11003 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 11004 WebViewImpl* webView = webViewHelper.initializeAndLoad( | |
| 11005 m_baseURL + "scrollbar-and-element-hover.html", true); | |
| 11006 | |
| 11007 webViewHelper.resize(WebSize(200, 200)); | |
| 11008 | |
| 11009 webView->updateAllLifecyclePhases(); | |
| 11010 | |
| 11011 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | |
| 11012 Document* document = toLocalFrame(webView->page()->mainFrame())->document(); | |
| 11013 | |
| 11014 Element* parentDiv = document->getElementById("parent"); | |
| 11015 EXPECT_TRUE(parentDiv); | |
| 11016 | |
| 11017 ScrollableArea* scrollableArea = | |
| 11018 toLayoutBox(parentDiv->layoutObject())->getScrollableArea(); | |
| 11019 | |
| 11020 EXPECT_TRUE(scrollableArea->verticalScrollbar()); | |
| 11021 | |
| 11022 // Ensure hittest only has DIV. | |
| 11023 HitTestResult hitTestResult = webView->coreHitTestResultAt(WebPoint(1, 1)); | |
| 11024 | |
| 11025 EXPECT_TRUE(hitTestResult.innerElement()); | |
| 11026 EXPECT_FALSE(hitTestResult.scrollbar()); | |
| 11027 | |
| 11028 // Mouse over DIV. | |
| 11029 WebMouseEvent mouseMoveOverDiv( | |
| 11030 WebInputEvent::MouseMove, WebFloatPoint(1, 1), WebFloatPoint(1, 1), | |
| 11031 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, | |
| 11032 TimeTicks::Now().InSeconds()); | |
| 11033 mouseMoveOverDiv.setFrameScale(1); | |
| 11034 document->frame()->eventHandler().handleMouseMoveEvent( | |
| 11035 mouseMoveOverDiv, Vector<WebMouseEvent>()); | |
| 11036 | |
| 11037 // DIV :hover. | |
| 11038 EXPECT_EQ(document->hoverNode(), parentDiv); | |
| 11039 | |
| 11040 // Ensure hittest has DIV and scrollbar. | |
| 11041 hitTestResult = webView->coreHitTestResultAt(WebPoint(175, 5)); | |
| 11042 | |
| 11043 EXPECT_TRUE(hitTestResult.innerElement()); | |
| 11044 EXPECT_TRUE(hitTestResult.scrollbar()); | |
| 11045 EXPECT_FALSE(hitTestResult.scrollbar()->isCustomScrollbar()); | |
| 11046 EXPECT_TRUE(hitTestResult.scrollbar()->enabled()); | |
| 11047 | |
| 11048 // Mouse over scrollbar. | |
| 11049 WebMouseEvent mouseMoveOverDivAndScrollbar( | |
| 11050 WebInputEvent::MouseMove, WebFloatPoint(175, 5), WebFloatPoint(175, 5), | |
| 11051 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, | |
| 11052 TimeTicks::Now().InSeconds()); | |
| 11053 mouseMoveOverDivAndScrollbar.setFrameScale(1); | |
| 11054 document->frame()->eventHandler().handleMouseMoveEvent( | |
| 11055 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); | |
| 11056 | |
| 11057 // Not change the DIV :hover. | |
| 11058 EXPECT_EQ(document->hoverNode(), parentDiv); | |
| 11059 | |
| 11060 // Disable the Scrollbar by remove the childDiv. | |
| 11061 frame->executeScript( | |
| 11062 WebScriptSource("var parent = document.getElementById('parent');" | |
| 11063 "var child = document.getElementById('child');" | |
| 11064 "parent.removeChild(child);")); | |
| 11065 webView->updateAllLifecyclePhases(); | |
| 11066 | |
| 11067 // Ensure hittest has DIV and no scrollbar. | |
| 11068 hitTestResult = webView->coreHitTestResultAt(WebPoint(175, 5)); | |
| 11069 | |
| 11070 EXPECT_TRUE(hitTestResult.innerElement()); | |
| 11071 EXPECT_FALSE(hitTestResult.scrollbar()); | |
| 11072 EXPECT_LE(hitTestResult.innerElement()->clientWidth(), 180); | |
| 
 
bokan
2017/02/03 18:24:28
clientWidth should be 165 (180 - 15). This means t
 
 | |
| 11073 | |
| 11074 // Mouse over disabled scrollbar. | |
| 11075 document->frame()->eventHandler().handleMouseMoveEvent( | |
| 11076 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); | |
| 11077 | |
| 11078 // Not change the DIV :hover. | |
| 11079 EXPECT_EQ(document->hoverNode(), parentDiv); | |
| 11080 } | |
| 11081 | |
| 10998 TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) { | 11082 TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) { | 
| 10999 registerMockedHttpURLLoad("custom-scrollbar-hover.html"); | 11083 registerMockedHttpURLLoad("custom-scrollbar-hover.html"); | 
| 11000 FrameTestHelpers::WebViewHelper webViewHelper; | 11084 FrameTestHelpers::WebViewHelper webViewHelper; | 
| 11001 WebViewImpl* webView = webViewHelper.initializeAndLoad( | 11085 WebViewImpl* webView = webViewHelper.initializeAndLoad( | 
| 11002 m_baseURL + "custom-scrollbar-hover.html"); | 11086 m_baseURL + "custom-scrollbar-hover.html"); | 
| 11003 | 11087 | 
| 11004 webViewHelper.resize(WebSize(200, 200)); | 11088 webViewHelper.resize(WebSize(200, 200)); | 
| 11005 | 11089 | 
| 11006 webView->updateAllLifecyclePhases(); | 11090 webView->updateAllLifecyclePhases(); | 
| 11007 | 11091 | 
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11257 | 11341 | 
| 11258 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11342 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 
| 11259 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11343 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 
| 11260 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11344 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 
| 11261 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11345 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 
| 11262 | 11346 | 
| 11263 webViewHelper.reset(); | 11347 webViewHelper.reset(); | 
| 11264 } | 11348 } | 
| 11265 | 11349 | 
| 11266 } // namespace blink | 11350 } // namespace blink | 
| OLD | NEW |