michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function debug(msg) { michael@0: //dump("BrowserElementChild - " + msg + "\n"); michael@0: } michael@0: michael@0: // NB: this must happen before we process any messages from michael@0: // mozbrowser API clients. michael@0: docShell.isActive = true; michael@0: michael@0: function parentDocShell(docshell) { michael@0: if (!docshell) { michael@0: return null; michael@0: } michael@0: let treeitem = docshell.QueryInterface(Ci.nsIDocShellTreeItem); michael@0: return treeitem.parent ? treeitem.parent.QueryInterface(Ci.nsIDocShell) : null; michael@0: } michael@0: michael@0: function isTopBrowserElement(docShell) { michael@0: while (docShell) { michael@0: docShell = parentDocShell(docShell); michael@0: if (docShell && docShell.isBrowserOrApp) { michael@0: return false; michael@0: } michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: if (!('BrowserElementIsPreloaded' in this)) { michael@0: if (isTopBrowserElement(docShell) && michael@0: Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) { michael@0: try { michael@0: Services.scriptloader.loadSubScript("chrome://global/content/forms.js"); michael@0: } catch (e) { michael@0: } michael@0: } michael@0: michael@0: Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js"); michael@0: ContentPanning.init(); michael@0: michael@0: Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js"); michael@0: } else { michael@0: ContentPanning.init(); michael@0: } michael@0: michael@0: var BrowserElementIsReady = true; michael@0: michael@0: let infos = sendSyncMessage('browser-element-api:call', michael@0: { 'msg_name': 'hello' })[0]; michael@0: docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name; michael@0: docShell.setFullscreenAllowed(infos.fullscreenAllowed);