layout/ipc/test-ipcbrowser-content.js

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     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/. */
     5 function windowUtils() {
     6     return content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
     7                .getInterface(Components.interfaces.nsIDOMWindowUtils);
     8 }
    10 function recvSetViewport(w, h) {
    12     dump("setting viewport to "+ w +"x"+ h +"\n");
    14     windowUtils().setCSSViewport(w, h);
    15 }
    17 function recvSetDisplayPort(x, y, w, h) {
    19     dump("setting displayPort to <"+ x +", "+ y +", "+ w +", "+ h +">\n");
    21     windowUtils().setDisplayPortForElement(x, y, w, h, content.document.documentElement, 0);
    22 }
    24 function recvSetResolution(xres, yres) {
    26     dump("setting xres="+ xres +" yres="+ yres +"\n");
    28     windowUtils().setResolution(xres, yres);
    29 }
    31 function recvScrollBy(dx, dy) {
    32     content.scrollBy(dx, dy);
    33 }
    35 function recvScrollTo(x, y) {
    36     content.scrollTo(x, y);
    37 }
    39 addMessageListener(
    40     "setViewport",
    41     function (m) { recvSetViewport(m.json.w, m.json.h); }
    42 );
    44 addMessageListener(
    45     "setDisplayPort",
    46     function (m) { recvSetDisplayPort(m.json.x, m.json.y,
    47                                       m.json.w, m.json.h); }
    48 );
    50 addMessageListener(
    51     "setResolution",
    52     function (m) { recvSetResolution(m.json.xres, m.json.yres); }
    53 );
    55 addMessageListener(
    56     "scrollBy",
    57     function(m) { recvScrollBy(m.json.dx, m.json.dy); }
    58 );
    60 addMessageListener(
    61     "scrollTo",
    62     function(m) { recvScrollTo(m.json.x, m.json.y); }
    63 );

mercurial