michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function windowUtils() { michael@0: return content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) michael@0: .getInterface(Components.interfaces.nsIDOMWindowUtils); michael@0: } michael@0: michael@0: function recvSetViewport(w, h) { michael@0: michael@0: dump("setting viewport to "+ w +"x"+ h +"\n"); michael@0: michael@0: windowUtils().setCSSViewport(w, h); michael@0: } michael@0: michael@0: function recvSetDisplayPort(x, y, w, h) { michael@0: michael@0: dump("setting displayPort to <"+ x +", "+ y +", "+ w +", "+ h +">\n"); michael@0: michael@0: windowUtils().setDisplayPortForElement(x, y, w, h, content.document.documentElement, 0); michael@0: } michael@0: michael@0: function recvSetResolution(xres, yres) { michael@0: michael@0: dump("setting xres="+ xres +" yres="+ yres +"\n"); michael@0: michael@0: windowUtils().setResolution(xres, yres); michael@0: } michael@0: michael@0: function recvScrollBy(dx, dy) { michael@0: content.scrollBy(dx, dy); michael@0: } michael@0: michael@0: function recvScrollTo(x, y) { michael@0: content.scrollTo(x, y); michael@0: } michael@0: michael@0: addMessageListener( michael@0: "setViewport", michael@0: function (m) { recvSetViewport(m.json.w, m.json.h); } michael@0: ); michael@0: michael@0: addMessageListener( michael@0: "setDisplayPort", michael@0: function (m) { recvSetDisplayPort(m.json.x, m.json.y, michael@0: m.json.w, m.json.h); } michael@0: ); michael@0: michael@0: addMessageListener( michael@0: "setResolution", michael@0: function (m) { recvSetResolution(m.json.xres, m.json.yres); } michael@0: ); michael@0: michael@0: addMessageListener( michael@0: "scrollBy", michael@0: function(m) { recvScrollBy(m.json.dx, m.json.dy); } michael@0: ); michael@0: michael@0: addMessageListener( michael@0: "scrollTo", michael@0: function(m) { recvScrollTo(m.json.x, m.json.y); } michael@0: );