content/base/public/nsIImageLoadingContent.idl

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "imgINotificationObserver.idl"
michael@0 7
michael@0 8 interface imgIRequest;
michael@0 9 interface nsIChannel;
michael@0 10 interface nsIStreamListener;
michael@0 11 interface nsIURI;
michael@0 12 interface nsIDocument;
michael@0 13 interface nsIFrame;
michael@0 14
michael@0 15 /**
michael@0 16 * This interface represents a content node that loads images. The interface
michael@0 17 * exists to allow getting information on the images that the content node
michael@0 18 * loads and to allow registration of observers for the image loads.
michael@0 19 *
michael@0 20 * Implementors of this interface should handle all the mechanics of actually
michael@0 21 * loading an image -- getting the URI, checking with content policies and
michael@0 22 * the security manager to see whether loading the URI is allowed, performing
michael@0 23 * the load, firing any DOM events as needed.
michael@0 24 *
michael@0 25 * An implementation of this interface may support the concepts of a
michael@0 26 * "current" image and a "pending" image. If it does, a request to change
michael@0 27 * the currently loaded image will start a "pending" request which will
michael@0 28 * become current only when the image is loaded. It is the responsibility of
michael@0 29 * observers to check which request they are getting notifications for.
michael@0 30 *
michael@0 31 * Observers added in mid-load will not get any notifications they
michael@0 32 * missed. We should NOT freeze this interface without considering
michael@0 33 * this issue. (It could be that the image status on imgIRequest is
michael@0 34 * sufficient, when combined with the imageBlockingStatus information.)
michael@0 35 *
michael@0 36 * Please make sure to update the MozImageLoadingContent WebIDL
michael@0 37 * interface to mirror this interface when changing it.
michael@0 38 */
michael@0 39
michael@0 40 [scriptable, builtinclass, uuid(e3968acd-b796-4ca3-aec0-e7f0880f2219)]
michael@0 41 interface nsIImageLoadingContent : imgINotificationObserver
michael@0 42 {
michael@0 43 /**
michael@0 44 * Request types. Image loading content nodes attempt to do atomic
michael@0 45 * image changes when the image url is changed. This means that
michael@0 46 * when the url changes the new image load will start, but the old
michael@0 47 * image will remain the "current" request until the new image is
michael@0 48 * fully loaded. At that point, the old "current" request will be
michael@0 49 * discarded and the "pending" request will become "current".
michael@0 50 */
michael@0 51 const long UNKNOWN_REQUEST = -1;
michael@0 52 const long CURRENT_REQUEST = 0;
michael@0 53 const long PENDING_REQUEST = 1;
michael@0 54
michael@0 55 /**
michael@0 56 * loadingEnabled is used to enable and disable loading in
michael@0 57 * situations where loading images is unwanted. Note that enabling
michael@0 58 * loading will *not* automatically trigger an image load.
michael@0 59 */
michael@0 60 attribute boolean loadingEnabled;
michael@0 61
michael@0 62 /**
michael@0 63 * Returns the image blocking status (@see nsIContentPolicy). This
michael@0 64 * will always be an nsIContentPolicy REJECT_* status for cases when
michael@0 65 * the image was blocked. This status always refers to the
michael@0 66 * CURRENT_REQUEST load.
michael@0 67 */
michael@0 68 readonly attribute short imageBlockingStatus;
michael@0 69
michael@0 70 /**
michael@0 71 * Used to register an image decoder observer. Typically, this will
michael@0 72 * be a proxy for a frame that wants to paint the image.
michael@0 73 * Notifications from ongoing image loads will be passed to all
michael@0 74 * registered observers. Notifications for all request types,
michael@0 75 * current and pending, will be passed through.
michael@0 76 *
michael@0 77 * @param aObserver the observer to register
michael@0 78 *
michael@0 79 * @throws NS_ERROR_OUT_OF_MEMORY
michael@0 80 */
michael@0 81 void addObserver(in imgINotificationObserver aObserver);
michael@0 82
michael@0 83 /**
michael@0 84 * Used to unregister an image decoder observer.
michael@0 85 *
michael@0 86 * @param aObserver the observer to unregister
michael@0 87 */
michael@0 88 void removeObserver(in imgINotificationObserver aObserver);
michael@0 89
michael@0 90 /**
michael@0 91 * Accessor to get the image requests
michael@0 92 *
michael@0 93 * @param aRequestType a value saying which request is wanted
michael@0 94 *
michael@0 95 * @return the imgIRequest object (may be null, even when no error
michael@0 96 * is thrown)
michael@0 97 *
michael@0 98 * @throws NS_ERROR_UNEXPECTED if the request type requested is not
michael@0 99 * known
michael@0 100 */
michael@0 101 imgIRequest getRequest(in long aRequestType);
michael@0 102
michael@0 103 /**
michael@0 104 * Used to notify the image loading content node that a frame has been
michael@0 105 * created.
michael@0 106 */
michael@0 107 [notxpcom] void frameCreated(in nsIFrame aFrame);
michael@0 108
michael@0 109 /**
michael@0 110 * Used to notify the image loading content node that a frame has been
michael@0 111 * destroyed.
michael@0 112 */
michael@0 113 [notxpcom] void frameDestroyed(in nsIFrame aFrame);
michael@0 114
michael@0 115 /**
michael@0 116 * Used to find out what type of request one is dealing with (eg
michael@0 117 * which request got passed through to the imgINotificationObserver
michael@0 118 * interface of an observer)
michael@0 119 *
michael@0 120 * @param aRequest the request whose type we want to know
michael@0 121 *
michael@0 122 * @return an enum value saying what type this request is
michael@0 123 *
michael@0 124 * @throws NS_ERROR_UNEXPECTED if aRequest is not known
michael@0 125 */
michael@0 126 long getRequestType(in imgIRequest aRequest);
michael@0 127
michael@0 128 /**
michael@0 129 * Gets the URI of the current request, if available.
michael@0 130 * Otherwise, returns the last URI that this content tried to load, or
michael@0 131 * null if there haven't been any such attempts.
michael@0 132 */
michael@0 133 readonly attribute nsIURI currentURI;
michael@0 134
michael@0 135 /**
michael@0 136 * loadImageWithChannel allows data from an existing channel to be
michael@0 137 * used as the image data for this content node.
michael@0 138 *
michael@0 139 * @param aChannel the channel that will deliver the data
michael@0 140 *
michael@0 141 * @return a stream listener to pump the image data into
michael@0 142 *
michael@0 143 * @see imgILoader::loadImageWithChannel
michael@0 144 *
michael@0 145 * @throws NS_ERROR_NULL_POINTER if aChannel is null
michael@0 146 */
michael@0 147 nsIStreamListener loadImageWithChannel(in nsIChannel aChannel);
michael@0 148
michael@0 149 /**
michael@0 150 * forceReload forces reloading of the image pointed to by currentURI
michael@0 151 *
michael@0 152 * @throws NS_ERROR_NOT_AVAILABLE if there is no current URI to reload
michael@0 153 */
michael@0 154 void forceReload();
michael@0 155
michael@0 156 /**
michael@0 157 * Enables/disables image state forcing. When |aForce| is PR_TRUE, we force
michael@0 158 * nsImageLoadingContent::ImageState() to return |aState|. Call again with |aForce|
michael@0 159 * as PR_FALSE to revert ImageState() to its original behaviour.
michael@0 160 */
michael@0 161 void forceImageState(in boolean aForce, in unsigned long long aState);
michael@0 162
michael@0 163 /**
michael@0 164 * A visible count is stored, if it is non-zero then this image is considered
michael@0 165 * visible. These methods increment, decrement, or return the visible coount.
michael@0 166 */
michael@0 167 [noscript, notxpcom] void IncrementVisibleCount();
michael@0 168 [noscript, notxpcom] void DecrementVisibleCount();
michael@0 169 [noscript, notxpcom] uint32_t GetVisibleCount();
michael@0 170 };

mercurial