Source code

Revision control

Other Tools

1
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
"use strict";
6
7
var EXPORTED_SYMBOLS = ["SwitchDocumentDirectionChild"];
8
9
class SwitchDocumentDirectionChild extends JSWindowActorChild {
10
receiveMessage(message) {
11
if (message.name == "SwitchDocumentDirection") {
12
let docShell = this.manager.browsingContext.docShell;
13
let document = docShell.QueryInterface(Ci.nsIWebNavigation).document;
14
this.switchDocumentDirection(document);
15
}
16
}
17
18
switchDocumentDirection(document) {
19
// document.dir can also be "auto", in which case it won't change
20
if (document.dir == "ltr" || document.dir == "") {
21
document.dir = "rtl";
22
} else if (document.dir == "rtl") {
23
document.dir = "ltr";
24
}
25
26
for (let frame of document.defaultView.frames) {
27
this.switchDocumentDirection(frame.document);
28
}
29
}
30
}