зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1593951 - Use MaybeUninit in style struct clone impls / constructors. r=xidorn
Differential Revision: https://phabricator.services.mozilla.com/D51788 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
de2c2a249a
Коммит
e47530e246
|
@ -2688,8 +2688,10 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
|
|||
mOverscrollBehaviorX(StyleOverscrollBehavior::Auto),
|
||||
mOverscrollBehaviorY(StyleOverscrollBehavior::Auto),
|
||||
mOverflowAnchor(StyleOverflowAnchor::Auto),
|
||||
mScrollSnapType(
|
||||
{StyleScrollSnapAxis::Both, StyleScrollSnapStrictness::None}),
|
||||
mScrollSnapAlign{StyleScrollSnapAlignKeyword::None,
|
||||
StyleScrollSnapAlignKeyword::None},
|
||||
mScrollSnapType{StyleScrollSnapAxis::Both,
|
||||
StyleScrollSnapStrictness::None},
|
||||
mLineClamp(0),
|
||||
mRotate(StyleRotate::None()),
|
||||
mTranslate(StyleTranslate::None()),
|
||||
|
@ -2753,6 +2755,8 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
|||
mScrollBehavior(aSource.mScrollBehavior),
|
||||
mOverscrollBehaviorX(aSource.mOverscrollBehaviorX),
|
||||
mOverscrollBehaviorY(aSource.mOverscrollBehaviorY),
|
||||
mOverflowAnchor(aSource.mOverflowAnchor),
|
||||
mScrollSnapAlign(aSource.mScrollSnapAlign),
|
||||
mScrollSnapType(aSource.mScrollSnapType),
|
||||
mLineClamp(aSource.mLineClamp),
|
||||
mTransform(aSource.mTransform),
|
||||
|
|
|
@ -46,7 +46,7 @@ use crate::rule_tree::StrongRuleNode;
|
|||
use crate::selector_parser::PseudoElement;
|
||||
use servo_arc::{Arc, RawOffsetArc, UniqueArc};
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::{forget, zeroed, ManuallyDrop};
|
||||
use std::mem::{forget, MaybeUninit};
|
||||
use std::{cmp, ops, ptr};
|
||||
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
|
||||
use crate::values::computed::{Percentage, TransitionProperty};
|
||||
|
@ -218,7 +218,7 @@ impl ComputedValuesInner {
|
|||
unsafe {
|
||||
let mut arc = UniqueArc::<ComputedValues>::new_uninit();
|
||||
bindings::Gecko_ComputedStyle_Init(
|
||||
&mut (*arc.as_mut_ptr()).0,
|
||||
arc.as_mut_ptr() as *mut _,
|
||||
&self,
|
||||
pseudo_ty,
|
||||
);
|
||||
|
@ -621,14 +621,14 @@ def set_gecko_property(ffi_name, expr):
|
|||
impl ${style_struct.gecko_struct_name} {
|
||||
#[allow(dead_code, unused_variables)]
|
||||
pub fn default(document: &structs::Document) -> Arc<Self> {
|
||||
let mut result = Arc::new(${style_struct.gecko_struct_name} { gecko: ManuallyDrop::new(unsafe { zeroed() }) });
|
||||
unsafe {
|
||||
let mut result = UniqueArc::<Self>::new_uninit();
|
||||
Gecko_Construct_Default_${style_struct.gecko_ffi_name}(
|
||||
&mut *Arc::get_mut(&mut result).unwrap().gecko,
|
||||
result.as_mut_ptr() as *mut _,
|
||||
document,
|
||||
);
|
||||
UniqueArc::assume_init(result).shareable()
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
impl Drop for ${style_struct.gecko_struct_name} {
|
||||
|
@ -641,9 +641,9 @@ impl Drop for ${style_struct.gecko_struct_name} {
|
|||
impl Clone for ${style_struct.gecko_struct_name} {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let mut result = ${style_struct.gecko_struct_name} { gecko: ManuallyDrop::new(zeroed()) };
|
||||
Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(&mut *result.gecko, &*self.gecko);
|
||||
result
|
||||
let mut result = MaybeUninit::<Self>::uninit();
|
||||
Gecko_CopyConstruct_${style_struct.gecko_ffi_name}(result.as_mut_ptr() as *mut _, &*self.gecko);
|
||||
result.assume_init()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче