mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #16704 - BorisChiou:stylo/transition/compute_from_string, r=birtles
stylo: Bug 1346052 - Add Servo_AnimationValue_Compute. This is an interdependent patch of Bug 1346052. We need this FFI to compute the AnimationValue from a property id and a string, so nsDOMWindowUtils::ComputeAnimationDistance() can use this FFI to get the AnimationValue. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix [Bug 1346052](https://bugzilla.mozilla.org/show_bug.cgi?id=1346052). - [X] These changes do not require tests because we have some tests for this in Gecko. <!-- 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/16704) <!-- Reviewable:end -->
This commit is contained in:
commit
1b9e1cc1f2
2 changed files with 53 additions and 4 deletions
|
@ -1074,10 +1074,6 @@ extern "C" {
|
|||
pub fn Gecko_CSSValue_GetAbsoluteLength(css_value: nsCSSValueBorrowed)
|
||||
-> nscoord;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetAppUnitsPerPhysicalInch(pres_context: RawGeckoPresContextBorrowed)
|
||||
-> i32;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_GetKeyword(aCSSValue: nsCSSValueBorrowed)
|
||||
-> nsCSSKeyword;
|
||||
|
@ -1172,6 +1168,11 @@ extern "C" {
|
|||
font_size: nscoord, use_user_font_set: bool)
|
||||
-> GeckoFontMetrics;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetAppUnitsPerPhysicalInch(pres_context:
|
||||
RawGeckoPresContextBorrowed)
|
||||
-> i32;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature;
|
||||
}
|
||||
|
@ -1855,6 +1856,15 @@ extern "C" {
|
|||
RawServoAnimationValueBorrowed)
|
||||
-> RawServoDeclarationBlockStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValue_Compute(declarations:
|
||||
RawServoDeclarationBlockBorrowed,
|
||||
style: ServoComputedValuesBorrowed,
|
||||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> RawServoAnimationValueStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ParseStyleAttribute(data: *const nsACString,
|
||||
extra_data: *mut RawGeckoURLExtraData)
|
||||
|
|
|
@ -2066,6 +2066,45 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValue_Compute(declarations: RawServoDeclarationBlockBorrowed,
|
||||
style: ServoComputedValuesBorrowed,
|
||||
parent_style: ServoComputedValuesBorrowedOrNull,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> RawServoAnimationValueStrong {
|
||||
use style::values::computed::Context;
|
||||
|
||||
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 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: QuirksMode::NoQuirks,
|
||||
};
|
||||
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
// We only compute the first element in declarations.
|
||||
match declarations.read_with(&guard).declarations().first() {
|
||||
Some(&(ref decl, imp)) if imp == Importance::Normal => {
|
||||
let animation = AnimationValue::from_declaration(decl, &mut context, default_values);
|
||||
animation.map_or(RawServoAnimationValueStrong::null(), |value| {
|
||||
Arc::new(value).into_strong()
|
||||
})
|
||||
},
|
||||
_ => RawServoAnimationValueStrong::null()
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue