From 8789b91bd9c2da45bca8281f51dc8fb17cc5c498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 28 Sep 2017 10:40:02 +0200 Subject: [PATCH] style: Avoid creating element data in Servo_ResolvePseudoStyle. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reason the patch in bug 1402285 doesn't work is that we call this function multiple times with the same element. This fixes it. Bug: 1403465 Reviewed-by: bholley MozReview-Commit-ID: Ko9zirCOzTR Signed-off-by: Emilio Cobos Álvarez --- ports/geckolib/glue.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 69c039a9817..5084a7085c6 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1772,21 +1772,31 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, -> ServoStyleContextStrong { let element = GeckoElement(element); - let data = unsafe { element.ensure_data() }; let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow(); debug!("Servo_ResolvePseudoStyle: {:?} {:?}, is_probe: {}", element, PseudoElement::from_pseudo_type(pseudo_type), is_probe); - // FIXME(bholley): Assert against this. - if !data.has_styles() { - warn!("Calling Servo_ResolvePseudoStyle on unstyled element"); - return if is_probe { - Strong::null() - } else { - doc_data.default_computed_values().clone().into() - }; - } + let data = element.borrow_data(); + + let data = match data.as_ref() { + Some(data) if data.has_styles() => data, + _ => { + // FIXME(bholley, emilio): Assert against this. + // + // Known offender is nsMathMLmoFrame::MarkIntrinsicISizesDirty, + // which goes and does a bunch of work involving style resolution. + // + // Bug 1403865 tracks fixing it, and potentially adding an assert + // here instead. + warn!("Calling Servo_ResolvePseudoStyle on unstyled element"); + return if is_probe { + Strong::null() + } else { + doc_data.default_computed_values().clone().into() + }; + } + }; let pseudo = PseudoElement::from_pseudo_type(pseudo_type) .expect("ResolvePseudoStyle with a non-pseudo?");