LCOV - code coverage report
Current view: top level - dom/html - ImageDocument.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 12 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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/. */
       6             : #ifndef mozilla_dom_ImageDocument_h
       7             : #define mozilla_dom_ImageDocument_h
       8             : 
       9             : #include "mozilla/Attributes.h"
      10             : #include "imgINotificationObserver.h"
      11             : #include "MediaDocument.h"
      12             : #include "nsIDOMEventListener.h"
      13             : #include "nsIImageDocument.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : class ImageDocument final : public MediaDocument,
      19             :                             public nsIImageDocument,
      20             :                             public imgINotificationObserver,
      21             :                             public nsIDOMEventListener
      22             : {
      23             : public:
      24             :   ImageDocument();
      25             : 
      26             :   NS_DECL_ISUPPORTS_INHERITED
      27             : 
      28             :   virtual nsresult Init() override;
      29             : 
      30             :   virtual nsresult StartDocumentLoad(const char*         aCommand,
      31             :                                      nsIChannel*         aChannel,
      32             :                                      nsILoadGroup*       aLoadGroup,
      33             :                                      nsISupports*        aContainer,
      34             :                                      nsIStreamListener** aDocListener,
      35             :                                      bool                aReset = true,
      36             :                                      nsIContentSink*     aSink = nullptr) override;
      37             : 
      38             :   virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) override;
      39             :   virtual void Destroy() override;
      40             :   virtual void OnPageShow(bool aPersisted,
      41             :                           EventTarget* aDispatchStartTarget) override;
      42             : 
      43             :   NS_DECL_NSIIMAGEDOCUMENT
      44             :   NS_DECL_IMGINOTIFICATIONOBSERVER
      45             : 
      46             :   // nsIDOMEventListener
      47             :   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
      48             : 
      49           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ImageDocument, MediaDocument)
      50             : 
      51             :   friend class ImageListener;
      52             : 
      53           0 :   void DefaultCheckOverflowing() { CheckOverflowing(mResizeImageByDefault); }
      54             : 
      55             :   // WebIDL API
      56             :   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      57             :     override;
      58             : 
      59           0 :   bool ImageIsOverflowing() const
      60             :   {
      61           0 :     return mImageIsOverflowingHorizontally || mImageIsOverflowingVertically;
      62             :   }
      63           0 :   bool ImageIsResized() const
      64             :   {
      65           0 :     return mImageIsResized;
      66             :   }
      67             :   already_AddRefed<imgIRequest> GetImageRequest(ErrorResult& aRv);
      68             :   void ShrinkToFit();
      69             :   void RestoreImage();
      70           0 :   void RestoreImageTo(int32_t aX, int32_t aY)
      71             :   {
      72           0 :     ScrollImageTo(aX, aY, true);
      73           0 :   }
      74             :   void ToggleImageSize();
      75             : 
      76             : protected:
      77             :   virtual ~ImageDocument();
      78             : 
      79             :   virtual nsresult CreateSyntheticDocument() override;
      80             : 
      81             :   nsresult CheckOverflowing(bool changeState);
      82             : 
      83             :   void UpdateTitleAndCharset();
      84             : 
      85             :   void ScrollImageTo(int32_t aX, int32_t aY, bool restoreImage);
      86             : 
      87           0 :   float GetRatio() {
      88           0 :     return std::min(mVisibleWidth / mImageWidth,
      89           0 :                     mVisibleHeight / mImageHeight);
      90             :   }
      91             : 
      92             :   void ResetZoomLevel();
      93             :   float GetZoomLevel();
      94             : 
      95             :   void UpdateSizeFromLayout();
      96             : 
      97             :   enum eModeClasses {
      98             :     eNone,
      99             :     eShrinkToFit,
     100             :     eOverflowingVertical, // And maybe horizontal too.
     101             :     eOverflowingHorizontalOnly
     102             :   };
     103             :   void SetModeClass(eModeClasses mode);
     104             : 
     105             :   nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
     106             :   nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
     107             :   void OnHasTransparency();
     108             : 
     109             :   nsCOMPtr<Element>             mImageContent;
     110             : 
     111             :   float                         mVisibleWidth;
     112             :   float                         mVisibleHeight;
     113             :   int32_t                       mImageWidth;
     114             :   int32_t                       mImageHeight;
     115             : 
     116             :   bool                          mResizeImageByDefault;
     117             :   bool                          mClickResizingEnabled;
     118             :   bool                          mImageIsOverflowingHorizontally;
     119             :   bool                          mImageIsOverflowingVertically;
     120             :   // mImageIsResized is true if the image is currently resized
     121             :   bool                          mImageIsResized;
     122             :   // mShouldResize is true if the image should be resized when it doesn't fit
     123             :   // mImageIsResized cannot be true when this is false, but mImageIsResized
     124             :   // can be false when this is true
     125             :   bool                          mShouldResize;
     126             :   bool                          mFirstResize;
     127             :   // mObservingImageLoader is true while the observer is set.
     128             :   bool                          mObservingImageLoader;
     129             : 
     130             :   float                         mOriginalZoomLevel;
     131             : };
     132             : 
     133             : } // namespace dom
     134             : } // namespace mozilla
     135             : 
     136             : #endif /* mozilla_dom_ImageDocument_h */

Generated by: LCOV version 1.13