mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
style: Cleanup refcounted types.
And make the handling of ComputedStyle more similar to these. Differential Revision: https://phabricator.services.mozilla.com/D24703
This commit is contained in:
parent
02bc29a11b
commit
ecda72a5fd
4 changed files with 11 additions and 76 deletions
|
@ -18,8 +18,6 @@ use crate::gecko_bindings::structs::RawServoMediaRule;
|
|||
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
|
||||
use crate::gecko_bindings::structs::RawServoNamespaceRule;
|
||||
use crate::gecko_bindings::structs::RawServoPageRule;
|
||||
use crate::gecko_bindings::structs::RawServoRuleNode;
|
||||
use crate::gecko_bindings::structs::RawServoRuleNodeStrong;
|
||||
use crate::gecko_bindings::structs::RawServoSupportsRule;
|
||||
use crate::gecko_bindings::structs::ServoCssRules;
|
||||
use crate::gecko_bindings::structs::RawServoAnimationValue;
|
||||
|
@ -34,7 +32,6 @@ use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
|
|||
use crate::media_queries::MediaList;
|
||||
use crate::properties::animated_properties::AnimationValue;
|
||||
use crate::properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
use crate::rule_tree::StrongRuleNode;
|
||||
use crate::shared_lock::Locked;
|
||||
use crate::stylesheets::keyframes_rule::Keyframe;
|
||||
use crate::stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
|
||||
|
@ -121,31 +118,6 @@ impl_arc_ffi!(CssUrlData => RawServoCssUrlData
|
|||
impl_arc_ffi!(Box<[QuotePair]> => RawServoQuotes
|
||||
[Servo_Quotes_AddRef, Servo_Quotes_Release]);
|
||||
|
||||
// RuleNode is a Arc-like type but it does not use Arc.
|
||||
|
||||
impl StrongRuleNode {
|
||||
pub fn into_strong(self) -> RawServoRuleNodeStrong {
|
||||
let ptr = self.ptr();
|
||||
mem::forget(self);
|
||||
unsafe { mem::transmute(ptr) }
|
||||
}
|
||||
|
||||
pub fn from_ffi<'a>(ffi: &'a &RawServoRuleNode) -> &'a Self {
|
||||
unsafe { &*(ffi as *const &RawServoRuleNode as *const StrongRuleNode) }
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_RuleNode_AddRef(obj: &RawServoRuleNode) {
|
||||
mem::forget(StrongRuleNode::from_ffi(&obj).clone());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_RuleNode_Release(obj: &RawServoRuleNode) {
|
||||
let ptr = StrongRuleNode::from_ffi(&obj);
|
||||
ptr::read(ptr as *const StrongRuleNode);
|
||||
}
|
||||
|
||||
// ComputedStyle is not an opaque type on any side of FFI.
|
||||
// This means that doing the HasArcFFI type trick is actually unsound,
|
||||
// since it gives us a way to construct an Arc<ComputedStyle> from
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue