Bug 1776680 [wpt PR 34603] - [@container] Test invalidation of font-relative units...
[gecko.git] / dom / smil / SMILBoolType.cpp
blob218b7af16f36d2f0541c5b00a4223e797968b824
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "SMILBoolType.h"
9 #include "mozilla/SMILValue.h"
10 #include "nsDebug.h"
11 #include <math.h>
13 namespace mozilla {
15 void SMILBoolType::Init(SMILValue& aValue) const {
16 MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
17 aValue.mU.mBool = false;
18 aValue.mType = this;
21 void SMILBoolType::Destroy(SMILValue& aValue) const {
22 MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
23 aValue.mU.mBool = false;
24 aValue.mType = SMILNullType::Singleton();
27 nsresult SMILBoolType::Assign(SMILValue& aDest, const SMILValue& aSrc) const {
28 MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
29 MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
30 aDest.mU.mBool = aSrc.mU.mBool;
31 return NS_OK;
34 bool SMILBoolType::IsEqual(const SMILValue& aLeft,
35 const SMILValue& aRight) const {
36 MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
37 MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
39 return aLeft.mU.mBool == aRight.mU.mBool;
42 nsresult SMILBoolType::Add(SMILValue& aDest, const SMILValue& aValueToAdd,
43 uint32_t aCount) const {
44 MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types");
45 MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
46 return NS_ERROR_FAILURE; // bool values can't be added to each other
49 nsresult SMILBoolType::ComputeDistance(const SMILValue& aFrom,
50 const SMILValue& aTo,
51 double& aDistance) const {
52 MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
53 MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
54 return NS_ERROR_FAILURE; // there is no concept of distance between bool
55 // values
58 nsresult SMILBoolType::Interpolate(const SMILValue& aStartVal,
59 const SMILValue& aEndVal,
60 double aUnitDistance,
61 SMILValue& aResult) const {
62 MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
63 "Trying to interpolate different types");
64 MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation");
65 MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
66 return NS_ERROR_FAILURE; // bool values do not interpolate
69 } // namespace mozilla