mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Cleanup position and make use of generic Position for its users
This commit is contained in:
parent
3f53fb148d
commit
61a17993eb
10 changed files with 277 additions and 677 deletions
|
@ -376,17 +376,17 @@ fn color_to_nscolor_zero_currentcolor(color: Color) -> structs::nscolor {
|
|||
<%def name="impl_position(ident, gecko_ffi_name, need_clone=False)">
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
${set_gecko_property("%s.mXPosition" % gecko_ffi_name, "v.horizontal.into()")}
|
||||
${set_gecko_property("%s.mYPosition" % gecko_ffi_name, "v.vertical.into()")}
|
||||
${set_gecko_property("%s.mXPosition" % gecko_ffi_name, "v.horizontal.0.into()")}
|
||||
${set_gecko_property("%s.mYPosition" % gecko_ffi_name, "v.vertical.0.into()")}
|
||||
}
|
||||
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
|
||||
% if need_clone:
|
||||
#[allow(non_snake_case)]
|
||||
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
use values::computed::Position;
|
||||
use values::generics::position::{HorizontalPosition, Position, VerticalPosition};
|
||||
Position {
|
||||
horizontal: self.gecko.${gecko_ffi_name}.mXPosition.into(),
|
||||
vertical: self.gecko.${gecko_ffi_name}.mYPosition.into(),
|
||||
horizontal: HorizontalPosition(self.gecko.${gecko_ffi_name}.mXPosition.into()),
|
||||
vertical: VerticalPosition(self.gecko.${gecko_ffi_name}.mYPosition.into()),
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
@ -1947,8 +1947,8 @@ fn static_assert() {
|
|||
for (gecko, servo) in self.gecko.mScrollSnapCoordinate
|
||||
.iter_mut()
|
||||
.zip(v.0.iter()) {
|
||||
gecko.mXPosition = servo.horizontal.into();
|
||||
gecko.mYPosition = servo.vertical.into();
|
||||
gecko.mXPosition = servo.horizontal.0.into();
|
||||
gecko.mYPosition = servo.vertical.0.into();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2600,7 +2600,7 @@ fn static_assert() {
|
|||
|
||||
pub fn clone_${shorthand}_position_${orientation[0]}(&self)
|
||||
-> longhands::${shorthand}_position_${orientation[0]}::computed_value::T {
|
||||
use values::computed::position::${orientation[1]}Position;
|
||||
use values::generics::position::${orientation[1]}Position;
|
||||
longhands::${shorthand}_position_${orientation[0]}::computed_value::T(
|
||||
self.gecko.${image_layers_field}.mLayers.iter()
|
||||
.take(self.gecko.${image_layers_field}.mPosition${orientation[0].upper()}Count as usize)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue