layout/style/ImageLoader.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 // A class that handles style system image loads (other image loads are handled
     6 // by the nodes in the content tree).
     8 #ifndef mozilla_css_ImageLoader_h___
     9 #define mozilla_css_ImageLoader_h___
    11 #include "nsClassHashtable.h"
    12 #include "nsHashKeys.h"
    13 #include "nsCSSValue.h"
    14 #include "imgIRequest.h"
    15 #include "imgIOnloadBlocker.h"
    16 #include "imgINotificationObserver.h"
    17 #include "mozilla/Attributes.h"
    19 class nsIFrame;
    20 class nsIDocument;
    21 class nsPresContext;
    22 class nsIURI;
    23 class nsIPrincipal;
    25 namespace mozilla {
    26 namespace css {
    28 class ImageLoader MOZ_FINAL : public imgINotificationObserver,
    29                               public imgIOnloadBlocker {
    30 public:
    31   typedef mozilla::css::ImageValue Image;
    33   ImageLoader(nsIDocument* aDocument)
    34   : mDocument(aDocument),
    35     mInClone(false)
    36   {
    37     MOZ_ASSERT(mDocument);
    38   }
    40   NS_DECL_ISUPPORTS
    41   NS_DECL_IMGIONLOADBLOCKER
    42   NS_DECL_IMGINOTIFICATIONOBSERVER
    44   void DropDocumentReference();
    46   void MaybeRegisterCSSImage(Image* aImage);
    47   void DeregisterCSSImage(Image* aImage);
    49   void AssociateRequestToFrame(imgIRequest* aRequest,
    50                                nsIFrame* aFrame);
    52   void DisassociateRequestFromFrame(imgIRequest* aRequest,
    53                                     nsIFrame* aFrame);
    55   void DropRequestsForFrame(nsIFrame* aFrame);
    57   void SetAnimationMode(uint16_t aMode);
    59   void ClearFrames();
    61   void LoadImage(nsIURI* aURI, nsIPrincipal* aPrincipal, nsIURI* aReferrer,
    62                  Image* aCSSValue);
    64   void DestroyRequest(imgIRequest* aRequest);
    66 private:
    67   // We need to be able to look up the frames associated with a request (for
    68   // delivering notifications) and the requests associated with a frame (when
    69   // the frame goes away). Thus we maintain hashtables going both ways.  These
    70   // should always be in sync.
    72   typedef nsTArray<nsIFrame*> FrameSet;
    73   typedef nsTArray<nsCOMPtr<imgIRequest> > RequestSet;
    74   typedef nsTHashtable<nsPtrHashKey<Image> > ImageHashSet;
    75   typedef nsClassHashtable<nsISupportsHashKey,
    76                            FrameSet> RequestToFrameMap;
    77   typedef nsClassHashtable<nsPtrHashKey<nsIFrame>,
    78                            RequestSet> FrameToRequestMap;
    80   void AddImage(Image* aCSSImage);
    81   void RemoveImage(Image* aCSSImage);
    83   nsPresContext* GetPresContext();
    85   void DoRedraw(FrameSet* aFrameSet);
    87   static PLDHashOperator
    88   SetAnimationModeEnumerator(nsISupports* aKey, FrameSet* aValue,
    89                              void* aClosure);
    91   nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer* aImage);
    92   nsresult OnStopFrame(imgIRequest *aRequest);
    93   nsresult OnImageIsAnimated(imgIRequest *aRequest);
    94   nsresult FrameChanged(imgIRequest* aRequest);
    95   // Do not override OnDataAvailable since background images are not
    96   // displayed incrementally; they are displayed after the entire image
    97   // has been loaded.
    99   // A map of imgIRequests to the nsIFrames that are using them.
   100   RequestToFrameMap mRequestToFrameMap;
   102   // A map of nsIFrames to the imgIRequests they use.
   103   FrameToRequestMap mFrameToRequestMap;
   105   // A weak pointer to our document. Nulled out by DropDocumentReference.
   106   nsIDocument* mDocument;
   108   // The set of all nsCSSValue::Images (whether they're associated a frame or
   109   // not).  We'll need this when we go away to remove any requests associated
   110   // with our document from those Images.
   111   ImageHashSet mImages;
   113   // Are we cloning?  If so, ignore any notifications we get.
   114   bool mInClone;
   115 };
   117 } // namespace css
   118 } // namespace mozilla
   120 #endif /* mozilla_css_ImageLoader_h___ */

mercurial