|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function windowUtils() { |
|
6 return content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
|
7 .getInterface(Components.interfaces.nsIDOMWindowUtils); |
|
8 } |
|
9 |
|
10 function recvSetViewport(w, h) { |
|
11 |
|
12 dump("setting viewport to "+ w +"x"+ h +"\n"); |
|
13 |
|
14 windowUtils().setCSSViewport(w, h); |
|
15 } |
|
16 |
|
17 function recvSetDisplayPort(x, y, w, h) { |
|
18 |
|
19 dump("setting displayPort to <"+ x +", "+ y +", "+ w +", "+ h +">\n"); |
|
20 |
|
21 windowUtils().setDisplayPortForElement(x, y, w, h, content.document.documentElement, 0); |
|
22 } |
|
23 |
|
24 function recvSetResolution(xres, yres) { |
|
25 |
|
26 dump("setting xres="+ xres +" yres="+ yres +"\n"); |
|
27 |
|
28 windowUtils().setResolution(xres, yres); |
|
29 } |
|
30 |
|
31 function recvScrollBy(dx, dy) { |
|
32 content.scrollBy(dx, dy); |
|
33 } |
|
34 |
|
35 function recvScrollTo(x, y) { |
|
36 content.scrollTo(x, y); |
|
37 } |
|
38 |
|
39 addMessageListener( |
|
40 "setViewport", |
|
41 function (m) { recvSetViewport(m.json.w, m.json.h); } |
|
42 ); |
|
43 |
|
44 addMessageListener( |
|
45 "setDisplayPort", |
|
46 function (m) { recvSetDisplayPort(m.json.x, m.json.y, |
|
47 m.json.w, m.json.h); } |
|
48 ); |
|
49 |
|
50 addMessageListener( |
|
51 "setResolution", |
|
52 function (m) { recvSetResolution(m.json.xres, m.json.yres); } |
|
53 ); |
|
54 |
|
55 addMessageListener( |
|
56 "scrollBy", |
|
57 function(m) { recvScrollBy(m.json.dx, m.json.dy); } |
|
58 ); |
|
59 |
|
60 addMessageListener( |
|
61 "scrollTo", |
|
62 function(m) { recvScrollTo(m.json.x, m.json.y); } |
|
63 ); |