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

Side by Side Diff: LayoutTests/editing/selection/resources/js-test-selection-shared.js

Issue 14794012: Make contenteditable="false" element as atomic node for selection motion (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-05-27T14:00 Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 function $(id) { return document.getElementById(id); }
2
3 var selection= window.getSelection();
4
5 function testCaretMotion(param) {
6 var direction = param.direction;
7 var granularity = param.granularity;
8 var repeatCount = param.repeatCount || 1;
9 var origin = param.origin;
10 var originOffset = param.originOffset || 0;
11 var target = param.target;
12 var targetOffset = param.targetOffset || 0;
13
14 if (direction == 'both') {
15 testCaretMotion({
16 'direction': 'forward',
17 'granularity': granularity,
18 'repeatCount': repeatCount,
19 'origin': origin,
20 'originOffset': originOffset,
21 'target': target,
22 'targetOffset': targetOffset
23 });
24 testCaretMotion({
25 'direction': 'backward',
26 'granularity': granularity,
27 'repeatCount': repeatCount,
28 'origin': target,
29 'originOffset': targetOffset,
30 'target': origin,
31 'targetOffset': originOffset
32 });
33 return;
34 }
35
36 if (typeof origin == 'string')
37 origin = $(origin);
38
39 if (typeof target == 'string')
40 target = $(target);
41
42 if (originOffset < 0)
43 originOffset = origin.firstChild.length + originOffset + 1;
44
45 if (targetOffset < 0)
46 targetOffset = target.firstChild.length + targetOffset + 1;
47
48 selection.setPosition(origin.firstChild, originOffset);
49 debug('Move ' + direction + ' ' + granularity + ' x ' + repeatCount);
50 for (var i = 0; i < repeatCount; ++i)
51 selection.modify("move", direction, granularity);
52 shouldEvaluateTo('selection.anchorNode', target.firstChild);
53 shouldEvaluateTo('selection.anchorOffset', targetOffset);
54 }
55
1 function objectAsString(object, properties) { 56 function objectAsString(object, properties) {
2 var result = "["; 57 var result = "[";
3 for (var x = 0; x < properties.length; x++) { 58 for (var x = 0; x < properties.length; x++) {
4 var property = properties[x]; 59 var property = properties[x];
5 if (x != 0) 60 if (x != 0)
6 result += " "; 61 result += " ";
7 62
8 var value = object[property]; 63 var value = object[property];
9 if (value && value.nodeType) // textNode 64 if (value && value.nodeType) // textNode
10 value = value + "(" + value.nodeValue + ")"; 65 value = value + "(" + value.nodeValue + ")";
(...skipping 28 matching lines...) Expand all
39 } 94 }
40 95
41 function clickAt(x, y) { 96 function clickAt(x, y) {
42 if (window.eventSender) { 97 if (window.eventSender) {
43 eventSender.mouseMoveTo(x, y); 98 eventSender.mouseMoveTo(x, y);
44 eventSender.mouseDown(); 99 eventSender.mouseDown();
45 eventSender.mouseUp(); 100 eventSender.mouseUp();
46 return true; 101 return true;
47 } 102 }
48 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698