aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/source.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-09-02 08:33:10 -0700
committerGitHub <noreply@github.com>2019-09-02 08:33:10 -0700
commit3c9f7ba15267f52dd1bf37cd8835e2f7b76819e7 (patch)
tree189f09ba4c2f8c57527a51dd29bf896079c832b6 /ext/fg/js/source.js
parent037363e3a70675a580431d2ee891e3d88fae511c (diff)
parent707d2569cc2c8c6da2bdacea6e999a7ea3ea6297 (diff)
Merge pull request #196 from toasted-nutbread/vertical-text-popup-position
Vertical text popup position
Diffstat (limited to 'ext/fg/js/source.js')
-rw-r--r--ext/fg/js/source.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index 69d8197d..e724488d 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -68,6 +68,10 @@ class TextSourceRange {
return this.range.getBoundingClientRect();
}
+ getWritingMode() {
+ return TextSourceRange.getElementWritingMode(TextSourceRange.getParentElement(this.range.startContainer));
+ }
+
getPaddedRect() {
const range = this.range.cloneRange();
const startOffset = range.startOffset;
@@ -211,6 +215,23 @@ class TextSourceRange {
return state.remainder > 0;
}
+
+ static getParentElement(node) {
+ while (node !== null && node.nodeType !== Node.ELEMENT_NODE) {
+ node = node.parentNode;
+ }
+ return node;
+ }
+
+ static getElementWritingMode(element) {
+ if (element === null) {
+ return 'horizontal-tb';
+ }
+
+ const style = window.getComputedStyle(element);
+ const writingMode = style.writingMode;
+ return typeof writingMode === 'string' ? writingMode : 'horizontal-tb';
+ }
}
@@ -278,6 +299,10 @@ class TextSourceElement {
return this.element.getBoundingClientRect();
}
+ getWritingMode() {
+ return 'horizontal-tb';
+ }
+
select() {
// NOP
}