aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/servo_arc/lib.rs168
-rw-r--r--components/style/gecko/media_queries.rs4
-rw-r--r--components/style/properties/cascade.rs23
-rw-r--r--components/style/properties/gecko.mako.rs532
-rw-r--r--components/style/properties/longhands/font.mako.rs2
-rw-r--r--components/style/properties/properties.mako.rs57
-rw-r--r--components/style/values/specified/font.rs6
7 files changed, 320 insertions, 472 deletions
diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs
index 4184dc95282..cb75f359486 100644
--- a/components/servo_arc/lib.rs
+++ b/components/servo_arc/lib.rs
@@ -218,8 +218,6 @@ impl<T> Arc<T> {
/// Convert the Arc<T> to a raw pointer, suitable for use across FFI
///
/// Note: This returns a pointer to the data T, which is offset in the allocation.
- ///
- /// It is recommended to use RawOffsetArc for this.
#[inline]
pub fn into_raw(this: Self) -> *const T {
let ptr = unsafe { &((*this.ptr()).data) as *const _ };
@@ -286,26 +284,6 @@ impl<T> Arc<T> {
ArcBorrow(&**self)
}
- /// Temporarily converts |self| into a bonafide RawOffsetArc and exposes it to the
- /// provided callback. The refcount is not modified.
- #[inline(always)]
- pub fn with_raw_offset_arc<F, U>(&self, f: F) -> U
- where
- F: FnOnce(&RawOffsetArc<T>) -> U,
- {
- // Synthesize transient Arc, which never touches the refcount of the ArcInner.
- let transient = unsafe { NoDrop::new(Arc::into_raw_offset(ptr::read(self))) };
-
- // Expose the transient Arc to the callback, which may clone it if it wants.
- let result = f(&transient);
-
- // Forget the transient Arc to leave the refcount untouched.
- mem::forget(transient);
-
- // Forward the result.
- result
- }
-
/// Returns the address on the heap of the Arc itself -- not the T within it -- for memory
/// reporting.
///
@@ -1100,149 +1078,6 @@ impl<H: PartialEq, T: PartialEq> PartialEq for ThinArc<H, T> {
impl<H: Eq, T: Eq> Eq for ThinArc<H, T> {}
-/// An `Arc`, except it holds a pointer to the T instead of to the
-/// entire ArcInner. This struct is FFI-compatible.
-///
-/// ```text
-/// Arc<T> RawOffsetArc<T>
-/// | |
-/// v v
-/// ---------------------
-/// | RefCount | T (data) | [ArcInner<T>]
-/// ---------------------
-/// ```
-///
-/// This means that this is a direct pointer to
-/// its contained data (and can be read from by both C++ and Rust),
-/// but we can also convert it to a "regular" Arc<T> by removing the offset.
-///
-/// This is very useful if you have an Arc-containing struct shared between Rust and C++,
-/// and wish for C++ to be able to read the data behind the `Arc` without incurring
-/// an FFI call overhead.
-#[derive(Eq)]
-#[repr(C)]
-pub struct RawOffsetArc<T> {
- ptr: ptr::NonNull<T>,
-}
-
-unsafe impl<T: Sync + Send> Send for RawOffsetArc<T> {}
-unsafe impl<T: Sync + Send> Sync for RawOffsetArc<T> {}
-
-impl<T> Deref for RawOffsetArc<T> {
- type Target = T;
- fn deref(&self) -> &Self::Target {
- unsafe { &*self.ptr.as_ptr() }
- }
-}
-
-impl<T> Clone for RawOffsetArc<T> {
- #[inline]
- fn clone(&self) -> Self {
- Arc::into_raw_offset(self.clone_arc())
- }
-}
-
-impl<T> Drop for RawOffsetArc<T> {
- fn drop(&mut self) {
- let _ = Arc::from_raw_offset(RawOffsetArc { ptr: self.ptr });
- }
-}
-
-impl<T: fmt::Debug> fmt::Debug for RawOffsetArc<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Debug::fmt(&**self, f)
- }
-}
-
-impl<T: PartialEq> PartialEq for RawOffsetArc<T> {
- fn eq(&self, other: &RawOffsetArc<T>) -> bool {
- *(*self) == *(*other)
- }
-}
-
-impl<T> RawOffsetArc<T> {
- /// Temporarily converts |self| into a bonafide Arc and exposes it to the
- /// provided callback. The refcount is not modified.
- #[inline]
- pub fn with_arc<F, U>(&self, f: F) -> U
- where
- F: FnOnce(&Arc<T>) -> U,
- {
- // Synthesize transient Arc, which never touches the refcount of the ArcInner.
- let transient = unsafe { NoDrop::new(Arc::from_raw(self.ptr.as_ptr())) };
-
- // Expose the transient Arc to the callback, which may clone it if it wants.
- let result = f(&transient);
-
- // Forget the transient Arc to leave the refcount untouched.
- // XXXManishearth this can be removed when unions stabilize,
- // since then NoDrop becomes zero overhead
- mem::forget(transient);
-
- // Forward the result.
- result
- }
-
- /// If uniquely owned, provide a mutable reference
- /// Else create a copy, and mutate that
- ///
- /// This is functionally the same thing as `Arc::make_mut`
- #[inline]
- pub fn make_mut(&mut self) -> &mut T
- where
- T: Clone,
- {
- unsafe {
- // extract the RawOffsetArc as an owned variable
- let this = ptr::read(self);
- // treat it as a real Arc
- let mut arc = Arc::from_raw_offset(this);
- // obtain the mutable reference. Cast away the lifetime
- // This may mutate `arc`
- let ret = Arc::make_mut(&mut arc) as *mut _;
- // Store the possibly-mutated arc back inside, after converting
- // it to a RawOffsetArc again
- ptr::write(self, Arc::into_raw_offset(arc));
- &mut *ret
- }
- }
-
- /// Clone it as an `Arc`
- #[inline]
- pub fn clone_arc(&self) -> Arc<T> {
- RawOffsetArc::with_arc(self, |a| a.clone())
- }
-
- /// Produce a pointer to the data that can be converted back
- /// to an `Arc`
- #[inline]
- pub fn borrow_arc<'a>(&'a self) -> ArcBorrow<'a, T> {
- ArcBorrow(&**self)
- }
-}
-
-impl<T> Arc<T> {
- /// Converts an `Arc` into a `RawOffsetArc`. This consumes the `Arc`, so the refcount
- /// is not modified.
- #[inline]
- pub fn into_raw_offset(a: Self) -> RawOffsetArc<T> {
- unsafe {
- RawOffsetArc {
- ptr: ptr::NonNull::new_unchecked(Arc::into_raw(a) as *mut T),
- }
- }
- }
-
- /// Converts a `RawOffsetArc` into an `Arc`. This consumes the `RawOffsetArc`, so the refcount
- /// is not modified.
- #[inline]
- pub fn from_raw_offset(a: RawOffsetArc<T>) -> Self {
- let ptr = a.ptr.as_ptr();
- mem::forget(a);
- unsafe { Arc::from_raw(ptr) }
- }
-}
-
/// A "borrowed `Arc`". This is a pointer to
/// a T that is known to have been allocated within an
/// `Arc`.
@@ -1253,8 +1088,7 @@ impl<T> Arc<T> {
/// It's also a direct pointer to `T`, so using this involves less pointer-chasing
///
/// However, C++ code may hand us refcounted things as pointers to T directly,
-/// so we have to conjure up a temporary `Arc` on the stack each time. The
-/// same happens for when the object is managed by a `RawOffsetArc`.
+/// so we have to conjure up a temporary `Arc` on the stack each time.
///
/// `ArcBorrow` lets us deal with borrows of known-refcounted objects
/// without needing to worry about where the `Arc<T>` is.
diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs
index d937b67dfe1..f666c930e6e 100644
--- a/components/style/gecko/media_queries.rs
+++ b/components/style/gecko/media_queries.rs
@@ -131,7 +131,7 @@ impl Device {
line_height,
pres_context.map_or(std::ptr::null(), |pc| pc),
vertical,
- font.gecko(),
+ &**font,
element.map_or(std::ptr::null(), |e| e.0)
)
});
@@ -231,7 +231,7 @@ impl Device {
bindings::Gecko_GetFontMetrics(
pc,
vertical,
- font.gecko(),
+ &**font,
base_size,
// we don't use the user font set in a media query
!in_media_query,
diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs
index 689498a38b7..62247e7bbd2 100644
--- a/components/style/properties/cascade.rs
+++ b/components/style/properties/cascade.rs
@@ -900,7 +900,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let builder = &mut self.context.builder;
let default_font_type = {
- let font = builder.get_font().gecko();
+ let font = builder.get_font();
if !font.mFont.family.is_initial {
return;
@@ -922,9 +922,8 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
default_font_type
};
- let font = builder.mutate_font().gecko_mut();
// NOTE: Leaves is_initial untouched.
- font.mFont.family.families = FontFamily::generic(default_font_type).families.clone();
+ builder.mutate_font().mFont.family.families = FontFamily::generic(default_font_type).families.clone();
}
/// Prioritize user fonts if needed by pref.
@@ -943,7 +942,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let builder = &mut self.context.builder;
let default_font_type = {
- let font = builder.get_font().gecko();
+ let font = builder.get_font();
if font.mFont.family.is_system_font {
return;
@@ -961,7 +960,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
}
};
- let font = builder.mutate_font().gecko_mut();
+ let font = builder.mutate_font();
font.mFont.family.families.prioritize_first_generic_or_prepend(default_font_type);
}
@@ -986,7 +985,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
},
};
- if font.gecko().mScriptUnconstrainedSize == new_size.computed_size {
+ if font.mScriptUnconstrainedSize == new_size.computed_size {
return;
}
@@ -1013,9 +1012,9 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let builder = &mut self.context.builder;
let min_font_size = {
- let font = builder.get_font().gecko();
+ let font = builder.get_font();
let min_font_size = unsafe {
- bindings::Gecko_nsStyleFont_ComputeMinSize(font, builder.device.document())
+ bindings::Gecko_nsStyleFont_ComputeMinSize(&**font, builder.device.document())
};
if font.mFont.size.0 >= min_font_size {
@@ -1025,7 +1024,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
NonNegative(min_font_size)
};
- builder.mutate_font().gecko_mut().mFont.size = min_font_size;
+ builder.mutate_font().mFont.size = min_font_size;
}
/// <svg:text> is not affected by text zoom, and it uses a preshint to disable it. We fix up
@@ -1133,8 +1132,8 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let (new_size, new_unconstrained_size) = {
let builder = &self.context.builder;
- let font = builder.get_font().gecko();
- let parent_font = builder.get_parent_font().gecko();
+ let font = builder.get_font();
+ let parent_font = builder.get_parent_font();
let delta = font.mMathDepth.saturating_sub(parent_font.mMathDepth);
@@ -1195,7 +1194,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
)
}
};
- let font = self.context.builder.mutate_font().gecko_mut();
+ let font = self.context.builder.mutate_font();
font.mFont.size = NonNegative(new_size);
font.mSize = NonNegative(new_size);
font.mScriptUnconstrainedSize = NonNegative(new_unconstrained_size);
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 6391b357200..bd4ac91115d 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -16,7 +16,6 @@ use crate::computed_value_flags::*;
use crate::custom_properties::CustomPropertiesMap;
use crate::gecko_bindings::bindings;
% for style_struct in data.style_structs:
-use crate::gecko_bindings::structs::${style_struct.gecko_ffi_name};
use crate::gecko_bindings::bindings::Gecko_Construct_Default_${style_struct.gecko_ffi_name};
use crate::gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
use crate::gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
@@ -35,8 +34,8 @@ use crate::media_queries::Device;
use crate::properties::longhands;
use crate::rule_tree::StrongRuleNode;
use crate::selector_parser::PseudoElement;
-use servo_arc::{Arc, RawOffsetArc, UniqueArc};
-use std::mem::{forget, MaybeUninit};
+use servo_arc::{Arc, UniqueArc};
+use std::mem::{forget, MaybeUninit, ManuallyDrop};
use std::{cmp, ops, ptr};
use crate::values::{self, CustomIdent, KeyframesName};
use crate::values::computed::{BorderStyle, Percentage, Time, TransitionProperty};
@@ -51,7 +50,6 @@ pub mod style_structs {
unsafe impl Send for ${style_struct.name} {}
unsafe impl Sync for ${style_struct.name} {}
% endfor
-
}
/// FIXME(emilio): This is completely duplicated with the other properties code.
@@ -148,6 +146,8 @@ impl ComputedValues {
impl Drop for ComputedValues {
fn drop(&mut self) {
+ // XXX this still relies on the destructor of ComputedValuesInner to run on the rust side,
+ // that's pretty wild.
unsafe {
bindings::Gecko_ComputedStyle_Destroy(&mut self.0);
}
@@ -167,13 +167,29 @@ impl Clone for ComputedValuesInner {
fn clone(&self) -> Self {
ComputedValuesInner {
% for style_struct in data.style_structs:
- ${style_struct.gecko_name}: self.${style_struct.gecko_name}.clone(),
+ ${style_struct.gecko_name}: Arc::into_raw(unsafe { Arc::from_raw_addrefed(self.${style_struct.name_lower}_ptr()) }) as *const _,
% endfor
custom_properties: self.custom_properties.clone(),
writing_mode: self.writing_mode.clone(),
flags: self.flags.clone(),
rules: self.rules.clone(),
- visited_style: self.visited_style.clone(),
+ visited_style: if self.visited_style.is_null() {
+ ptr::null()
+ } else {
+ Arc::into_raw(unsafe { Arc::from_raw_addrefed(self.visited_style_ptr()) }) as *const _
+ },
+ }
+ }
+}
+
+
+impl Drop for ComputedValuesInner {
+ fn drop(&mut self) {
+ % for style_struct in data.style_structs:
+ let _ = unsafe { Arc::from_raw(self.${style_struct.name_lower}_ptr()) };
+ % endfor
+ if !self.visited_style.is_null() {
+ let _ = unsafe { Arc::from_raw(self.visited_style_ptr()) };
}
}
}
@@ -193,18 +209,15 @@ impl ComputedValuesInner {
custom_properties,
writing_mode,
rules,
- visited_style: visited_style.map(Arc::into_raw_offset),
+ visited_style: visited_style.map_or(ptr::null(), |p| Arc::into_raw(p)) as *const _,
flags,
% for style_struct in data.style_structs:
- ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
+ ${style_struct.gecko_name}: Arc::into_raw(${style_struct.ident}) as *const _,
% endfor
}
}
- fn to_outer(
- self,
- pseudo: Option<<&PseudoElement>,
- ) -> Arc<ComputedValues> {
+ fn to_outer(self, pseudo: Option<<&PseudoElement>) -> Arc<ComputedValues> {
let pseudo_ty = match pseudo {
Some(p) => p.pseudo_type(),
None => structs::PseudoStyleType::NotPseudo,
@@ -226,12 +239,14 @@ impl ComputedValuesInner {
impl ops::Deref for ComputedValues {
type Target = ComputedValuesInner;
+ #[inline]
fn deref(&self) -> &ComputedValuesInner {
&self.0.mSource
}
}
impl ops::DerefMut for ComputedValues {
+ #[inline]
fn deref_mut(&mut self) -> &mut ComputedValuesInner {
&mut self.0.mSource
}
@@ -245,44 +260,44 @@ impl ComputedValuesInner {
self.get_counters().ineffective_content_property()
}
+ #[inline]
+ fn visited_style_ptr(&self) -> *const ComputedValues {
+ self.visited_style as *const _
+ }
+
+ /// Returns the visited style, if any.
+ pub fn visited_style(&self) -> Option<<&ComputedValues> {
+ unsafe { self.visited_style_ptr().as_ref() }
+ }
+
% for style_struct in data.style_structs:
#[inline]
+ fn ${style_struct.name_lower}_ptr(&self) -> *const style_structs::${style_struct.name} {
+ // This is sound because the wrapper we create is repr(transparent).
+ self.${style_struct.gecko_name} as *const _
+ }
+
+ #[inline]
pub fn clone_${style_struct.name_lower}(&self) -> Arc<style_structs::${style_struct.name}> {
- Arc::from_raw_offset(self.${style_struct.gecko_name}.clone())
+ unsafe { Arc::from_raw_addrefed(self.${style_struct.name_lower}_ptr()) }
}
#[inline]
pub fn get_${style_struct.name_lower}(&self) -> &style_structs::${style_struct.name} {
- &self.${style_struct.gecko_name}
- }
-
-
- pub fn ${style_struct.name_lower}_arc(&self) -> &RawOffsetArc<style_structs::${style_struct.name}> {
- &self.${style_struct.gecko_name}
+ unsafe { &*self.${style_struct.name_lower}_ptr() }
}
#[inline]
pub fn mutate_${style_struct.name_lower}(&mut self) -> &mut style_structs::${style_struct.name} {
- RawOffsetArc::make_mut(&mut self.${style_struct.gecko_name})
+ unsafe {
+ let mut arc = Arc::from_raw(self.${style_struct.name_lower}_ptr());
+ let ptr = Arc::make_mut(&mut arc) as *mut _;
+ // Sound for the same reason _ptr() is sound.
+ self.${style_struct.gecko_name} = Arc::into_raw(arc) as *const _;
+ &mut *ptr
+ }
}
% endfor
-
- /// Gets the raw visited style. Useful for memory reporting.
- pub fn get_raw_visited_style(&self) -> &Option<RawOffsetArc<ComputedValues>> {
- &self.visited_style
- }
-}
-
-<%def name="declare_style_struct(style_struct)">
-pub use crate::gecko_bindings::structs::mozilla::Gecko${style_struct.gecko_name} as ${style_struct.gecko_struct_name};
-impl ${style_struct.gecko_struct_name} {
- pub fn gecko(&self) -> &${style_struct.gecko_ffi_name} {
- &self.gecko
- }
- pub fn gecko_mut(&mut self) -> &mut ${style_struct.gecko_ffi_name} {
- &mut self.gecko
- }
}
-</%def>
<%def name="impl_simple_setter(ident, gecko_ffi_name)">
#[allow(non_snake_case)]
@@ -294,14 +309,14 @@ impl ${style_struct.gecko_struct_name} {
<%def name="impl_simple_clone(ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
- From::from(self.gecko.${gecko_ffi_name}.clone())
+ From::from(self.${gecko_ffi_name}.clone())
}
</%def>
<%def name="impl_simple_copy(ident, gecko_ffi_name, *kwargs)">
#[allow(non_snake_case)]
pub fn copy_${ident}_from(&mut self, other: &Self) {
- self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name}.clone();
+ self.${gecko_ffi_name} = other.${gecko_ffi_name}.clone();
}
#[allow(non_snake_case)]
@@ -312,10 +327,10 @@ impl ${style_struct.gecko_struct_name} {
<%!
def get_gecko_property(ffi_name, self_param = "self"):
- return "%s.gecko.%s" % (self_param, ffi_name)
+ return "%s.%s" % (self_param, ffi_name)
def set_gecko_property(ffi_name, expr):
- return "self.gecko.%s = %s;" % (ffi_name, expr)
+ return "self.%s = %s;" % (ffi_name, expr)
%>
<%def name="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type='u8')">
@@ -389,7 +404,7 @@ def set_gecko_property(ffi_name, expr):
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
let value = {
% if round_to_pixels:
- let au_per_device_px = Au(self.gecko.mTwipsPerPixel);
+ let au_per_device_px = Au(self.mTwipsPerPixel);
round_border_to_device_pixels(Au::from(v), au_per_device_px).0
% else:
v.0.to_i32_au()
@@ -397,15 +412,15 @@ def set_gecko_property(ffi_name, expr):
};
% if inherit_from:
- self.gecko.${inherit_from} = value;
+ self.${inherit_from} = value;
% endif
- self.gecko.${gecko_ffi_name} = value;
+ self.${gecko_ffi_name} = value;
}
#[allow(non_snake_case)]
pub fn copy_${ident}_from(&mut self, other: &Self) {
% if inherit_from:
- self.gecko.${inherit_from} = other.gecko.${inherit_from};
+ self.${inherit_from} = other.${inherit_from};
// NOTE: This is needed to easily handle the `unset` and `initial`
// keywords, which are implemented calling this function.
//
@@ -414,9 +429,9 @@ def set_gecko_property(ffi_name, expr):
//
// FIXME(emilio): We could clean this up a bit special-casing the reset_
// function below.
- self.gecko.${gecko_ffi_name} = other.gecko.${inherit_from};
+ self.${gecko_ffi_name} = other.${inherit_from};
% else:
- self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name};
+ self.${gecko_ffi_name} = other.${gecko_ffi_name};
% endif
}
@@ -427,19 +442,19 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
- Au(self.gecko.${gecko_ffi_name}).into()
+ Au(self.${gecko_ffi_name}).into()
}
</%def>
<%def name="impl_split_style_coord(ident, gecko_ffi_name, index)">
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
- self.gecko.${gecko_ffi_name}.${index} = v;
+ self.${gecko_ffi_name}.${index} = v;
}
#[allow(non_snake_case)]
pub fn copy_${ident}_from(&mut self, other: &Self) {
- self.gecko.${gecko_ffi_name}.${index} =
- other.gecko.${gecko_ffi_name}.${index}.clone();
+ self.${gecko_ffi_name}.${index} =
+ other.${gecko_ffi_name}.${index}.clone();
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
@@ -448,7 +463,7 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
- self.gecko.${gecko_ffi_name}.${index}.clone()
+ self.${gecko_ffi_name}.${index}.clone()
}
</%def>
@@ -457,8 +472,8 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn copy_${ident}_from(&mut self, other: &Self) {
% for side in SIDES:
- self.gecko.${gecko_ffi_name}.data_at_mut(${side.index})
- .copy_from(&other.gecko.${gecko_ffi_name}.data_at(${side.index}));
+ self.${gecko_ffi_name}.data_at_mut(${side.index})
+ .copy_from(&other.${gecko_ffi_name}.data_at(${side.index}));
% endfor
${ caller.body() }
}
@@ -472,12 +487,12 @@ def set_gecko_property(ffi_name, expr):
<%def name="impl_corner_style_coord(ident, gecko_ffi_name, corner)">
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
- self.gecko.${gecko_ffi_name}.${corner} = v;
+ self.${gecko_ffi_name}.${corner} = v;
}
#[allow(non_snake_case)]
pub fn copy_${ident}_from(&mut self, other: &Self) {
- self.gecko.${gecko_ffi_name}.${corner} =
- other.gecko.${gecko_ffi_name}.${corner}.clone();
+ self.${gecko_ffi_name}.${corner} =
+ other.${gecko_ffi_name}.${corner}.clone();
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
@@ -485,7 +500,7 @@ def set_gecko_property(ffi_name, expr):
}
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
- self.gecko.${gecko_ffi_name}.${corner}.clone()
+ self.${gecko_ffi_name}.${corner}.clone()
}
</%def>
@@ -494,6 +509,26 @@ def set_gecko_property(ffi_name, expr):
</%def>
<%def name="impl_style_struct(style_struct)">
+/// A wrapper for ${style_struct.gecko_ffi_name}, to be able to manually construct / destruct /
+/// clone it.
+#[repr(transparent)]
+pub struct ${style_struct.gecko_struct_name}(ManuallyDrop<structs::${style_struct.gecko_ffi_name}>);
+
+impl ops::Deref for ${style_struct.gecko_struct_name} {
+ type Target = structs::${style_struct.gecko_ffi_name};
+ #[inline]
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl ops::DerefMut for ${style_struct.gecko_struct_name} {
+ #[inline]
+ fn deref_mut(&mut self) -> &mut <Self as ops::Deref>::Target {
+ &mut self.0
+ }
+}
+
impl ${style_struct.gecko_struct_name} {
#[allow(dead_code, unused_variables)]
pub fn default(document: &structs::Document) -> Arc<Self> {
@@ -510,10 +545,11 @@ impl ${style_struct.gecko_struct_name} {
}
}
}
+
impl Drop for ${style_struct.gecko_struct_name} {
fn drop(&mut self) {
unsafe {
- Gecko_Destroy_${style_struct.gecko_ffi_name}(&mut *self.gecko);
+ Gecko_Destroy_${style_struct.gecko_ffi_name}(&mut **self);
}
}
}
@@ -524,25 +560,24 @@ impl Clone for ${style_struct.gecko_struct_name} {
// FIXME(bug 1595895): Zero the memory to keep valgrind happy, but
// these looks like Valgrind false-positives at a quick glance.
ptr::write_bytes::<Self>(result.as_mut_ptr(), 0, 1);
- Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(result.as_mut_ptr() as *mut _, &*self.gecko);
+ Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(result.as_mut_ptr() as *mut _, &**self);
result.assume_init()
}
}
}
-
</%def>
<%def name="impl_simple_type_with_conversion(ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
- self.gecko.${gecko_ffi_name} = From::from(v)
+ self.${gecko_ffi_name} = From::from(v)
}
<% impl_simple_copy(ident, gecko_ffi_name) %>
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
- From::from(self.gecko.${gecko_ffi_name})
+ From::from(self.${gecko_ffi_name})
}
</%def>
@@ -556,12 +591,12 @@ impl Clone for ${style_struct.gecko_struct_name} {
mTag: other.tag.0,
mValue: other.value as ${gecko_value_type},
});
- self.gecko.mFont.${gecko_ffi_name}.assign_from_iter_pod(iter);
+ self.mFont.${gecko_ffi_name}.assign_from_iter_pod(iter);
}
pub fn copy_${ident}_from(&mut self, other: &Self) {
- let iter = other.gecko.mFont.${gecko_ffi_name}.iter().map(|s| *s);
- self.gecko.mFont.${gecko_ffi_name}.assign_from_iter_pod(iter);
+ let iter = other.mFont.${gecko_ffi_name}.iter().map(|s| *s);
+ self.mFont.${gecko_ffi_name}.assign_from_iter_pod(iter);
}
pub fn reset_${ident}(&mut self, other: &Self) {
@@ -572,7 +607,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
use crate::values::generics::font::{FontSettings, FontTag, ${tag_type}};
FontSettings(
- self.gecko.mFont.${gecko_ffi_name}.iter().map(|gecko_font_setting| {
+ self.mFont.${gecko_ffi_name}.iter().map(|gecko_font_setting| {
${tag_type} {
tag: FontTag(gecko_font_setting.mTag),
value: gecko_font_setting.mValue as ${value_type},
@@ -651,7 +686,7 @@ fn static_assert() {
skip_longhands="${skip_border_longhands} border-image-repeat">
% for side in SIDES:
pub fn set_border_${side.ident}_style(&mut self, v: BorderStyle) {
- self.gecko.mBorderStyle[${side.index}] = v;
+ self.mBorderStyle[${side.index}] = v;
// This is needed because the initial mComputedBorder value is set to
// zero.
@@ -682,11 +717,11 @@ fn static_assert() {
// Once we're here, we know that we'll run style fixups, so it's fine to
// just copy the specified border here, we'll adjust it if it's
// incorrect later.
- self.gecko.mComputedBorder.${side.ident} = self.gecko.mBorder.${side.ident};
+ self.mComputedBorder.${side.ident} = self.mBorder.${side.ident};
}
pub fn copy_border_${side.ident}_style_from(&mut self, other: &Self) {
- self.set_border_${side.ident}_style(other.gecko.mBorderStyle[${side.index}]);
+ self.set_border_${side.ident}_style(other.mBorderStyle[${side.index}]);
}
pub fn reset_border_${side.ident}_style(&mut self, other: &Self) {
@@ -695,7 +730,7 @@ fn static_assert() {
#[inline]
pub fn clone_border_${side.ident}_style(&self) -> BorderStyle {
- self.gecko.mBorderStyle[${side.index}]
+ self.mBorderStyle[${side.index}]
}
<% impl_simple("border_%s_color" % side.ident, "mBorder%sColor" % side.name) %>
@@ -706,7 +741,7 @@ fn static_assert() {
round_to_pixels=True) %>
pub fn border_${side.ident}_has_nonzero_width(&self) -> bool {
- self.gecko.mComputedBorder.${side.ident} != 0
+ self.mComputedBorder.${side.ident} != 0
}
% endfor
@@ -725,7 +760,7 @@ fn static_assert() {
use crate::gecko_bindings::structs::StyleBorderImageRepeat;
% for i, side in enumerate(["H", "V"]):
- self.gecko.mBorderImageRepeat${side} = match v.${i} {
+ self.mBorderImageRepeat${side} = match v.${i} {
% for keyword in border_image_repeat_keywords:
BorderImageRepeatKeyword::${keyword} => StyleBorderImageRepeat::${keyword},
% endfor
@@ -734,8 +769,8 @@ fn static_assert() {
}
pub fn copy_border_image_repeat_from(&mut self, other: &Self) {
- self.gecko.mBorderImageRepeatH = other.gecko.mBorderImageRepeatH;
- self.gecko.mBorderImageRepeatV = other.gecko.mBorderImageRepeatV;
+ self.mBorderImageRepeatH = other.mBorderImageRepeatH;
+ self.mBorderImageRepeatV = other.mBorderImageRepeatV;
}
pub fn reset_border_image_repeat(&mut self, other: &Self) {
@@ -747,7 +782,7 @@ fn static_assert() {
use crate::gecko_bindings::structs::StyleBorderImageRepeat;
% for side in ["H", "V"]:
- let servo_${side.lower()} = match self.gecko.mBorderImageRepeat${side} {
+ let servo_${side.lower()} = match self.mBorderImageRepeat${side} {
% for keyword in border_image_repeat_keywords:
StyleBorderImageRepeat::${keyword} => BorderImageRepeatKeyword::${keyword},
% endfor
@@ -798,7 +833,7 @@ fn static_assert() {
% endfor
pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) {
debug_assert_ne!(v.0, crate::values::specified::align::AlignFlags::LEGACY);
- self.gecko.mJustifyItems.computed = v;
+ self.mJustifyItems.computed = v;
}
${impl_simple_type_with_conversion("masonry_auto_flow", "mMasonryAutoFlow")}
@@ -808,15 +843,15 @@ fn static_assert() {
skip_longhands="outline-style outline-width">
pub fn set_outline_style(&mut self, v: longhands::outline_style::computed_value::T) {
- self.gecko.mOutlineStyle = v;
+ self.mOutlineStyle = v;
// NB: This is needed to correctly handling the initial value of
// outline-width when outline-style changes, see the
// update_border_${side.ident} comment for more details.
- self.gecko.mActualOutlineWidth = self.gecko.mOutlineWidth;
+ self.mActualOutlineWidth = self.mOutlineWidth;
}
pub fn copy_outline_style_from(&mut self, other: &Self) {
- self.set_outline_style(other.gecko.mOutlineStyle);
+ self.set_outline_style(other.mOutlineStyle);
}
pub fn reset_outline_style(&mut self, other: &Self) {
@@ -824,7 +859,7 @@ fn static_assert() {
}
pub fn clone_outline_style(&self) -> longhands::outline_style::computed_value::T {
- self.gecko.mOutlineStyle.clone()
+ self.mOutlineStyle.clone()
}
<% impl_non_negative_length("outline_width", "mActualOutlineWidth",
@@ -832,7 +867,7 @@ fn static_assert() {
round_to_pixels=True) %>
pub fn outline_has_nonzero_width(&self) -> bool {
- self.gecko.mActualOutlineWidth != 0
+ self.mActualOutlineWidth != 0
}
</%self:impl_trait>
@@ -852,23 +887,23 @@ fn static_assert() {
pub fn unzoom_fonts(&mut self, device: &Device) {
use crate::values::generics::NonNegative;
- self.gecko.mSize = NonNegative(device.unzoom_text(self.gecko.mSize.0));
- self.gecko.mScriptUnconstrainedSize = NonNegative(device.unzoom_text(self.gecko.mScriptUnconstrainedSize.0));
- self.gecko.mFont.size = NonNegative(device.unzoom_text(self.gecko.mFont.size.0));
+ self.mSize = NonNegative(device.unzoom_text(self.mSize.0));
+ self.mScriptUnconstrainedSize = NonNegative(device.unzoom_text(self.mScriptUnconstrainedSize.0));
+ self.mFont.size = NonNegative(device.unzoom_text(self.mFont.size.0));
}
pub fn copy_font_size_from(&mut self, other: &Self) {
- self.gecko.mScriptUnconstrainedSize = other.gecko.mScriptUnconstrainedSize;
+ self.mScriptUnconstrainedSize = other.mScriptUnconstrainedSize;
- self.gecko.mSize = other.gecko.mScriptUnconstrainedSize;
+ self.mSize = other.mScriptUnconstrainedSize;
// NOTE: Intentionally not copying from mFont.size. The cascade process
// recomputes the used size as needed.
- self.gecko.mFont.size = other.gecko.mSize;
- self.gecko.mFontSizeKeyword = other.gecko.mFontSizeKeyword;
+ self.mFont.size = other.mSize;
+ self.mFontSizeKeyword = other.mFontSizeKeyword;
// TODO(emilio): Should we really copy over these two?
- self.gecko.mFontSizeFactor = other.gecko.mFontSizeFactor;
- self.gecko.mFontSizeOffset = other.gecko.mFontSizeOffset;
+ self.mFontSizeFactor = other.mFontSizeFactor;
+ self.mFontSizeOffset = other.mFontSizeOffset;
}
pub fn reset_font_size(&mut self, other: &Self) {
@@ -877,29 +912,29 @@ fn static_assert() {
pub fn set_font_size(&mut self, v: FontSize) {
let computed_size = v.computed_size;
- self.gecko.mScriptUnconstrainedSize = computed_size;
+ self.mScriptUnconstrainedSize = computed_size;
// These two may be changed from Cascade::fixup_font_stuff.
- self.gecko.mSize = computed_size;
+ self.mSize = computed_size;
// NOTE: Intentionally not copying from used_size. The cascade process
// recomputes the used size as needed.
- self.gecko.mFont.size = computed_size;
+ self.mFont.size = computed_size;
- self.gecko.mFontSizeKeyword = v.keyword_info.kw;
- self.gecko.mFontSizeFactor = v.keyword_info.factor;
- self.gecko.mFontSizeOffset = v.keyword_info.offset;
+ self.mFontSizeKeyword = v.keyword_info.kw;
+ self.mFontSizeFactor = v.keyword_info.factor;
+ self.mFontSizeOffset = v.keyword_info.offset;
}
pub fn clone_font_size(&self) -> FontSize {
use crate::values::specified::font::KeywordInfo;
FontSize {
- computed_size: self.gecko.mSize,
- used_size: self.gecko.mFont.size,
+ computed_size: self.mSize,
+ used_size: self.mFont.size,
keyword_info: KeywordInfo {
- kw: self.gecko.mFontSizeKeyword,
- factor: self.gecko.mFontSizeFactor,
- offset: self.gecko.mFontSizeOffset,
+ kw: self.mFontSizeKeyword,
+ factor: self.mFontSizeFactor,
+ offset: self.mFontSizeOffset,
}
}
}
@@ -919,14 +954,14 @@ fn static_assert() {
let ptr = v.0.as_ptr();
forget(v);
unsafe {
- Gecko_nsStyleFont_SetLang(&mut *self.gecko, ptr);
+ Gecko_nsStyleFont_SetLang(&mut **self, ptr);
}
}
#[allow(non_snake_case)]
pub fn copy__x_lang_from(&mut self, other: &Self) {
unsafe {
- Gecko_nsStyleFont_CopyLangFrom(&mut *self.gecko, &*other.gecko);
+ Gecko_nsStyleFont_CopyLangFrom(&mut **self, &**other);
}
}
@@ -938,7 +973,7 @@ fn static_assert() {
#[allow(non_snake_case)]
pub fn clone__x_lang(&self) -> longhands::_x_lang::computed_value::T {
longhands::_x_lang::computed_value::T(unsafe {
- Atom::from_raw(self.gecko.mLanguage.mRawPtr)
+ Atom::from_raw(self.mLanguage.mRawPtr)
})
}
@@ -952,7 +987,7 @@ fn static_assert() {
pub fn clone__moz_min_font_size_ratio(
&self,
) -> longhands::_moz_min_font_size_ratio::computed_value::T {
- Percentage(self.gecko.mMinFontSizeRatio as f32 / 100.)
+ Percentage(self.mMinFontSizeRatio as f32 / 100.)
}
#[allow(non_snake_case)]
@@ -966,7 +1001,7 @@ fn static_assert() {
scaled
};
- self.gecko.mMinFontSizeRatio = percentage as u8;
+ self.mMinFontSizeRatio = percentage as u8;
}
${impl_simple_copy('_moz_min_font_size_ratio', 'mMinFontSizeRatio')}
@@ -975,13 +1010,13 @@ fn static_assert() {
<%def name="impl_coordinated_property_copy(type, ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn copy_${type}_${ident}_from(&mut self, other: &Self) {
- self.gecko.m${to_camel_case(type)}s.ensure_len(other.gecko.m${to_camel_case(type)}s.len());
+ self.m${to_camel_case(type)}s.ensure_len(other.m${to_camel_case(type)}s.len());
- let count = other.gecko.m${to_camel_case(type)}${gecko_ffi_name}Count;
- self.gecko.m${to_camel_case(type)}${gecko_ffi_name}Count = count;
+ let count = other.m${to_camel_case(type)}${gecko_ffi_name}Count;
+ self.m${to_camel_case(type)}${gecko_ffi_name}Count = count;
- let iter = self.gecko.m${to_camel_case(type)}s.iter_mut().take(count as usize).zip(
- other.gecko.m${to_camel_case(type)}s.iter()
+ let iter = self.m${to_camel_case(type)}s.iter_mut().take(count as usize).zip(
+ other.m${to_camel_case(type)}s.iter()
);
for (ours, others) in iter {
@@ -997,7 +1032,7 @@ fn static_assert() {
<%def name="impl_coordinated_property_count(type, ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn ${type}_${ident}_count(&self) -> usize {
- self.gecko.m${to_camel_case(type)}${gecko_ffi_name}Count as usize
+ self.m${to_camel_case(type)}${gecko_ffi_name}Count as usize
}
</%def>
@@ -1011,17 +1046,17 @@ fn static_assert() {
let v = v.into_iter();
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
- self.gecko.m${to_camel_case(type)}s.ensure_len(input_len);
+ self.m${to_camel_case(type)}s.ensure_len(input_len);
- self.gecko.m${to_camel_case(type)}${gecko_ffi_name}Count = input_len as u32;
- for (gecko, servo) in self.gecko.m${to_camel_case(type)}s.iter_mut().take(input_len as usize).zip(v) {
+ self.m${to_camel_case(type)}${gecko_ffi_name}Count = input_len as u32;
+ for (gecko, servo) in self.m${to_camel_case(type)}s.iter_mut().take(input_len as usize).zip(v) {
gecko.m${gecko_ffi_name} = servo;
}
}
#[allow(non_snake_case)]
pub fn ${type}_${ident}_at(&self, index: usize)
-> longhands::${type}_${ident}::computed_value::SingleComputedValue {
- self.gecko.m${to_camel_case(type)}s[index % self.${type}_${ident}_count()].m${gecko_ffi_name}.clone()
+ self.m${to_camel_case(type)}s[index % self.${type}_${ident}_count()].m${gecko_ffi_name}.clone()
}
${impl_coordinated_property_copy(type, ident, gecko_ffi_name)}
${impl_coordinated_property_count(type, ident, gecko_ffi_name)}
@@ -1040,11 +1075,11 @@ fn static_assert() {
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
- self.gecko.mAnimations.ensure_len(input_len);
+ self.mAnimations.ensure_len(input_len);
- self.gecko.mAnimation${gecko_ffi_name}Count = input_len as u32;
+ self.mAnimation${gecko_ffi_name}Count = input_len as u32;
- for (gecko, servo) in self.gecko.mAnimations.iter_mut().take(input_len as usize).zip(v) {
+ for (gecko, servo) in self.mAnimations.iter_mut().take(input_len as usize).zip(v) {
let result = match servo {
% for value in keyword.values_for("gecko"):
Keyword::${to_camel_case(value)} =>
@@ -1058,7 +1093,7 @@ fn static_assert() {
pub fn animation_${ident}_at(&self, index: usize)
-> longhands::animation_${ident}::computed_value::SingleComputedValue {
use crate::properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword;
- match self.gecko.mAnimations[index].m${gecko_ffi_name} ${keyword.maybe_cast("u32")} {
+ match self.mAnimations[index].m${gecko_ffi_name} ${keyword.maybe_cast("u32")} {
% for value in keyword.values_for("gecko"):
structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
% endfor
@@ -1075,13 +1110,13 @@ fn static_assert() {
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
#[inline]
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
- self.gecko.mDisplay = v;
- self.gecko.mOriginalDisplay = v;
+ self.mDisplay = v;
+ self.mOriginalDisplay = v;
}
#[inline]
pub fn copy_display_from(&mut self, other: &Self) {
- self.set_display(other.gecko.mDisplay);
+ self.set_display(other.mDisplay);
}
#[inline]
@@ -1095,23 +1130,23 @@ fn static_assert() {
v: longhands::display::computed_value::T,
_is_item_or_root: bool
) {
- self.gecko.mDisplay = v;
+ self.mDisplay = v;
}
#[inline]
pub fn clone_display(&self) -> longhands::display::computed_value::T {
- self.gecko.mDisplay
+ self.mDisplay
}
#[inline]
pub fn set_contain(&mut self, v: longhands::contain::computed_value::T) {
- self.gecko.mContain = v;
- self.gecko.mEffectiveContainment = v;
+ self.mContain = v;
+ self.mEffectiveContainment = v;
}
#[inline]
pub fn copy_contain_from(&mut self, other: &Self) {
- self.set_contain(other.gecko.mContain);
+ self.set_contain(other.mContain);
}
#[inline]
@@ -1121,7 +1156,7 @@ fn static_assert() {
#[inline]
pub fn clone_contain(&self) -> longhands::contain::computed_value::T {
- self.gecko.mContain
+ self.mContain
}
#[inline]
@@ -1129,12 +1164,12 @@ fn static_assert() {
&mut self,
v: longhands::contain::computed_value::T
) {
- self.gecko.mEffectiveContainment = v;
+ self.mEffectiveContainment = v;
}
#[inline]
pub fn clone_effective_containment(&self) -> longhands::contain::computed_value::T {
- self.gecko.mEffectiveContainment
+ self.mEffectiveContainment
}
</%self:impl_trait>
@@ -1152,12 +1187,12 @@ fn static_assert() {
let v = v.into_iter();
unsafe {
- Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field}, v.len(),
+ Gecko_EnsureImageLayersLength(&mut self.${image_layers_field}, v.len(),
LayerType::${shorthand.title()});
}
- self.gecko.${image_layers_field}.${field_name}Count = v.len() as u32;
- for (servo, geckolayer) in v.zip(self.gecko.${image_layers_field}.mLayers.iter_mut()) {
+ self.${image_layers_field}.${field_name}Count = v.len() as u32;
+ for (servo, geckolayer) in v.zip(self.${image_layers_field}.mLayers.iter_mut()) {
geckolayer.${field_name} = {
${caller.body()}
};
@@ -1169,19 +1204,19 @@ fn static_assert() {
pub fn copy_${shorthand}_${name}_from(&mut self, other: &Self) {
use crate::gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
- let count = other.gecko.${layers_field_name}.${field_name}Count;
+ let count = other.${layers_field_name}.${field_name}Count;
unsafe {
- Gecko_EnsureImageLayersLength(&mut self.gecko.${layers_field_name},
+ Gecko_EnsureImageLayersLength(&mut self.${layers_field_name},
count as usize,
LayerType::${shorthand.title()});
}
// FIXME(emilio): This may be bogus in the same way as bug 1426246.
- for (layer, other) in self.gecko.${layers_field_name}.mLayers.iter_mut()
- .zip(other.gecko.${layers_field_name}.mLayers.iter())
+ for (layer, other) in self.${layers_field_name}.mLayers.iter_mut()
+ .zip(other.${layers_field_name}.mLayers.iter())
.take(count as usize) {
layer.${field_name} = other.${field_name}.clone();
}
- self.gecko.${layers_field_name}.${field_name}Count = count;
+ self.${layers_field_name}.${field_name}Count = count;
}
pub fn reset_${shorthand}_${name}(&mut self, other: &Self) {
@@ -1210,12 +1245,12 @@ fn static_assert() {
let v = v.into_iter();
unsafe {
- Gecko_EnsureImageLayersLength(&mut self.gecko.${layer_field_name}, v.len(),
+ Gecko_EnsureImageLayersLength(&mut self.${layer_field_name}, v.len(),
LayerType::${shorthand.title()});
}
- self.gecko.${layer_field_name}.${field_name}Count = v.len() as u32;
- for (servo, geckolayer) in v.zip(self.gecko.${layer_field_name}.mLayers.iter_mut()) {
+ self.${layer_field_name}.${field_name}Count = v.len() as u32;
+ for (servo, geckolayer) in v.zip(self.${layer_field_name}.mLayers.iter_mut()) {
geckolayer.${field_name} = {
match servo {
% for value in keyword.values_for("gecko"):
@@ -1238,8 +1273,8 @@ fn static_assert() {
% endif
longhands::${ident}::computed_value::List(
- self.gecko.${layer_field_name}.mLayers.iter()
- .take(self.gecko.${layer_field_name}.${field_name}Count as usize)
+ self.${layer_field_name}.mLayers.iter()
+ .take(self.${layer_field_name}.${field_name}Count as usize)
.map(|ref layer| {
match layer.${field_name} {
% for value in longhand.keyword.values_for("gecko"):
@@ -1307,8 +1342,8 @@ fn static_assert() {
}
longhands::${shorthand}_repeat::computed_value::List(
- self.gecko.${image_layers_field}.mLayers.iter()
- .take(self.gecko.${image_layers_field}.mRepeatCount as usize)
+ self.${image_layers_field}.mLayers.iter()
+ .take(self.${image_layers_field}.mRepeatCount as usize)
.map(|ref layer| {
T(to_servo(layer.mRepeat.mXRepeat), to_servo(layer.mRepeat.mYRepeat))
}).collect()
@@ -1322,20 +1357,20 @@ fn static_assert() {
pub fn copy_${shorthand}_position_${orientation}_from(&mut self, other: &Self) {
use crate::gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
- let count = other.gecko.${image_layers_field}.mPosition${orientation.upper()}Count;
+ let count = other.${image_layers_field}.mPosition${orientation.upper()}Count;
unsafe {
- Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
+ Gecko_EnsureImageLayersLength(&mut self.${image_layers_field},
count as usize,
LayerType::${shorthand.capitalize()});
}
- for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
- .zip(other.gecko.${image_layers_field}.mLayers.iter())
+ for (layer, other) in self.${image_layers_field}.mLayers.iter_mut()
+ .zip(other.${image_layers_field}.mLayers.iter())
.take(count as usize) {
layer.mPosition.${keyword} = other.mPosition.${keyword}.clone();
}
- self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count = count;
+ self.${image_layers_field}.mPosition${orientation.upper()}Count = count;
}
pub fn reset_${shorthand}_position_${orientation}(&mut self, other: &Self) {
@@ -1345,8 +1380,8 @@ fn static_assert() {
pub fn clone_${shorthand}_position_${orientation}(&self)
-> longhands::${shorthand}_position_${orientation}::computed_value::T {
longhands::${shorthand}_position_${orientation}::computed_value::List(
- self.gecko.${image_layers_field}.mLayers.iter()
- .take(self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count as usize)
+ self.${image_layers_field}.mLayers.iter()
+ .take(self.${image_layers_field}.mPosition${orientation.upper()}Count as usize)
.map(|position| position.mPosition.${keyword}.clone())
.collect()
)
@@ -1363,12 +1398,12 @@ fn static_assert() {
let v = v.into_iter();
unsafe {
- Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field}, v.len(),
+ Gecko_EnsureImageLayersLength(&mut self.${image_layers_field}, v.len(),
LayerType::${shorthand.capitalize()});
}
- self.gecko.${image_layers_field}.mPosition${orientation[0].upper()}Count = v.len() as u32;
- for (servo, geckolayer) in v.zip(self.gecko.${image_layers_field}
+ self.${image_layers_field}.mPosition${orientation[0].upper()}Count = v.len() as u32;
+ for (servo, geckolayer) in v.zip(self.${image_layers_field}
.mLayers.iter_mut()) {
geckolayer.mPosition.${keyword} = servo;
}
@@ -1381,24 +1416,24 @@ fn static_assert() {
pub fn clone_${shorthand}_size(&self) -> longhands::${shorthand}_size::computed_value::T {
longhands::${shorthand}_size::computed_value::List(
- self.gecko.${image_layers_field}.mLayers.iter().map(|layer| layer.mSize.clone()).collect()
+ self.${image_layers_field}.mLayers.iter().map(|layer| layer.mSize.clone()).collect()
)
}
pub fn copy_${shorthand}_image_from(&mut self, other: &Self) {
use crate::gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
unsafe {
- let count = other.gecko.${image_layers_field}.mImageCount;
- Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
+ let count = other.${image_layers_field}.mImageCount;
+ Gecko_EnsureImageLayersLength(&mut self.${image_layers_field},
count as usize,
LayerType::${shorthand.capitalize()});
- for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
- .zip(other.gecko.${image_layers_field}.mLayers.iter())
+ for (layer, other) in self.${image_layers_field}.mLayers.iter_mut()
+ .zip(other.${image_layers_field}.mLayers.iter())
.take(count as usize) {
layer.mImage = other.mImage.clone();
}
- self.gecko.${image_layers_field}.mImageCount = count;
+ self.${image_layers_field}.mImageCount = count;
}
}
@@ -1417,14 +1452,14 @@ fn static_assert() {
unsafe {
Gecko_EnsureImageLayersLength(
- &mut self.gecko.${image_layers_field},
+ &mut self.${image_layers_field},
images.len(),
LayerType::${shorthand.title()},
);
}
- self.gecko.${image_layers_field}.mImageCount = images.len() as u32;
- for (image, geckoimage) in images.zip(self.gecko.${image_layers_field}
+ self.${image_layers_field}.mImageCount = images.len() as u32;
+ for (image, geckoimage) in images.zip(self.${image_layers_field}
.mLayers.iter_mut()) {
geckoimage.mImage = image;
}
@@ -1432,8 +1467,8 @@ fn static_assert() {
pub fn clone_${shorthand}_image(&self) -> longhands::${shorthand}_image::computed_value::T {
longhands::${shorthand}_image::computed_value::List(
- self.gecko.${image_layers_field}.mLayers.iter()
- .take(self.gecko.${image_layers_field}.mImageCount as usize)
+ self.${image_layers_field}.mLayers.iter()
+ .take(self.${image_layers_field}.mImageCount as usize)
.map(|layer| layer.mImage.clone())
.collect()
)
@@ -1452,12 +1487,12 @@ fn static_assert() {
use std::cmp;
let mut max_len = 1;
% for member in fill_fields.split():
- max_len = cmp::max(max_len, self.gecko.${image_layers_field}.${member}Count);
+ max_len = cmp::max(max_len, self.${image_layers_field}.${member}Count);
% endfor
unsafe {
// While we could do this manually, we'd need to also manually
// run all the copy constructors, so we just delegate to gecko
- Gecko_FillAllImageLayers(&mut self.gecko.${image_layers_field}, max_len);
+ Gecko_FillAllImageLayers(&mut self.${image_layers_field}, max_len);
}
}
</%def>
@@ -1486,12 +1521,12 @@ fn static_assert() {
use self::longhands::list_style_type::computed_value::T;
match v {
T::None => unsafe {
- bindings::Gecko_SetCounterStyleToNone(&mut self.gecko.mCounterStyle)
+ bindings::Gecko_SetCounterStyleToNone(&mut self.mCounterStyle)
}
- T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle),
+ T::CounterStyle(s) => s.to_gecko_value(&mut self.mCounterStyle),
T::String(s) => unsafe {
bindings::Gecko_SetCounterStyleToString(
- &mut self.gecko.mCounterStyle,
+ &mut self.mCounterStyle,
&nsCStr::from(&s) as &nsACString,
)
}
@@ -1500,7 +1535,7 @@ fn static_assert() {
pub fn copy_list_style_type_from(&mut self, other: &Self) {
unsafe {
- Gecko_CopyCounterStyle(&mut self.gecko.mCounterStyle, &other.gecko.mCounterStyle);
+ Gecko_CopyCounterStyle(&mut self.mCounterStyle, &other.mCounterStyle);
}
}
@@ -1515,7 +1550,7 @@ fn static_assert() {
use crate::gecko_bindings::bindings;
let name = unsafe {
- bindings::Gecko_CounterStyle_GetName(&self.gecko.mCounterStyle)
+ bindings::Gecko_CounterStyle_GetName(&self.mCounterStyle)
};
if !name.is_null() {
let name = unsafe { Atom::from_raw(name) };
@@ -1523,7 +1558,7 @@ fn static_assert() {
return T::None;
}
}
- let result = CounterStyle::from_gecko_value(&self.gecko.mCounterStyle);
+ let result = CounterStyle::from_gecko_value(&self.mCounterStyle);
match result {
Either::First(counter_style) => T::CounterStyle(counter_style),
Either::Second(string) => T::String(string),
@@ -1544,13 +1579,13 @@ fn static_assert() {
skip_longhands="border-spacing">
pub fn set_border_spacing(&mut self, v: longhands::border_spacing::computed_value::T) {
- self.gecko.mBorderSpacingCol = v.horizontal().0;
- self.gecko.mBorderSpacingRow = v.vertical().0;
+ self.mBorderSpacingCol = v.horizontal().0;
+ self.mBorderSpacingRow = v.vertical().0;
}
pub fn copy_border_spacing_from(&mut self, other: &Self) {
- self.gecko.mBorderSpacingCol = other.gecko.mBorderSpacingCol;
- self.gecko.mBorderSpacingRow = other.gecko.mBorderSpacingRow;
+ self.mBorderSpacingCol = other.mBorderSpacingCol;
+ self.mBorderSpacingRow = other.mBorderSpacingRow;
}
pub fn reset_border_spacing(&mut self, other: &Self) {
@@ -1559,8 +1594,8 @@ fn static_assert() {
pub fn clone_border_spacing(&self) -> longhands::border_spacing::computed_value::T {
longhands::border_spacing::computed_value::T::new(
- Au(self.gecko.mBorderSpacingCol).into(),
- Au(self.gecko.mBorderSpacingRow).into()
+ Au(self.mBorderSpacingCol).into(),
+ Au(self.mBorderSpacingRow).into()
)
}
</%self:impl_trait>
@@ -1577,23 +1612,23 @@ fn static_assert() {
use crate::values::generics::text::InitialLetter;
match v {
InitialLetter::Normal => {
- self.gecko.mInitialLetterSize = 0.;
- self.gecko.mInitialLetterSink = 0;
+ self.mInitialLetterSize = 0.;
+ self.mInitialLetterSink = 0;
},
InitialLetter::Specified(size, sink) => {
- self.gecko.mInitialLetterSize = size;
+ self.mInitialLetterSize = size;
if let Some(sink) = sink {
- self.gecko.mInitialLetterSink = sink;
+ self.mInitialLetterSink = sink;
} else {
- self.gecko.mInitialLetterSink = size.floor() as i32;
+ self.mInitialLetterSink = size.floor() as i32;
}
}
}
}
pub fn copy_initial_letter_from(&mut self, other: &Self) {
- self.gecko.mInitialLetterSize = other.gecko.mInitialLetterSize;
- self.gecko.mInitialLetterSink = other.gecko.mInitialLetterSink;
+ self.mInitialLetterSize = other.mInitialLetterSize;
+ self.mInitialLetterSink = other.mInitialLetterSink;
}
pub fn reset_initial_letter(&mut self, other: &Self) {
@@ -1603,12 +1638,12 @@ fn static_assert() {
pub fn clone_initial_letter(&self) -> longhands::initial_letter::computed_value::T {
use crate::values::generics::text::InitialLetter;
- if self.gecko.mInitialLetterSize == 0. && self.gecko.mInitialLetterSink == 0 {
+ if self.mInitialLetterSize == 0. && self.mInitialLetterSink == 0 {
InitialLetter::Normal
- } else if self.gecko.mInitialLetterSize.floor() as i32 == self.gecko.mInitialLetterSink {
- InitialLetter::Specified(self.gecko.mInitialLetterSize, None)
+ } else if self.mInitialLetterSize.floor() as i32 == self.mInitialLetterSink {
+ InitialLetter::Specified(self.mInitialLetterSize, None)
} else {
- InitialLetter::Specified(self.gecko.mInitialLetterSize, Some(self.gecko.mInitialLetterSink))
+ InitialLetter::Specified(self.mInitialLetterSize, Some(self.mInitialLetterSink))
}
}
</%self:impl_trait>
@@ -1637,7 +1672,7 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
pub fn set_column_count(&mut self, v: longhands::column_count::computed_value::T) {
use crate::gecko_bindings::structs::{nsStyleColumn_kColumnCountAuto, nsStyleColumn_kMaxColumnCount};
- self.gecko.mColumnCount = match v {
+ self.mColumnCount = match v {
ColumnCount::Integer(integer) => {
cmp::min(integer.0 as u32, unsafe { nsStyleColumn_kMaxColumnCount })
},
@@ -1649,25 +1684,25 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
pub fn clone_column_count(&self) -> longhands::column_count::computed_value::T {
use crate::gecko_bindings::structs::{nsStyleColumn_kColumnCountAuto, nsStyleColumn_kMaxColumnCount};
- if self.gecko.mColumnCount != nsStyleColumn_kColumnCountAuto {
- debug_assert!(self.gecko.mColumnCount >= 1 &&
- self.gecko.mColumnCount <= nsStyleColumn_kMaxColumnCount);
- ColumnCount::Integer((self.gecko.mColumnCount as i32).into())
+ if self.mColumnCount != nsStyleColumn_kColumnCountAuto {
+ debug_assert!(self.mColumnCount >= 1 &&
+ self.mColumnCount <= nsStyleColumn_kMaxColumnCount);
+ ColumnCount::Integer((self.mColumnCount as i32).into())
} else {
ColumnCount::Auto
}
}
pub fn set_column_rule_style(&mut self, v: longhands::column_rule_style::computed_value::T) {
- self.gecko.mColumnRuleStyle = v;
+ self.mColumnRuleStyle = v;
// NB: This is needed to correctly handling the initial value of
// column-rule-width when colun-rule-style changes, see the
// update_border_${side.ident} comment for more details.
- self.gecko.mActualColumnRuleWidth = self.gecko.mColumnRuleWidth;
+ self.mActualColumnRuleWidth = self.mColumnRuleWidth;
}
pub fn copy_column_rule_style_from(&mut self, other: &Self) {
- self.set_column_rule_style(other.gecko.mColumnRuleStyle);
+ self.set_column_rule_style(other.mColumnRuleStyle);
}
pub fn reset_column_rule_style(&mut self, other: &Self) {
@@ -1675,7 +1710,7 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
}
pub fn clone_column_rule_style(&self) -> longhands::column_rule_style::computed_value::T {
- self.gecko.mColumnRuleStyle.clone()
+ self.mColumnRuleStyle.clone()
}
<% impl_non_negative_length("column_rule_width", "mActualColumnRuleWidth",
@@ -1683,13 +1718,13 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
round_to_pixels=True) %>
pub fn column_rule_has_nonzero_width(&self) -> bool {
- self.gecko.mActualColumnRuleWidth != 0
+ self.mActualColumnRuleWidth != 0
}
</%self:impl_trait>
<%self:impl_trait style_struct_name="Counters">
pub fn ineffective_content_property(&self) -> bool {
- !self.gecko.mContent.is_items()
+ !self.mContent.is_items()
}
</%self:impl_trait>
@@ -1727,9 +1762,9 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
let v = v.into_iter();
if v.len() != 0 {
- self.gecko.mTransitions.ensure_len(v.len());
- self.gecko.mTransitionPropertyCount = v.len() as u32;
- for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
+ self.mTransitions.ensure_len(v.len());
+ self.mTransitionPropertyCount = v.len() as u32;
+ for (servo, gecko) in v.zip(self.mTransitions.iter_mut()) {
unsafe { gecko.mUnknownProperty.clear() };
match servo {
@@ -1746,21 +1781,21 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
}
} else {
// In gecko |none| is represented by eCSSPropertyExtra_no_properties.
- self.gecko.mTransitionPropertyCount = 1;
- self.gecko.mTransitions[0].mProperty = eCSSPropertyExtra_no_properties;
+ self.mTransitionPropertyCount = 1;
+ self.mTransitions[0].mProperty = eCSSPropertyExtra_no_properties;
}
}
/// Returns whether there are any transitions specified.
pub fn specifies_transitions(&self) -> bool {
use crate::gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_all_properties;
- if self.gecko.mTransitionPropertyCount == 1 &&
- self.gecko.mTransitions[0].mProperty == eCSSPropertyExtra_all_properties &&
+ if self.mTransitionPropertyCount == 1 &&
+ self.mTransitions[0].mProperty == eCSSPropertyExtra_all_properties &&
self.transition_combined_duration_at(0).seconds() <= 0.0f32 {
return false;
}
- self.gecko.mTransitionPropertyCount > 0
+ self.mTransitionPropertyCount > 0
}
pub fn transition_property_at(&self, index: usize)
@@ -1769,15 +1804,15 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
use crate::gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_variable;
use crate::gecko_bindings::structs::nsCSSPropertyID::eCSSProperty_UNKNOWN;
- let property = self.gecko.mTransitions[index].mProperty;
+ let property = self.mTransitions[index].mProperty;
if property == eCSSProperty_UNKNOWN {
- let atom = self.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
+ let atom = self.mTransitions[index].mUnknownProperty.mRawPtr;
debug_assert!(!atom.is_null());
TransitionProperty::Unsupported(CustomIdent(unsafe{
Atom::from_raw(atom)
}))
} else if property == eCSSPropertyExtra_variable {
- let atom = self.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
+ let atom = self.mTransitions[index].mUnknownProperty.mRawPtr;
debug_assert!(!atom.is_null());
TransitionProperty::Custom(unsafe{
Atom::from_raw(atom)
@@ -1795,23 +1830,23 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
}
pub fn transition_nscsspropertyid_at(&self, index: usize) -> nsCSSPropertyID {
- self.gecko.mTransitions[index].mProperty
+ self.mTransitions[index].mProperty
}
pub fn copy_transition_property_from(&mut self, other: &Self) {
use crate::gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_variable;
use crate::gecko_bindings::structs::nsCSSPropertyID::eCSSProperty_UNKNOWN;
- self.gecko.mTransitions.ensure_len(other.gecko.mTransitions.len());
+ self.mTransitions.ensure_len(other.mTransitions.len());
- let count = other.gecko.mTransitionPropertyCount;
- self.gecko.mTransitionPropertyCount = count;
+ let count = other.mTransitionPropertyCount;
+ self.mTransitionPropertyCount = count;
- for (index, transition) in self.gecko.mTransitions.iter_mut().enumerate().take(count as usize) {
- transition.mProperty = other.gecko.mTransitions[index].mProperty;
+ for (index, transition) in self.mTransitions.iter_mut().enumerate().take(count as usize) {
+ transition.mProperty = other.mTransitions[index].mProperty;
unsafe { transition.mUnknownProperty.clear() };
if transition.mProperty == eCSSProperty_UNKNOWN ||
transition.mProperty == eCSSPropertyExtra_variable {
- let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
+ let atom = other.mTransitions[index].mUnknownProperty.mRawPtr;
debug_assert!(!atom.is_null());
transition.mUnknownProperty.mRawPtr = unsafe { Atom::from_raw(atom) }.into_addrefed();
}
@@ -1825,17 +1860,17 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
${impl_coordinated_property_count('transition', 'property', 'Property')}
pub fn animations_equals(&self, other: &Self) -> bool {
- return self.gecko.mAnimationNameCount == other.gecko.mAnimationNameCount
- && self.gecko.mAnimationDelayCount == other.gecko.mAnimationDelayCount
- && self.gecko.mAnimationDirectionCount == other.gecko.mAnimationDirectionCount
- && self.gecko.mAnimationDurationCount == other.gecko.mAnimationDurationCount
- && self.gecko.mAnimationFillModeCount == other.gecko.mAnimationFillModeCount
- && self.gecko.mAnimationIterationCountCount == other.gecko.mAnimationIterationCountCount
- && self.gecko.mAnimationPlayStateCount == other.gecko.mAnimationPlayStateCount
- && self.gecko.mAnimationTimingFunctionCount == other.gecko.mAnimationTimingFunctionCount
- && self.gecko.mAnimationCompositionCount == other.gecko.mAnimationCompositionCount
- && self.gecko.mAnimationTimelineCount == other.gecko.mAnimationTimelineCount
- && unsafe { bindings::Gecko_StyleAnimationsEquals(&self.gecko.mAnimations, &other.gecko.mAnimations) }
+ return self.mAnimationNameCount == other.mAnimationNameCount
+ && self.mAnimationDelayCount == other.mAnimationDelayCount
+ && self.mAnimationDirectionCount == other.mAnimationDirectionCount
+ && self.mAnimationDurationCount == other.mAnimationDurationCount
+ && self.mAnimationFillModeCount == other.mAnimationFillModeCount
+ && self.mAnimationIterationCountCount == other.mAnimationIterationCountCount
+ && self.mAnimationPlayStateCount == other.mAnimationPlayStateCount
+ && self.mAnimationTimingFunctionCount == other.mAnimationTimingFunctionCount
+ && self.mAnimationCompositionCount == other.mAnimationCompositionCount
+ && self.mAnimationTimelineCount == other.mAnimationTimelineCount
+ && unsafe { bindings::Gecko_StyleAnimationsEquals(&self.mAnimations, &other.mAnimations) }
}
pub fn set_animation_name<I>(&mut self, v: I)
@@ -1845,10 +1880,10 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
{
let v = v.into_iter();
debug_assert_ne!(v.len(), 0);
- self.gecko.mAnimations.ensure_len(v.len());
+ self.mAnimations.ensure_len(v.len());
- self.gecko.mAnimationNameCount = v.len() as u32;
- for (servo, gecko) in v.zip(self.gecko.mAnimations.iter_mut()) {
+ self.mAnimationNameCount = v.len() as u32;
+ for (servo, gecko) in v.zip(self.mAnimations.iter_mut()) {
let atom = servo.0.as_atom().clone();
unsafe { bindings::Gecko_SetAnimationName(gecko, atom.into_addrefed()); }
}
@@ -1857,12 +1892,12 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
-> longhands::animation_name::computed_value::SingleComputedValue {
use crate::properties::longhands::animation_name::single_value::SpecifiedValue as AnimationName;
- let atom = self.gecko.mAnimations[index].mName.mRawPtr;
+ let atom = self.mAnimations[index].mName.mRawPtr;
AnimationName(KeyframesName::from_atom(unsafe { Atom::from_raw(atom) }))
}
pub fn copy_animation_name_from(&mut self, other: &Self) {
- self.gecko.mAnimationNameCount = other.gecko.mAnimationNameCount;
- unsafe { bindings::Gecko_CopyAnimationNames(&mut self.gecko.mAnimations, &other.gecko.mAnimations); }
+ self.mAnimationNameCount = other.mAnimationNameCount;
+ unsafe { bindings::Gecko_CopyAnimationNames(&mut self.mAnimations, &other.mAnimations); }
}
pub fn reset_animation_name(&mut self, other: &Self) {
@@ -1888,12 +1923,12 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
${impl_coordinated_property('scroll_timeline', 'axis', 'Axis')}
pub fn scroll_timelines_equals(&self, other: &Self) -> bool {
- self.gecko.mScrollTimelineNameCount == other.gecko.mScrollTimelineNameCount
- && self.gecko.mScrollTimelineAxisCount == other.gecko.mScrollTimelineAxisCount
+ self.mScrollTimelineNameCount == other.mScrollTimelineNameCount
+ && self.mScrollTimelineAxisCount == other.mScrollTimelineAxisCount
&& unsafe {
bindings::Gecko_StyleScrollTimelinesEquals(
- &self.gecko.mScrollTimelines,
- &other.gecko.mScrollTimelines,
+ &self.mScrollTimelines,
+ &other.mScrollTimelines,
)
}
}
@@ -1903,13 +1938,13 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
${impl_coordinated_property('view_timeline', 'inset', 'Inset')}
pub fn view_timelines_equals(&self, other: &Self) -> bool {
- self.gecko.mViewTimelineNameCount == other.gecko.mViewTimelineNameCount
- && self.gecko.mViewTimelineAxisCount == other.gecko.mViewTimelineAxisCount
- && self.gecko.mViewTimelineInsetCount == other.gecko.mViewTimelineInsetCount
+ self.mViewTimelineNameCount == other.mViewTimelineNameCount
+ && self.mViewTimelineAxisCount == other.mViewTimelineAxisCount
+ && self.mViewTimelineInsetCount == other.mViewTimelineInsetCount
&& unsafe {
bindings::Gecko_StyleViewTimelinesEquals(
- &self.gecko.mViewTimelines,
- &other.gecko.mViewTimelines,
+ &self.mViewTimelines,
+ &other.mViewTimelines,
)
}
}
@@ -1919,7 +1954,6 @@ mask-mode mask-repeat mask-clip mask-origin mask-composite mask-position-x mask-
</%self:impl_trait>
% for style_struct in data.style_structs:
-${declare_style_struct(style_struct)}
${impl_style_struct(style_struct)}
% endfor
diff --git a/components/style/properties/longhands/font.mako.rs b/components/style/properties/longhands/font.mako.rs
index e116f305e28..91eb872592b 100644
--- a/components/style/properties/longhands/font.mako.rs
+++ b/components/style/properties/longhands/font.mako.rs
@@ -401,7 +401,7 @@ pub mod system_font {
bindings::Gecko_nsFont_InitSystem(
system.as_mut_ptr(),
*self,
- cx.style().get_font().gecko(),
+ &**cx.style().get_font(),
cx.device().document()
);
&mut *system.as_mut_ptr()
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 6c8b436c7ff..f2acecc8d0e 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -3098,14 +3098,9 @@ impl ComputedValues {
self.rules.as_ref().unwrap()
}
- /// Returns the visited style, if any.
- pub fn visited_style(&self) -> Option<<&ComputedValues> {
- self.visited_style.as_deref()
- }
-
/// Returns the visited rules, if applicable.
pub fn visited_rules(&self) -> Option<<&StrongRuleNode> {
- self.visited_style.as_ref().and_then(|s| s.rules.as_ref())
+ self.visited_style().and_then(|s| s.rules.as_ref())
}
/// Gets a reference to the custom properties map (if one exists).
@@ -3346,6 +3341,11 @@ impl ops::DerefMut for ComputedValues {
#[cfg(feature = "servo")]
impl ComputedValuesInner {
+ /// Returns the visited style, if any.
+ pub fn visited_style(&self) -> Option<<&ComputedValues> {
+ self.visited_style.as_deref()
+ }
+
% for style_struct in data.active_style_structs():
/// Clone the ${style_struct.name} struct.
#[inline]
@@ -3359,12 +3359,6 @@ impl ComputedValuesInner {
&self.${style_struct.ident}
}
- /// Gets an immutable reference to the refcounted value that wraps
- /// `${style_struct.name}`.
- pub fn ${style_struct.name_lower}_arc(&self) -> &Arc<style_structs::${style_struct.name}> {
- &self.${style_struct.ident}
- }
-
/// Get a mutable reference to the ${style_struct.name} struct.
#[inline]
pub fn mutate_${style_struct.name_lower}(&mut self) -> &mut style_structs::${style_struct.name} {
@@ -3563,24 +3557,10 @@ impl ComputedValuesInner {
}
}
-% if engine == "gecko":
- pub use crate::servo_arc::RawOffsetArc as BuilderArc;
- /// Clone an arc, returning a regular arc
- fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
- Arc::from_raw_offset(x.clone())
- }
-% else:
- pub use crate::servo_arc::Arc as BuilderArc;
- /// Clone an arc, returning a regular arc
- fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
- x.clone()
- }
-% endif
-
/// A reference to a style struct of the parent, or our own style struct.
pub enum StyleStructRef<'a, T: 'static> {
/// A borrowed struct from the parent, for example, for inheriting style.
- Borrowed(&'a BuilderArc<T>),
+ Borrowed(&'a T),
/// An owned struct, that we've already mutated.
Owned(UniqueArc<T>),
/// Temporarily vacated, will panic if accessed
@@ -3595,7 +3575,7 @@ where
/// borrowed value, or returning the owned one.
pub fn mutate(&mut self) -> &mut T {
if let StyleStructRef::Borrowed(v) = *self {
- *self = StyleStructRef::Owned(UniqueArc::new((**v).clone()));
+ *self = StyleStructRef::Owned(UniqueArc::new(v.clone()));
}
match *self {
@@ -3614,8 +3594,8 @@ where
pub fn ptr_eq(&self, struct_to_copy_from: &T) -> bool {
match *self {
StyleStructRef::Owned(..) => false,
- StyleStructRef::Borrowed(arc) => {
- &**arc as *const T == struct_to_copy_from as *const T
+ StyleStructRef::Borrowed(s) => {
+ s as *const T == struct_to_copy_from as *const T
}
StyleStructRef::Vacated => panic!("Accessed vacated style struct")
}
@@ -3632,7 +3612,7 @@ where
match inner {
StyleStructRef::Owned(arc) => arc,
- StyleStructRef::Borrowed(arc) => UniqueArc::new((**arc).clone()),
+ StyleStructRef::Borrowed(s) => UniqueArc::new(s.clone()),
StyleStructRef::Vacated => panic!("Accessed vacated style struct"),
}
}
@@ -3658,7 +3638,8 @@ where
pub fn build(self) -> Arc<T> {
match self {
StyleStructRef::Owned(v) => v.shareable(),
- StyleStructRef::Borrowed(v) => clone_arc(v),
+ // SAFETY: We know all style structs are arc-allocated.
+ StyleStructRef::Borrowed(v) => unsafe { Arc::from_raw_addrefed(v) },
StyleStructRef::Vacated => panic!("Accessed vacated style struct")
}
}
@@ -3670,7 +3651,7 @@ impl<'a, T: 'a> ops::Deref for StyleStructRef<'a, T> {
fn deref(&self) -> &T {
match *self {
StyleStructRef::Owned(ref v) => &**v,
- StyleStructRef::Borrowed(v) => &**v,
+ StyleStructRef::Borrowed(v) => v,
StyleStructRef::Vacated => panic!("Accessed vacated style struct")
}
}
@@ -3773,9 +3754,9 @@ impl<'a> StyleBuilder<'a> {
visited_style: None,
% for style_struct in data.active_style_structs():
% if style_struct.inherited:
- ${style_struct.ident}: StyleStructRef::Borrowed(inherited_style.${style_struct.name_lower}_arc()),
+ ${style_struct.ident}: StyleStructRef::Borrowed(inherited_style.get_${style_struct.name_lower}()),
% else:
- ${style_struct.ident}: StyleStructRef::Borrowed(reset_style.${style_struct.name_lower}_arc()),
+ ${style_struct.ident}: StyleStructRef::Borrowed(reset_style.get_${style_struct.name_lower}()),
% endif
% endfor
}
@@ -3813,7 +3794,7 @@ impl<'a> StyleBuilder<'a> {
visited_style: None,
% for style_struct in data.active_style_structs():
${style_struct.ident}: StyleStructRef::Borrowed(
- style_to_derive_from.${style_struct.name_lower}_arc()
+ style_to_derive_from.get_${style_struct.name_lower}()
),
% endfor
}
@@ -3824,7 +3805,7 @@ impl<'a> StyleBuilder<'a> {
% for style_struct in data.active_style_structs():
% if not style_struct.inherited:
self.${style_struct.ident} =
- StyleStructRef::Borrowed(style.${style_struct.name_lower}_arc());
+ StyleStructRef::Borrowed(style.get_${style_struct.name_lower}());
% endif
% endfor
}
@@ -3991,7 +3972,7 @@ impl<'a> StyleBuilder<'a> {
/// Reset the current `${style_struct.name}` style to its default value.
pub fn reset_${style_struct.name_lower}_struct(&mut self) {
self.${style_struct.ident} =
- StyleStructRef::Borrowed(self.reset_style.${style_struct.name_lower}_arc());
+ StyleStructRef::Borrowed(self.reset_style.get_${style_struct.name_lower}());
}
% endfor
<% del style_struct %>
diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs
index 4e0a730e9c5..68401da02b4 100644
--- a/components/style/values/specified/font.rs
+++ b/components/style/values/specified/font.rs
@@ -775,13 +775,13 @@ impl FontSizeKeyword {
#[cfg(feature = "gecko")]
#[inline]
fn to_length(&self, cx: &Context) -> NonNegativeLength {
- let gecko_font = cx.style().get_font().gecko();
- let family = &gecko_font.mFont.family.families;
+ let font = cx.style().get_font();
+ let family = &font.mFont.family.families;
let generic = family
.single_generic()
.unwrap_or(computed::GenericFontFamily::None);
let base_size = unsafe {
- Atom::with(gecko_font.mLanguage.mRawPtr, |language| {
+ Atom::with(font.mLanguage.mRawPtr, |language| {
cx.device().base_size_for_generic(language, generic)
})
};