browser/components/tabview/content.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 let Cu = Components.utils;
     8 let Ci = Components.interfaces;
    10 Cu.import("resource:///modules/tabview/utils.jsm");
    12 // Bug 671101 - directly using webProgress in this context
    13 // causes docShells to leak
    14 this.__defineGetter__("webProgress", function () {
    15   let ifaceReq = docShell.QueryInterface(Ci.nsIInterfaceRequestor);
    16   return ifaceReq.getInterface(Ci.nsIWebProgress);
    17 });
    19 // ----------
    20 // WindowEventHandler
    21 //
    22 // Handles events dispatched by the content window.
    23 let WindowEventHandler = {
    24   // ----------
    25   // Function: onDOMWillOpenModalDialog
    26   // Sends a synchronous message when the "onDOMWillOpenModalDialog" event
    27   // is fired right before a modal dialog will be opened by the current page.
    28   onDOMWillOpenModalDialog: function WEH_onDOMWillOpenModalDialog(event) {
    29     // (event.isTrusted == true) when the event is generated by a user action
    30     // and does not originate from a script.
    31     if (!event.isTrusted)
    32       return;
    34     // we're intentionally sending a synchronous message to handle this event
    35     // as quick as possible, switch the selected tab and hide the tabview
    36     // before the modal dialog is shown
    37     sendSyncMessage("Panorama:DOMWillOpenModalDialog");
    38   },
    40   // ----------
    41   // Function: onMozAfterPaint
    42   // Sends an asynchronous message when the "onMozAfterPaint" event
    43   // is fired.
    44   onMozAfterPaint: function WEH_onMozAfterPaint(event) {
    45     if (event.clientRects.length > 0) {
    46       sendAsyncMessage("Panorama:MozAfterPaint");
    47     }
    48   }
    49 };
    51 // add event listeners
    52 addEventListener("DOMWillOpenModalDialog", WindowEventHandler.onDOMWillOpenModalDialog, false);
    53 addEventListener("MozAfterPaint", WindowEventHandler.onMozAfterPaint, false);
    55 // ----------
    56 // WindowMessageHandler
    57 //
    58 // Handles messages sent by the chrome process.
    59 let WindowMessageHandler = {
    60   // ----------
    61   // Function: isDocumentLoaded
    62   // Checks if the currently active document is loaded.
    63   isDocumentLoaded: function WMH_isDocumentLoaded(cx) {
    64     let isLoaded = (content.document.readyState != "uninitialized" &&
    65                     !webProgress.isLoadingDocument);
    67     sendAsyncMessage(cx.name, {isLoaded: isLoaded});
    68   },
    70   // ----------
    71   // Function: isImageDocument
    72   // Checks if the currently active document is an image document or not.
    73   isImageDocument: function WMH_isImageDocument(cx) {
    74     let isImageDocument = (content.document instanceof Ci.nsIImageDocument);
    76     sendAsyncMessage(cx.name, {isImageDocument: isImageDocument});
    77   }
    78 };
    80 // add message listeners
    81 addMessageListener("Panorama:isDocumentLoaded", WindowMessageHandler.isDocumentLoaded);
    82 addMessageListener("Panorama:isImageDocument", WindowMessageHandler.isImageDocument);

mercurial