@@ -85,8 +85,12 @@ impl<L: LengthNum> MediaQueryStatus<L> {
8585 }
8686}
8787
88+ /// The class for a `StyleNode`.
8889pub trait StyleNodeClass {
90+ /// The name of the class.
8991 fn name ( & self ) -> & str ;
92+
93+ /// The style scope of the class.
9094 fn scope ( & self ) -> Option < NonZeroUsize > ;
9195}
9296
@@ -100,19 +104,25 @@ impl StyleNodeClass for (String, Option<NonZeroUsize>) {
100104 }
101105}
102106
107+ /// The case-sensitivity for attribute matching.
103108pub enum StyleNodeAttributeCaseSensitivity {
109+ /// Case-sensitive.
104110 CaseSensitive ,
111+
112+ /// Case-insensitive.
105113 CaseInsensitive ,
106114}
107115
108116impl StyleNodeAttributeCaseSensitivity {
117+ /// Matches two strings with this case-sensitivity.
109118 pub fn eq ( & self , a : & str , b : & str ) -> bool {
110119 match self {
111120 Self :: CaseSensitive => a == b,
112121 Self :: CaseInsensitive => a. eq_ignore_ascii_case ( b) ,
113122 }
114123 }
115124
125+ /// Check if `a` starts with `b` in this case-sensitivity.
116126 pub fn starts_with ( & self , a : & str , b : & str ) -> bool {
117127 // FIXME: reduce memory allocation
118128 match self {
@@ -121,6 +131,7 @@ impl StyleNodeAttributeCaseSensitivity {
121131 }
122132 }
123133
134+ /// Check if `a` ends with `b` in this case-sensitivity.
124135 pub fn ends_with ( & self , a : & str , b : & str ) -> bool {
125136 // FIXME: reduce memory allocation
126137 match self {
@@ -129,6 +140,7 @@ impl StyleNodeAttributeCaseSensitivity {
129140 }
130141 }
131142
143+ /// Check if `a` contains `b` in this case-sensitivity.
132144 pub fn contains ( & self , a : & str , b : & str ) -> bool {
133145 // FIXME: reduce memory allocation
134146 match self {
@@ -138,20 +150,38 @@ impl StyleNodeAttributeCaseSensitivity {
138150 }
139151}
140152
153+ /// A node descriptor for a style query.
141154pub trait StyleNode {
155+ /// The type for a class.
142156 type Class : StyleNodeClass ;
157+
158+ /// The type for classes iteration.
143159 type ClassIter < ' a > : Iterator < Item = & ' a Self :: Class >
144160 where
145161 Self : ' a ;
146162
163+ /// The style scope of the node itself.
147164 fn style_scope ( & self ) -> Option < NonZeroUsize > ;
165+
166+ /// The extra style scope of the node.
148167 fn extra_style_scope ( & self ) -> Option < NonZeroUsize > ;
168+
169+ /// The extra style scope for the `:host` selector.
149170 fn host_style_scope ( & self ) -> Option < NonZeroUsize > ;
171+
172+ /// The tag name of the node.
150173 fn tag_name ( & self ) -> & str ;
174+
175+ /// The id of the node.
151176 fn id ( & self ) -> Option < & str > ;
177+
178+ /// The classes of the node.
152179 fn classes ( & self ) -> Self :: ClassIter < ' _ > ;
180+
181+ /// Get an attribute of the node.
153182 fn attribute ( & self , name : & str ) -> Option < ( & str , StyleNodeAttributeCaseSensitivity ) > ;
154183
184+ /// Check if the node has a specified scope.
155185 fn contain_scope ( & self , scope : Option < NonZeroUsize > ) -> bool {
156186 scope. is_none ( )
157187 || self . style_scope ( ) == scope
@@ -236,7 +266,7 @@ impl<'a> StyleNode for StyleQuery<'a> {
236266 self . classes . iter ( )
237267 }
238268
239- fn attribute ( & self , name : & str ) -> Option < ( & str , StyleNodeAttributeCaseSensitivity ) > {
269+ fn attribute ( & self , _name : & str ) -> Option < ( & str , StyleNodeAttributeCaseSensitivity ) > {
240270 None
241271 }
242272}
@@ -272,7 +302,7 @@ impl<'b, 'a: 'b> StyleNode for &'b StyleQuery<'a> {
272302 self . classes . iter ( )
273303 }
274304
275- fn attribute ( & self , name : & str ) -> Option < ( & str , StyleNodeAttributeCaseSensitivity ) > {
305+ fn attribute ( & self , _name : & str ) -> Option < ( & str , StyleNodeAttributeCaseSensitivity ) > {
276306 None
277307 }
278308}
0 commit comments