@@ -134,7 +134,7 @@ pub fn is_html_element(node: &Node) -> bool {
134134}
135135
136136const OVERFLOW_VALUES : [ & str ; 5 ] = [ "auto" , "scroll" , "overlay" , "hidden" , "clip" ] ;
137- const DISPLAY_VALUES : [ & str ; 2 ] = [ "inline" , "contents" ] ;
137+ const INVALID_OVERFLOW_DISPLAY_VALUES : [ & str ; 2 ] = [ "inline" , "contents" ] ;
138138
139139pub fn is_overflow_element ( element : & Element ) -> bool {
140140 let style = get_computed_style ( element) ;
@@ -148,20 +148,29 @@ pub fn is_overflow_element(element: &Element) -> bool {
148148 OVERFLOW_VALUES
149149 . into_iter ( )
150150 . any ( |s| overflow_combined. contains ( s) )
151- && !DISPLAY_VALUES . into_iter ( ) . any ( |s| display == s)
151+ && !INVALID_OVERFLOW_DISPLAY_VALUES
152+ . into_iter ( )
153+ . any ( |s| display == s)
152154}
153155
156+ const TABLE_ELEMENTS : [ & str ; 3 ] = [ "table" , "td" , "th" ] ;
157+
154158pub fn is_table_element ( element : & Element ) -> bool {
155159 let node_name = get_node_name ( element. into ( ) ) ;
156- [ "table" , "td" , "th" ] . into_iter ( ) . any ( |s| node_name == s)
160+ TABLE_ELEMENTS . into_iter ( ) . any ( |s| node_name == s)
157161}
158162
163+ const TOP_LAYER_SELECTORS : [ & str ; 2 ] = [ ":popover-open" , ":modal" ] ;
164+
159165pub fn is_top_layer ( element : & Element ) -> bool {
160- [ ":popover-open" , ":modal" ]
166+ TOP_LAYER_SELECTORS
161167 . into_iter ( )
162168 . any ( |selector| element. matches ( selector) . unwrap_or ( false ) )
163169}
164170
171+ const TRANSFORM_PROPERTIES : [ & str ; 5 ] =
172+ [ "transform" , "translate" , "scale" , "rotate" , "perspective" ] ;
173+
165174const WILL_CHANGE_VALUES : [ & str ; 6 ] = [
166175 "transform" ,
167176 "translate" ,
@@ -170,6 +179,7 @@ const WILL_CHANGE_VALUES: [&str; 6] = [
170179 "perspective" ,
171180 "filter" ,
172181] ;
182+
173183const CONTAIN_VALUES : [ & str ; 4 ] = [ "paint" , "layout" , "strict" , "content" ] ;
174184
175185pub enum ElementOrCss < ' a > {
@@ -204,17 +214,14 @@ pub fn is_containing_block(element: ElementOrCss) -> bool {
204214
205215 // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
206216 // https://drafts.csswg.org/css-transforms-2/#individual-transforms
207- [ "transform" , "translate" , "scale" , "rotate" , "perspective" ]
208- . into_iter ( )
209- . any ( |property| {
210- css. get_property_value ( property)
211- . map ( |value| value != "none" )
212- . unwrap_or ( false )
213- } )
214- || css
215- . get_property_value ( "container-type" )
216- . map ( |value| value != "normal" )
217+ TRANSFORM_PROPERTIES . into_iter ( ) . any ( |property| {
218+ css. get_property_value ( property)
219+ . map ( |value| value != "none" )
217220 . unwrap_or ( false )
221+ } ) || css
222+ . get_property_value ( "container-type" )
223+ . map ( |value| value != "normal" )
224+ . unwrap_or ( false )
218225 || ( !webkit
219226 && css
220227 . get_property_value ( "backdrop-filter" )
@@ -262,9 +269,11 @@ pub fn is_web_kit() -> bool {
262269 css:: supports_with_value ( "-webkit-backdrop-filter" , "none" ) . unwrap_or ( false )
263270}
264271
272+ const LAST_TRAVERSABLE_NODE_NAMES : [ & str ; 3 ] = [ "html" , "body" , "#document" ] ;
273+
265274pub fn is_last_traversable_node ( node : & Node ) -> bool {
266275 let node_name = get_node_name ( node. into ( ) ) ;
267- [ "html" , "body" , "#document" ]
276+ LAST_TRAVERSABLE_NODE_NAMES
268277 . into_iter ( )
269278 . any ( |s| node_name == s)
270279}
0 commit comments