mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 757137, part 5: Update b2g "chrome" to use html:iframe mozbrowser, and set a manifest for the system app. r=fabrice,vingtetun
This commit is contained in:
parent
dd7fb3f7e6
commit
5feaae0e02
@ -84,6 +84,10 @@ var shell = {
|
||||
return Services.prefs.getCharPref('browser.homescreenURL');
|
||||
},
|
||||
|
||||
get manifestURL() {
|
||||
return Services.prefs.getCharPref('browser.manifestURL');
|
||||
},
|
||||
|
||||
start: function shell_start() {
|
||||
let homeURL = this.homeURL;
|
||||
if (!homeURL) {
|
||||
@ -92,6 +96,21 @@ var shell = {
|
||||
return;
|
||||
}
|
||||
|
||||
let manifestURL = this.manifestURL;
|
||||
// <html:iframe id="homescreen"
|
||||
// mozbrowser="true" mozallowfullscreen="true"
|
||||
// style="overflow: hidden; -moz-box-flex: 1; border: none;"
|
||||
// src="data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/>
|
||||
let browserFrame =
|
||||
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:iframe');
|
||||
browserFrame.setAttribute('id', 'homescreen');
|
||||
browserFrame.setAttribute('mozbrowser', 'true');
|
||||
browserFrame.setAttribute('mozapp', manifestURL);
|
||||
browserFrame.setAttribute('mozallowfullscreen', 'true');
|
||||
browserFrame.setAttribute('style', "overflow: hidden; -moz-box-flex: 1; border: none;");
|
||||
browserFrame.setAttribute('src', "data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;");
|
||||
document.getElementById('shell').appendChild(browserFrame);
|
||||
|
||||
['keydown', 'keypress', 'keyup'].forEach((function listenKey(type) {
|
||||
window.addEventListener(type, this, false, true);
|
||||
window.addEventListener(type, this, true, true);
|
||||
@ -100,7 +119,7 @@ var shell = {
|
||||
window.addEventListener('MozApplicationManifest', this);
|
||||
window.addEventListener('mozfullscreenchange', this);
|
||||
window.addEventListener('sizemodechange', this);
|
||||
this.contentBrowser.addEventListener('load', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowserloadstart', this, true);
|
||||
|
||||
// Until the volume can be set from the content side, set it to a
|
||||
// a specific value when the device starts. This way the front-end
|
||||
@ -120,14 +139,6 @@ var shell = {
|
||||
|
||||
addPermissions(domains.split(","));
|
||||
|
||||
// Load webapi.js as a frame script
|
||||
let webapiUrl = 'chrome://browser/content/webapi.js';
|
||||
try {
|
||||
messageManager.loadFrameScript(webapiUrl, true);
|
||||
} catch (e) {
|
||||
dump('shell.js: Error loading ' + webapiUrl + ' as a frame script: ' + e + '\n');
|
||||
}
|
||||
|
||||
CustomEventManager.init();
|
||||
|
||||
WebappsHelper.init();
|
||||
@ -140,9 +151,7 @@ var shell = {
|
||||
Services.prefs.setBoolPref("nglayout.debug.paint_flashing", value);
|
||||
});
|
||||
|
||||
let browser = this.contentBrowser;
|
||||
browser.homePage = homeURL;
|
||||
browser.goHome();
|
||||
this.contentBrowser.src = homeURL;
|
||||
},
|
||||
|
||||
stop: function shell_stop() {
|
||||
@ -151,11 +160,10 @@ var shell = {
|
||||
window.removeEventListener(type, this, true, true);
|
||||
}).bind(this));
|
||||
|
||||
window.addEventListener('MozApplicationManifest', this);
|
||||
window.removeEventListener('MozApplicationManifest', this);
|
||||
window.removeEventListener('mozfullscreenchange', this);
|
||||
window.removeEventListener('sizemodechange', this);
|
||||
this.contentBrowser.removeEventListener('load', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
|
||||
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
delete Services.audioManager;
|
||||
@ -186,6 +194,7 @@ var shell = {
|
||||
},
|
||||
|
||||
forwardKeyToContent: function shell_forwardKeyToContent(evt) {
|
||||
let content = shell.contentBrowser.contentWindow;
|
||||
let generatedEvent = content.document.createEvent('KeyboardEvent');
|
||||
generatedEvent.initKeyEvent(evt.type, true, true, evt.view, evt.ctrlKey,
|
||||
evt.altKey, evt.shiftKey, evt.metaKey,
|
||||
@ -195,6 +204,7 @@ var shell = {
|
||||
},
|
||||
|
||||
handleEvent: function shell_handleEvent(evt) {
|
||||
let content = this.contentBrowser.contentWindow;
|
||||
switch (evt.type) {
|
||||
case 'keydown':
|
||||
case 'keyup':
|
||||
@ -233,13 +243,13 @@ var shell = {
|
||||
break;
|
||||
case 'sizemodechange':
|
||||
if (window.windowState == window.STATE_MINIMIZED) {
|
||||
this.contentBrowser.docShell.isActive = false;
|
||||
this.contentBrowser.setVisible(false);
|
||||
} else {
|
||||
this.contentBrowser.docShell.isActive = true;
|
||||
this.contentBrowser.setVisible(true);
|
||||
}
|
||||
break;
|
||||
case 'load':
|
||||
this.contentBrowser.removeEventListener('load', this, true);
|
||||
case 'mozbrowserloadstart':
|
||||
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
|
||||
|
||||
let chromeWindow = window.QueryInterface(Ci.nsIDOMChromeWindow);
|
||||
chromeWindow.browserDOMWindow = new nsBrowserAccess();
|
||||
@ -297,6 +307,7 @@ nsBrowserAccess.prototype = {
|
||||
|
||||
openURI: function openURI(uri, opener, where, context) {
|
||||
// TODO This should be replaced by an 'open-browser-window' intent
|
||||
let content = shell.contentBrowser.contentWindow;
|
||||
let contentWindow = content.wrappedJSObject;
|
||||
if (!('getApplicationManager' in contentWindow))
|
||||
return null;
|
||||
@ -368,6 +379,7 @@ nsBrowserAccess.prototype = {
|
||||
var CustomEventManager = {
|
||||
init: function custevt_init() {
|
||||
window.addEventListener("ContentStart", (function(evt) {
|
||||
let content = shell.contentBrowser.contentWindow;
|
||||
content.addEventListener("mozContentEvent", this, false, true);
|
||||
}).bind(this), false);
|
||||
},
|
||||
@ -418,6 +430,7 @@ var AlertsHelper = {
|
||||
showAlertNotification: function alert_showAlertNotification(imageUrl, title, text, textClickable,
|
||||
cookie, alertListener, name) {
|
||||
let id = this.registerListener(cookie, alertListener);
|
||||
let content = shell.contentBrowser.contentWindow;
|
||||
shell.sendEvent(content, "mozChromeEvent", { type: "desktop-notification", id: id, icon: imageUrl,
|
||||
title: title, text: text } );
|
||||
}
|
||||
@ -454,6 +467,7 @@ var WebappsHelper = {
|
||||
},
|
||||
|
||||
observe: function webapps_observe(subject, topic, data) {
|
||||
let content = shell.contentBrowser.contentWindow;
|
||||
let json = JSON.parse(data);
|
||||
switch(topic) {
|
||||
case "webapps-launch":
|
||||
@ -576,6 +590,7 @@ window.addEventListener('ContentStart', function(evt) {
|
||||
// detail.type set to 'saved-screenshot' and detail.filename set to
|
||||
// the filename.
|
||||
window.addEventListener('ContentStart', function ss_onContentStart() {
|
||||
let content = shell.contentBrowser.contentWindow;
|
||||
content.addEventListener('mozContentEvent', function ss_onMozContentEvent(e) {
|
||||
if (e.detail.type !== 'save-screenshot')
|
||||
return;
|
||||
|
@ -16,15 +16,10 @@
|
||||
|
||||
<script type="application/javascript" src="chrome://browser/content/settings.js"/>
|
||||
<script type="application/javascript" src="chrome://browser/content/shell.js"/>
|
||||
|
||||
|
||||
#ifndef ANDROID
|
||||
<!-- this script handles the screen argument for desktop builds -->
|
||||
<script type="application/javascript" src="chrome://browser/content/screen.js"/>
|
||||
#endif
|
||||
<browser id="homescreen"
|
||||
type="content-primary"
|
||||
flex="1"
|
||||
style="overflow: hidden;"
|
||||
src="data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/>
|
||||
<!-- The html:iframe containing the UI is created here. -->
|
||||
</window>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user