1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/BrowserElementChild.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; 1.11 +Cu.import("resource://gre/modules/Services.jsm"); 1.12 + 1.13 +function debug(msg) { 1.14 + //dump("BrowserElementChild - " + msg + "\n"); 1.15 +} 1.16 + 1.17 +// NB: this must happen before we process any messages from 1.18 +// mozbrowser API clients. 1.19 +docShell.isActive = true; 1.20 + 1.21 +function parentDocShell(docshell) { 1.22 + if (!docshell) { 1.23 + return null; 1.24 + } 1.25 + let treeitem = docshell.QueryInterface(Ci.nsIDocShellTreeItem); 1.26 + return treeitem.parent ? treeitem.parent.QueryInterface(Ci.nsIDocShell) : null; 1.27 +} 1.28 + 1.29 +function isTopBrowserElement(docShell) { 1.30 + while (docShell) { 1.31 + docShell = parentDocShell(docShell); 1.32 + if (docShell && docShell.isBrowserOrApp) { 1.33 + return false; 1.34 + } 1.35 + } 1.36 + return true; 1.37 +} 1.38 + 1.39 +if (!('BrowserElementIsPreloaded' in this)) { 1.40 + if (isTopBrowserElement(docShell) && 1.41 + Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) { 1.42 + try { 1.43 + Services.scriptloader.loadSubScript("chrome://global/content/forms.js"); 1.44 + } catch (e) { 1.45 + } 1.46 + } 1.47 + 1.48 + Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js"); 1.49 + ContentPanning.init(); 1.50 + 1.51 + Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js"); 1.52 +} else { 1.53 + ContentPanning.init(); 1.54 +} 1.55 + 1.56 +var BrowserElementIsReady = true; 1.57 + 1.58 +let infos = sendSyncMessage('browser-element-api:call', 1.59 + { 'msg_name': 'hello' })[0]; 1.60 +docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name; 1.61 +docShell.setFullscreenAllowed(infos.fullscreenAllowed);