Bug 1550519 - Show a translucent parent highlight when a subgrid is highlighted....
[gecko.git] / dom / base / nsIImageLoadingContent.idl
blob9356aacd9a96aeac3c4c3dc49a485af3b6cd2694
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "imgINotificationObserver.idl"
8 %{C++
9 #include "mozilla/Maybe.h"
10 #include "Visibility.h"
13 interface imgIRequest;
14 interface nsIChannel;
15 interface nsIStreamListener;
16 interface nsIURI;
17 interface nsIFrame;
19 [ref] native MaybeOnNonvisible(const mozilla::Maybe<mozilla::OnNonvisible>);
20 native Visibility(mozilla::Visibility);
22 /**
23 * This interface represents a content node that loads images. The interface
24 * exists to allow getting information on the images that the content node
25 * loads and to allow registration of observers for the image loads.
27 * Implementors of this interface should handle all the mechanics of actually
28 * loading an image -- getting the URI, checking with content policies and
29 * the security manager to see whether loading the URI is allowed, performing
30 * the load, firing any DOM events as needed.
32 * An implementation of this interface may support the concepts of a
33 * "current" image and a "pending" image. If it does, a request to change
34 * the currently loaded image will start a "pending" request which will
35 * become current only when the image is loaded. It is the responsibility of
36 * observers to check which request they are getting notifications for.
38 * Please make sure to update the MozImageLoadingContent WebIDL
39 * interface to mirror this interface when changing it.
42 // We can't make this interface noscript yet, because there is JS code doing
43 // "instanceof Ci.nsIImageLoadingContent" and using the nsIImageLoadingContent
44 // constants.
45 [scriptable, builtinclass, uuid(0357123d-9224-4d12-a47e-868c32689777)]
46 interface nsIImageLoadingContent : imgINotificationObserver
48 /**
49 * Request types. Image loading content nodes attempt to do atomic
50 * image changes when the image url is changed. This means that
51 * when the url changes the new image load will start, but the old
52 * image will remain the "current" request until the new image is
53 * fully loaded. At that point, the old "current" request will be
54 * discarded and the "pending" request will become "current".
56 const long UNKNOWN_REQUEST = -1;
57 const long CURRENT_REQUEST = 0;
58 const long PENDING_REQUEST = 1;
60 /**
61 * setLoadingEnabled is used to enable and disable loading in
62 * situations where loading images is unwanted. Note that enabling
63 * loading will *not* automatically trigger an image load.
65 [notxpcom, nostdcall] void setLoadingEnabled(in boolean aEnabled);
67 /**
68 * Returns the image blocking status (@see nsIContentPolicy). This
69 * will always be an nsIContentPolicy REJECT_* status for cases when
70 * the image was blocked. This status always refers to the
71 * CURRENT_REQUEST load.
73 [notxpcom, nostdcall] readonly attribute short imageBlockingStatus;
75 /**
76 * Used to register an image decoder observer. Typically, this will
77 * be a proxy for a frame that wants to paint the image.
78 * Notifications from ongoing image loads will be passed to all
79 * registered observers. Notifications for all request types,
80 * current and pending, will be passed through.
82 * @param aObserver the observer to register
84 [notxpcom, nostdcall] void addNativeObserver(in imgINotificationObserver aObserver);
86 /**
87 * Used to unregister an image decoder observer.
89 * @param aObserver the observer to unregister
91 [notxpcom, nostdcall] void removeNativeObserver(in imgINotificationObserver aObserver);
93 /**
94 * Accessor to get the image requests
96 * @param aRequestType a value saying which request is wanted
98 * @return the imgIRequest object (may be null, even when no error
99 * is thrown)
101 * @throws NS_ERROR_UNEXPECTED if the request type requested is not
102 * known
104 [noscript] imgIRequest getRequest(in long aRequestType);
107 * Call this function when the request was blocked by any of the
108 * security policies enforced.
110 * @param aContentDecision the decision returned from nsIContentPolicy
111 * (any of the types REJECT_*)
113 [notxpcom, nostdcall] void setBlockedRequest(in int16_t aContentDecision);
116 * Used to notify the image loading content node that a frame has been
117 * created.
119 [notxpcom] void frameCreated(in nsIFrame aFrame);
122 * Used to notify the image loading content node that a frame has been
123 * destroyed.
125 [notxpcom] void frameDestroyed(in nsIFrame aFrame);
128 * Used to find out what type of request one is dealing with (eg
129 * which request got passed through to the imgINotificationObserver
130 * interface of an observer)
132 * @param aRequest the request whose type we want to know
134 * @return an enum value saying what type this request is
136 * @throws NS_ERROR_UNEXPECTED if aRequest is not known
138 [noscript] long getRequestType(in imgIRequest aRequest);
141 * Gets the URI of the current request, if available.
142 * Otherwise, returns the last URI that this content tried to load, or
143 * null if there haven't been any such attempts.
145 [noscript] readonly attribute nsIURI currentURI;
148 * loadImageWithChannel allows data from an existing channel to be
149 * used as the image data for this content node.
151 * @param aChannel the channel that will deliver the data
153 * @return a stream listener to pump the image data into
155 * @see imgILoader::loadImageWithChannel
157 * @throws NS_ERROR_NULL_POINTER if aChannel is null
159 [noscript] nsIStreamListener loadImageWithChannel(in nsIChannel aChannel);
162 * Enables/disables image state forcing. When |aForce| is true, we force
163 * nsImageLoadingContent::ImageState() to return |aState|. Call again with |aForce|
164 * as false to revert ImageState() to its original behaviour.
166 [notxpcom, nostdcall] void forceImageState(in boolean aForce, in unsigned long long aState);
169 * Called by layout to announce when the frame associated with this content
170 * has changed its visibility state.
172 * @param aNewVisibility The new visibility state.
173 * @param aNonvisibleAction A requested action if the frame has become
174 * nonvisible. If Nothing(), no action is
175 * requested. If DISCARD_IMAGES is specified, the
176 * frame is requested to ask any images it's
177 * associated with to discard their surfaces if
178 * possible.
180 [noscript, notxpcom] void onVisibilityChange(in Visibility aNewVisibility,
181 in MaybeOnNonvisible aNonvisibleAction);