Bug 1140878 - Move SwitchDocumentDirection() to toolkit/content/browser-content.js so it can be safely used in e10s. r=mconley

This commit is contained in:
Ian Moody 2015-03-11 21:19:18 +00:00
parent e80d9e5e73
commit 320c3c45bf
4 changed files with 20 additions and 13 deletions

View File

@ -317,7 +317,9 @@
hidden="true"
label="&bidiSwitchPageDirectionItem.label;"
accesskey="&bidiSwitchPageDirectionItem.accesskey;"
oncommand="SwitchDocumentDirection(window.content)"/>
oncommand="gBrowser.selectedBrowser
.messageManager
.sendAsyncMessage('SwitchDocumentDirection');"/>
</menupopup>
</menu>

View File

@ -6489,17 +6489,6 @@ function AddKeywordForSearchField() {
}, window);
}
function SwitchDocumentDirection(aWindow) {
// document.dir can also be "auto", in which case it won't change
if (aWindow.document.dir == "ltr" || aWindow.document.dir == "") {
aWindow.document.dir = "rtl";
} else if (aWindow.document.dir == "rtl") {
aWindow.document.dir = "ltr";
}
for (var run = 0; run < aWindow.frames.length; run++)
SwitchDocumentDirection(aWindow.frames[run]);
}
function convertFromUnicode(charset, str)
{
try {

View File

@ -1649,7 +1649,7 @@ nsContextMenu.prototype = {
},
switchPageDirection: function CM_switchPageDirection() {
SwitchDocumentDirection(this.browser.contentWindowAsCPOW);
this.browser.messageManager.sendAsyncMessage("SwitchDocumentDirection");
},
mediaCommand : function CM_mediaCommand(command, data) {

View File

@ -540,3 +540,19 @@ let Printing = {
}
Printing.init();
function SwitchDocumentDirection(aWindow) {
// document.dir can also be "auto", in which case it won't change
if (aWindow.document.dir == "ltr" || aWindow.document.dir == "") {
aWindow.document.dir = "rtl";
} else if (aWindow.document.dir == "rtl") {
aWindow.document.dir = "ltr";
}
for (let run = 0; run < aWindow.frames.length; run++) {
SwitchDocumentDirection(aWindow.frames[run]);
}
}
addMessageListener("SwitchDocumentDirection", () => {
SwitchDocumentDirection(content.window);
});