Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: LayoutTests/scrollbars/scrollbar-pointer-events.html

Issue 68243009: Fix RenderBlock::nodeAtPoint() for scrollbars of hidden and pointer-events:none elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test the effect of pointer-events:none on scrollbars Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/scrollbars/scrollbar-pointer-events-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>Test the effect of pointer-events on overflow scrollbars.</p>
5
6 <div id="result">FAIL: script didn't run to completion.</div>
7
8 <div id="div1" style="position: absolute; top: 100px; width: 130px; height: 340p x; background-color: SeaShell; overflow: none;">
9 Div 1
10 </div>
11 <div id="div2" style="position: absolute; top: 120px; width: 100px; height: 300p x; background-color: Salmon; overflow: auto; pointer-events: all; z-index: 1;">
12 <div id="div2Content" style="width: 200%; height: 500px;">
13 Div 2
14 </div>
15 </div>
16
17 <div id="div3" style="position: absolute; top: 100px; left: 300px; width: 300px; height: 300px; background-color: PaleTurquoise; overflow: none;">
18 Div 3
19 <div id="div4" style="position: absolute; top: 30px; left: 30px; width: 240p x; height: 240px; background-color: MediumTurquoise; overflow: auto; pointer-eve nts: none;">
20 <div id="div4Content" style="width: 200%; height: 200%;">
21 Div 4
22 <div id="div5" style="position: absolute; top: 30px; left: 30px; width: 180px; height: 180px; background-color: DarkSeaGreen; overflow: auto; pointer-ev ents: all;">
23 <div id="div5Content" style="width: 200%; height: 200%;">
24 Div 5
25 </div>
26 </div>
27 </div>
28 </div>
29 </div>
30
31 <script>
32
33 if (window.testRunner)
34 testRunner.dumpAsText();
35
36 var div1 = document.getElementById("div1");
37 var div2 = document.getElementById("div2");
38
39 // First sanity check points that should be within div2's vertical and horiz ontal scrollbars
40 // when it has pointer-events:all.
41 // Subtract 5px from the right (bottom) edge to get a point within the verti cal (horizontal) scrollbar.
42 var verticalPoint = [div2.offsetLeft + div2.offsetWidth - 5, div2.offsetTop + Math.floor(div2.offsetHeight / 2)];
43 var horizontalPoint = [div2.offsetLeft + Math.floor(div2.offsetWidth / 2), d iv2.offsetTop + div2.offsetHeight - 5];
44 var elem = document.elementFromPoint(verticalPoint[0], verticalPoint[1]);
45 var elem2 = document.elementFromPoint(horizontalPoint[0], horizontalPoint[1] );
46 if (elem.id != div2.id || elem2.id != div2.id) {
47 document.getElementById("result").firstChild.data = "FAILURE: The elemen t at points (" + verticalPoint + ") and (" + horizontalPoint + ") needs to be di v2. You may need to turn on overflow scrollbars temporarily. (On Mac: Change the 'Show scroll bars' setting to 'Always'.)";
48 throw "failure";
49 }
50
51 // Apply pointer-events:visible to div2.
52 div2.style.pointerEvents = "visible";
53 if (window.getComputedStyle(div2).visibility != "visible") {
54 document.getElementById("result").firstChild.data = "FAILURE: div2 needs to be visible.";
55 throw "failure";
56 }
57 elem = document.elementFromPoint(verticalPoint[0], verticalPoint[1]);
58 elem2 = document.elementFromPoint(horizontalPoint[0], horizontalPoint[1]);
59 if (elem.id != div2.id || elem2.id != div2.id) {
60 document.getElementById("result").firstChild.data = "FAILURE: With point er-events:visible and visibility:visible applied to div2, (" + verticalPoint + " ) and (" + horizontalPoint + ") should be div2.";
61 throw "failure";
62 }
63
64 // Hide div2 by applying visibility:hidden. Now when we hit test div2's scro llbars, we should
65 // get div1 instead.
66 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0338.html
67 div2.style.visibility = "hidden";
68 elem = document.elementFromPoint(verticalPoint[0], verticalPoint[1]);
69 elem2 = document.elementFromPoint(horizontalPoint[0], horizontalPoint[1]);
70 if (elem.id != div1.id || elem2.id != div1.id) {
71 document.getElementById("result").firstChild.data = "FAILURE: With point er-events:visible and visibility:hidden applied to div2, (" + verticalPoint + ") and (" + horizontalPoint + ") should be div1.";
72 throw "failure";
73 }
74
75 var div3 = document.getElementById("div3");
76 var div4 = document.getElementById("div4");
77 var div5 = document.getElementById("div5");
78
79 // div4 has pointer-events:none and scrollbars. Overflow scrollbars of an el ement having
80 // pointer-events:none do not participate in hit testing.
81 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0338.html
82 var bcr = div4.getBoundingClientRect();
83 verticalPoint = [Math.floor(bcr.right - 5), Math.floor(bcr.top + bcr.height / 2)];
84 horizontalPoint = [Math.floor(bcr.left + bcr.width / 2), Math.floor(bcr.bott om - 5)];
85 elem = document.elementFromPoint(verticalPoint[0], verticalPoint[1]);
86 elem2 = document.elementFromPoint(horizontalPoint[0], horizontalPoint[1]);
87 if (elem.id != div3.id || elem2.id != div3.id) {
88 document.getElementById("result").firstChild.data = "FAILURE: With point er-events:none applied to div4, (" + verticalPoint + ") and (" + horizontalPoint + ") should be div3.";
89 throw "failure";
90 }
91
92 // However, descendants of pointer-events:none elements having pointer-event s:all do
93 // participate in hit testing.
94 bcr = div5.getBoundingClientRect();
95 verticalPoint = [Math.floor(bcr.right - 5), Math.floor(bcr.top + bcr.height / 2)];
96 horizontalPoint = [Math.floor(bcr.left + bcr.width / 2), Math.floor(bcr.bott om - 5)];
97 elem = document.elementFromPoint(verticalPoint[0], verticalPoint[1]);
98 elem2 = document.elementFromPoint(horizontalPoint[0], horizontalPoint[1]);
99 if (elem.id != div5.id || elem2.id != div5.id) {
100 document.getElementById("result").firstChild.data = "FAILURE: With point er-events:all applied to div5, (" + verticalPoint + ") and (" + horizontalPoint + ") should be div5 even though it is a descendant of a pointer-events:none elem ent.";
101 throw "failure";
102 }
103
104 document.getElementById("result").firstChild.data = "SUCCESS";
105
106 </script>
107 </body>
108 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/scrollbars/scrollbar-pointer-events-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698