mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Auto merge of #17137 - hiikezoe:get-parent-style-in-servo-side, r=birtles
Get parent style in servo side <!-- Please describe your changes on the following line: --> This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1367293 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because it's for stylo <!-- 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/17137) <!-- Reviewable:end -->
This commit is contained in:
commit
cf71a0cd96
4 changed files with 1855 additions and 1798 deletions
|
@ -2120,9 +2120,8 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_GetComputedKeyframeValues(keyframes:
|
pub fn Servo_GetComputedKeyframeValues(keyframes:
|
||||||
RawGeckoKeyframeListBorrowed,
|
RawGeckoKeyframeListBorrowed,
|
||||||
|
element: RawGeckoElementBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoComputedValuesBorrowed,
|
||||||
parent_style:
|
|
||||||
ServoComputedValuesBorrowedOrNull,
|
|
||||||
set: RawServoStyleSetBorrowed,
|
set: RawServoStyleSetBorrowed,
|
||||||
result:
|
result:
|
||||||
RawGeckoComputedKeyframeValuesListBorrowedMut);
|
RawGeckoComputedKeyframeValuesListBorrowedMut);
|
||||||
|
@ -2208,11 +2207,10 @@ extern "C" {
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_AnimationValue_Compute(declarations:
|
pub fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
||||||
|
declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoComputedValuesBorrowed,
|
||||||
parent_style:
|
|
||||||
ServoComputedValuesBorrowedOrNull,
|
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
-> RawServoAnimationValueStrong;
|
-> RawServoAnimationValueStrong;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,7 @@ use style::dom::{AnimationOnlyDirtyDescendants, DirtyDescendants};
|
||||||
use style::dom::{ShowSubtreeData, TElement, TNode};
|
use style::dom::{ShowSubtreeData, TElement, TNode};
|
||||||
use style::element_state::ElementState;
|
use style::element_state::ElementState;
|
||||||
use style::error_reporting::RustLogReporter;
|
use style::error_reporting::RustLogReporter;
|
||||||
use style::font_metrics::get_metrics_provider_for_product;
|
use style::font_metrics::{FontMetricsProvider, get_metrics_provider_for_product};
|
||||||
use style::gecko::data::{PerDocumentStyleData, PerDocumentStyleDataImpl};
|
use style::gecko::data::{PerDocumentStyleData, PerDocumentStyleDataImpl};
|
||||||
use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData};
|
use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData};
|
||||||
use style::gecko::restyle_damage::GeckoRestyleDamage;
|
use style::gecko::restyle_damage::GeckoRestyleDamage;
|
||||||
|
@ -112,6 +112,7 @@ use style::traversal::{ANIMATION_ONLY, DomTraversal, FOR_CSS_RULE_CHANGES, FOR_R
|
||||||
use style::traversal::{FOR_DEFAULT_STYLES, TraversalDriver, TraversalFlags, UNSTYLED_CHILDREN_ONLY};
|
use style::traversal::{FOR_DEFAULT_STYLES, TraversalDriver, TraversalFlags, UNSTYLED_CHILDREN_ONLY};
|
||||||
use style::traversal::{resolve_style, resolve_default_style};
|
use style::traversal::{resolve_style, resolve_default_style};
|
||||||
use style::values::{CustomIdent, KeyframesName};
|
use style::values::{CustomIdent, KeyframesName};
|
||||||
|
use style::values::computed::Context;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use super::stylesheet_loader::StylesheetLoader;
|
use super::stylesheet_loader::StylesheetLoader;
|
||||||
|
|
||||||
|
@ -2436,41 +2437,51 @@ fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||||
|
font_metrics_provider: &'a FontMetricsProvider,
|
||||||
|
style: &'a ComputedValues,
|
||||||
|
parent_style: &'a Option<&Arc<ComputedValues>>)
|
||||||
|
-> Context<'a> {
|
||||||
|
let default_values = per_doc_data.default_computed_values();
|
||||||
|
|
||||||
|
Context {
|
||||||
|
is_root_element: false,
|
||||||
|
device: per_doc_data.stylist.device(),
|
||||||
|
inherited_style: parent_style.unwrap_or(default_values),
|
||||||
|
layout_parent_style: parent_style.unwrap_or(default_values),
|
||||||
|
style: StyleBuilder::for_derived_style(&style),
|
||||||
|
font_metrics_provider: font_metrics_provider,
|
||||||
|
cached_system_font: None,
|
||||||
|
in_media_query: false,
|
||||||
|
quirks_mode: per_doc_data.stylist.quirks_mode(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed,
|
pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed,
|
||||||
|
element: RawGeckoElementBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoComputedValuesBorrowed,
|
||||||
parent_style: ServoComputedValuesBorrowedOrNull,
|
|
||||||
raw_data: RawServoStyleSetBorrowed,
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
|
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
|
||||||
{
|
{
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use style::properties::LonghandIdSet;
|
use style::properties::LonghandIdSet;
|
||||||
use style::properties::declaration_block::Importance;
|
use style::properties::declaration_block::Importance;
|
||||||
use style::values::computed::Context;
|
|
||||||
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
|
let metrics = get_metrics_provider_for_product();
|
||||||
|
let style = ComputedValues::as_arc(&style);
|
||||||
|
|
||||||
|
let element = GeckoElement(element);
|
||||||
|
let parent_element = element.inheritance_parent();
|
||||||
|
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||||
|
let parent_style = parent_data.as_ref().map(|d| d.styles().primary.values());
|
||||||
|
|
||||||
|
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||||
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let guard = global_style_data.shared_lock.read();
|
let guard = global_style_data.shared_lock.read();
|
||||||
|
|
||||||
|
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
|
||||||
|
|
||||||
let style = ComputedValues::as_arc(&style);
|
|
||||||
let parent_style = parent_style.as_ref().map(|r| &**ComputedValues::as_arc(&r));
|
|
||||||
|
|
||||||
let default_values = data.default_computed_values();
|
let default_values = data.default_computed_values();
|
||||||
let metrics = get_metrics_provider_for_product();
|
|
||||||
|
|
||||||
let mut context = Context {
|
|
||||||
is_root_element: false,
|
|
||||||
device: data.stylist.device(),
|
|
||||||
inherited_style: parent_style.unwrap_or(default_values),
|
|
||||||
layout_parent_style: parent_style.unwrap_or(default_values),
|
|
||||||
style: StyleBuilder::for_derived_style(&style),
|
|
||||||
font_metrics_provider: &metrics,
|
|
||||||
cached_system_font: None,
|
|
||||||
in_media_query: false,
|
|
||||||
quirks_mode: data.stylist.quirks_mode(),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (index, keyframe) in keyframes.iter().enumerate() {
|
for (index, keyframe) in keyframes.iter().enumerate() {
|
||||||
let ref mut animation_values = computed_keyframes[index];
|
let ref mut animation_values = computed_keyframes[index];
|
||||||
|
@ -2530,30 +2541,23 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Compute(declarations: RawServoDeclarationBlockBorrowed,
|
pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
||||||
|
declarations: RawServoDeclarationBlockBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoComputedValuesBorrowed,
|
||||||
parent_style: ServoComputedValuesBorrowedOrNull,
|
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
-> RawServoAnimationValueStrong {
|
-> RawServoAnimationValueStrong {
|
||||||
use style::values::computed::Context;
|
|
||||||
|
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
let style = ComputedValues::as_arc(&style);
|
let style = ComputedValues::as_arc(&style);
|
||||||
let parent_style = parent_style.as_ref().map(|r| &**ComputedValues::as_arc(&r));
|
|
||||||
let default_values = data.default_computed_values();
|
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
let mut context = Context {
|
|
||||||
is_root_element: false,
|
|
||||||
device: data.stylist.device(),
|
|
||||||
inherited_style: parent_style.unwrap_or(default_values),
|
|
||||||
layout_parent_style: parent_style.unwrap_or(default_values),
|
|
||||||
style: StyleBuilder::for_derived_style(&style),
|
|
||||||
font_metrics_provider: &metrics,
|
|
||||||
cached_system_font: None,
|
|
||||||
in_media_query: false,
|
|
||||||
quirks_mode: data.stylist.quirks_mode(),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
let element = GeckoElement(element);
|
||||||
|
let parent_element = element.inheritance_parent();
|
||||||
|
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||||
|
let parent_style = parent_data.as_ref().map(|d| d.styles().primary.values());
|
||||||
|
|
||||||
|
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||||
|
|
||||||
|
let default_values = data.default_computed_values();
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let guard = global_style_data.shared_lock.read();
|
let guard = global_style_data.shared_lock.read();
|
||||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue