mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #16164 - heycam:stale-styles, r=bholley
stylo: Add argument to Servo_ResolveStyle to allow stale styles to be returned. This is the Servo-side part of https://bugzilla.mozilla.org/show_bug.cgi?id=1350671. <!-- 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/16164) <!-- Reviewable:end -->
This commit is contained in:
commit
6311321882
2 changed files with 12 additions and 4 deletions
|
@ -1812,7 +1812,8 @@ extern "C" {
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||||
set: RawServoStyleSetBorrowed)
|
set: RawServoStyleSetBorrowed,
|
||||||
|
allow_stale: bool)
|
||||||
-> ServoComputedValuesStrong;
|
-> ServoComputedValuesStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -1473,15 +1473,22 @@ pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed) -> nsCh
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
|
allow_stale: bool)
|
||||||
-> ServoComputedValuesStrong
|
-> ServoComputedValuesStrong
|
||||||
{
|
{
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
debug!("Servo_ResolveStyle: {:?}", element);
|
debug!("Servo_ResolveStyle: {:?}", element);
|
||||||
let data = unsafe { element.ensure_data() }.borrow_mut();
|
let data = unsafe { element.ensure_data() }.borrow_mut();
|
||||||
|
|
||||||
if !data.has_current_styles() {
|
let valid_styles = if allow_stale {
|
||||||
warn!("Resolving style on unstyled element with lazy computation forbidden.");
|
data.has_styles()
|
||||||
|
} else {
|
||||||
|
data.has_current_styles()
|
||||||
|
};
|
||||||
|
|
||||||
|
if !valid_styles {
|
||||||
|
warn!("Resolving style on element without current styles with lazy computation forbidden.");
|
||||||
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
return per_doc_data.default_computed_values().clone().into_strong();
|
return per_doc_data.default_computed_values().clone().into_strong();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue