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 | // Main header first: |
michael@0 | 7 | #include "nsSVGGFrame.h" |
michael@0 | 8 | |
michael@0 | 9 | // Keep others in (case-insensitive) order: |
michael@0 | 10 | #include "nsGkAtoms.h" |
michael@0 | 11 | #include "SVGTransformableElement.h" |
michael@0 | 12 | #include "nsIFrame.h" |
michael@0 | 13 | #include "SVGGraphicsElement.h" |
michael@0 | 14 | #include "nsSVGIntegrationUtils.h" |
michael@0 | 15 | #include "nsSVGUtils.h" |
michael@0 | 16 | |
michael@0 | 17 | using namespace mozilla::dom; |
michael@0 | 18 | |
michael@0 | 19 | //---------------------------------------------------------------------- |
michael@0 | 20 | // Implementation |
michael@0 | 21 | |
michael@0 | 22 | nsIFrame* |
michael@0 | 23 | NS_NewSVGGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) |
michael@0 | 24 | { |
michael@0 | 25 | return new (aPresShell) nsSVGGFrame(aContext); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | NS_IMPL_FRAMEARENA_HELPERS(nsSVGGFrame) |
michael@0 | 29 | |
michael@0 | 30 | #ifdef DEBUG |
michael@0 | 31 | void |
michael@0 | 32 | nsSVGGFrame::Init(nsIContent* aContent, |
michael@0 | 33 | nsIFrame* aParent, |
michael@0 | 34 | nsIFrame* aPrevInFlow) |
michael@0 | 35 | { |
michael@0 | 36 | NS_ASSERTION(aContent->IsSVG() && |
michael@0 | 37 | static_cast<nsSVGElement*>(aContent)->IsTransformable(), |
michael@0 | 38 | "The element doesn't support nsIDOMSVGTransformable"); |
michael@0 | 39 | |
michael@0 | 40 | nsSVGGFrameBase::Init(aContent, aParent, aPrevInFlow); |
michael@0 | 41 | } |
michael@0 | 42 | #endif /* DEBUG */ |
michael@0 | 43 | |
michael@0 | 44 | nsIAtom * |
michael@0 | 45 | nsSVGGFrame::GetType() const |
michael@0 | 46 | { |
michael@0 | 47 | return nsGkAtoms::svgGFrame; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | //---------------------------------------------------------------------- |
michael@0 | 51 | // nsISVGChildFrame methods |
michael@0 | 52 | |
michael@0 | 53 | void |
michael@0 | 54 | nsSVGGFrame::NotifySVGChanged(uint32_t aFlags) |
michael@0 | 55 | { |
michael@0 | 56 | NS_ABORT_IF_FALSE(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), |
michael@0 | 57 | "Invalidation logic may need adjusting"); |
michael@0 | 58 | |
michael@0 | 59 | if (aFlags & TRANSFORM_CHANGED) { |
michael@0 | 60 | // make sure our cached transform matrix gets (lazily) updated |
michael@0 | 61 | mCanvasTM = nullptr; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | nsSVGGFrameBase::NotifySVGChanged(aFlags); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | gfxMatrix |
michael@0 | 68 | nsSVGGFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot) |
michael@0 | 69 | { |
michael@0 | 70 | if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY) && !aTransformRoot) { |
michael@0 | 71 | if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) || |
michael@0 | 72 | (aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) { |
michael@0 | 73 | return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this); |
michael@0 | 74 | } |
michael@0 | 75 | } |
michael@0 | 76 | if (!mCanvasTM) { |
michael@0 | 77 | NS_ASSERTION(mParent, "null parent"); |
michael@0 | 78 | |
michael@0 | 79 | nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent); |
michael@0 | 80 | SVGGraphicsElement *content = static_cast<SVGGraphicsElement*>(mContent); |
michael@0 | 81 | gfxMatrix tm = content->PrependLocalTransformsTo( |
michael@0 | 82 | this == aTransformRoot ? gfxMatrix() : |
michael@0 | 83 | parent->GetCanvasTM(aFor, aTransformRoot)); |
michael@0 | 84 | |
michael@0 | 85 | mCanvasTM = new gfxMatrix(tm); |
michael@0 | 86 | } |
michael@0 | 87 | return *mCanvasTM; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | nsresult |
michael@0 | 91 | nsSVGGFrame::AttributeChanged(int32_t aNameSpaceID, |
michael@0 | 92 | nsIAtom* aAttribute, |
michael@0 | 93 | int32_t aModType) |
michael@0 | 94 | { |
michael@0 | 95 | if (aNameSpaceID == kNameSpaceID_None && |
michael@0 | 96 | aAttribute == nsGkAtoms::transform) { |
michael@0 | 97 | // We don't invalidate for transform changes (the layers code does that). |
michael@0 | 98 | // Also note that SVGTransformableElement::GetAttributeChangeHint will |
michael@0 | 99 | // return nsChangeHint_UpdateOverflow for "transform" attribute changes |
michael@0 | 100 | // and cause DoApplyRenderingChangeToTree to make the SchedulePaint call. |
michael@0 | 101 | NotifySVGChanged(TRANSFORM_CHANGED); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | return NS_OK; |
michael@0 | 105 | } |