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

Side by Side Diff: content/test/data/touch_selection.html

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased after blink issue fixed: r200194 Created 5 years, 4 months 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 | « content/test/BUILD.gn ('k') | ui/touch_selection/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <div id='textDiv'>Some text we can select</div> 2 <div id='textDiv'>Some text we can select</div>
3 <input id='textfield' type="text" value="Text in a textfield"> 3 <input id='textfield' type="text" value="Text in a textfield">
4 <script> 4 <script>
5 5
6 function select_all_text() {
7 var div = document.getElementById("textDiv");
8 var range = document.createRange();
9 range.selectNodeContents(div);
10 var sel = window.getSelection();
11 sel.removeAllRanges();
12 sel.addRange(range);
13 }
14
15 function get_selection() {
16 return (window.getSelection() + "");
17 }
18
19 function focus_textfield() { 6 function focus_textfield() {
20 document.getElementById("textfield").focus(); 7 document.getElementById("textfield").focus();
21 // Focusing the textfiled selects its text. Collapse selection to a cursor. 8 // Focusing the textfiled selects its text. Collapse selection to a cursor.
22 window.getSelection().collapseToStart(); 9 window.getSelection().collapseToStart();
23 } 10 }
24 11
25 function get_cursor_position() { 12 function get_point_inside(element) {
26 var div = document.getElementById("textfield"); 13 var rect = element.getBoundingClientRect();
27 var start = div.selectionStart; 14 var point = {
28 var end = div.selectionEnd; 15 x: rect.left + 8,
29 if (start == end) 16 y: (rect.top + rect.bottom) / 2
30 return start; 17 };
31 else 18 window.domAutomationController.send(JSON.stringify(point));
32 return -1; 19 }
20
21 function get_point_inside_text() {
22 get_point_inside(document.getElementById('textDiv'));
23 }
24
25 function get_point_inside_textfield() {
26 get_point_inside(document.getElementById('textfield'));
33 } 27 }
34 28
35 </script> 29 </script>
36 30
37 </html> 31 </html>
OLDNEW
« no previous file with comments | « content/test/BUILD.gn ('k') | ui/touch_selection/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698