From a079e8682025fa4e6850f8e69c74ce54f62c87b4 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Sat, 3 Dec 2016 14:53:31 +0800 Subject: [PATCH] stylo: Add FFI function to check if a node is dirty. --- ports/geckolib/glue.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 3043f879e648..02d54692b19f 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -202,6 +202,23 @@ pub extern "C" fn Servo_Element_ClearData(element: RawGeckoElementBorrowed) -> ( GeckoElement(element).clear_data(); } +#[no_mangle] +pub extern "C" fn Servo_Element_ShouldTraverse(element: RawGeckoElementBorrowed) -> bool { + let element = GeckoElement(element); + if let Some(data) = element.get_data() { + debug_assert!(!element.has_dirty_descendants(), + "only call Servo_Element_ShouldTraverse if you know the element \ + does not have dirty descendants"); + match *data.borrow() { + ElementData::Initial(None) | + ElementData::Restyle(..) => true, + _ => false, + } + } else { + false + } +} + #[no_mangle] pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyleSheetStrong { let url = ServoUrl::parse("about:blank").unwrap();