aboutsummaryrefslogtreecommitdiff
path: root/ext/js/dom/text-source-element.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/dom/text-source-element.js')
-rw-r--r--ext/js/dom/text-source-element.js29
1 files changed, 8 insertions, 21 deletions
diff --git a/ext/js/dom/text-source-element.js b/ext/js/dom/text-source-element.js
index b5fc1683..13c5cd86 100644
--- a/ext/js/dom/text-source-element.js
+++ b/ext/js/dom/text-source-element.js
@@ -21,9 +21,9 @@
*/
class TextSourceElement {
- constructor(element, fullContent=null, startOffset=0, endOffset=0) {
+ constructor(element, fullContent, startOffset, endOffset) {
this._element = element;
- this._fullContent = (typeof fullContent === 'string' ? fullContent : TextSourceElement.getElementContent(element));
+ this._fullContent = fullContent;
this._startOffset = startOffset;
this._endOffset = endOffset;
this._content = this._fullContent.substring(this._startOffset, this._endOffset);
@@ -49,10 +49,6 @@ class TextSourceElement {
return this._endOffset;
}
- get isConnected() {
- return this._element.isConnected;
- }
-
clone() {
return new TextSourceElement(this._element, this._fullContent, this._startOffset, this._endOffset);
}
@@ -65,7 +61,7 @@ class TextSourceElement {
return this._content;
}
- setEndOffset(length, _layoutAwareScan, fromEnd) {
+ setEndOffset(length, fromEnd) {
const offset = fromEnd ? this._endOffset : this._startOffset;
length = Math.min(this._fullContent.length - offset, length);
if (length > 0) {
@@ -86,19 +82,6 @@ class TextSourceElement {
return length;
}
- collapse(toStart) {
- if (toStart) {
- this._endOffset = this._startOffset;
- } else {
- this._startOffset = this._endOffset;
- }
- this._content = '';
- }
-
- getRect() {
- return DocumentUtil.convertRectZoomCoordinates(this._element.getBoundingClientRect(), this._element);
- }
-
getRects() {
return DocumentUtil.convertMultipleRectZoomCoordinates(this._element.getClientRects(), this._element);
}
@@ -130,7 +113,11 @@ class TextSourceElement {
return [this._element];
}
- static getElementContent(element) {
+ static create(element) {
+ return new TextSourceElement(element, this._getElementContent(element), 0, 0);
+ }
+
+ static _getElementContent(element) {
let content;
switch (element.nodeName.toUpperCase()) {
case 'BUTTON':