image/public/imgIRequest.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "nsISupports.idl"
     8 #include "nsIRequest.idl"
    10 interface imgIContainer;
    11 interface imgINotificationObserver;
    12 interface nsIURI;
    13 interface nsIPrincipal;
    15 /**
    16  * imgIRequest interface
    17  *
    18  * @author Stuart Parmenter <stuart@mozilla.com>
    19  * @version 0.1
    20  * @see imagelib2
    21  */
    22 [scriptable, builtinclass, uuid(9c709b50-bd1a-476d-b313-d64db874f80a)]
    23 interface imgIRequest : nsIRequest
    24 {
    25   /**
    26    * the image container...
    27    * @return the image object associated with the request.
    28    * @attention NEED DOCS
    29    */
    30   readonly attribute imgIContainer image;
    32   /**
    33    * Bits set in the return value from imageStatus
    34    * @name statusflags
    35    *
    36    * Meanings:
    37    *
    38    * STATUS_NONE: Nothing to report.
    39    *
    40    * STATUS_SIZE_AVAILABLE: We received enough image data
    41    * from the network or filesystem that we know the width
    42    * and height of the image, and have thus called SetSize()
    43    * on the container.
    44    *
    45    * STATUS_LOAD_PARTIAL: Used internally by imgRequest to
    46    * flag that a request is being cancelled as a result of
    47    * a failure of a proxy holder and not an internal failure.
    48    * At least I think that's what it does. Regardless, there's
    49    * no reason for this flag to be public, and it should either
    50    * go away or become a private state flag within imgRequest.
    51    * Don't rely on it.
    52    *
    53    * STATUS_LOAD_COMPLETE: The data has been fully loaded
    54    * to memory, but not necessarily fully decoded.
    55    *
    56    * STATUS_ERROR: An error occurred loading the image.
    57    *
    58    * STATUS_DECODE_STARTED: The decoding process has begun, but not yet
    59    * finished.
    60    *
    61    * STATUS_FRAME_COMPLETE: The first frame has been
    62    * completely decoded.
    63    *
    64    * STATUS_DECODE_COMPLETE: The whole image has been decoded.
    65    */
    66   //@{
    67   const long STATUS_NONE             = 0x0;
    68   const long STATUS_SIZE_AVAILABLE   = 0x1;
    69   const long STATUS_LOAD_PARTIAL     = 0x2;
    70   const long STATUS_LOAD_COMPLETE    = 0x4;
    71   const long STATUS_ERROR            = 0x8;
    72   const long STATUS_DECODE_STARTED   = 0x10;
    73   const long STATUS_FRAME_COMPLETE   = 0x20;
    74   const long STATUS_DECODE_COMPLETE  = 0x40;
    75   //@}
    77   /**
    78    * Status flags of the STATUS_* variety.
    79    */
    80   readonly attribute unsigned long imageStatus;
    82   /**
    83    * The URI the image load was started with.  Note that this might not be the
    84    * actual URI for the image (e.g. if HTTP redirects happened during the
    85    * load).
    86    */
    87   readonly attribute nsIURI URI;
    89   readonly attribute imgINotificationObserver notificationObserver;
    91   readonly attribute string mimeType;
    93   /**
    94    * Clone this request; the returned request will have aObserver as the
    95    * observer.  aObserver will be notified synchronously (before the clone()
    96    * call returns) with all the notifications that have already been dispatched
    97    * for this image load.
    98    */
    99   imgIRequest clone(in imgINotificationObserver aObserver);
   101   /**
   102    * The principal gotten from the channel the image was loaded from.
   103    */
   104   readonly attribute nsIPrincipal imagePrincipal;
   106   /**
   107    * Whether the request is multipart (ie, multipart/x-mixed-replace)
   108    */
   109   readonly attribute bool multipart;
   111   /**
   112    * CORS modes images can be loaded with.
   113    *
   114    * By default, all images are loaded with CORS_NONE and cannot be used
   115    * cross-origin in context like WebGL.
   116    *
   117    * If an HTML img element has the crossorigin attribute set, the imgIRequest
   118    * will be validated for cross-origin usage with CORS, and, if successful,
   119    * will have its CORS mode set to the relevant type.
   120    */
   121   //@{
   122   const long CORS_NONE = 1;
   123   const long CORS_ANONYMOUS = 2;
   124   const long CORS_USE_CREDENTIALS = 3;
   125   //@}
   127   /**
   128    * The CORS mode that this image was loaded with. 
   129    */
   130   readonly attribute long CORSMode;
   132   /**
   133    * Cancels this request as in nsIRequest::Cancel(); further, also nulls out
   134    * decoderObserver so it gets no further notifications from us.
   135    *
   136    * NOTE: You should not use this in any new code; instead, use cancel(). Note
   137    * that cancel() is asynchronous, which means that some time after you call
   138    * it, the listener/observer will get an OnStopRequest(). This means that, if
   139    * you're the observer, you can't call cancel() from your destructor.
   140    */
   141   void cancelAndForgetObserver(in nsresult aStatus);
   143   /**
   144    * Requests a decode for the image.
   145    *
   146    * imgIContainer has a requestDecode() method, but callers may want to request
   147    * a decode before the container has necessarily been instantiated. Calling
   148    * requestDecode() on the imgIRequest simply forwards along the request if the
   149    * container already exists, or calls it once it gets OnStartContainer if the
   150    * container does not yet exist.
   151    */
   152   void requestDecode();
   153   void startDecoding();
   155   /**
   156    * Locks an image. If the image does not exist yet, locks it once it becomes
   157    * available. The lock persists for the lifetime of the imgIRequest (until
   158    * unlockImage is called) even if the underlying image changes.
   159    *
   160    * If you don't call unlockImage() by the time this imgIRequest goes away, it
   161    * will be called for you automatically.
   162    *
   163    * @see imgIContainer::lockImage for documentation of the underlying call.
   164    */
   165   void lockImage();
   167   /**
   168    * Unlocks an image.
   169    *
   170    * @see imgIContainer::unlockImage for documentation of the underlying call.
   171    */
   172   void unlockImage();
   174   /**
   175    * If this image is unlocked, discard the image's decoded data.  If the image
   176    * is locked or is already discarded, do nothing.
   177    */
   178   void requestDiscard();
   180   /**
   181    * If this request is for an animated image, the method creates a new
   182    * request which contains the current frame of the image.
   183    * Otherwise returns the same request.
   184    */
   185   imgIRequest getStaticRequest();
   187   /**
   188    * Requests that the image animate (if it has an animation).
   189    *
   190    * @see Image::IncrementAnimationConsumers for documentation of the underlying call.
   191    */
   192   void incrementAnimationConsumers();
   194   /**
   195    * Tell the image it can forget about a request that the image animate.
   196    *
   197    * @see Image::DecrementAnimationConsumers for documentation of the underlying call.
   198    */
   199   void decrementAnimationConsumers();
   200 };

mercurial