Auto merge of #17532 - bholley:set_explicit_style, r=emilio

stylo: Attach styles explicitly to generated content

https://bugzilla.mozilla.org/show_bug.cgi?id=1376245

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17532)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-27 10:27:49 -07:00 committed by GitHub
commit 12ff92592f

View file

@ -1493,6 +1493,20 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
} }
} }
#[no_mangle]
pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
style: ServoComputedValuesBorrowed)
{
let element = GeckoElement(element);
let style = ComputedValues::as_arc(&style);
debug!("Servo_SetExplicitStyle: {:?}", element);
// We only support this API for initial styling. There's no reason it couldn't
// work for other things, we just haven't had a reason to do so.
debug_assert!(element.get_data().is_none());
let mut data = unsafe { element.ensure_data() }.borrow_mut();
data.styles.primary = Some(style.clone());
}
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed, pub extern "C" fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed,
rule_type_mask: u32, rule_type_mask: u32,
@ -1627,6 +1641,14 @@ pub extern "C" fn Servo_ComputedValues_GetVisitedStyle(values: ServoComputedValu
} }
} }
#[no_mangle]
pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoComputedValuesBorrowed)
-> bool {
let values = ComputedValues::as_arc(&values);
let b = values.get_box();
b.specifies_animations() || b.specifies_transitions()
}
/// See the comment in `Device` to see why it's ok to pass an owned reference to /// See the comment in `Device` to see why it's ok to pass an owned reference to
/// the pres context (hint: the context outlives the StyleSet, that holds the /// the pres context (hint: the context outlives the StyleSet, that holds the
/// device alive). /// device alive).