layout/svg/nsSVGContainerFrame.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
michael@0 6 #ifndef NS_SVGCONTAINERFRAME_H
michael@0 7 #define NS_SVGCONTAINERFRAME_H
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "nsContainerFrame.h"
michael@0 11 #include "nsFrame.h"
michael@0 12 #include "nsIFrame.h"
michael@0 13 #include "nsISVGChildFrame.h"
michael@0 14 #include "nsQueryFrame.h"
michael@0 15 #include "nsRect.h"
michael@0 16 #include "nsSVGUtils.h"
michael@0 17
michael@0 18 class nsFrameList;
michael@0 19 class nsIContent;
michael@0 20 class nsIPresShell;
michael@0 21 class nsRenderingContext;
michael@0 22 class nsStyleContext;
michael@0 23
michael@0 24 struct nsPoint;
michael@0 25 struct nsRect;
michael@0 26 struct nsIntRect;
michael@0 27
michael@0 28 typedef nsContainerFrame nsSVGContainerFrameBase;
michael@0 29
michael@0 30 /**
michael@0 31 * Base class for SVG container frames. Frame sub-classes that do not
michael@0 32 * display their contents directly (such as the frames for <marker> or
michael@0 33 * <pattern>) just inherit this class. Frame sub-classes that do or can
michael@0 34 * display their contents directly (such as the frames for inner-<svg> or
michael@0 35 * <g>) inherit our nsDisplayContainerFrame sub-class.
michael@0 36 *
michael@0 37 * *** WARNING ***
michael@0 38 *
michael@0 39 * Do *not* blindly cast to SVG element types in this class's methods (see the
michael@0 40 * warning comment for nsSVGDisplayContainerFrame below).
michael@0 41 */
michael@0 42 class nsSVGContainerFrame : public nsSVGContainerFrameBase
michael@0 43 {
michael@0 44 friend nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
michael@0 45 nsStyleContext* aContext);
michael@0 46 protected:
michael@0 47 nsSVGContainerFrame(nsStyleContext* aContext)
michael@0 48 : nsSVGContainerFrameBase(aContext)
michael@0 49 {
michael@0 50 AddStateBits(NS_FRAME_SVG_LAYOUT);
michael@0 51 }
michael@0 52
michael@0 53 public:
michael@0 54 NS_DECL_QUERYFRAME_TARGET(nsSVGContainerFrame)
michael@0 55 NS_DECL_QUERYFRAME
michael@0 56 NS_DECL_FRAMEARENA_HELPERS
michael@0 57
michael@0 58 // Returns the transform to our gfxContext (to device pixels, not CSS px)
michael@0 59 virtual gfxMatrix GetCanvasTM(uint32_t aFor,
michael@0 60 nsIFrame* aTransformRoot = nullptr) {
michael@0 61 return gfxMatrix();
michael@0 62 }
michael@0 63
michael@0 64 /**
michael@0 65 * Returns true if the frame's content has a transform that applies only to
michael@0 66 * its children, and not to the frame itself. For example, an implicit
michael@0 67 * transform introduced by a 'viewBox' attribute, or an explicit transform
michael@0 68 * due to a root-<svg> having its currentScale/currentTransform properties
michael@0 69 * set. If aTransform is non-null, then it will be set to the transform.
michael@0 70 */
michael@0 71 virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const {
michael@0 72 return false;
michael@0 73 }
michael@0 74
michael@0 75 // nsIFrame:
michael@0 76 virtual nsresult AppendFrames(ChildListID aListID,
michael@0 77 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 78 virtual nsresult InsertFrames(ChildListID aListID,
michael@0 79 nsIFrame* aPrevFrame,
michael@0 80 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 81 virtual nsresult RemoveFrame(ChildListID aListID,
michael@0 82 nsIFrame* aOldFrame) MOZ_OVERRIDE;
michael@0 83
michael@0 84 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 85 {
michael@0 86 return nsSVGContainerFrameBase::IsFrameOfType(
michael@0 87 aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
michael@0 88 }
michael@0 89
michael@0 90 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 91 const nsRect& aDirtyRect,
michael@0 92 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
michael@0 93
michael@0 94 virtual bool UpdateOverflow() MOZ_OVERRIDE;
michael@0 95
michael@0 96 protected:
michael@0 97 /**
michael@0 98 * Traverses a frame tree, marking any SVGTextFrame frames as dirty
michael@0 99 * and calling InvalidateRenderingObservers() on it.
michael@0 100 */
michael@0 101 static void ReflowSVGNonDisplayText(nsIFrame* aContainer);
michael@0 102 };
michael@0 103
michael@0 104 /**
michael@0 105 * Frame class or base-class for SVG containers that can or do display their
michael@0 106 * contents directly.
michael@0 107 *
michael@0 108 * *** WARNING ***
michael@0 109 *
michael@0 110 * This class's methods can *not* assume that mContent points to an instance of
michael@0 111 * an SVG element class since this class is inherited by
michael@0 112 * nsSVGGenericContainerFrame which is used for unrecognized elements in the
michael@0 113 * SVG namespace. Do *not* blindly cast to SVG element types.
michael@0 114 */
michael@0 115 class nsSVGDisplayContainerFrame : public nsSVGContainerFrame,
michael@0 116 public nsISVGChildFrame
michael@0 117 {
michael@0 118 protected:
michael@0 119 nsSVGDisplayContainerFrame(nsStyleContext* aContext)
michael@0 120 : nsSVGContainerFrame(aContext)
michael@0 121 {
michael@0 122 AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
michael@0 123 }
michael@0 124
michael@0 125 public:
michael@0 126 NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame)
michael@0 127 NS_DECL_QUERYFRAME
michael@0 128 NS_DECL_FRAMEARENA_HELPERS
michael@0 129
michael@0 130 // nsIFrame:
michael@0 131 virtual nsresult InsertFrames(ChildListID aListID,
michael@0 132 nsIFrame* aPrevFrame,
michael@0 133 nsFrameList& aFrameList) MOZ_OVERRIDE;
michael@0 134 virtual nsresult RemoveFrame(ChildListID aListID,
michael@0 135 nsIFrame* aOldFrame) MOZ_OVERRIDE;
michael@0 136 virtual void Init(nsIContent* aContent,
michael@0 137 nsIFrame* aParent,
michael@0 138 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 139
michael@0 140 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 141 const nsRect& aDirtyRect,
michael@0 142 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
michael@0 143
michael@0 144 virtual bool IsSVGTransformed(Matrix *aOwnTransform = nullptr,
michael@0 145 Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
michael@0 146
michael@0 147 // nsISVGChildFrame interface:
michael@0 148 virtual nsresult PaintSVG(nsRenderingContext* aContext,
michael@0 149 const nsIntRect *aDirtyRect,
michael@0 150 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
michael@0 151 virtual nsIFrame* GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
michael@0 152 virtual nsRect GetCoveredRegion() MOZ_OVERRIDE;
michael@0 153 virtual void ReflowSVG() MOZ_OVERRIDE;
michael@0 154 virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
michael@0 155 virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
michael@0 156 uint32_t aFlags) MOZ_OVERRIDE;
michael@0 157 virtual bool IsDisplayContainer() MOZ_OVERRIDE { return true; }
michael@0 158 };
michael@0 159
michael@0 160 #endif

mercurial