1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! Groups for attributes
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
bitflags! {
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
#[cfg_attr(feature = "wasm", tsify(type = "number"))]
#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
#[cfg_attr(feature = "napi", napi)]
#[derive(Debug)]
/// Specifies which attribute groups an attribute may belong to
pub struct AttributeGroup: u32 {
/// Attributes used for animation addition
const AnimationAddition = 1 << 0;
/// Attributes used for animation targets
const AnimationAttributeTarget = 1 << 1;
/// Attributes used for animation events
const AnimationEvent = 1 << 2;
/// Attributes used to identify the target element for an animation
const AnimationTargetElement = 1 << 3;
/// Attributes used for animation timing
const AnimationTiming = 1 << 4;
/// Attributes used for animation values
const AnimationValue = 1 << 5;
/// Attributes used for assistive information
const Aria = 1 << 6;
/// Attributes used for conditional processing
const ConditionalProcessing = 1 << 7;
/// Attributes used for any SVG element
const Core = 1 << 8;
/// Attributes used for document events
const DocumentEvent = 1 << 9;
/// Attributes used for document element events
const DocumentElementEvent = 1 << 10;
/// Attributes used for filter primitive elements
const FilterPrimitive = 1 << 11;
/// Attributes used for graphical events
const GraphicalEvent = 1 << 12;
/// Attributes used for global events
const GlobalEvent = 1 << 13;
/// Attributes used for styling
const Presentation = 1 << 14;
/// Attributes used for transfer functions
const TransferFunction = 1 << 15;
/// Attributes used for xlink features
const XLink = 1 << 16;
}
}
impl AttributeGroup {
/// Returns union of all event groups
pub const fn event() -> Self {
Self::AnimationEvent
.union(Self::DocumentEvent)
.union(Self::DocumentElementEvent)
.union(Self::GraphicalEvent)
.union(Self::GlobalEvent)
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for AttributeGroup {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
self.bits().serialize(serializer)
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for AttributeGroup {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
Ok(AttributeGroup::from_bits_retain(u32::deserialize(
deserializer,
)?))
}
}
#[cfg(feature = "napi")]
#[napi]
impl AttributeGroup {
#[napi(constructor)]
/// Convert from bits
pub fn new(bits: u32) -> AttributeGroup {
AttributeGroup::from_bits_retain(bits)
}
#[napi]
/// Get the underlying bits
pub const fn to_bits(&self) -> u32 {
self.bits()
}
}
bitflags! {
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
/// Specifies info about an attribute
pub struct AttributeInfo: u32 {
/// A deprecated attribute that can be safely removed
///
/// Usually this means the attribute is no longer supported in
/// the SVG 2 draft and it's removal has no ill-effect
const DeprecatedSafe = 1 << 0;
/// A deprecated attribute that cannot be safely removed
///
/// Usually this means the attribute is no longer supported in
/// the SVG 2 draft but it's removal has some effect
const DeprecatedUnsafe = 1 << 1;
/// The attribute automatically inherits from parent elements
const Inheritable = 1 << 2;
/// The attribute is an inheritable presentation attribute but
/// compounds, so it cannot be arbitrarily added or removed.
const PresentationNonInheritableGroupAttrs = 1 << 3;
}
}