Skip to content

Commit

Permalink
Get parent style from the target element.
Browse files Browse the repository at this point in the history
We can get the parent style from element tree in servo side.
The parent style has been already restyled.
E.g.;
 When we get target element style with nsComputedDOMStyle::GetStyleContext,
 the function flushes styles so that the parent style has also
 restyled.

 When we call Servo_GetComputedKeyframeValues, it's called from a
 SequentialTask, that means all elements have been already restyled.

Unfortunately we can't assert that the parent style is not stale
to check the parent element has no dirty descendant bit since
Servo_GetComputedKeyframeValues is called in a SequantialTask
that is processed before post traversal, that means elements
still have the dirty bit to update nsStyleContext in the
post traversal.
  • Loading branch information
Hiroyuki Ikezoe committed Jun 2, 2017
1 parent e0ec2dc commit 4af88b1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ports/geckolib/glue.rs
Expand Up @@ -2440,7 +2440,7 @@ fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
font_metrics_provider: &'a FontMetricsProvider,
style: &'a ComputedValues,
parent_style: &'a Option<&ComputedValues>)
parent_style: &'a Option<&Arc<ComputedValues>>)
-> Context<'a> {
let default_values = per_doc_data.default_computed_values();

Expand All @@ -2459,8 +2459,8 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,

#[no_mangle]
pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed,
element: RawGeckoElementBorrowed,
style: ServoComputedValuesBorrowed,
parent_style: ServoComputedValuesBorrowedOrNull,
raw_data: RawServoStyleSetBorrowed,
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
{
Expand All @@ -2471,7 +2471,11 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let metrics = get_metrics_provider_for_product();
let style = ComputedValues::as_arc(&style);
let parent_style = parent_style.as_ref().map(|r| &**ComputedValues::as_arc(&r));

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);

Expand Down Expand Up @@ -2537,15 +2541,20 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
}

#[no_mangle]
pub extern "C" fn Servo_AnimationValue_Compute(declarations: RawServoDeclarationBlockBorrowed,
pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
declarations: RawServoDeclarationBlockBorrowed,
style: ServoComputedValuesBorrowed,
parent_style: ServoComputedValuesBorrowedOrNull,
raw_data: RawServoStyleSetBorrowed)
-> RawServoAnimationValueStrong {
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 metrics = get_metrics_provider_for_product();

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();
Expand Down

0 comments on commit 4af88b1

Please sign in to comment.