mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
stylo: Implement scroll-snap-coordinate
MozReview-Commit-ID: 6mr4ktfeEGT
This commit is contained in:
parent
a095565a8c
commit
20796ee94e
4 changed files with 62 additions and 4 deletions
|
@ -93,4 +93,13 @@ impl<T> nsTArray<T> {
|
||||||
let mut header = self.header_mut();
|
let mut header = self.header_mut();
|
||||||
header.mLength = len;
|
header.mLength = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resizes an array containing only POD elements
|
||||||
|
///
|
||||||
|
/// This will not leak since it only works on POD types (and thus doesn't assert)
|
||||||
|
pub unsafe fn set_len_pod(&mut self, len: u32) where T: Copy {
|
||||||
|
self.ensure_capacity(len as usize);
|
||||||
|
let mut header = unsafe { self.header_mut() };
|
||||||
|
header.mLength = len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1169,7 +1169,8 @@ fn static_assert() {
|
||||||
animation-iteration-count animation-timing-function
|
animation-iteration-count animation-timing-function
|
||||||
-moz-binding page-break-before page-break-after
|
-moz-binding page-break-before page-break-after
|
||||||
scroll-snap-points-x scroll-snap-points-y transform
|
scroll-snap-points-x scroll-snap-points-y transform
|
||||||
scroll-snap-type-y scroll-snap-destination perspective-origin transform-origin""" %>
|
scroll-snap-type-y scroll-snap-destination scroll-snap-coordinate
|
||||||
|
perspective-origin transform-origin""" %>
|
||||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||||
|
|
||||||
// We manually-implement the |display| property until we get general
|
// We manually-implement the |display| property until we get general
|
||||||
|
@ -1347,6 +1348,34 @@ fn static_assert() {
|
||||||
|
|
||||||
${impl_simple_copy('scroll_snap_destination', 'mScrollSnapDestination')}
|
${impl_simple_copy('scroll_snap_destination', 'mScrollSnapDestination')}
|
||||||
|
|
||||||
|
pub fn set_scroll_snap_coordinate(&mut self, v: longhands::scroll_snap_coordinate::computed_value::T) {
|
||||||
|
unsafe { self.gecko.mScrollSnapCoordinate.set_len_pod(v.0.len() as u32); }
|
||||||
|
for (gecko, servo) in self.gecko.mScrollSnapCoordinate
|
||||||
|
.iter_mut()
|
||||||
|
.zip(v.0.iter()) {
|
||||||
|
gecko.mXPosition = servo.horizontal.into();
|
||||||
|
gecko.mYPosition = servo.vertical.into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_scroll_snap_coordinate_from(&mut self, other: &Self) {
|
||||||
|
unsafe {
|
||||||
|
self.gecko.mScrollSnapCoordinate
|
||||||
|
.set_len_pod(other.gecko.mScrollSnapCoordinate.len() as u32);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (this, that) in self.gecko.mScrollSnapCoordinate
|
||||||
|
.iter_mut()
|
||||||
|
.zip(other.gecko.mScrollSnapCoordinate.iter()) {
|
||||||
|
*this = *that;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clone_scroll_snap_coordinate(&self) -> longhands::scroll_snap_coordinate::computed_value::T {
|
||||||
|
let vec = self.gecko.mScrollSnapCoordinate.iter().map(|f| f.into()).collect();
|
||||||
|
longhands::scroll_snap_coordinate::computed_value::T(vec)
|
||||||
|
}
|
||||||
|
|
||||||
<%def name="transform_function_arm(name, keyword, items)">
|
<%def name="transform_function_arm(name, keyword, items)">
|
||||||
<%
|
<%
|
||||||
pattern = None
|
pattern = None
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
</%call>
|
</%call>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="predefined_type(name, type, initial_value, parse_method='parse', needs_context=True, **kwargs)">
|
<%def name="predefined_type(name, type, initial_value, parse_method='parse',
|
||||||
<%call expr="longhand(name, predefined_type=type, **kwargs)">
|
needs_context=True, vector=False, **kwargs)">
|
||||||
|
<%def name="predefined_type_inner(name, type, initial_value, parse_method)">
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Color as CSSParserColor, RGBA};
|
use cssparser::{Color as CSSParserColor, RGBA};
|
||||||
|
@ -40,7 +41,16 @@
|
||||||
specified::${type}::${parse_method}(input)
|
specified::${type}::${parse_method}(input)
|
||||||
% endif
|
% endif
|
||||||
}
|
}
|
||||||
</%call>
|
</%def>
|
||||||
|
% if vector:
|
||||||
|
<%call expr="vector_longhand(name, predefined_type=type, **kwargs)">
|
||||||
|
${predefined_type_inner(name, type, initial_value, parse_method)}
|
||||||
|
</%call>
|
||||||
|
% else:
|
||||||
|
<%call expr="longhand(name, predefined_type=type, **kwargs)">
|
||||||
|
${predefined_type_inner(name, type, initial_value, parse_method)}
|
||||||
|
</%call>
|
||||||
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
// FIXME (Manishearth): Add computed_value_as_specified argument
|
// FIXME (Manishearth): Add computed_value_as_specified argument
|
||||||
|
|
|
@ -1056,6 +1056,16 @@ ${helpers.predefined_type("scroll-snap-destination",
|
||||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
||||||
animatable=False)}
|
animatable=False)}
|
||||||
|
|
||||||
|
${helpers.predefined_type("scroll-snap-coordinate",
|
||||||
|
"Position",
|
||||||
|
"computed::Position::zero()",
|
||||||
|
vector=True,
|
||||||
|
products="gecko",
|
||||||
|
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
||||||
|
animatable=False,
|
||||||
|
allow_empty=True)}
|
||||||
|
|
||||||
|
|
||||||
<%helpers:longhand name="transform" products="gecko servo" extra_prefixes="webkit"
|
<%helpers:longhand name="transform" products="gecko servo" extra_prefixes="webkit"
|
||||||
animatable="True"
|
animatable="True"
|
||||||
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
|
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue