layout/svg/nsSVGStopFrame.cpp

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 // Keep in (case-insensitive) order:
michael@0 7 #include "nsFrame.h"
michael@0 8 #include "nsGkAtoms.h"
michael@0 9 #include "nsStyleContext.h"
michael@0 10 #include "nsSVGEffects.h"
michael@0 11
michael@0 12 // This is a very simple frame whose only purpose is to capture style change
michael@0 13 // events and propagate them to the parent. Most of the heavy lifting is done
michael@0 14 // within the nsSVGGradientFrame, which is the parent for this frame
michael@0 15
michael@0 16 typedef nsFrame nsSVGStopFrameBase;
michael@0 17
michael@0 18 class nsSVGStopFrame : public nsSVGStopFrameBase
michael@0 19 {
michael@0 20 friend nsIFrame*
michael@0 21 NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 22 protected:
michael@0 23 nsSVGStopFrame(nsStyleContext* aContext)
michael@0 24 : nsSVGStopFrameBase(aContext)
michael@0 25 {
michael@0 26 AddStateBits(NS_FRAME_IS_NONDISPLAY);
michael@0 27 }
michael@0 28
michael@0 29 public:
michael@0 30 NS_DECL_FRAMEARENA_HELPERS
michael@0 31
michael@0 32 // nsIFrame interface:
michael@0 33 #ifdef DEBUG
michael@0 34 virtual void Init(nsIContent* aContent,
michael@0 35 nsIFrame* aParent,
michael@0 36 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 37 #endif
michael@0 38
michael@0 39 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 40 const nsRect& aDirtyRect,
michael@0 41 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
michael@0 42
michael@0 43 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
michael@0 44 nsIAtom* aAttribute,
michael@0 45 int32_t aModType) MOZ_OVERRIDE;
michael@0 46
michael@0 47 /**
michael@0 48 * Get the "type" of the frame
michael@0 49 *
michael@0 50 * @see nsGkAtoms::svgStopFrame
michael@0 51 */
michael@0 52 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
michael@0 53
michael@0 54 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 55 {
michael@0 56 return nsSVGStopFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
michael@0 57 }
michael@0 58
michael@0 59 #ifdef DEBUG_FRAME_DUMP
michael@0 60 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
michael@0 61 {
michael@0 62 return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
michael@0 63 }
michael@0 64 #endif
michael@0 65 };
michael@0 66
michael@0 67 //----------------------------------------------------------------------
michael@0 68 // Implementation
michael@0 69
michael@0 70 NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
michael@0 71
michael@0 72 //----------------------------------------------------------------------
michael@0 73 // nsIFrame methods:
michael@0 74
michael@0 75 #ifdef DEBUG
michael@0 76 void
michael@0 77 nsSVGStopFrame::Init(nsIContent* aContent,
michael@0 78 nsIFrame* aParent,
michael@0 79 nsIFrame* aPrevInFlow)
michael@0 80 {
michael@0 81 NS_ASSERTION(aContent->IsSVG(nsGkAtoms::stop), "Content is not a stop element");
michael@0 82
michael@0 83 nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow);
michael@0 84 }
michael@0 85 #endif /* DEBUG */
michael@0 86
michael@0 87 nsIAtom *
michael@0 88 nsSVGStopFrame::GetType() const
michael@0 89 {
michael@0 90 return nsGkAtoms::svgStopFrame;
michael@0 91 }
michael@0 92
michael@0 93 nsresult
michael@0 94 nsSVGStopFrame::AttributeChanged(int32_t aNameSpaceID,
michael@0 95 nsIAtom* aAttribute,
michael@0 96 int32_t aModType)
michael@0 97 {
michael@0 98 if (aNameSpaceID == kNameSpaceID_None &&
michael@0 99 aAttribute == nsGkAtoms::offset) {
michael@0 100 nsSVGEffects::InvalidateRenderingObservers(this);
michael@0 101 }
michael@0 102
michael@0 103 return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID,
michael@0 104 aAttribute, aModType);
michael@0 105 }
michael@0 106
michael@0 107 // -------------------------------------------------------------------------
michael@0 108 // Public functions
michael@0 109 // -------------------------------------------------------------------------
michael@0 110
michael@0 111 nsIFrame* NS_NewSVGStopFrame(nsIPresShell* aPresShell,
michael@0 112 nsStyleContext* aContext)
michael@0 113 {
michael@0 114 return new (aPresShell) nsSVGStopFrame(aContext);
michael@0 115 }

mercurial