image/public/imgIRequest.idl

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial