mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Bug 1298588 part 6, servo piece. Stop using initial_values when doing inheritance in Gecko glue code. r=bholley
This commit is contained in:
parent
56941d61a7
commit
c313c8d17e
3 changed files with 10 additions and 13 deletions
|
@ -1361,7 +1361,8 @@ extern "C" {
|
||||||
-> ServoComputedValuesStrong;
|
-> ServoComputedValuesStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ComputedValues_Inherit(parent_style:
|
pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed,
|
||||||
|
parent_style:
|
||||||
ServoComputedValuesBorrowedOrNull)
|
ServoComputedValuesBorrowedOrNull)
|
||||||
-> ServoComputedValuesStrong;
|
-> ServoComputedValuesStrong;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub struct ComputedValues {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputedValues {
|
impl ComputedValues {
|
||||||
pub fn inherit_from(parent: &Arc<Self>) -> Arc<Self> {
|
pub fn inherit_from(parent: &Arc<Self>, default: &Arc<Self>) -> Arc<Self> {
|
||||||
Arc::new(ComputedValues {
|
Arc::new(ComputedValues {
|
||||||
custom_properties: parent.custom_properties.clone(),
|
custom_properties: parent.custom_properties.clone(),
|
||||||
shareable: parent.shareable,
|
shareable: parent.shareable,
|
||||||
|
@ -88,7 +88,7 @@ impl ComputedValues {
|
||||||
% if style_struct.inherited:
|
% if style_struct.inherited:
|
||||||
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
||||||
% else:
|
% else:
|
||||||
${style_struct.ident}: Self::initial_values().${style_struct.ident}.clone(),
|
${style_struct.ident}: default.${style_struct.ident}.clone(),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
})
|
})
|
||||||
|
@ -113,13 +113,6 @@ impl ComputedValues {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn style_for_child_text_node(parent: &Arc<Self>) -> Arc<Self> {
|
|
||||||
// Gecko expects text nodes to be styled as if they were elements that
|
|
||||||
// matched no rules (that is, inherited style structs are inherited and
|
|
||||||
// non-inherited style structs are set to their initial values).
|
|
||||||
ComputedValues::inherit_from(parent)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn initial_values() -> &'static Self {
|
pub fn initial_values() -> &'static Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug_assert!(!raw_initial_values().is_null());
|
debug_assert!(!raw_initial_values().is_null());
|
||||||
|
|
|
@ -581,13 +581,16 @@ fn get_pseudo_style(element: GeckoElement, pseudo_tag: *mut nsIAtom,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComputedValues_Inherit(parent_style: ServoComputedValuesBorrowedOrNull)
|
pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||||
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
|
parent_style: ServoComputedValuesBorrowedOrNull)
|
||||||
-> ServoComputedValuesStrong {
|
-> ServoComputedValuesStrong {
|
||||||
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
let maybe_arc = ComputedValues::arc_from_borrowed(&parent_style);
|
let maybe_arc = ComputedValues::arc_from_borrowed(&parent_style);
|
||||||
let style = if let Some(reference) = maybe_arc.as_ref() {
|
let style = if let Some(reference) = maybe_arc.as_ref() {
|
||||||
ComputedValues::inherit_from(reference)
|
ComputedValues::inherit_from(reference, &data.default_computed_values)
|
||||||
} else {
|
} else {
|
||||||
Arc::new(ComputedValues::initial_values().clone())
|
data.default_computed_values.clone()
|
||||||
};
|
};
|
||||||
style.into_strong()
|
style.into_strong()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue