Source code

Revision control

Other Tools

1
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
"use strict";
6
7
var EXPORTED_SYMBOLS = ["DOMFullscreenChild"];
8
9
const { ActorChild } = ChromeUtils.import(
11
);
12
13
class DOMFullscreenChild extends ActorChild {
14
receiveMessage(aMessage) {
15
let windowUtils = this.content && this.content.windowUtils;
16
switch (aMessage.name) {
17
case "DOMFullscreen:Entered": {
18
this._lastTransactionId = windowUtils.lastTransactionId;
19
if (
20
!windowUtils.handleFullscreenRequests() &&
21
!this.content.document.fullscreenElement
22
) {
23
// If we don't actually have any pending fullscreen request
24
// to handle, neither we have been in fullscreen, tell the
25
// parent to just exit.
26
this.mm.sendAsyncMessage("DOMFullscreen:Exit");
27
}
28
break;
29
}
30
case "DOMFullscreen:CleanUp": {
31
// If we've exited fullscreen at this point, no need to record
32
// transaction id or call exit fullscreen. This is especially
33
// important for non-e10s, since in that case, it is possible
34
// that no more paint would be triggered after this point.
35
if (this.content.document.fullscreenElement && windowUtils) {
36
this._lastTransactionId = windowUtils.lastTransactionId;
37
windowUtils.exitFullscreen();
38
}
39
break;
40
}
41
}
42
}
43
44
handleEvent(aEvent) {
45
switch (aEvent.type) {
46
case "MozDOMFullscreen:Request": {
47
this.mm.sendAsyncMessage("DOMFullscreen:Request");
48
break;
49
}
50
case "MozDOMFullscreen:NewOrigin": {
51
this.mm.sendAsyncMessage("DOMFullscreen:NewOrigin", {
52
originNoSuffix: aEvent.target.nodePrincipal.originNoSuffix,
53
});
54
break;
55
}
56
case "MozDOMFullscreen:Exit": {
57
this.mm.sendAsyncMessage("DOMFullscreen:Exit");
58
break;
59
}
60
case "MozDOMFullscreen:Entered":
61
case "MozDOMFullscreen:Exited": {
62
this.mm.addEventListener("MozAfterPaint", this);
63
if (!this.content || !this.content.document.fullscreenElement) {
64
// If we receive any fullscreen change event, and find we are
65
// actually not in fullscreen, also ask the parent to exit to
66
// ensure that the parent always exits fullscreen when we do.
67
this.mm.sendAsyncMessage("DOMFullscreen:Exit");
68
}
69
break;
70
}
71
case "MozAfterPaint": {
72
// Only send Painted signal after we actually finish painting
73
// the transition for the fullscreen change.
74
// Note that this._lastTransactionId is not set when in non-e10s
75
// mode, so we need to check that explicitly.
76
if (
77
!this._lastTransactionId ||
78
aEvent.transactionId > this._lastTransactionId
79
) {
80
this.mm.removeEventListener("MozAfterPaint", this);
81
this.mm.sendAsyncMessage("DOMFullscreen:Painted");
82
}
83
break;
84
}
85
}
86
}
87
}