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