Auto merge of #18229 - legnaleurc:bug_1388298, r=emilio

Add an API to process all invalidations on the main thread

fixes [bug 1388298](https://bugzil.la/1388298)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/18229)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-25 03:36:34 -05:00 committed by GitHub
commit 04e6051742

View file

@ -3659,3 +3659,31 @@ pub extern "C" fn Servo_GetCustomPropertyNameAt(computed_values: ServoStyleConte
true true
} }
#[no_mangle]
pub extern "C" fn Servo_ProcessInvalidations(set: RawServoStyleSetBorrowed,
element: RawGeckoElementBorrowed,
snapshots: *const ServoElementSnapshotTable) {
debug_assert!(!snapshots.is_null());
let element = GeckoElement(element);
debug_assert!(element.has_snapshot());
debug_assert!(!element.handled_snapshot());
let mut data = element.mutate_data();
debug_assert!(data.is_some());
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let per_doc_data = PerDocumentStyleData::from_ffi(set).borrow();
let shared_style_context = create_shared_context(&global_style_data,
&guard,
&per_doc_data,
TraversalFlags::empty(),
unsafe { &*snapshots });
let mut data = data.as_mut().map(|d| &mut **d);
if let Some(ref mut data) = data {
data.invalidate_style_if_needed(element, &shared_style_context);
}
}