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.

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

mercurial