Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / touchadjustment / context-menu-text-subtargets.html
blob40ff6c6f6c18320e4faaeca1b6d9258ebaed7c66
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Touch Adjustment : Adjust context-menu to text-node subtargets - bug 94449</title>
5 <script src="../resources/ahem.js"></script>
6 <script src="../resources/js-test.js"></script>
7 <script src="resources/touchadjustment.js"></script>
8 <style>
9 #sandbox {
10 position: absolute;
11 top: 0px;
12 left: 0px;
13 width: 400px;
14 height: 200px;
16 #sandbox div {
17 padding: 10px;
18 font: 20px Ahem;
19 white-space: pre-wrap;
21 </style>
22 </head>
23 <body>
25 <div id=sandbox>
26 <!-- The layout of the two words should be: (10,10)x(80,20) and (170,10)x(80,20). -->
27 <div id=div1><span id=span1>Text text</span></div>
28 </div>
30 <p id='description'></p>
31 <div id='console'></div>
33 <script>
34 // Set up shortcut access to elements
35 var e = {};
36 ['sandbox', 'div1', 'span1'].forEach(function(a) {
37 e[a] = document.getElementById(a);
38 });
40 function testAdjustedTouches()
42 var adjustedPoint;
43 var word1Bounds = { left: 10, top: 10, width: 80, height: 20 };
44 var word2Bounds = { left: 170, top: 10, width: 80, height: 20 };
46 // Set editing-behaviour mac, so context-menu gesture triggers selections.
47 internals.settings.setEditingBehavior('mac');
48 // Check the context-menu is adjusted to the individual words.
49 adjustedPoint = adjustTouchPointContextMenu(touchPoint(5, 5, 20, 10));
50 shouldBeWithin(adjustedPoint, word1Bounds);
51 adjustedPoint = adjustTouchPointContextMenu(touchPoint(100, 15, 20, 10));
52 shouldBeWithin(adjustedPoint, word1Bounds);
54 adjustedPoint = adjustTouchPointContextMenu(touchPoint(150, 15, 30, 10));
55 shouldBeWithin(adjustedPoint, word2Bounds);
56 adjustedPoint = adjustTouchPointContextMenu(touchPoint(260, 35, 20, 10));
57 shouldBeWithin(adjustedPoint, word2Bounds);
59 // Set editing-behaviour to win, so context-menu gesture does not trigger selections.
60 internals.settings.setEditingBehavior('win');
61 var range = document.createRange();
62 range.setStart(e.span1.firstChild, 2);
63 range.setEnd(e.span1.firstChild, 6);
64 window.getSelection().addRange(range);
65 var selectionBounds = { left: 50, top: 10, width: 80, height: 20 };
66 adjustedPoint = adjustTouchPointContextMenu(touchPoint(25, 5, 30, 20));
67 shouldBeWithin(adjustedPoint, selectionBounds);
68 adjustedPoint = adjustTouchPointContextMenu(touchPoint(140, 10, 20, 10));
69 shouldBeWithin(adjustedPoint, selectionBounds);
72 function runTests()
74 if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestContextMenuNode) {
75 description('Test touch-adjustment to individual words or active selection.');
76 testAdjustedTouches();
77 e.sandbox.style.display = 'none';
80 runTests();
81 </script>
84 </body>
85 </html>