layout/xul/nsImageBoxFrame.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 #ifndef nsImageBoxFrame_h___
michael@0 6 #define nsImageBoxFrame_h___
michael@0 7
michael@0 8 #include "mozilla/Attributes.h"
michael@0 9 #include "nsLeafBoxFrame.h"
michael@0 10
michael@0 11 #include "imgILoader.h"
michael@0 12 #include "imgIRequest.h"
michael@0 13 #include "imgIContainer.h"
michael@0 14 #include "imgINotificationObserver.h"
michael@0 15 #include "imgIOnloadBlocker.h"
michael@0 16
michael@0 17 class imgRequestProxy;
michael@0 18 class nsImageBoxFrame;
michael@0 19
michael@0 20 class nsDisplayXULImage;
michael@0 21
michael@0 22 class nsImageBoxListener : public imgINotificationObserver,
michael@0 23 public imgIOnloadBlocker
michael@0 24 {
michael@0 25 public:
michael@0 26 nsImageBoxListener();
michael@0 27 virtual ~nsImageBoxListener();
michael@0 28
michael@0 29 NS_DECL_ISUPPORTS
michael@0 30 NS_DECL_IMGINOTIFICATIONOBSERVER
michael@0 31 NS_DECL_IMGIONLOADBLOCKER
michael@0 32
michael@0 33 void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
michael@0 34
michael@0 35 private:
michael@0 36 nsImageBoxFrame *mFrame;
michael@0 37 };
michael@0 38
michael@0 39 class nsImageBoxFrame : public nsLeafBoxFrame
michael@0 40 {
michael@0 41 public:
michael@0 42 typedef mozilla::layers::LayerManager LayerManager;
michael@0 43
michael@0 44 friend class nsDisplayXULImage;
michael@0 45 NS_DECL_FRAMEARENA_HELPERS
michael@0 46
michael@0 47 virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 48 virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 49 virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 50 virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
michael@0 51
michael@0 52 nsresult Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData);
michael@0 53
michael@0 54 friend nsIFrame* NS_NewImageBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 55
michael@0 56 virtual void Init(nsIContent* aContent,
michael@0 57 nsIFrame* aParent,
michael@0 58 nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
michael@0 59
michael@0 60 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
michael@0 61 nsIAtom* aAttribute,
michael@0 62 int32_t aModType) MOZ_OVERRIDE;
michael@0 63
michael@0 64 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
michael@0 65
michael@0 66 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
michael@0 67
michael@0 68 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 69 #ifdef DEBUG_FRAME_DUMP
michael@0 70 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
michael@0 71 #endif
michael@0 72
michael@0 73 /**
michael@0 74 * Update mUseSrcAttr from appropriate content attributes or from
michael@0 75 * style, throw away the current image, and load the appropriate
michael@0 76 * image.
michael@0 77 * */
michael@0 78 void UpdateImage();
michael@0 79
michael@0 80 /**
michael@0 81 * Update mLoadFlags from content attributes. Does not attempt to reload the
michael@0 82 * image using the new load flags.
michael@0 83 */
michael@0 84 void UpdateLoadFlags();
michael@0 85
michael@0 86 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 87 const nsRect& aDirtyRect,
michael@0 88 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
michael@0 89
michael@0 90 virtual ~nsImageBoxFrame();
michael@0 91
michael@0 92 void PaintImage(nsRenderingContext& aRenderingContext,
michael@0 93 const nsRect& aDirtyRect,
michael@0 94 nsPoint aPt, uint32_t aFlags);
michael@0 95
michael@0 96 already_AddRefed<mozilla::layers::ImageContainer> GetContainer(LayerManager* aManager);
michael@0 97 protected:
michael@0 98 nsImageBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext);
michael@0 99
michael@0 100 virtual void GetImageSize();
michael@0 101
michael@0 102 private:
michael@0 103 nsresult OnStartContainer(imgIRequest *request, imgIContainer *image);
michael@0 104 nsresult OnStopDecode(imgIRequest *request);
michael@0 105 nsresult OnStopRequest(imgIRequest *request, nsresult status);
michael@0 106 nsresult OnImageIsAnimated(imgIRequest* aRequest);
michael@0 107 nsresult FrameChanged(imgIRequest *aRequest);
michael@0 108
michael@0 109 nsRect mSubRect; ///< If set, indicates that only the portion of the image specified by the rect should be used.
michael@0 110 nsSize mIntrinsicSize;
michael@0 111 nsSize mImageSize;
michael@0 112
michael@0 113 // Boolean variable to determine if the current image request has been
michael@0 114 // registered with the refresh driver.
michael@0 115 bool mRequestRegistered;
michael@0 116
michael@0 117 nsRefPtr<imgRequestProxy> mImageRequest;
michael@0 118 nsCOMPtr<imgINotificationObserver> mListener;
michael@0 119
michael@0 120 int32_t mLoadFlags;
michael@0 121
michael@0 122 bool mUseSrcAttr; ///< Whether or not the image src comes from an attribute.
michael@0 123 bool mSuppressStyleCheck;
michael@0 124 bool mFireEventOnDecode;
michael@0 125 }; // class nsImageBoxFrame
michael@0 126
michael@0 127 class nsDisplayXULImage : public nsDisplayImageContainer {
michael@0 128 public:
michael@0 129 nsDisplayXULImage(nsDisplayListBuilder* aBuilder,
michael@0 130 nsImageBoxFrame* aFrame) :
michael@0 131 nsDisplayImageContainer(aBuilder, aFrame) {
michael@0 132 MOZ_COUNT_CTOR(nsDisplayXULImage);
michael@0 133 }
michael@0 134 #ifdef NS_BUILD_REFCNT_LOGGING
michael@0 135 virtual ~nsDisplayXULImage() {
michael@0 136 MOZ_COUNT_DTOR(nsDisplayXULImage);
michael@0 137 }
michael@0 138 #endif
michael@0 139
michael@0 140 virtual already_AddRefed<ImageContainer> GetContainer(LayerManager* aManager,
michael@0 141 nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
michael@0 142 virtual void ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset) MOZ_OVERRIDE;
michael@0 143 virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE
michael@0 144 {
michael@0 145 *aSnap = true;
michael@0 146 return nsRect(ToReferenceFrame(), Frame()->GetSize());
michael@0 147 }
michael@0 148 virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
michael@0 149 const nsDisplayItemGeometry* aGeometry,
michael@0 150 nsRegion* aInvalidRegion) MOZ_OVERRIDE;
michael@0 151 // Doesn't handle HitTest because nsLeafBoxFrame already creates an
michael@0 152 // event receiver for us
michael@0 153 virtual void Paint(nsDisplayListBuilder* aBuilder,
michael@0 154 nsRenderingContext* aCtx) MOZ_OVERRIDE;
michael@0 155 NS_DISPLAY_DECL_NAME("XULImage", TYPE_XUL_IMAGE)
michael@0 156 };
michael@0 157
michael@0 158 #endif /* nsImageBoxFrame_h___ */

mercurial