Bug 787378 - Part 1: Fire a "firstpaint" event in iframe mozbrowser.

This commit is contained in:
Justin Lebar 2012-09-05 10:34:06 -04:00
parent 7c9a912940
commit fc6bed0372
2 changed files with 20 additions and 0 deletions

View File

@ -107,6 +107,12 @@ BrowserElementChild.prototype = {
/* useCapture = */ true, /* useCapture = */ true,
/* wantsUntrusted = */ false); /* wantsUntrusted = */ false);
this._afterPaintHandlerClosure = this._afterPaintHandler.bind(this);
addEventListener('MozAfterPaint',
this._afterPaintHandlerClosure,
/* useCapture = */ true,
/* wantsUntrusted = */ false);
var self = this; var self = this;
function addMsgListener(msg, handler) { function addMsgListener(msg, handler) {
addMessageListener('browser-element-api:' + msg, handler.bind(self)); addMessageListener('browser-element-api:' + msg, handler.bind(self));
@ -351,6 +357,19 @@ BrowserElementChild.prototype = {
} }
}, },
_afterPaintHandler: function(e) {
let uri = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI;
debug("Got afterpaint event: " + uri.spec);
if (uri.spec != "about:blank") {
/* this._afterPaintHandlerClosure == arguments.callee, except we're in
* strict mode so we don't have arguments.callee. */
removeEventListener('MozAfterPaint', this._afterPaintHandlerClosure,
/* useCapture */ true);
sendAsyncMsg('firstpaint');
}
},
_closeHandler: function(e) { _closeHandler: function(e) {
let win = e.target; let win = e.target;
if (win != content || e.defaultPrevented) { if (win != content || e.defaultPrevented) {

View File

@ -195,6 +195,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
addMessageListener("securitychange", this._fireEventFromMsg); addMessageListener("securitychange", this._fireEventFromMsg);
addMessageListener("error", this._fireEventFromMsg); addMessageListener("error", this._fireEventFromMsg);
addMessageListener("scroll", this._fireEventFromMsg); addMessageListener("scroll", this._fireEventFromMsg);
addMessageListener("firstpaint", this._fireEventFromMsg);
addMessageListener("keyevent", this._fireKeyEvent); addMessageListener("keyevent", this._fireKeyEvent);
addMessageListener("showmodalprompt", this._handleShowModalPrompt); addMessageListener("showmodalprompt", this._handleShowModalPrompt);
addMessageListener('got-screenshot', this._gotDOMRequestResult); addMessageListener('got-screenshot', this._gotDOMRequestResult);