4 <title>Test touch adjustment to a non-rectilinear element.
</title>
5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/touchadjustment.js"></script>
8 body { margin:
0px; padding:
0px; }
10 -webkit-box-sizing: border-box;
12 border:
1px solid black;
17 -webkit-box-sizing: border-box;
18 transform: rotate(
45deg);
19 border:
1px solid black;
33 <div id=
"rotated"></div>
36 <p id='description'
></p>
37 <div id='console'
></div>
40 // Set up shortcut access to elements
42 ['container', 'rotated'].forEach(function(a
) {
43 e
[a
] = document
.getElementById(a
);
44 e
[a
].addEventListener('click', function() {}, false);
47 function testDirectTouches()
49 debug('Direct Touches');
51 testTouchPoint(touchPoint(30, 30, 20), e
.rotated
);
52 testTouchPoint(touchPoint(20, 30, 20), e
.rotated
);
53 testTouchPoint(touchPoint(40, 30, 20), e
.rotated
);
54 testTouchPoint(touchPoint(30, 20, 20), e
.rotated
);
55 testTouchPoint(touchPoint(30, 40, 20), e
.rotated
);
57 testTouchPoint(touchPoint(80, 80, 20), e
.container
);
58 testTouchPoint(touchPoint(80, 20, 20), e
.container
);
59 testTouchPoint(touchPoint(20, 80, 20), e
.container
);
62 function testAdjustedTouches()
64 debug('\nAdjusted Touches');
66 // Touch overlaps center of element.
67 testTouchPoint(touchPoint(10, 10, 30), e
.rotated
);
69 // Touch overlaps corner of element.
70 testTouchPoint(touchPoint(20, 0, 20), e
.rotated
);
72 debug('\nNear Misses');
74 // Touch overlaps bounding-box of element, but not the actual bounds.
75 testTouchPoint(touchPoint(71, 0, 20), e
.container
);
76 testTouchPoint(touchPoint(71, 60, 20), e
.container
);
79 function testAdjustedPoints()
81 debug('\nAdjusted point within bounds');
82 var adjustedPoint
= adjustTouchPoint(touchPoint(20, 0, 20))
83 // Note: we allow 1 pixel of slop here due to corresponding 1px
84 // padding FIXME in HitTestLocation::rectForPoint.
85 shouldBeWithin(adjustedPoint
, touchPoint(20.5, 0.5, 20.5));
87 adjustedPoint
= adjustTouchPoint(touchPoint(60, 60, 20))
88 shouldBeWithin(adjustedPoint
, touchPoint(60, 60, 20));
90 adjustedPoint
= adjustTouchPoint(touchPoint(0, 60, 40, 20))
91 shouldBeWithin(adjustedPoint
, touchPoint(0, 60, 40, 20));
93 adjustedPoint
= adjustTouchPoint(touchPoint(70, 20, 20, 40))
94 shouldBeWithin(adjustedPoint
, touchPoint(70, 20, 20, 40));
99 document
.addEventListener('click', function() {}, false);
100 if (window
.testRunner
&& window
.internals
&& internals
.touchNodeAdjustedToBestClickableNode
) {
101 description(document
.title
);
103 testAdjustedTouches();
105 e
.container
.style
.display
= 'none';