1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Boris Zbarsky <bzbarsky@mit.edu>.
19 * Portions created by the Initial Developer are Copyright (C) 2003
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include
"imgIDecoderObserver.idl"
40 interface imgIRequest
;
42 interface nsIStreamListener
;
46 * This interface represents a content node that loads images. The interface
47 * exists to allow getting information on the images that the content node
48 * loads and to allow registration of observers for the image loads.
50 * Implementors of this interface should handle all the mechanics of actually
51 * loading an image -- getting the URI, checking with content policies and
52 * the security manager to see whether loading the URI is allowed, performing
53 * the load, firing any DOM events as needed.
55 * An implementation of this interface may support the concepts of a
56 * "current" image and a "pending" image. If it does, a request to change
57 * the currently loaded image will start a "pending" request which will
58 * become current only when the image is loaded. It is the responsibility of
59 * observers to check which request they are getting notifications for.
61 * Observers added in mid-load will not get any notifications they
62 * missed. We should NOT freeze this interface without considering
63 * this issue. (It could be that the image status on imgIRequest is
64 * sufficient, when combined with the imageBlockingStatus information.)
67 [scriptable
, uuid(7744c6d3
-5c60
-4b7b
-a526
-4fe9d5ac7e97
)]
68 interface nsIImageLoadingContent
: imgIDecoderObserver
71 * Request types. Image loading content nodes attempt to do atomic
72 * image changes when the image url is changed. This means that
73 * when the url changes the new image load will start, but the old
74 * image will remain the "current" request until the new image is
75 * fully loaded. At that point, the old "current" request will be
76 * discarded and the "pending" request will become "current".
78 const long UNKNOWN_REQUEST
= -1;
79 const long CURRENT_REQUEST
= 0;
80 const long PENDING_REQUEST
= 1;
83 * loadingEnabled is used to enable and disable loading in
84 * situations where loading images is unwanted. Note that enabling
85 * loading will *not* automatically trigger an image load.
87 attribute
boolean loadingEnabled
;
90 * Returns the image blocking status (@see nsIContentPolicy). This
91 * will always be an nsIContentPolicy REJECT_* status for cases when
92 * the image was blocked. This status always refers to the
93 * CURRENT_REQUEST load.
95 readonly attribute
short imageBlockingStatus
;
98 * Used to register an image decoder observer. Typically, this will
99 * be a proxy for a frame that wants to paint the image.
100 * Notifications from ongoing image loads will be passed to all
101 * registered observers. Notifications for all request types,
102 * current and pending, will be passed through.
104 * @param aObserver the observer to register
106 * @throws NS_ERROR_OUT_OF_MEMORY
108 void addObserver
(in imgIDecoderObserver aObserver
);
111 * Used to unregister an image decoder observer.
113 * @param aObserver the observer to unregister
115 void removeObserver
(in imgIDecoderObserver aObserver
);
118 * Accessor to get the image requests
120 * @param aRequestType a value saying which request is wanted
122 * @return the imgIRequest object (may be null, even when no error
125 * @throws NS_ERROR_UNEXPECTED if the request type requested is not
128 imgIRequest getRequest
(in long aRequestType
);
131 * Used to find out what type of request one is dealing with (eg
132 * which request got passed through to the imgIDecoderObserver
133 * interface of an observer)
135 * @param aRequest the request whose type we want to know
137 * @return an enum value saying what type this request is
139 * @throws NS_ERROR_UNEXPECTED if aRequest is not known
141 long getRequestType
(in imgIRequest aRequest
);
144 * Gets the URI of the current request, if available.
145 * Otherwise, returns the last URI that this content tried to load, or
146 * null if there haven't been any such attempts.
148 readonly attribute nsIURI currentURI
;
151 * loadImageWithChannel allows data from an existing channel to be
152 * used as the image data for this content node.
154 * @param aChannel the channel that will deliver the data
156 * @return a stream listener to pump the image data into
158 * @see imgILoader::loadImageWithChannel
160 * @throws NS_ERROR_NULL_POINTER if aChannel is null
162 nsIStreamListener loadImageWithChannel
(in nsIChannel aChannel
);
165 * forceReload forces reloading of the image pointed to by currentURI
167 * @throws NS_ERROR_NOT_AVAILABLE if there is no current URI to reload