|
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/. */ |
|
5 |
|
6 #include "nsSMILSetAnimationFunction.h" |
|
7 |
|
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 } |
|
28 |
|
29 return false; |
|
30 } |
|
31 |
|
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 } |
|
53 |
|
54 return nsSMILAnimationFunction::SetAttr(aAttribute, aValue, |
|
55 aResult, aParseResult); |
|
56 } |
|
57 |
|
58 bool |
|
59 nsSMILSetAnimationFunction::UnsetAttr(nsIAtom* aAttribute) |
|
60 { |
|
61 if (IsDisallowedAttribute(aAttribute)) { |
|
62 return true; |
|
63 } |
|
64 |
|
65 return nsSMILAnimationFunction::UnsetAttr(aAttribute); |
|
66 } |
|
67 |
|
68 bool |
|
69 nsSMILSetAnimationFunction::HasAttr(nsIAtom* aAttName) const |
|
70 { |
|
71 if (IsDisallowedAttribute(aAttName)) |
|
72 return false; |
|
73 |
|
74 return nsSMILAnimationFunction::HasAttr(aAttName); |
|
75 } |
|
76 |
|
77 const nsAttrValue* |
|
78 nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName) const |
|
79 { |
|
80 if (IsDisallowedAttribute(aAttName)) |
|
81 return nullptr; |
|
82 |
|
83 return nsSMILAnimationFunction::GetAttr(aAttName); |
|
84 } |
|
85 |
|
86 bool |
|
87 nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName, |
|
88 nsAString& aResult) const |
|
89 { |
|
90 if (IsDisallowedAttribute(aAttName)) |
|
91 return false; |
|
92 |
|
93 return nsSMILAnimationFunction::GetAttr(aAttName, aResult); |
|
94 } |
|
95 |
|
96 bool |
|
97 nsSMILSetAnimationFunction::WillReplace() const |
|
98 { |
|
99 return true; |
|
100 } |