Auto merge of #17794 - birtles:assign-properties-safely, r=hiro

Assign properties safely

These are the Servo-side changes for [Bugzilla bug 1381389](https://bugzilla.mozilla.org/show_bug.cgi?id=1381389).

<!-- 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/17794)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-19 22:48:47 -07:00 committed by GitHub
commit 513e6b2979
5 changed files with 2587 additions and 2889 deletions

View file

@ -124,6 +124,8 @@ cfg_if! {
pub static nsGkAtoms_allowmodals: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms20alloworientationlockE"]
pub static nsGkAtoms_alloworientationlock: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms19allowpaymentrequestE"]
pub static nsGkAtoms_allowpaymentrequest: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms16allowpointerlockE"]
pub static nsGkAtoms_allowpointerlock: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms26allowpopupstoescapesandboxE"]
@ -4338,8 +4340,8 @@ cfg_if! {
pub static nsGkAtoms_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms18overlay_scrollbarsE"]
pub static nsGkAtoms_overlay_scrollbars: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms28windows_accent_color_appliesE"]
pub static nsGkAtoms_windows_accent_color_applies: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms32windows_accent_color_in_titlebarE"]
pub static nsGkAtoms_windows_accent_color_in_titlebar: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms21windows_default_themeE"]
pub static nsGkAtoms_windows_default_theme: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms18mac_graphite_themeE"]
@ -4390,8 +4392,8 @@ cfg_if! {
pub static nsGkAtoms__moz_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms23_moz_overlay_scrollbarsE"]
pub static nsGkAtoms__moz_overlay_scrollbars: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms33_moz_windows_accent_color_appliesE"]
pub static nsGkAtoms__moz_windows_accent_color_applies: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms37_moz_windows_accent_color_in_titlebarE"]
pub static nsGkAtoms__moz_windows_accent_color_in_titlebar: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms26_moz_windows_default_themeE"]
pub static nsGkAtoms__moz_windows_default_theme: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms23_moz_mac_graphite_themeE"]
@ -5251,6 +5253,8 @@ cfg_if! {
pub static nsGkAtoms_allowmodals: *mut nsIAtom;
#[link_name = "?alloworientationlock@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_alloworientationlock: *mut nsIAtom;
#[link_name = "?allowpaymentrequest@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_allowpaymentrequest: *mut nsIAtom;
#[link_name = "?allowpointerlock@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_allowpointerlock: *mut nsIAtom;
#[link_name = "?allowpopupstoescapesandbox@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -9465,8 +9469,8 @@ cfg_if! {
pub static nsGkAtoms_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "?overlay_scrollbars@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_overlay_scrollbars: *mut nsIAtom;
#[link_name = "?windows_accent_color_applies@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_windows_accent_color_applies: *mut nsIAtom;
#[link_name = "?windows_accent_color_in_titlebar@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_windows_accent_color_in_titlebar: *mut nsIAtom;
#[link_name = "?windows_default_theme@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_windows_default_theme: *mut nsIAtom;
#[link_name = "?mac_graphite_theme@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -9517,8 +9521,8 @@ cfg_if! {
pub static nsGkAtoms__moz_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "?_moz_overlay_scrollbars@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_overlay_scrollbars: *mut nsIAtom;
#[link_name = "?_moz_windows_accent_color_applies@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_windows_accent_color_applies: *mut nsIAtom;
#[link_name = "?_moz_windows_accent_color_in_titlebar@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_windows_accent_color_in_titlebar: *mut nsIAtom;
#[link_name = "?_moz_windows_default_theme@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms__moz_windows_default_theme: *mut nsIAtom;
#[link_name = "?_moz_mac_graphite_theme@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -10378,6 +10382,8 @@ cfg_if! {
pub static nsGkAtoms_allowmodals: *mut nsIAtom;
#[link_name = "\x01?alloworientationlock@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_alloworientationlock: *mut nsIAtom;
#[link_name = "\x01?allowpaymentrequest@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_allowpaymentrequest: *mut nsIAtom;
#[link_name = "\x01?allowpointerlock@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_allowpointerlock: *mut nsIAtom;
#[link_name = "\x01?allowpopupstoescapesandbox@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -14592,8 +14598,8 @@ cfg_if! {
pub static nsGkAtoms_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "\x01?overlay_scrollbars@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_overlay_scrollbars: *mut nsIAtom;
#[link_name = "\x01?windows_accent_color_applies@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_windows_accent_color_applies: *mut nsIAtom;
#[link_name = "\x01?windows_accent_color_in_titlebar@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_windows_accent_color_in_titlebar: *mut nsIAtom;
#[link_name = "\x01?windows_default_theme@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_windows_default_theme: *mut nsIAtom;
#[link_name = "\x01?mac_graphite_theme@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -14644,8 +14650,8 @@ cfg_if! {
pub static nsGkAtoms__moz_scrollbar_thumb_proportional: *mut nsIAtom;
#[link_name = "\x01?_moz_overlay_scrollbars@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_overlay_scrollbars: *mut nsIAtom;
#[link_name = "\x01?_moz_windows_accent_color_applies@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_windows_accent_color_applies: *mut nsIAtom;
#[link_name = "\x01?_moz_windows_accent_color_in_titlebar@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_windows_accent_color_in_titlebar: *mut nsIAtom;
#[link_name = "\x01?_moz_windows_default_theme@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms__moz_windows_default_theme: *mut nsIAtom;
#[link_name = "\x01?_moz_mac_graphite_theme@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -15508,6 +15514,8 @@ macro_rules! atom {
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_allowmodals as *mut _) } };
("allow-orientation-lock") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_alloworientationlock as *mut _) } };
("allowpaymentrequest") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_allowpaymentrequest as *mut _) } };
("allow-pointer-lock") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_allowpointerlock as *mut _) } };
("allow-popups-to-escape-sandbox") =>
@ -19722,8 +19730,8 @@ macro_rules! atom {
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_scrollbar_thumb_proportional as *mut _) } };
("overlay-scrollbars") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_overlay_scrollbars as *mut _) } };
("windows-accent-color-applies") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_windows_accent_color_applies as *mut _) } };
("windows-accent-color-in-titlebar") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_windows_accent_color_in_titlebar as *mut _) } };
("windows-default-theme") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_windows_default_theme as *mut _) } };
("mac-graphite-theme") =>
@ -19774,8 +19782,8 @@ macro_rules! atom {
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_scrollbar_thumb_proportional as *mut _) } };
("-moz-overlay-scrollbars") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_overlay_scrollbars as *mut _) } };
("-moz-windows-accent-color-applies") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_windows_accent_color_applies as *mut _) } };
("-moz-windows-accent-color-in-titlebar") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_windows_accent_color_in_titlebar as *mut _) } };
("-moz-windows-default-theme") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms__moz_windows_default_theme as *mut _) } };
("-moz-mac-graphite-theme") =>

View file

@ -25,6 +25,7 @@ use gecko_bindings::structs::RawGeckoCSSPropertyIDList;
use gecko_bindings::structs::RawGeckoDocument;
use gecko_bindings::structs::RawGeckoElement;
use gecko_bindings::structs::RawGeckoKeyframeList;
use gecko_bindings::structs::RawGeckoPropertyValuePairList;
use gecko_bindings::structs::RawGeckoComputedKeyframeValuesList;
use gecko_bindings::structs::RawGeckoFontFaceRuleList;
use gecko_bindings::structs::RawGeckoNode;
@ -54,6 +55,7 @@ use gecko_bindings::structs::FontSizePrefs;
use gecko_bindings::structs::GeckoFontMetrics;
use gecko_bindings::structs::IterationCompositeOperation;
use gecko_bindings::structs::Keyframe;
use gecko_bindings::structs::PropertyValuePair;
use gecko_bindings::structs::ServoBundledURI;
use gecko_bindings::structs::ServoElementSnapshot;
use gecko_bindings::structs::ServoElementSnapshotTable;
@ -297,6 +299,10 @@ pub type RawGeckoKeyframeListBorrowed<'a> = &'a RawGeckoKeyframeList;
pub type RawGeckoKeyframeListBorrowedOrNull<'a> = Option<&'a RawGeckoKeyframeList>;
pub type RawGeckoKeyframeListBorrowedMut<'a> = &'a mut RawGeckoKeyframeList;
pub type RawGeckoKeyframeListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoKeyframeList>;
pub type RawGeckoPropertyValuePairListBorrowed<'a> = &'a RawGeckoPropertyValuePairList;
pub type RawGeckoPropertyValuePairListBorrowedOrNull<'a> = Option<&'a RawGeckoPropertyValuePairList>;
pub type RawGeckoPropertyValuePairListBorrowedMut<'a> = &'a mut RawGeckoPropertyValuePairList;
pub type RawGeckoPropertyValuePairListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoPropertyValuePairList>;
pub type RawGeckoComputedKeyframeValuesListBorrowed<'a> = &'a RawGeckoComputedKeyframeValuesList;
pub type RawGeckoComputedKeyframeValuesListBorrowedOrNull<'a> = Option<&'a RawGeckoComputedKeyframeValuesList>;
pub type RawGeckoComputedKeyframeValuesListBorrowedMut<'a> = &'a mut RawGeckoComputedKeyframeValuesList;
@ -1164,6 +1170,12 @@ extern "C" {
*const nsTimingFunction)
-> *mut Keyframe;
}
extern "C" {
pub fn Gecko_AppendPropertyValuePair(aProperties:
RawGeckoPropertyValuePairListBorrowedMut,
aProperty: nsCSSPropertyID)
-> *mut PropertyValuePair;
}
extern "C" {
pub fn Gecko_ResetStyleCoord(unit: *mut nsStyleUnit,
value: *mut nsStyleUnion);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -45,6 +45,7 @@ use style::gecko_bindings::bindings::{RawServoSupportsRule, RawServoSupportsRule
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
use style::gecko_bindings::bindings::{nsACString, nsAString, nsCSSPropertyIDSetBorrowedMut};
use style::gecko_bindings::bindings::Gecko_AddPropertyToSet;
use style::gecko_bindings::bindings::Gecko_AppendPropertyValuePair;
use style::gecko_bindings::bindings::Gecko_GetOrCreateFinalKeyframe;
use style::gecko_bindings::bindings::Gecko_GetOrCreateInitialKeyframe;
use style::gecko_bindings::bindings::Gecko_GetOrCreateKeyframeAtStart;
@ -3077,16 +3078,6 @@ pub extern "C" fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed) {
assert_subtree_is_clean(root);
}
fn append_computed_property_value(keyframe: *mut structs::Keyframe,
property: &AnimatableLonghand) {
unsafe {
let index = (*keyframe).mPropertyValues.len();
(*keyframe).mPropertyValues.set_len((index + 1) as u32);
(*keyframe).mPropertyValues[index].mProperty = property.into();
(*keyframe).mPropertyValues[index].mServoDeclarationBlock.mRawPtr = ptr::null_mut();
}
}
enum Offset {
Zero,
One
@ -3118,7 +3109,8 @@ fn fill_in_missing_keyframe_values(all_properties: &[AnimatableLonghand],
// Append properties that have not been set at this offset.
for ref property in all_properties.iter() {
if !properties_set_at_offset.has_animatable_longhand_bit(property) {
append_computed_property_value(keyframe, property);
unsafe { Gecko_AppendPropertyValuePair(&mut (*keyframe).mPropertyValues,
(*property).into()); }
}
}
}
@ -3181,7 +3173,10 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
// animation should be set to the underlying computed value for
// that keyframe.
for property in animation.properties_changed.iter() {
append_computed_property_value(keyframe, property);
unsafe {
Gecko_AppendPropertyValuePair(&mut (*keyframe).mPropertyValues,
property.into());
}
}
if current_offset == 0.0 {
has_complete_initial_keyframe = true;
@ -3199,7 +3194,6 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
declaration.is_animatable()
});
let mut index = unsafe { (*keyframe).mPropertyValues.len() };
for &(ref declaration, _) in animatable {
let property = AnimatableLonghand::from_declaration(declaration).unwrap();
// Skip the 'display' property because although it is animatable from SMIL,
@ -3213,17 +3207,17 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
properties_set_at_end.set_animatable_longhand_bit(&property);
}
let property = AnimatableLonghand::from_declaration(declaration).unwrap();
unsafe {
let property = AnimatableLonghand::from_declaration(declaration).unwrap();
(*keyframe).mPropertyValues.set_len((index + 1) as u32);
(*keyframe).mPropertyValues[index].mProperty = (&property).into();
(*keyframe).mPropertyValues[index].mServoDeclarationBlock.set_arc_leaky(
let pair =
Gecko_AppendPropertyValuePair(&mut (*keyframe).mPropertyValues,
(&property).into());
(*pair).mServoDeclarationBlock.set_arc_leaky(
Arc::new(global_style_data.shared_lock.wrap(
PropertyDeclarationBlock::with_one(
declaration.clone(), Importance::Normal
PropertyDeclarationBlock::with_one(
declaration.clone(), Importance::Normal
))));
}
index += 1;
}
}
},