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

Unified 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-17T17:08 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/editing/selection/resources/js-test-selection-shared.js
diff --git a/LayoutTests/editing/selection/resources/js-test-selection-shared.js b/LayoutTests/editing/selection/resources/js-test-selection-shared.js
index ed7cbb3ada35e3de45c32662579fee586b9c6b4a..33ca54dbde749a672bcb9d478cfde32b3cbce84a 100644
--- a/LayoutTests/editing/selection/resources/js-test-selection-shared.js
+++ b/LayoutTests/editing/selection/resources/js-test-selection-shared.js
@@ -1,3 +1,34 @@
+function $(id) { return document.getElementById(id); }
+
+var selection= window.getSelection();
+
+function testCaretMotion(direction, granularity, repeatCount, origin, originOffset, target, targetOffset) {
+ if (direction == 'both') {
+ testCaretMotion('forward', granularity, repeatCount, origin, originOffset, target, targetOffset);
ojan 2013/05/22 02:25:20 Here and elsewhere, Blink style is 4-space indents
yosin_UTC9 2013/05/22 07:54:12 Done.
+ testCaretMotion('backward', granularity,repeatCount, target, targetOffset, origin, originOffset);
+ return;
+ }
+
+ if (typeof origin == 'string')
+ origin = $(origin);
+
+ if (typeof target == 'string')
+ target = $(target);
+
+ if (originOffset < 0)
+ originOffset = origin.firstChild.length + originOffset + 1;
+
+ if (targetOffset < 0)
+ targetOffset = target.firstChild.length + targetOffset + 1;
+
+ selection.setPosition(origin.firstChild, originOffset);
+ debug('Move ' + direction + ' ' + granularity + ' x ' + repeatCount);
+ for (var i = 0; i < repeatCount; ++i)
+ selection.modify("move", direction, granularity);
+ shouldEvaluateTo('selection.anchorNode', target.firstChild);
+ shouldEvaluateTo('selection.anchorOffset', targetOffset);
+}
+
function objectAsString(object, properties) {
var result = "[";
for (var x = 0; x < properties.length; x++) {

Powered by Google App Engine
This is Rietveld 408576698