dom/smil/nsSMILSetAnimationFunction.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 #include "nsSMILSetAnimationFunction.h"
michael@0 7
michael@0 8 inline bool
michael@0 9 nsSMILSetAnimationFunction::IsDisallowedAttribute(
michael@0 10 const nsIAtom* aAttribute) const
michael@0 11 {
michael@0 12 //
michael@0 13 // A <set> element is similar to <animate> but lacks:
michael@0 14 // AnimationValue.attrib(calcMode, values, keyTimes, keySplines, from, to,
michael@0 15 // by) -- BUT has 'to'
michael@0 16 // AnimationAddition.attrib(additive, accumulate)
michael@0 17 //
michael@0 18 if (aAttribute == nsGkAtoms::calcMode ||
michael@0 19 aAttribute == nsGkAtoms::values ||
michael@0 20 aAttribute == nsGkAtoms::keyTimes ||
michael@0 21 aAttribute == nsGkAtoms::keySplines ||
michael@0 22 aAttribute == nsGkAtoms::from ||
michael@0 23 aAttribute == nsGkAtoms::by ||
michael@0 24 aAttribute == nsGkAtoms::additive ||
michael@0 25 aAttribute == nsGkAtoms::accumulate) {
michael@0 26 return true;
michael@0 27 }
michael@0 28
michael@0 29 return false;
michael@0 30 }
michael@0 31
michael@0 32 bool
michael@0 33 nsSMILSetAnimationFunction::SetAttr(nsIAtom* aAttribute,
michael@0 34 const nsAString& aValue,
michael@0 35 nsAttrValue& aResult,
michael@0 36 nsresult* aParseResult)
michael@0 37 {
michael@0 38 if (IsDisallowedAttribute(aAttribute)) {
michael@0 39 aResult.SetTo(aValue);
michael@0 40 if (aParseResult) {
michael@0 41 // SMILANIM 4.2 says:
michael@0 42 //
michael@0 43 // The additive and accumulate attributes are not allowed, and will be
michael@0 44 // ignored if specified.
michael@0 45 //
michael@0 46 // So at least for those two attributes we shouldn't report an error even
michael@0 47 // if they're present. For now we'll also just silently ignore other
michael@0 48 // attribute types too.
michael@0 49 *aParseResult = NS_OK;
michael@0 50 }
michael@0 51 return true;
michael@0 52 }
michael@0 53
michael@0 54 return nsSMILAnimationFunction::SetAttr(aAttribute, aValue,
michael@0 55 aResult, aParseResult);
michael@0 56 }
michael@0 57
michael@0 58 bool
michael@0 59 nsSMILSetAnimationFunction::UnsetAttr(nsIAtom* aAttribute)
michael@0 60 {
michael@0 61 if (IsDisallowedAttribute(aAttribute)) {
michael@0 62 return true;
michael@0 63 }
michael@0 64
michael@0 65 return nsSMILAnimationFunction::UnsetAttr(aAttribute);
michael@0 66 }
michael@0 67
michael@0 68 bool
michael@0 69 nsSMILSetAnimationFunction::HasAttr(nsIAtom* aAttName) const
michael@0 70 {
michael@0 71 if (IsDisallowedAttribute(aAttName))
michael@0 72 return false;
michael@0 73
michael@0 74 return nsSMILAnimationFunction::HasAttr(aAttName);
michael@0 75 }
michael@0 76
michael@0 77 const nsAttrValue*
michael@0 78 nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName) const
michael@0 79 {
michael@0 80 if (IsDisallowedAttribute(aAttName))
michael@0 81 return nullptr;
michael@0 82
michael@0 83 return nsSMILAnimationFunction::GetAttr(aAttName);
michael@0 84 }
michael@0 85
michael@0 86 bool
michael@0 87 nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName,
michael@0 88 nsAString& aResult) const
michael@0 89 {
michael@0 90 if (IsDisallowedAttribute(aAttName))
michael@0 91 return false;
michael@0 92
michael@0 93 return nsSMILAnimationFunction::GetAttr(aAttName, aResult);
michael@0 94 }
michael@0 95
michael@0 96 bool
michael@0 97 nsSMILSetAnimationFunction::WillReplace() const
michael@0 98 {
michael@0 99 return true;
michael@0 100 }

mercurial