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.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // Keep in (case-insensitive) order:
7 #include "nsFrame.h"
8 #include "nsGkAtoms.h"
9 #include "nsStyleContext.h"
10 #include "nsSVGEffects.h"
12 // This is a very simple frame whose only purpose is to capture style change
13 // events and propagate them to the parent. Most of the heavy lifting is done
14 // within the nsSVGGradientFrame, which is the parent for this frame
16 typedef nsFrame nsSVGStopFrameBase;
18 class nsSVGStopFrame : public nsSVGStopFrameBase
19 {
20 friend nsIFrame*
21 NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
22 protected:
23 nsSVGStopFrame(nsStyleContext* aContext)
24 : nsSVGStopFrameBase(aContext)
25 {
26 AddStateBits(NS_FRAME_IS_NONDISPLAY);
27 }
29 public:
30 NS_DECL_FRAMEARENA_HELPERS
32 // nsIFrame interface:
33 #ifdef DEBUG
34 virtual void Init(nsIContent* aContent,
35 nsIFrame* aParent,
36 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
37 #endif
39 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
40 const nsRect& aDirtyRect,
41 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
43 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
44 nsIAtom* aAttribute,
45 int32_t aModType) MOZ_OVERRIDE;
47 /**
48 * Get the "type" of the frame
49 *
50 * @see nsGkAtoms::svgStopFrame
51 */
52 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
54 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
55 {
56 return nsSVGStopFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
57 }
59 #ifdef DEBUG_FRAME_DUMP
60 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
61 {
62 return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
63 }
64 #endif
65 };
67 //----------------------------------------------------------------------
68 // Implementation
70 NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
72 //----------------------------------------------------------------------
73 // nsIFrame methods:
75 #ifdef DEBUG
76 void
77 nsSVGStopFrame::Init(nsIContent* aContent,
78 nsIFrame* aParent,
79 nsIFrame* aPrevInFlow)
80 {
81 NS_ASSERTION(aContent->IsSVG(nsGkAtoms::stop), "Content is not a stop element");
83 nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow);
84 }
85 #endif /* DEBUG */
87 nsIAtom *
88 nsSVGStopFrame::GetType() const
89 {
90 return nsGkAtoms::svgStopFrame;
91 }
93 nsresult
94 nsSVGStopFrame::AttributeChanged(int32_t aNameSpaceID,
95 nsIAtom* aAttribute,
96 int32_t aModType)
97 {
98 if (aNameSpaceID == kNameSpaceID_None &&
99 aAttribute == nsGkAtoms::offset) {
100 nsSVGEffects::InvalidateRenderingObservers(this);
101 }
103 return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID,
104 aAttribute, aModType);
105 }
107 // -------------------------------------------------------------------------
108 // Public functions
109 // -------------------------------------------------------------------------
111 nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell,
112 nsStyleContext* aContext)
113 {
114 return new (aPresShell) nsSVGStopFrame(aContext);
115 }