Renaming classes
This commit is contained in:
parent
a72e958ebf
commit
6d9b4392e2
@ -90,12 +90,12 @@ class Client {
|
|||||||
textSourceFromPoint(point) {
|
textSourceFromPoint(point) {
|
||||||
const element = document.elementFromPoint(point.x, point.y);
|
const element = document.elementFromPoint(point.x, point.y);
|
||||||
if (element !== null && element.nodeName === 'IMG') {
|
if (element !== null && element.nodeName === 'IMG') {
|
||||||
return new ImageSource(element);
|
return new TextSourceImage(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
const range = document.caretRangeFromPoint(point.x, point.y);
|
const range = document.caretRangeFromPoint(point.x, point.y);
|
||||||
if (range !== null) {
|
if (range !== null) {
|
||||||
return new RangeSource(range);
|
return new TextSourceRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class ImageSource {
|
class TextSourceImage {
|
||||||
constructor(image) {
|
constructor(image) {
|
||||||
this.img = image;
|
this.img = image;
|
||||||
this.length = -1;
|
this.length = -1;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class RangeSource {
|
class TextSourceRange {
|
||||||
constructor(range) {
|
constructor(range) {
|
||||||
this.rng = range;
|
this.rng = range;
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ class RangeSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLength(length) {
|
setLength(length) {
|
||||||
const end = RangeSource.seekEnd(this.rng.startContainer, this.rng.startOffset + length);
|
const end = TextSourceRange.seekEnd(this.rng.startContainer, this.rng.startOffset + length);
|
||||||
this.rng.setEnd(end.node, end.offset);
|
this.rng.setEnd(end.node, end.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,18 +70,18 @@ class RangeSource {
|
|||||||
static seekEnd(node, length) {
|
static seekEnd(node, length) {
|
||||||
const state = {node, offset: 0, length};
|
const state = {node, offset: 0, length};
|
||||||
|
|
||||||
if (!RangeSource.seekEndRecurse(node, state)) {
|
if (!TextSourceRange.seekEndRecurse(node, state)) {
|
||||||
return {node: state.node, offset: state.offset};
|
return {node: state.node, offset: state.offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let sibling = node.nextSibling; sibling !== null; sibling = sibling.nextSibling) {
|
for (let sibling = node.nextSibling; sibling !== null; sibling = sibling.nextSibling) {
|
||||||
if (!RangeSource.seekEndRecurse(sibling, state)) {
|
if (!TextSourceRange.seekEndRecurse(sibling, state)) {
|
||||||
return {node: state.node, offset: state.offset};
|
return {node: state.node, offset: state.offset};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let sibling = node.parentElement.nextSibling; sibling !== null; sibling = sibling.nextSibling) {
|
for (let sibling = node.parentElement.nextSibling; sibling !== null; sibling = sibling.nextSibling) {
|
||||||
if (!RangeSource.seekEndRecurse(sibling, state)) {
|
if (!TextSourceRange.seekEndRecurse(sibling, state)) {
|
||||||
return {node: state.node, offset: state.offset};
|
return {node: state.node, offset: state.offset};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ class RangeSource {
|
|||||||
state.length -= consumed;
|
state.length -= consumed;
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < node.childNodes.length; ++i) {
|
for (let i = 0; i < node.childNodes.length; ++i) {
|
||||||
if (!RangeSource.seekEndRecurse(node.childNodes[i], state)) {
|
if (!TextSourceRange.seekEndRecurse(node.childNodes[i], state)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user