summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/source.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index ee4f58e2..a483952e 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -229,13 +229,29 @@ class TextSourceRange {
}
static getElementWritingMode(element) {
- if (element === null) {
- return 'horizontal-tb';
+ if (element !== null) {
+ const style = window.getComputedStyle(element);
+ const writingMode = style.writingMode;
+ if (typeof writingMode === 'string') {
+ TextSourceRange.normalizeWritingMode(writingMode);
+ }
}
+ return 'horizontal-tb';
+ }
- const style = window.getComputedStyle(element);
- const writingMode = style.writingMode;
- return typeof writingMode === 'string' ? writingMode : 'horizontal-tb';
+ static normalizeWritingMode(writingMode) {
+ switch (writingMode) {
+ case 'lr':
+ case 'lr-tb':
+ case 'rl':
+ return 'horizontal-tb';
+ case 'tb':
+ return 'vertical-lr';
+ case 'tb-rl':
+ return 'vertical-rl';
+ default:
+ return writingMode;
+ }
}
static getNodesInRange(range) {