dom/smil/SMILBoolType.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 "SMILBoolType.h"
     7 #include "nsSMILValue.h"
     8 #include "nsDebug.h"
     9 #include <math.h>
    11 namespace mozilla {
    13 void
    14 SMILBoolType::Init(nsSMILValue& aValue) const
    15 {
    16   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
    17   aValue.mU.mBool = false;
    18   aValue.mType = this;
    19 }
    21 void
    22 SMILBoolType::Destroy(nsSMILValue& aValue) const
    23 {
    24   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
    25   aValue.mU.mBool = false;
    26   aValue.mType = nsSMILNullType::Singleton();
    27 }
    29 nsresult
    30 SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
    31 {
    32   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
    33   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
    34   aDest.mU.mBool = aSrc.mU.mBool;
    35   return NS_OK;
    36 }
    38 bool
    39 SMILBoolType::IsEqual(const nsSMILValue& aLeft,
    40                       const nsSMILValue& aRight) const
    41 {
    42   NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
    43   NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
    45   return aLeft.mU.mBool == aRight.mU.mBool;
    46 }
    48 nsresult
    49 SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
    50                   uint32_t aCount) const
    51 {
    52   NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
    53                   "Trying to add invalid types");
    54   NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
    55   return NS_ERROR_FAILURE; // bool values can't be added to each other
    56 }
    58 nsresult
    59 SMILBoolType::ComputeDistance(const nsSMILValue& aFrom,
    60                               const nsSMILValue& aTo,
    61                               double& aDistance) const
    62 {
    63   NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
    64   NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
    65   return NS_ERROR_FAILURE; // there is no concept of distance between bool values
    66 }
    68 nsresult
    69 SMILBoolType::Interpolate(const nsSMILValue& aStartVal,
    70                           const nsSMILValue& aEndVal,
    71                           double aUnitDistance,
    72                           nsSMILValue& aResult) const
    73 {
    74   NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
    75       "Trying to interpolate different types");
    76   NS_PRECONDITION(aStartVal.mType == this,
    77       "Unexpected types for interpolation");
    78   NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
    79   return NS_ERROR_FAILURE; // bool values do not interpolate
    80 }
    82 } // namespace mozilla

mercurial