зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #17929 - Make grid-template-areas/columns/rows animatable (from dadaa:make-grid-template-XX-animatable); r=hiro,waffles
<!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes. The test code is patch 4 in https://bugzilla.mozilla.org/show_bug.cgi?id=1379922 <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 4d71eed8988ac6f2d1cfe740376eb4ecd31aecd3 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 236315e70cc9878c67282a2518183d3f813b439c
This commit is contained in:
Родитель
b440b8b98a
Коммит
21bd6b2f7a
|
@ -810,7 +810,8 @@ impl TrackSize<LengthOrPercentage> {
|
|||
|
||||
if gecko_min.unit() == nsStyleUnit::eStyleUnit_None {
|
||||
debug_assert!(gecko_max.unit() == nsStyleUnit::eStyleUnit_Coord ||
|
||||
gecko_max.unit() == nsStyleUnit::eStyleUnit_Percent);
|
||||
gecko_max.unit() == nsStyleUnit::eStyleUnit_Percent ||
|
||||
gecko_max.unit() == nsStyleUnit::eStyleUnit_Calc);
|
||||
return TrackSize::FitContent(LengthOrPercentage::from_gecko_style_coord(gecko_max)
|
||||
.expect("gecko_max could not convert to LengthOrPercentage"));
|
||||
}
|
||||
|
|
|
@ -1683,6 +1683,97 @@ fn static_assert() {
|
|||
pub fn reset_grid_template_${kind}(&mut self, other: &Self) {
|
||||
self.copy_grid_template_${kind}_from(other)
|
||||
}
|
||||
|
||||
pub fn clone_grid_template_${kind}(&self) -> longhands::grid_template_${kind}::computed_value::T {
|
||||
<% self_grid = "self.gecko.mGridTemplate%s" % kind.title() %>
|
||||
use Atom;
|
||||
use gecko_bindings::structs::nsTArray;
|
||||
use nsstring::nsStringRepr;
|
||||
use values::CustomIdent;
|
||||
use values::generics::grid::{GridTemplateComponent, LineNameList, RepeatCount};
|
||||
use values::generics::grid::{TrackList, TrackListType, TrackRepeat, TrackSize};
|
||||
|
||||
if ${self_grid}.mRepeatAutoLineNameListBefore.len() == 0 &&
|
||||
${self_grid}.mRepeatAutoLineNameListAfter.len() == 0 &&
|
||||
${self_grid}.mMinTrackSizingFunctions.len() == 0 &&
|
||||
${self_grid}.mMaxTrackSizingFunctions.len() == 0 &&
|
||||
${self_grid}.mLineNameLists.len() == 0 &&
|
||||
${self_grid}.mRepeatAutoIndex == -1 &&
|
||||
!${self_grid}.mIsAutoFill() &&
|
||||
!${self_grid}.mIsSubgrid() {
|
||||
return GridTemplateComponent::None;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_boxed_customident_slice(gecko_names: &nsTArray<nsStringRepr>) -> Box<[CustomIdent]> {
|
||||
let idents: Vec<CustomIdent> = gecko_names.iter().map(|gecko_name| {
|
||||
CustomIdent(Atom::from(gecko_name.to_string()))
|
||||
}).collect();
|
||||
idents.into_boxed_slice()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_line_names_vec(gecko_line_names: &nsTArray<nsTArray<nsStringRepr>>)
|
||||
-> Vec<Box<[CustomIdent]>> {
|
||||
gecko_line_names.iter().map(|gecko_names| {
|
||||
to_boxed_customident_slice(gecko_names)
|
||||
}).collect()
|
||||
}
|
||||
|
||||
let repeat_auto_index = ${self_grid}.mRepeatAutoIndex as usize;
|
||||
if ${self_grid}.mIsSubgrid() {
|
||||
let mut names_vec = to_line_names_vec(&${self_grid}.mLineNameLists);
|
||||
let fill_idx = if ${self_grid}.mIsAutoFill() {
|
||||
names_vec.insert(
|
||||
repeat_auto_index,
|
||||
to_boxed_customident_slice(&${self_grid}.mRepeatAutoLineNameListBefore));
|
||||
Some(repeat_auto_index as u32)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let names = names_vec.into_boxed_slice();
|
||||
|
||||
GridTemplateComponent::Subgrid(LineNameList{names, fill_idx})
|
||||
} else {
|
||||
let mut auto_repeat = None;
|
||||
let mut list_type = TrackListType::Normal;
|
||||
let line_names = to_line_names_vec(&${self_grid}.mLineNameLists).into_boxed_slice();
|
||||
let mut values = Vec::with_capacity(${self_grid}.mMinTrackSizingFunctions.len());
|
||||
|
||||
let min_max_iter = ${self_grid}.mMinTrackSizingFunctions.iter()
|
||||
.zip(${self_grid}.mMaxTrackSizingFunctions.iter());
|
||||
for (i, (gecko_min, gecko_max)) in min_max_iter.enumerate() {
|
||||
let track_size = TrackSize::from_gecko_style_coords(gecko_min, gecko_max);
|
||||
|
||||
if i == repeat_auto_index {
|
||||
list_type = TrackListType::Auto(repeat_auto_index as u16);
|
||||
|
||||
let count = if ${self_grid}.mIsAutoFill() {
|
||||
RepeatCount::AutoFill
|
||||
} else {
|
||||
RepeatCount::AutoFit
|
||||
};
|
||||
|
||||
let line_names = {
|
||||
let mut vec: Vec<Box<[CustomIdent]>> = Vec::with_capacity(2);
|
||||
vec.push(to_boxed_customident_slice(
|
||||
&${self_grid}.mRepeatAutoLineNameListBefore));
|
||||
vec.push(to_boxed_customident_slice(
|
||||
&${self_grid}.mRepeatAutoLineNameListAfter));
|
||||
vec.into_boxed_slice()
|
||||
};
|
||||
|
||||
let track_sizes = vec!(track_size);
|
||||
|
||||
auto_repeat = Some(TrackRepeat{count, line_names, track_sizes});
|
||||
} else {
|
||||
values.push(track_size);
|
||||
}
|
||||
}
|
||||
|
||||
GridTemplateComponent::TrackList(TrackList{list_type, values, line_names, auto_repeat})
|
||||
}
|
||||
}
|
||||
% endfor
|
||||
|
||||
${impl_simple_type_with_conversion("grid_auto_flow")}
|
||||
|
@ -1726,6 +1817,49 @@ fn static_assert() {
|
|||
pub fn reset_grid_template_areas(&mut self, other: &Self) {
|
||||
self.copy_grid_template_areas_from(other)
|
||||
}
|
||||
|
||||
pub fn clone_grid_template_areas(&self) -> longhands::grid_template_areas::computed_value::T {
|
||||
use properties::longhands::grid_template_areas::{NamedArea, TemplateAreas};
|
||||
use std::ops::Range;
|
||||
use values::None_;
|
||||
|
||||
if self.gecko.mGridTemplateAreas.mRawPtr.is_null() {
|
||||
return Either::Second(None_);
|
||||
}
|
||||
|
||||
let gecko_grid_template_areas = self.gecko.mGridTemplateAreas.mRawPtr;
|
||||
let areas = unsafe {
|
||||
let vec: Vec<NamedArea> =
|
||||
(*gecko_grid_template_areas).mNamedAreas.iter().map(|gecko_name_area| {
|
||||
let name = gecko_name_area.mName.to_string().into_boxed_str();
|
||||
let rows = Range {
|
||||
start: gecko_name_area.mRowStart,
|
||||
end: gecko_name_area.mRowEnd
|
||||
};
|
||||
let columns = Range {
|
||||
start: gecko_name_area.mColumnStart,
|
||||
end: gecko_name_area.mColumnEnd
|
||||
};
|
||||
NamedArea{ name, rows, columns }
|
||||
}).collect();
|
||||
vec.into_boxed_slice()
|
||||
};
|
||||
|
||||
let strings = unsafe {
|
||||
let vec: Vec<Box<str>> =
|
||||
(*gecko_grid_template_areas).mTemplates.iter().map(|gecko_template| {
|
||||
gecko_template.to_string().into_boxed_str()
|
||||
}).collect();
|
||||
vec.into_boxed_slice()
|
||||
};
|
||||
|
||||
let width = unsafe {
|
||||
(*gecko_grid_template_areas).mNColumns
|
||||
};
|
||||
|
||||
Either::First(TemplateAreas{ areas, strings, width })
|
||||
}
|
||||
|
||||
</%self:impl_trait>
|
||||
|
||||
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +
|
||||
|
|
|
@ -282,7 +282,7 @@ ${helpers.predefined_type("object-position",
|
|||
products="gecko",
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
|
||||
boxed=True,
|
||||
animation_value_type="none")}
|
||||
animation_value_type="discrete")}
|
||||
|
||||
% endfor
|
||||
|
||||
|
@ -416,7 +416,7 @@ ${helpers.predefined_type("object-position",
|
|||
<%helpers:longhand name="grid-template-areas"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas"
|
||||
products="gecko"
|
||||
animation_value_type="none"
|
||||
animation_value_type="discrete"
|
||||
disable_when_testing="True"
|
||||
boxed="True">
|
||||
use std::collections::HashMap;
|
||||
|
@ -442,14 +442,14 @@ ${helpers.predefined_type("object-position",
|
|||
SpecifiedValue::parse(context, input)
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct TemplateAreas {
|
||||
pub areas: Box<[NamedArea]>,
|
||||
pub strings: Box<[Box<str>]>,
|
||||
pub width: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct NamedArea {
|
||||
pub name: Box<str>,
|
||||
pub rows: Range<u32>,
|
||||
|
|
Загрузка…
Ссылка в новой задаче