Bug 1777732 [wpt PR 34677] - Check for 'revert-layer' in both versions of IsCSSWideKe...
[gecko.git] / image / imgIRequest.idl
blob0a5bb6285f8171d8bc233bdc369377b7d71f1700
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"
9 #include "imgIContainer.idl"
11 //interface imgIContainer;
12 interface imgINotificationObserver;
13 interface nsIURI;
14 interface nsIPrincipal;
16 /**
17 * imgIRequest interface
19 * @author Stuart Parmenter <stuart@mozilla.com>
20 * @version 0.1
21 * @see imagelib2
23 [scriptable, builtinclass, uuid(db0a945c-3883-424a-98d0-2ee0523b0255)]
24 interface imgIRequest : nsIRequest
26 /**
27 * the image container...
28 * @return the image object associated with the request.
29 * @attention NEED DOCS
31 readonly attribute imgIContainer image;
33 /**
34 * Provider ID for image providers created by this image.
36 [infallible] readonly attribute unsigned long providerId;
38 /**
39 * Bits set in the return value from imageStatus
40 * @name statusflags
42 * Meanings:
44 * STATUS_NONE: Nothing to report.
46 * STATUS_SIZE_AVAILABLE: We received enough image data
47 * from the network or filesystem that we know the width
48 * and height of the image, and have thus called SetSize()
49 * on the container.
51 * STATUS_LOAD_COMPLETE: The data has been fully loaded
52 * to memory, but not necessarily fully decoded.
54 * STATUS_ERROR: An error occurred loading the image.
56 * STATUS_FRAME_COMPLETE: The first frame has been
57 * completely decoded.
59 * STATUS_DECODE_COMPLETE: The whole image has been decoded.
61 * STATUS_IS_ANIMATED: The image is animated.
63 * STATUS_HAS_TRANSPARENCY: The image is partially or completely transparent.
65 //@{
66 const long STATUS_NONE = 0x0;
67 const long STATUS_SIZE_AVAILABLE = 0x1;
68 const long STATUS_LOAD_COMPLETE = 0x2;
69 const long STATUS_ERROR = 0x4;
70 const long STATUS_FRAME_COMPLETE = 0x8;
71 const long STATUS_DECODE_COMPLETE = 0x10;
72 const long STATUS_IS_ANIMATED = 0x20;
73 const long STATUS_HAS_TRANSPARENCY = 0x40;
74 //@}
76 /**
77 * Status flags of the STATUS_* variety.
79 readonly attribute unsigned long imageStatus;
82 * Actual error code that generated a STATUS_ERROR imageStatus
83 * (see xpcom/base/ErrorList.h)
85 [noscript] readonly attribute nsresult imageErrorCode;
87 /**
88 * The URI the image load was started with. Note that this might not be the
89 * actual URI for the image (e.g. if HTTP redirects happened during the
90 * load).
92 readonly attribute nsIURI URI;
94 /**
95 * The URI of the resource we ended up loading after all redirects, etc.
97 readonly attribute nsIURI finalURI;
99 readonly attribute imgINotificationObserver notificationObserver;
101 readonly attribute string mimeType;
104 * The filename that should be used when saving the image. This is determined
105 * from the Content-Disposition, if present, or the uri of the image. This
106 * filename should be validated using nsIMIMEService::GetValidFilenameForSaving
107 * before creating the file.
109 readonly attribute ACString fileName;
112 * Clone this request; the returned request will have aObserver as the
113 * observer. aObserver will be notified synchronously (before the clone()
114 * call returns) with all the notifications that have already been dispatched
115 * for this image load.
117 imgIRequest clone(in imgINotificationObserver aObserver);
120 * The principal gotten from the channel the image was loaded from.
122 readonly attribute nsIPrincipal imagePrincipal;
125 * true if the loading of the image required cross-origin redirects.
127 readonly attribute bool hadCrossOriginRedirects;
130 * Whether the request is multipart (ie, multipart/x-mixed-replace)
132 readonly attribute bool multipart;
135 * The CORS mode that this image was loaded with (a mozilla::CORSMode).
137 readonly attribute long CORSMode;
140 * Cancels this request as in nsIRequest::Cancel(); further, also nulls out
141 * decoderObserver so it gets no further notifications from us.
143 * NOTE: You should not use this in any new code; instead, use cancel(). Note
144 * that cancel() is asynchronous, which means that some time after you call
145 * it, the listener/observer will get an OnStopRequest(). This means that, if
146 * you're the observer, you can't call cancel() from your destructor.
148 void cancelAndForgetObserver(in nsresult aStatus);
151 * Requests a synchronous decode for the image.
153 * imgIContainer has a startDecoding() method, but callers may want to request
154 * a decode before the container has necessarily been instantiated. Calling
155 * startDecoding() on the imgIRequest simply forwards along the request if the
156 * container already exists, or calls it once the container becomes available
157 * if it does not yet exist.
159 void startDecoding(in uint32_t aFlags);
162 * Exactly like startDecoding above except returns whether the current frame
163 * of the image is complete or not.
165 * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY
166 * is accepted; all others are ignored.
168 [noscript, notxpcom] boolean startDecodingWithResult(in uint32_t aFlags);
171 * This method triggers decoding for an image, but unlike startDecoding() it
172 * enables the caller to provide more detailed information about the decode
173 * request.
175 * @param aFlags Flags of the FLAG_* variety.
176 * @return DECODE_SURFACE_AVAILABLE if is a surface that satisfies the
177 * request and it is fully decoded.
178 * DECODE_REQUESTED if we requested a decode.
179 * DECODE_REQUEST_FAILED if we failed to request a decode. This means
180 * that either there is an error in the image or we cannot allocate a
181 * surface that big.
183 [noscript, notxpcom] imgIContainer_DecodeResult requestDecodeWithResult(in uint32_t aFlags);
184 /*%{C++
185 DecodeResult RequestDecodeWithResult(uint32_t aFlags);
186 %}*/
189 * Returns true if there is a image and the image has a frame and the frame
190 * currently has a least 1 decoded pixel. Only valid for raster images.
192 [noscript, notxpcom] boolean hasDecodedPixels();
195 * Locks an image. If the image does not exist yet, locks it once it becomes
196 * available. The lock persists for the lifetime of the imgIRequest (until
197 * unlockImage is called) even if the underlying image changes.
199 * If you don't call unlockImage() by the time this imgIRequest goes away, it
200 * will be called for you automatically.
202 * @see imgIContainer::lockImage for documentation of the underlying call.
204 void lockImage();
207 * Unlocks an image.
209 * @see imgIContainer::unlockImage for documentation of the underlying call.
211 void unlockImage();
214 * If this image is unlocked, discard the image's decoded data. If the image
215 * is locked or is already discarded, do nothing.
217 void requestDiscard();
220 * If this request is for an animated image, the method creates a new
221 * request which contains the current frame of the image.
222 * Otherwise returns the same request.
224 imgIRequest getStaticRequest();
227 * Requests that the image animate (if it has an animation).
229 * @see Image::IncrementAnimationConsumers for documentation of the
230 * underlying call.
232 void incrementAnimationConsumers();
235 * Tell the image it can forget about a request that the image animate.
237 * @see Image::DecrementAnimationConsumers for documentation of the
238 * underlying call.
240 void decrementAnimationConsumers();
243 * Request loading priority boost to requested category, each category
244 * of request increases priority only one time.
246 * CATEGORY_FRAME_INIT: increase priority when the imgRequest is associated
247 * with an nsImageFrame.
249 * CATEGORY_FRAME_STYLE: increase priority when the imgRequest is for a CSS
250 * background-image, list-style-image, etc. on a ComputedStyle, and a frame
251 * has been assigned this ComputedStyle.
253 * CATEGORY_SIZE_QUERY: increase priority when size decoding is necessary to
254 * determine the layout size of an associated nsImageFrame.
256 * CATEGORY_DISPLAY: increase priority when the image is about to be displayed
257 * in the viewport.
259 const uint32_t CATEGORY_FRAME_INIT = 1 << 0;
260 const uint32_t CATEGORY_FRAME_STYLE = 1 << 1;
261 const uint32_t CATEGORY_SIZE_QUERY = 1 << 2;
262 const uint32_t CATEGORY_DISPLAY = 1 << 3;
263 void boostPriority(in uint32_t aCategory);