|
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/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; |
|
8 Cu.import("resource://gre/modules/Services.jsm"); |
|
9 |
|
10 function debug(msg) { |
|
11 //dump("BrowserElementChild - " + msg + "\n"); |
|
12 } |
|
13 |
|
14 // NB: this must happen before we process any messages from |
|
15 // mozbrowser API clients. |
|
16 docShell.isActive = true; |
|
17 |
|
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 } |
|
25 |
|
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 } |
|
35 |
|
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 } |
|
44 |
|
45 Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js"); |
|
46 ContentPanning.init(); |
|
47 |
|
48 Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js"); |
|
49 } else { |
|
50 ContentPanning.init(); |
|
51 } |
|
52 |
|
53 var BrowserElementIsReady = true; |
|
54 |
|
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); |