Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
8 Cu.import("resource://gre/modules/Services.jsm");
10 function debug(msg) {
11 //dump("BrowserElementChild - " + msg + "\n");
12 }
14 // NB: this must happen before we process any messages from
15 // mozbrowser API clients.
16 docShell.isActive = true;
18 function parentDocShell(docshell) {
19 if (!docshell) {
20 return null;
21 }
22 let treeitem = docshell.QueryInterface(Ci.nsIDocShellTreeItem);
23 return treeitem.parent ? treeitem.parent.QueryInterface(Ci.nsIDocShell) : null;
24 }
26 function isTopBrowserElement(docShell) {
27 while (docShell) {
28 docShell = parentDocShell(docShell);
29 if (docShell && docShell.isBrowserOrApp) {
30 return false;
31 }
32 }
33 return true;
34 }
36 if (!('BrowserElementIsPreloaded' in this)) {
37 if (isTopBrowserElement(docShell) &&
38 Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
39 try {
40 Services.scriptloader.loadSubScript("chrome://global/content/forms.js");
41 } catch (e) {
42 }
43 }
45 Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js");
46 ContentPanning.init();
48 Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js");
49 } else {
50 ContentPanning.init();
51 }
53 var BrowserElementIsReady = true;
55 let infos = sendSyncMessage('browser-element-api:call',
56 { 'msg_name': 'hello' })[0];
57 docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
58 docShell.setFullscreenAllowed(infos.fullscreenAllowed);