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 10889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10900 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | 10900 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 10901 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | 10901 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 10902 "</a>" | 10902 "</a>" |
| 10903 "<div style='position: absolute; top: 1000px'>end</div>"); | 10903 "<div style='position: absolute; top: 1000px'>end</div>"); |
| 10904 | 10904 |
| 10905 webView->updateAllLifecyclePhases(); | 10905 webView->updateAllLifecyclePhases(); |
| 10906 | 10906 |
| 10907 Document* document = webView->mainFrameImpl()->frame()->document(); | 10907 Document* document = webView->mainFrameImpl()->frame()->document(); |
| 10908 Element* aTag = document->getElementById("a"); | 10908 Element* aTag = document->getElementById("a"); |
| 10909 | 10909 |
| 10910 // Ensure hittest has scrollbar and link | 10910 // Ensure hittest only has scrollbar. |
|
bokan
2017/03/31 20:07:00
What changed here? Shouldn't the hit test set the
| |
| 10911 HitTestResult hitTestResult = | 10911 HitTestResult hitTestResult = |
| 10912 webView->coreHitTestResultAt(WebPoint(18, aTag->offsetTop())); | 10912 webView->coreHitTestResultAt(WebPoint(18, aTag->offsetTop())); |
| 10913 | 10913 |
| 10914 EXPECT_TRUE(hitTestResult.URLElement()); | 10914 EXPECT_FALSE(hitTestResult.URLElement()); |
| 10915 EXPECT_TRUE(hitTestResult.innerElement()); | 10915 EXPECT_FALSE(hitTestResult.innerElement()); |
| 10916 EXPECT_TRUE(hitTestResult.scrollbar()); | 10916 EXPECT_TRUE(hitTestResult.scrollbar()); |
| 10917 EXPECT_FALSE(hitTestResult.scrollbar()->isCustomScrollbar()); | 10917 EXPECT_FALSE(hitTestResult.scrollbar()->isCustomScrollbar()); |
| 10918 | 10918 |
| 10919 // Mouse over link. Mouse cursor should be hand. | 10919 // Mouse over link. Mouse cursor should be hand. |
| 10920 WebMouseEvent mouseMoveOverLinkEvent( | 10920 WebMouseEvent mouseMoveOverLinkEvent( |
| 10921 WebInputEvent::MouseMove, | 10921 WebInputEvent::MouseMove, |
| 10922 WebFloatPoint(aTag->offsetLeft(), aTag->offsetTop()), | 10922 WebFloatPoint(aTag->offsetLeft(), aTag->offsetTop()), |
| 10923 WebFloatPoint(aTag->offsetLeft(), aTag->offsetTop()), | 10923 WebFloatPoint(aTag->offsetLeft(), aTag->offsetTop()), |
| 10924 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, | 10924 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, |
| 10925 TimeTicks::Now().InSeconds()); | 10925 TimeTicks::Now().InSeconds()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11040 TimeTicks::Now().InSeconds()); | 11040 TimeTicks::Now().InSeconds()); |
| 11041 mouseMoveOverDivAndScrollbar.setFrameScale(1); | 11041 mouseMoveOverDivAndScrollbar.setFrameScale(1); |
| 11042 document->frame()->eventHandler().handleMouseMoveEvent( | 11042 document->frame()->eventHandler().handleMouseMoveEvent( |
| 11043 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); | 11043 mouseMoveOverDivAndScrollbar, Vector<WebMouseEvent>()); |
| 11044 | 11044 |
| 11045 // Custom not change the DIV :hover | 11045 // Custom not change the DIV :hover |
| 11046 EXPECT_EQ(document->hoverNode(), scrollbarDiv); | 11046 EXPECT_EQ(document->hoverNode(), scrollbarDiv); |
| 11047 EXPECT_EQ(hitTestResult.scrollbar()->hoveredPart(), ScrollbarPart::ThumbPart); | 11047 EXPECT_EQ(hitTestResult.scrollbar()->hoveredPart(), ScrollbarPart::ThumbPart); |
| 11048 } | 11048 } |
| 11049 | 11049 |
| 11050 // Makes sure that mouse hover over an overlay scrollbar doesn't hover iframe | |
| 11051 // below. | |
| 11052 TEST_F(WebFrameTest, MouseOverScrollbarAndIFrame) { | |
| 11053 registerMockedHttpURLLoad("scrollbar-and-iframe-hover.html"); | |
| 11054 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 11055 WebViewImpl* webView = webViewHelper.initializeAndLoad( | |
| 11056 m_baseURL + "scrollbar-and-iframe-hover.html"); | |
| 11057 | |
| 11058 webViewHelper.resize(WebSize(200, 200)); | |
| 11059 | |
| 11060 webView->updateAllLifecyclePhases(); | |
| 11061 | |
| 11062 Document* document = toLocalFrame(webView->page()->mainFrame())->document(); | |
| 11063 | |
| 11064 // Ensure hittest only has IFRAME. | |
| 11065 HitTestResult hitTestResult = webView->coreHitTestResultAt(WebPoint(5, 5)); | |
| 11066 | |
| 11067 EXPECT_TRUE(hitTestResult.innerElement()); | |
| 11068 EXPECT_FALSE(hitTestResult.scrollbar()); | |
| 11069 | |
| 11070 // Mouse over IFRAME. | |
| 11071 WebMouseEvent mouseMoveOverIFrame( | |
| 11072 WebInputEvent::MouseMove, WebFloatPoint(5, 5), WebFloatPoint(5, 5), | |
| 11073 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, | |
| 11074 TimeTicks::Now().InSeconds()); | |
| 11075 mouseMoveOverIFrame.setFrameScale(1); | |
| 11076 document->frame()->eventHandler().handleMouseMoveEvent( | |
| 11077 mouseMoveOverIFrame, Vector<WebMouseEvent>()); | |
| 11078 | |
| 11079 // IFRAME hover. | |
| 11080 EXPECT_EQ(document->hoverNode()->nodeName(), "IFRAME"); | |
|
bokan
2017/03/31 20:07:00
Give the iframe an id, save document.getElelementB
| |
| 11081 | |
| 11082 // Ensure hittest has scrollbar. | |
| 11083 hitTestResult = webView->coreHitTestResultAt(WebPoint(195, 5)); | |
| 11084 EXPECT_FALSE(hitTestResult.innerElement()); | |
| 11085 EXPECT_TRUE(hitTestResult.scrollbar()); | |
| 11086 EXPECT_TRUE(hitTestResult.scrollbar()->enabled()); | |
| 11087 | |
| 11088 // Mouse over scrollbar. | |
| 11089 WebMouseEvent mouseMoveOverIFrameAndScrollbar( | |
| 11090 WebInputEvent::MouseMove, WebFloatPoint(195, 5), WebFloatPoint(195, 5), | |
| 11091 WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers, | |
| 11092 TimeTicks::Now().InSeconds()); | |
| 11093 mouseMoveOverIFrameAndScrollbar.setFrameScale(1); | |
| 11094 document->frame()->eventHandler().handleMouseMoveEvent( | |
| 11095 mouseMoveOverIFrameAndScrollbar, Vector<WebMouseEvent>()); | |
| 11096 | |
| 11097 // IFRAME not hover. | |
| 11098 EXPECT_FALSE(document->hoverNode()); | |
|
bokan
2017/03/31 20:07:00
The iframe shouldn't be hovered, but shouldn't the
chaopeng
2017/04/03 17:50:26
For root scrollbar: scrollableArea->layoutBox()->n
bokan
2017/04/04 15:18:01
Ok, that behavior is unchanged from before this pa
chaopeng
2017/04/04 18:20:36
Yes, we dont change the behavior.
| |
| 11099 | |
| 11100 // Disable the Scrollbar. | |
| 11101 webView->mainFrameImpl()->frameView()->setScrollbarsHidden(true); | |
| 11102 | |
| 11103 // Ensure hittest has IFRAME and no scrollbar. | |
| 11104 hitTestResult = webView->coreHitTestResultAt(WebPoint(195, 5)); | |
| 11105 | |
| 11106 EXPECT_TRUE(hitTestResult.innerElement()); | |
| 11107 EXPECT_FALSE(hitTestResult.scrollbar()); | |
| 11108 | |
| 11109 // Mouse over disabled scrollbar. | |
| 11110 document->frame()->eventHandler().handleMouseMoveEvent( | |
| 11111 mouseMoveOverIFrameAndScrollbar, Vector<WebMouseEvent>()); | |
|
bokan
2017/03/31 20:07:00
For safety, I'd change the coordinate here by at l
| |
| 11112 | |
| 11113 // IFRAME hover. | |
| 11114 EXPECT_EQ(document->hoverNode()->nodeName(), "IFRAME"); | |
| 11115 } | |
| 11116 | |
| 11050 // Makes sure that mouse hover over a scrollbar also hover the element owns the | 11117 // Makes sure that mouse hover over a scrollbar also hover the element owns the |
| 11051 // scrollbar. | 11118 // scrollbar. |
| 11052 TEST_F(WebFrameTest, MouseOverScrollbarAndParentElement) { | 11119 TEST_F(WebFrameTest, MouseOverScrollbarAndParentElement) { |
| 11053 registerMockedHttpURLLoad("scrollbar-and-element-hover.html"); | 11120 registerMockedHttpURLLoad("scrollbar-and-element-hover.html"); |
| 11054 FrameTestHelpers::WebViewHelper webViewHelper; | 11121 FrameTestHelpers::WebViewHelper webViewHelper; |
| 11055 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); | 11122 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); |
| 11056 WebViewImpl* webView = webViewHelper.initializeAndLoad( | 11123 WebViewImpl* webView = webViewHelper.initializeAndLoad( |
| 11057 m_baseURL + "scrollbar-and-element-hover.html"); | 11124 m_baseURL + "scrollbar-and-element-hover.html"); |
| 11058 | 11125 |
| 11059 webViewHelper.resize(WebSize(200, 200)); | 11126 webViewHelper.resize(WebSize(200, 200)); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11559 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); | 11626 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
| 11560 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); | 11627 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
| 11561 EXPECT_FALSE(testSelectAll("<input>")); | 11628 EXPECT_FALSE(testSelectAll("<input>")); |
| 11562 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); | 11629 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
| 11563 // TODO(amaralp): Empty contenteditable should not have select all enabled. | 11630 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
| 11564 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); | 11631 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
| 11565 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); | 11632 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
| 11566 } | 11633 } |
| 11567 | 11634 |
| 11568 } // namespace blink | 11635 } // namespace blink |
| OLD | NEW |