mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #11045 - heycam:non-element, r=bholley
Add Servo_GetComputedValuesForOtherNonElement. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11045) <!-- Reviewable:end -->
This commit is contained in:
commit
50f2349551
3 changed files with 31 additions and 13 deletions
|
@ -104,6 +104,8 @@ extern "C" {
|
|||
set: *mut RawServoStyleSet,
|
||||
is_probe: bool)
|
||||
-> *mut ServoComputedValues;
|
||||
pub fn Servo_InheritComputedValues(parent_style: *mut ServoComputedValues)
|
||||
-> *mut ServoComputedValues;
|
||||
pub fn Servo_AddRefComputedValues(arg1: *mut ServoComputedValues);
|
||||
pub fn Servo_ReleaseComputedValues(arg1: *mut ServoComputedValues);
|
||||
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *const u8, nslen: u32,
|
||||
|
|
|
@ -342,6 +342,16 @@ pub extern "C" fn Servo_GetComputedValuesForPseudoElement(parent_style: *mut Ser
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_InheritComputedValues(parent_style: *mut ServoComputedValues)
|
||||
-> *mut ServoComputedValues {
|
||||
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
|
||||
Helpers::with(parent_style, |parent| {
|
||||
let style = GeckoComputedValues::inherit_from(parent);
|
||||
Helpers::from(style)
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AddRefComputedValues(ptr: *mut ServoComputedValues) -> () {
|
||||
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
|
||||
|
|
|
@ -44,6 +44,24 @@ pub struct GeckoComputedValues {
|
|||
pub root_font_size: Au,
|
||||
}
|
||||
|
||||
impl GeckoComputedValues {
|
||||
pub fn inherit_from(parent: &Arc<Self>) -> Arc<Self> {
|
||||
Arc::new(GeckoComputedValues {
|
||||
custom_properties: parent.custom_properties.clone(),
|
||||
shareable: parent.shareable,
|
||||
writing_mode: parent.writing_mode,
|
||||
root_font_size: parent.root_font_size,
|
||||
% for style_struct in data.style_structs:
|
||||
% if style_struct.inherited:
|
||||
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
||||
% else:
|
||||
${style_struct.ident}: Self::initial_values().${style_struct.ident}.clone(),
|
||||
% endif
|
||||
% endfor
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputedValues for GeckoComputedValues {
|
||||
% for style_struct in data.style_structs:
|
||||
type Concrete${style_struct.trait_name} = ${style_struct.gecko_struct_name};
|
||||
|
@ -76,19 +94,7 @@ impl ComputedValues for GeckoComputedValues {
|
|||
// 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).
|
||||
Arc::new(GeckoComputedValues {
|
||||
custom_properties: parent.custom_properties.clone(),
|
||||
shareable: parent.shareable,
|
||||
writing_mode: parent.writing_mode,
|
||||
root_font_size: parent.root_font_size,
|
||||
% for style_struct in data.style_structs:
|
||||
% if style_struct.inherited:
|
||||
${style_struct.ident}: parent.${style_struct.ident}.clone(),
|
||||
% else:
|
||||
${style_struct.ident}: Self::initial_values().${style_struct.ident}.clone(),
|
||||
% endif
|
||||
% endfor
|
||||
})
|
||||
GeckoComputedValues::inherit_from(parent)
|
||||
}
|
||||
|
||||
fn initial_values() -> &'static Self { &*INITIAL_GECKO_VALUES }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue