aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/source-range.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-07-23 12:47:42 -0700
committerAlex Yatskov <alex@foosoft.net>2016-07-23 12:47:42 -0700
commita889e1ffaa8b64b18a5b8416db1838ab497f52d6 (patch)
treeda033f74d7a5b6d5b7e487085989a2c8d2a3e702 /ext/fg/js/source-range.js
parent6099de71d86b923e1bc76b32833a7ccfcab73692 (diff)
WIP
Diffstat (limited to 'ext/fg/js/source-range.js')
-rw-r--r--ext/fg/js/source-range.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/ext/fg/js/source-range.js b/ext/fg/js/source-range.js
index c4cabf4b..a6c3d722 100644
--- a/ext/fg/js/source-range.js
+++ b/ext/fg/js/source-range.js
@@ -17,7 +17,7 @@
*/
-class Range {
+class RangeSource {
constructor(range) {
this.rng = range;
}
@@ -27,7 +27,7 @@ class Range {
}
setLength(length) {
- const end = Range.seekEnd(this.rng.startContainer, this.rng.startOffset + length);
+ const end = RangeSource.seekEnd(this.rng.startContainer, this.rng.startOffset + length);
this.rng.setEnd(end.node, end.offset);
}
@@ -70,18 +70,18 @@ class Range {
static seekEnd(node, length) {
const state = {node, offset: 0, length};
- if (!Range.seekEndRecurse(node, state)) {
+ if (!RangeSource.seekEndRecurse(node, state)) {
return {node: state.node, offset: state.offset};
}
for (let sibling = node.nextSibling; sibling !== null; sibling = sibling.nextSibling) {
- if (!Range.seekEndRecurse(sibling, state)) {
+ if (!RangeSource.seekEndRecurse(sibling, state)) {
return {node: state.node, offset: state.offset};
}
}
for (let sibling = node.parentElement.nextSibling; sibling !== null; sibling = sibling.nextSibling) {
- if (!Range.seekEndRecurse(sibling, state)) {
+ if (!RangeSource.seekEndRecurse(sibling, state)) {
return {node: state.node, offset: state.offset};
}
}
@@ -97,7 +97,7 @@ class Range {
state.length -= consumed;
} else {
for (let i = 0; i < node.childNodes.length; ++i) {
- if (!Range.seekEndRecurse(node.childNodes[i], state)) {
+ if (!RangeSource.seekEndRecurse(node.childNodes[i], state)) {
break;
}
}
@@ -105,9 +105,4 @@ class Range {
return state.length > 0;
}
-
- static fromPoint(point) {
- const range = document.caretRangeFromPoint(point.x, point.y);
- return range === null ? null : new Range(range);
- }
}