mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #15682 - upsuper:arc-types, r=Manishearth
Simplify defining arc ffi types r? @Manishearth I don't have a good sense for creating syntax... so if you have any suggestion for the syntax of `impl_arc_ffi` macro, it would be appreciated. <!-- 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/15682) <!-- Reviewable:end -->
This commit is contained in:
commit
af292c4a71
6 changed files with 61 additions and 118 deletions
58
components/style/gecko/arc_types.rs
Normal file
58
components/style/gecko/arc_types.rs
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! This file lists all arc FFI types and defines corresponding addref
|
||||
//! and release functions. This list corresponds to ServoArcTypeList.h
|
||||
//! file in Gecko.
|
||||
|
||||
#![allow(non_snake_case, missing_docs)]
|
||||
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoStyleRule, RawServoImportRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
use gecko_bindings::structs::{RawServoAnimationValue, RawServoDeclarationBlock};
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
use parking_lot::RwLock;
|
||||
use properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
use properties::animated_properties::AnimationValue;
|
||||
use stylesheets::{CssRules, Stylesheet, StyleRule, ImportRule};
|
||||
|
||||
macro_rules! impl_arc_ffi {
|
||||
($servo_type:ty => $gecko_type:ty [$addref:ident, $release:ident]) => {
|
||||
unsafe impl HasFFI for $servo_type {
|
||||
type FFIType = $gecko_type;
|
||||
}
|
||||
unsafe impl HasArcFFI for $servo_type {}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn $addref(obj: &$gecko_type) -> () {
|
||||
<$servo_type>::addref(obj);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn $release(obj: &$gecko_type) -> () {
|
||||
<$servo_type>::release(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl_arc_ffi!(RwLock<CssRules> => ServoCssRules
|
||||
[Servo_CssRules_AddRef, Servo_CssRules_Release]);
|
||||
|
||||
impl_arc_ffi!(Stylesheet => RawServoStyleSheet
|
||||
[Servo_StyleSheet_AddRef, Servo_StyleSheet_Release]);
|
||||
|
||||
impl_arc_ffi!(ComputedValues => ServoComputedValues
|
||||
[Servo_ComputedValues_AddRef, Servo_ComputedValues_Release]);
|
||||
|
||||
impl_arc_ffi!(RwLock<PropertyDeclarationBlock> => RawServoDeclarationBlock
|
||||
[Servo_DeclarationBlock_AddRef, Servo_DeclarationBlock_Release]);
|
||||
|
||||
impl_arc_ffi!(RwLock<StyleRule> => RawServoStyleRule
|
||||
[Servo_StyleRule_AddRef, Servo_StyleRule_Release]);
|
||||
|
||||
impl_arc_ffi!(RwLock<ImportRule> => RawServoImportRule
|
||||
[Servo_ImportRule_AddRef, Servo_ImportRule_Release]);
|
||||
|
||||
impl_arc_ffi!(AnimationValue => RawServoAnimationValue
|
||||
[Servo_AnimationValue_AddRef, Servo_AnimationValue_Release]);
|
|
@ -11,47 +11,12 @@
|
|||
use app_units::Au;
|
||||
use gecko::values::convert_rgba_to_nscolor;
|
||||
use gecko_bindings::bindings::{Gecko_CreateGradient, Gecko_SetGradientImageValue, Gecko_SetUrlImageValue};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoStyleRule, RawServoImportRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
use gecko_bindings::structs::{nsStyleCoord_CalcValue, nsStyleImage};
|
||||
use gecko_bindings::structs::RawServoDeclarationBlock;
|
||||
use gecko_bindings::structs::nsresult;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordDataMut};
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
use parking_lot::RwLock;
|
||||
use properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
use stylesheets::{CssRules, RulesMutateError, Stylesheet, StyleRule, ImportRule};
|
||||
use stylesheets::RulesMutateError;
|
||||
use values::computed::{CalcLengthOrPercentage, Gradient, Image, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
|
||||
unsafe impl HasFFI for Stylesheet {
|
||||
type FFIType = RawServoStyleSheet;
|
||||
}
|
||||
unsafe impl HasArcFFI for Stylesheet {}
|
||||
unsafe impl HasFFI for ComputedValues {
|
||||
type FFIType = ServoComputedValues;
|
||||
}
|
||||
unsafe impl HasArcFFI for ComputedValues {}
|
||||
|
||||
unsafe impl HasFFI for RwLock<PropertyDeclarationBlock> {
|
||||
type FFIType = RawServoDeclarationBlock;
|
||||
}
|
||||
unsafe impl HasArcFFI for RwLock<PropertyDeclarationBlock> {}
|
||||
|
||||
unsafe impl HasFFI for RwLock<CssRules> {
|
||||
type FFIType = ServoCssRules;
|
||||
}
|
||||
unsafe impl HasArcFFI for RwLock<CssRules> {}
|
||||
|
||||
unsafe impl HasFFI for RwLock<StyleRule> {
|
||||
type FFIType = RawServoStyleRule;
|
||||
}
|
||||
unsafe impl HasArcFFI for RwLock<StyleRule> {}
|
||||
|
||||
unsafe impl HasFFI for RwLock<ImportRule> {
|
||||
type FFIType = RawServoImportRule;
|
||||
}
|
||||
unsafe impl HasArcFFI for RwLock<ImportRule> {}
|
||||
|
||||
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||
let has_percentage = other.percentage.is_some();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
//! Gecko-specific style-system bits.
|
||||
|
||||
pub mod arc_types;
|
||||
pub mod conversions;
|
||||
pub mod data;
|
||||
pub mod media_queries;
|
||||
|
|
|
@ -232,17 +232,6 @@ impl AnimatedProperty {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
% if product == "gecko":
|
||||
use gecko_bindings::structs::RawServoAnimationValue;
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
|
||||
unsafe impl HasFFI for AnimationValue {
|
||||
type FFIType = RawServoAnimationValue;
|
||||
}
|
||||
unsafe impl HasArcFFI for AnimationValue {}
|
||||
% endif
|
||||
|
||||
/// An enum to represent a single computed value belonging to an animated
|
||||
/// property in order to be interpolated with another one. When interpolating,
|
||||
/// both values need to belong to the same property.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue