aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/source.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2019-10-20 11:23:20 -0700
committerAlex Yatskov <alex@foosoft.net>2019-10-20 11:23:20 -0700
commit438498435227cfa59cf9ed3430045b288cd2a7c0 (patch)
tree6a05520e5d6fa8d26d372673a9ed3e5d2da7e3fd /ext/fg/js/source.js
parent06d7713189be9eb51669d3842b78278371e6cfa4 (diff)
parentd32fd1381b6cd5141a21c22f9ef639b2fe9774fb (diff)
Merge branch 'master' into testing
Diffstat (limited to 'ext/fg/js/source.js')
-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..c3da9f46 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') {
+ return 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) {