Tue, 06 Jan 2015 21:39:09 +0100
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 | |
michael@0 | 6 | #ifndef NSSVGINTEGRATIONUTILS_H_ |
michael@0 | 7 | #define NSSVGINTEGRATIONUTILS_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "gfxMatrix.h" |
michael@0 | 10 | #include "GraphicsFilter.h" |
michael@0 | 11 | #include "gfxRect.h" |
michael@0 | 12 | #include "nsAutoPtr.h" |
michael@0 | 13 | |
michael@0 | 14 | class gfxDrawable; |
michael@0 | 15 | class nsDisplayList; |
michael@0 | 16 | class nsDisplayListBuilder; |
michael@0 | 17 | class nsIFrame; |
michael@0 | 18 | class nsRenderingContext; |
michael@0 | 19 | class nsIntRegion; |
michael@0 | 20 | |
michael@0 | 21 | struct nsRect; |
michael@0 | 22 | struct nsIntRect; |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | namespace layers { |
michael@0 | 26 | class LayerManager; |
michael@0 | 27 | } |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | struct nsPoint; |
michael@0 | 31 | struct nsSize; |
michael@0 | 32 | |
michael@0 | 33 | /** |
michael@0 | 34 | * Integration of SVG effects (clipPath clipping, masking and filters) into |
michael@0 | 35 | * regular display list based painting and hit-testing. |
michael@0 | 36 | */ |
michael@0 | 37 | class nsSVGIntegrationUtils MOZ_FINAL |
michael@0 | 38 | { |
michael@0 | 39 | public: |
michael@0 | 40 | /** |
michael@0 | 41 | * Returns true if SVG effects are currently applied to this frame. |
michael@0 | 42 | */ |
michael@0 | 43 | static bool |
michael@0 | 44 | UsingEffectsForFrame(const nsIFrame* aFrame); |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * Returns the size of the union of the border-box rects of all of |
michael@0 | 48 | * aNonSVGFrame's continuations. |
michael@0 | 49 | */ |
michael@0 | 50 | static nsSize |
michael@0 | 51 | GetContinuationUnionSize(nsIFrame* aNonSVGFrame); |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | * When SVG effects need to resolve percentage, userSpaceOnUse lengths, they |
michael@0 | 55 | * need a coordinate context to resolve them against. This method provides |
michael@0 | 56 | * that coordinate context for non-SVG frames with SVG effects applied to |
michael@0 | 57 | * them. The gfxSize returned is the size of the union of all of the given |
michael@0 | 58 | * frame's continuations' border boxes, converted to SVG user units (equal to |
michael@0 | 59 | * CSS px units), as required by the SVG code. |
michael@0 | 60 | */ |
michael@0 | 61 | static mozilla::gfx::Size |
michael@0 | 62 | GetSVGCoordContextForNonSVGFrame(nsIFrame* aNonSVGFrame); |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * SVG effects such as SVG filters, masking and clipPath may require an SVG |
michael@0 | 66 | * "bbox" for the element they're being applied to in order to make decisions |
michael@0 | 67 | * about positioning, and to resolve various lengths against. This method |
michael@0 | 68 | * provides the "bbox" for non-SVG frames. The bbox returned is in CSS px |
michael@0 | 69 | * units, and is the union of all aNonSVGFrame's continuations' overflow |
michael@0 | 70 | * areas, relative to the top-left of the union of all aNonSVGFrame's |
michael@0 | 71 | * continuations' border box rects. |
michael@0 | 72 | */ |
michael@0 | 73 | static gfxRect |
michael@0 | 74 | GetSVGBBoxForNonSVGFrame(nsIFrame* aNonSVGFrame); |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * Used to adjust a frame's pre-effects visual overflow rect to take account |
michael@0 | 78 | * of SVG effects. |
michael@0 | 79 | * |
michael@0 | 80 | * XXX This method will not do the right thing for frames with continuations. |
michael@0 | 81 | * It really needs all the continuations to have been reflowed before being |
michael@0 | 82 | * called, but we currently call it on each continuation as its overflow |
michael@0 | 83 | * rects are set during the reflow of each particular continuation. Gecko's |
michael@0 | 84 | * current reflow architecture does not allow us to set the overflow rects |
michael@0 | 85 | * for a whole chain of continuations for a given element at the point when |
michael@0 | 86 | * the last continuation is reflowed. See: |
michael@0 | 87 | * http://groups.google.com/group/mozilla.dev.tech.layout/msg/6b179066f3051f65 |
michael@0 | 88 | */ |
michael@0 | 89 | static nsRect |
michael@0 | 90 | ComputePostEffectsVisualOverflowRect(nsIFrame* aFrame, |
michael@0 | 91 | const nsRect& aPreEffectsOverflowRect); |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * Used to adjust the area of a frame that needs to be invalidated to take |
michael@0 | 95 | * account of SVG effects. |
michael@0 | 96 | * |
michael@0 | 97 | * @param aFrame The effects frame. |
michael@0 | 98 | * @param aToReferenceFrame The offset (in app units) from aFrame to its |
michael@0 | 99 | * reference display item. |
michael@0 | 100 | * @param aInvalidRegion The pre-effects invalid region in pixels relative to |
michael@0 | 101 | * the reference display item. |
michael@0 | 102 | * @return The post-effects invalid rect in pixels relative to the reference |
michael@0 | 103 | * display item. |
michael@0 | 104 | */ |
michael@0 | 105 | static nsIntRegion |
michael@0 | 106 | AdjustInvalidAreaForSVGEffects(nsIFrame* aFrame, const nsPoint& aToReferenceFrame, |
michael@0 | 107 | const nsIntRegion& aInvalidRegion); |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Figure out which area of the source is needed given an area to |
michael@0 | 111 | * repaint |
michael@0 | 112 | */ |
michael@0 | 113 | static nsRect |
michael@0 | 114 | GetRequiredSourceForInvalidArea(nsIFrame* aFrame, const nsRect& aDamageRect); |
michael@0 | 115 | |
michael@0 | 116 | /** |
michael@0 | 117 | * Returns true if the given point is not clipped out by effects. |
michael@0 | 118 | * @param aPt in appunits relative to aFrame |
michael@0 | 119 | */ |
michael@0 | 120 | static bool |
michael@0 | 121 | HitTestFrameForEffects(nsIFrame* aFrame, const nsPoint& aPt); |
michael@0 | 122 | |
michael@0 | 123 | /** |
michael@0 | 124 | * Paint non-SVG frame with SVG effects. |
michael@0 | 125 | */ |
michael@0 | 126 | static void |
michael@0 | 127 | PaintFramesWithEffects(nsRenderingContext* aCtx, |
michael@0 | 128 | nsIFrame* aFrame, const nsRect& aDirtyRect, |
michael@0 | 129 | nsDisplayListBuilder* aBuilder, |
michael@0 | 130 | mozilla::layers::LayerManager* aManager); |
michael@0 | 131 | |
michael@0 | 132 | /** |
michael@0 | 133 | * SVG frames expect to paint in SVG user units, which are equal to CSS px |
michael@0 | 134 | * units. This method provides a transform matrix to multiply onto a |
michael@0 | 135 | * gfxContext's current transform to convert the context's current units from |
michael@0 | 136 | * its usual dev pixels to SVG user units/CSS px to keep the SVG code happy. |
michael@0 | 137 | */ |
michael@0 | 138 | static gfxMatrix |
michael@0 | 139 | GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame); |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * @param aRenderingContext the target rendering context in which the paint |
michael@0 | 143 | * server will be rendered |
michael@0 | 144 | * @param aTarget the target frame onto which the paint server will be |
michael@0 | 145 | * rendered |
michael@0 | 146 | * @param aPaintServer a first-continuation frame to use as the source |
michael@0 | 147 | * @param aFilter a filter to be applied when scaling |
michael@0 | 148 | * @param aDest the area the paint server image should be mapped to |
michael@0 | 149 | * @param aFill the area to be filled with copies of the paint server image |
michael@0 | 150 | * @param aAnchor a point in aFill which we will ensure is pixel-aligned in |
michael@0 | 151 | * the output |
michael@0 | 152 | * @param aDirty pixels outside this area may be skipped |
michael@0 | 153 | * @param aPaintServerSize the size that would be filled when using |
michael@0 | 154 | * background-repeat:no-repeat and background-size:auto. For normal background |
michael@0 | 155 | * images, this would be the intrinsic size of the image; for gradients and |
michael@0 | 156 | * patterns this would be the whole target frame fill area. |
michael@0 | 157 | * @param aFlags pass FLAG_SYNC_DECODE_IMAGES and any images in the paint |
michael@0 | 158 | * server will be decoding synchronously if they are not decoded already. |
michael@0 | 159 | */ |
michael@0 | 160 | enum { |
michael@0 | 161 | FLAG_SYNC_DECODE_IMAGES = 0x01, |
michael@0 | 162 | }; |
michael@0 | 163 | |
michael@0 | 164 | static already_AddRefed<gfxDrawable> |
michael@0 | 165 | DrawableFromPaintServer(nsIFrame* aFrame, |
michael@0 | 166 | nsIFrame* aTarget, |
michael@0 | 167 | const nsSize& aPaintServerSize, |
michael@0 | 168 | const gfxIntSize& aRenderSize, |
michael@0 | 169 | const gfxMatrix& aContextMatrix, |
michael@0 | 170 | uint32_t aFlags); |
michael@0 | 171 | }; |
michael@0 | 172 | |
michael@0 | 173 | #endif /*NSSVGINTEGRATIONUTILS_H_*/ |