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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/editing.js

Issue 2709983005: Selection API: Do not change focus by Selection functions. (Closed)
Patch Set: . Created 3 years, 10 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
OLDNEW
1 //------------------------------------------------------------------------------ ------------------------- 1 //------------------------------------------------------------------------------ -------------------------
2 // Java script library to run editing layout tests 2 // Java script library to run editing layout tests
3 3
4 var commandCount = 1; 4 var commandCount = 1;
5 var commandDelay = window.location.search.substring(1); 5 var commandDelay = window.location.search.substring(1);
6 if (commandDelay == '') 6 if (commandDelay == '')
7 commandDelay = 0; 7 commandDelay = 0;
8 var selection = window.getSelection(); 8 var selection = window.getSelection();
9 9
10 //------------------------------------------------------------------------------ ------------------------- 10 //------------------------------------------------------------------------------ -------------------------
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 offset++; 920 offset++;
921 return { 'node': node, 'offset': offset }; 921 return { 'node': node, 'offset': offset };
922 } 922 }
923 923
924 if (node.nodeName == 'BR' || node.nodeName == 'IMG') 924 if (node.nodeName == 'BR' || node.nodeName == 'IMG')
925 return { 'node': node.parentNode, 'offset': offset }; 925 return { 'node': node.parentNode, 'offset': offset };
926 926
927 return null; 927 return null;
928 }); 928 });
929 929
930 for (var focusTarget = elem; focusTarget; focusTarget = focusTarget.pare ntNode) {
931 focusTarget.focus();
yoichio 2017/02/24 01:54:51 Why do we need to focus on all ancestors?
tkent 2017/02/24 01:59:44 This just focus on the nearest focusable ancestor.
932 if (focusTarget.ownerDocument.activeElement == focusTarget)
933 break;
934 }
930 if (firstVisiblePosition) 935 if (firstVisiblePosition)
931 selection.collapse(firstVisiblePosition.node, firstVisiblePosition.o ffset); 936 selection.collapse(firstVisiblePosition.node, firstVisiblePosition.o ffset);
932 else 937 else
933 selection.collapse(elem, 0); 938 selection.collapse(elem, 0);
934 } else { 939 } else {
935 selection.removeAllRanges(); 940 selection.removeAllRanges();
936 } 941 }
937 } 942 }
938 943
939 function runEditingTest() { 944 function runEditingTest() {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 function executeCommand(command,arg1,arg2) { 1026 function executeCommand(command,arg1,arg2) {
1022 if (commandDelay > 0) { 1027 if (commandDelay > 0) {
1023 queueCommand(runCommand, commandCount * commandDelay); 1028 queueCommand(runCommand, commandCount * commandDelay);
1024 commandCount++; 1029 commandCount++;
1025 } 1030 }
1026 else { 1031 else {
1027 runCommand(command,arg1,arg2); 1032 runCommand(command,arg1,arg2);
1028 } 1033 }
1029 } 1034 }
1030 1035
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698