From c3185eab0186e3aa96a60d4861cbc797fa84f050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 29 Mar 2018 03:49:26 +0200 Subject: [PATCH] style: Add an FFI function to see if an element is display: contents. Bug: 1303605 Reviewed-by: bz --- ports/geckolib/glue.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 655965fcaa3..41905bfe55e 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1043,17 +1043,34 @@ pub extern "C" fn Servo_Element_GetPseudoComputedValues( } #[no_mangle] -pub extern "C" fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool { +pub extern "C" fn Servo_Element_IsDisplayNone( + element: RawGeckoElementBorrowed, +) -> bool { let element = GeckoElement(element); - let data = element.get_data().expect("Invoking Servo_Element_IsDisplayNone on unstyled element"); + let data = element.get_data() + .expect("Invoking Servo_Element_IsDisplayNone on unstyled element"); - // This function is hot, so we bypass the AtomicRefCell. It would be nice to also assert that - // we're not in the servo traversal, but this function is called at various intermediate - // checkpoints when managing the traversal on the Gecko side. + // This function is hot, so we bypass the AtomicRefCell. + // + // It would be nice to also assert that we're not in the servo traversal, + // but this function is called at various intermediate checkpoints when + // managing the traversal on the Gecko side. debug_assert!(is_main_thread()); unsafe { &*data.as_ptr() }.styles.is_display_none() } +#[no_mangle] +pub extern "C" fn Servo_Element_IsDisplayContents( + element: RawGeckoElementBorrowed, +) -> bool { + let element = GeckoElement(element); + let data = element.get_data() + .expect("Invoking Servo_Element_IsDisplayContents on unstyled element"); + + debug_assert!(is_main_thread()); + unsafe { &*data.as_ptr() }.styles.primary().get_box().clone_display().is_contents() +} + #[no_mangle] pub extern "C" fn Servo_Element_IsPrimaryStyleReusedViaRuleNode(element: RawGeckoElementBorrowed) -> bool { let element = GeckoElement(element);