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

Unified Diff: third_party/WebKit/LayoutTests/editing/assert_selection.js

Issue 2963113002: Introduce Selection#compute{Left,Top} in assert_selection() (Closed)
Patch Set: 2017-06-29T17:38:54 Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/assert_selection.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/editing/assert_selection.js
diff --git a/third_party/WebKit/LayoutTests/editing/assert_selection.js b/third_party/WebKit/LayoutTests/editing/assert_selection.js
index a92d65e31d0bfbfbec4c43f0a8d59590ea5a4b72..e05b848d7d35c6485fd6ebec8fdde9154079acad 100644
--- a/third_party/WebKit/LayoutTests/editing/assert_selection.js
+++ b/third_party/WebKit/LayoutTests/editing/assert_selection.js
@@ -60,6 +60,10 @@ const DumpAs = {
FLAT_TREE: 'flattree',
};
+// Offset adjustment for mouse clicking used in |compute{Left,Top}()|.
yoichio 2017/06/30 01:45:59 Why do you need this adjustment?
yosin_UTC9 2017/06/30 08:21:50 This value should be 2. It is border-size comes fr
+const kOffsetLeftAdjustment = 4;
+const kOffsetTopAdjustment = 4;
+
/** @const @type {string} */
const kTextArea = 'TEXTAREA';
@@ -664,6 +668,28 @@ class Serializer {
}
/**
+ * @param {!HTMLElement} element
+ * @return {number}
+ */
+function computeLeft(element) {
+ let left = kOffsetLeftAdjustment + element.ownerDocument.offsetLeft;
+ for (let runner = element; runner; runner = runner.offsetParent)
+ left += runner.offsetLeft;
+ return left;
+}
+
+/**
+ * @param {!HTMLElement} element
+ * @return {number}
+ */
+function computeTop(element) {
+ let top = kOffsetTopAdjustment + element.ownerDocument.offsetTop;
+ for (let runner = element; runner; runner = runner.offsetParent)
+ top += runner.offsetTop;
+ return top;
+}
+
+/**
* @this {!DOMSelection}
* @param {string} html
* @param {string=} opt_text
@@ -712,6 +738,8 @@ class Sample {
this.selection_.document.offsetLeft = this.iframe_.offsetLeft;
this.selection_.document.offsetTop = this.iframe_.offsetTop;
this.selection_.setClipboardData = setClipboardData;
+ this.selection_.computeLeft = computeLeft;
+ this.selection_.computeTop = computeTop;
this.load(sampleText);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/assert_selection.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698