Bug 1575399 [wpt PR 18572] - [LayoutNG] Give flex items their stretched size earlier...
[gecko.git] / image / imgIRequest.idl
blob099497ee05dbf5edbc7f55d5749ec642cd1baaa5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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
18 * @author Stuart Parmenter <stuart@mozilla.com>
19 * @version 0.1
20 * @see imagelib2
22 [scriptable, builtinclass, uuid(db0a945c-3883-424a-98d0-2ee0523b0255)]
23 interface imgIRequest : nsIRequest
25 /**
26 * the image container...
27 * @return the image object associated with the request.
28 * @attention NEED DOCS
30 readonly attribute imgIContainer image;
32 /**
33 * Producer ID for image containers created by this image.
35 [infallible] readonly attribute unsigned long producerId;
37 /**
38 * Bits set in the return value from imageStatus
39 * @name statusflags
41 * Meanings:
43 * STATUS_NONE: Nothing to report.
45 * STATUS_SIZE_AVAILABLE: We received enough image data
46 * from the network or filesystem that we know the width
47 * and height of the image, and have thus called SetSize()
48 * on the container.
50 * STATUS_LOAD_COMPLETE: The data has been fully loaded
51 * to memory, but not necessarily fully decoded.
53 * STATUS_ERROR: An error occurred loading the image.
55 * STATUS_FRAME_COMPLETE: The first frame has been
56 * completely decoded.
58 * STATUS_DECODE_COMPLETE: The whole image has been decoded.
60 * STATUS_IS_ANIMATED: The image is animated.
62 * STATUS_HAS_TRANSPARENCY: The image is partially or completely transparent.
64 //@{
65 const long STATUS_NONE = 0x0;
66 const long STATUS_SIZE_AVAILABLE = 0x1;
67 const long STATUS_LOAD_COMPLETE = 0x2;
68 const long STATUS_ERROR = 0x4;
69 const long STATUS_FRAME_COMPLETE = 0x8;
70 const long STATUS_DECODE_COMPLETE = 0x10;
71 const long STATUS_IS_ANIMATED = 0x20;
72 const long STATUS_HAS_TRANSPARENCY = 0x40;
73 //@}
75 /**
76 * Status flags of the STATUS_* variety.
78 readonly attribute unsigned long imageStatus;
81 * Actual error code that generated a STATUS_ERROR imageStatus
82 * (see xpcom/base/ErrorList.h)
84 [noscript] readonly attribute nsresult imageErrorCode;
86 /**
87 * The URI the image load was started with. Note that this might not be the
88 * actual URI for the image (e.g. if HTTP redirects happened during the
89 * load).
91 readonly attribute nsIURI URI;
93 /**
94 * The URI of the resource we ended up loading after all redirects, etc.
96 readonly attribute nsIURI finalURI;
98 readonly attribute imgINotificationObserver notificationObserver;
100 readonly attribute string mimeType;
103 * Clone this request; the returned request will have aObserver as the
104 * observer. aObserver will be notified synchronously (before the clone()
105 * call returns) with all the notifications that have already been dispatched
106 * for this image load.
108 imgIRequest clone(in imgINotificationObserver aObserver);
111 * The principal gotten from the channel the image was loaded from.
113 readonly attribute nsIPrincipal imagePrincipal;
116 * true if the loading of the image required cross-origin redirects.
118 readonly attribute bool hadCrossOriginRedirects;
121 * Whether the request is multipart (ie, multipart/x-mixed-replace)
123 readonly attribute bool multipart;
126 * CORS modes images can be loaded with.
128 * By default, all images are loaded with CORS_NONE and cannot be used
129 * cross-origin in context like WebGL.
131 * If an HTML img element has the crossorigin attribute set, the imgIRequest
132 * will be validated for cross-origin usage with CORS, and, if successful,
133 * will have its CORS mode set to the relevant type.
135 //@{
136 const long CORS_NONE = 1;
137 const long CORS_ANONYMOUS = 2;
138 const long CORS_USE_CREDENTIALS = 3;
139 //@}
142 * The CORS mode that this image was loaded with.
144 readonly attribute long CORSMode;
147 * Cancels this request as in nsIRequest::Cancel(); further, also nulls out
148 * decoderObserver so it gets no further notifications from us.
150 * NOTE: You should not use this in any new code; instead, use cancel(). Note
151 * that cancel() is asynchronous, which means that some time after you call
152 * it, the listener/observer will get an OnStopRequest(). This means that, if
153 * you're the observer, you can't call cancel() from your destructor.
155 void cancelAndForgetObserver(in nsresult aStatus);
158 * Requests a synchronous decode for the image.
160 * imgIContainer has a startDecoding() method, but callers may want to request
161 * a decode before the container has necessarily been instantiated. Calling
162 * startDecoding() on the imgIRequest simply forwards along the request if the
163 * container already exists, or calls it once the container becomes available
164 * if it does not yet exist.
166 void startDecoding(in uint32_t aFlags);
169 * Exactly like startDecoding above except returns whether the current frame
170 * of the image is complete or not.
172 * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY
173 * is accepted; all others are ignored.
175 [noscript, notxpcom] boolean startDecodingWithResult(in uint32_t aFlags);
178 * This method triggers decoding for an image, but unlike startDecoding() it
179 * enables the caller to provide more detailed information about the decode
180 * request.
182 * @param aFlags Flags of the FLAG_* variety.
183 * @return True there is a surface that satisfies the request and it is
184 * fully decoded, else false.
186 [noscript, notxpcom] boolean requestDecodeWithResult(in uint32_t aFlags);
189 * Locks an image. If the image does not exist yet, locks it once it becomes
190 * available. The lock persists for the lifetime of the imgIRequest (until
191 * unlockImage is called) even if the underlying image changes.
193 * If you don't call unlockImage() by the time this imgIRequest goes away, it
194 * will be called for you automatically.
196 * @see imgIContainer::lockImage for documentation of the underlying call.
198 void lockImage();
201 * Unlocks an image.
203 * @see imgIContainer::unlockImage for documentation of the underlying call.
205 void unlockImage();
208 * If this image is unlocked, discard the image's decoded data. If the image
209 * is locked or is already discarded, do nothing.
211 void requestDiscard();
214 * If this request is for an animated image, the method creates a new
215 * request which contains the current frame of the image.
216 * Otherwise returns the same request.
218 imgIRequest getStaticRequest();
221 * Requests that the image animate (if it has an animation).
223 * @see Image::IncrementAnimationConsumers for documentation of the
224 * underlying call.
226 void incrementAnimationConsumers();
229 * Tell the image it can forget about a request that the image animate.
231 * @see Image::DecrementAnimationConsumers for documentation of the
232 * underlying call.
234 void decrementAnimationConsumers();
237 * Request loading priority boost to requested category, each category
238 * of request increases priority only one time.
240 * CATEGORY_FRAME_INIT: increase priority when the imgRequest is associated
241 * with an nsImageFrame.
243 * CATEGORY_FRAME_STYLE: increase priority when the imgRequest is for a CSS
244 * background-image, list-style-image, etc. on a ComputedStyle, and a frame
245 * has been assigned this ComputedStyle.
247 * CATEGORY_SIZE_QUERY: increase priority when size decoding is necessary to
248 * determine the layout size of an associated nsImageFrame.
250 * CATEGORY_DISPLAY: increase priority when the image is about to be displayed
251 * in the viewport.
253 const uint32_t CATEGORY_FRAME_INIT = 1 << 0;
254 const uint32_t CATEGORY_FRAME_STYLE = 1 << 1;
255 const uint32_t CATEGORY_SIZE_QUERY = 1 << 2;
256 const uint32_t CATEGORY_DISPLAY = 1 << 3;
257 void boostPriority(in uint32_t aCategory);