mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #18700 - aethanyc:refactor-style-shape-source, r=heycam
style: Refactor style shape source This was reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1404243 <!-- 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/18700) <!-- Reviewable:end -->
This commit is contained in:
commit
e554d1c9d4
6 changed files with 1725 additions and 1265 deletions
|
@ -617,13 +617,14 @@ pub mod basic_shape {
|
|||
StyleShapeSourceType::Box => ShapeSource::Box(other.mReferenceBox.into()),
|
||||
StyleShapeSourceType::URL => {
|
||||
unsafe {
|
||||
let other_url = &(**other.__bindgen_anon_1.mURL.as_ref());
|
||||
let shape_image = &*other.mShapeImage.mPtr;
|
||||
let other_url = &(**shape_image.__bindgen_anon_1.mURLValue.as_ref());
|
||||
let url = SpecifiedUrl::from_url_value_data(&other_url._base).unwrap();
|
||||
ShapeSource::Url(url)
|
||||
}
|
||||
},
|
||||
StyleShapeSourceType::Shape => {
|
||||
let other_shape = unsafe { &(**other.__bindgen_anon_1.mBasicShape.as_ref()) };
|
||||
let other_shape = unsafe { &*other.mBasicShape.mPtr };
|
||||
let shape = other_shape.into();
|
||||
let reference_box = if other.mReferenceBox == StyleGeometryBox::NoBox {
|
||||
None
|
||||
|
|
|
@ -4074,6 +4074,8 @@ cfg_if! {
|
|||
pub static nsGkAtoms_http: *mut nsIAtom;
|
||||
#[link_name = "_ZN9nsGkAtoms5httpsE"]
|
||||
pub static nsGkAtoms_https: *mut nsIAtom;
|
||||
#[link_name = "_ZN9nsGkAtoms5proxyE"]
|
||||
pub static nsGkAtoms_proxy: *mut nsIAtom;
|
||||
#[link_name = "_ZN9nsGkAtoms12cdataTagNameE"]
|
||||
pub static nsGkAtoms_cdataTagName: *mut nsIAtom;
|
||||
#[link_name = "_ZN9nsGkAtoms14commentTagNameE"]
|
||||
|
@ -9239,6 +9241,8 @@ cfg_if! {
|
|||
pub static nsGkAtoms_http: *mut nsIAtom;
|
||||
#[link_name = "?https@nsGkAtoms@@2PEAVnsIAtom@@EA"]
|
||||
pub static nsGkAtoms_https: *mut nsIAtom;
|
||||
#[link_name = "?proxy@nsGkAtoms@@2PEAVnsIAtom@@EA"]
|
||||
pub static nsGkAtoms_proxy: *mut nsIAtom;
|
||||
#[link_name = "?cdataTagName@nsGkAtoms@@2PEAVnsIAtom@@EA"]
|
||||
pub static nsGkAtoms_cdataTagName: *mut nsIAtom;
|
||||
#[link_name = "?commentTagName@nsGkAtoms@@2PEAVnsIAtom@@EA"]
|
||||
|
@ -14404,6 +14408,8 @@ cfg_if! {
|
|||
pub static nsGkAtoms_http: *mut nsIAtom;
|
||||
#[link_name = "\x01?https@nsGkAtoms@@2PAVnsIAtom@@A"]
|
||||
pub static nsGkAtoms_https: *mut nsIAtom;
|
||||
#[link_name = "\x01?proxy@nsGkAtoms@@2PAVnsIAtom@@A"]
|
||||
pub static nsGkAtoms_proxy: *mut nsIAtom;
|
||||
#[link_name = "\x01?cdataTagName@nsGkAtoms@@2PAVnsIAtom@@A"]
|
||||
pub static nsGkAtoms_cdataTagName: *mut nsIAtom;
|
||||
#[link_name = "\x01?commentTagName@nsGkAtoms@@2PAVnsIAtom@@A"]
|
||||
|
@ -19572,6 +19578,8 @@ macro_rules! atom {
|
|||
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_http as *mut _) } };
|
||||
("https") =>
|
||||
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_https as *mut _) } };
|
||||
("proxy") =>
|
||||
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_proxy as *mut _) } };
|
||||
("#cdata-section") =>
|
||||
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_cdataTagName as *mut _) } };
|
||||
("#comment") =>
|
||||
|
|
|
@ -65,7 +65,6 @@ use gecko_bindings::structs::ServoElementSnapshot;
|
|||
use gecko_bindings::structs::ServoElementSnapshotTable;
|
||||
use gecko_bindings::structs::ServoStyleSetSizes;
|
||||
use gecko_bindings::structs::SheetParsingMode;
|
||||
use gecko_bindings::structs::StyleBasicShape;
|
||||
use gecko_bindings::structs::StyleBasicShapeType;
|
||||
use gecko_bindings::structs::StyleShapeSource;
|
||||
use gecko_bindings::structs::StyleTransition;
|
||||
|
@ -1220,8 +1219,8 @@ extern "C" {
|
|||
pub fn Gecko_DestroyShapeSource(shape: *mut StyleShapeSource);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_NewBasicShape(type_: StyleBasicShapeType)
|
||||
-> *mut StyleBasicShape;
|
||||
pub fn Gecko_NewBasicShape(shape: *mut StyleShapeSource,
|
||||
type_: StyleBasicShapeType);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_StyleShapeSource_SetURLValue(shape: *mut StyleShapeSource,
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -4912,17 +4912,13 @@ fn static_assert() {
|
|||
${ident}.mType = StyleShapeSourceType::Box;
|
||||
}
|
||||
ShapeSource::Shape(servo_shape, maybe_box) => {
|
||||
${ident}.mReferenceBox = maybe_box.map(Into::into)
|
||||
.unwrap_or(StyleGeometryBox::NoBox);
|
||||
${ident}.mType = StyleShapeSourceType::Shape;
|
||||
|
||||
fn init_shape(${ident}: &mut StyleShapeSource, ty: StyleBasicShapeType) -> &mut StyleBasicShape {
|
||||
fn init_shape(${ident}: &mut StyleShapeSource, basic_shape_type: StyleBasicShapeType)
|
||||
-> &mut StyleBasicShape {
|
||||
unsafe {
|
||||
// We have to be very careful to avoid a copy here!
|
||||
let ref mut union = ${ident}.__bindgen_anon_1;
|
||||
let shape: &mut *mut StyleBasicShape = union.mBasicShape.as_mut();
|
||||
*shape = Gecko_NewBasicShape(ty);
|
||||
&mut **shape
|
||||
// Create StyleBasicShape in StyleShapeSource. mReferenceBox and mType
|
||||
// will be set manually later.
|
||||
Gecko_NewBasicShape(${ident}, basic_shape_type);
|
||||
&mut *${ident}.mBasicShape.mPtr
|
||||
}
|
||||
}
|
||||
match servo_shape {
|
||||
|
@ -4984,6 +4980,10 @@ fn static_assert() {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
${ident}.mReferenceBox = maybe_box.map(Into::into)
|
||||
.unwrap_or(StyleGeometryBox::NoBox);
|
||||
${ident}.mType = StyleShapeSourceType::Shape;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue