mirror of
https://github.com/servo/servo.git
synced 2025-08-25 07:08:21 +01:00
Switch to GridTemplateComponent for subgrid line names
This commit is contained in:
parent
8af912200c
commit
9d9d99ec25
9 changed files with 144 additions and 38 deletions
|
@ -1244,7 +1244,7 @@ fn static_assert() {
|
|||
use std::usize;
|
||||
use values::CustomIdent;
|
||||
use values::generics::grid::TrackListType::Auto;
|
||||
use values::generics::grid::{RepeatCount, TrackSize};
|
||||
use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackSize};
|
||||
|
||||
#[inline]
|
||||
fn set_line_names(servo_names: &[CustomIdent], gecko_names: &mut nsTArray<nsStringRepr>) {
|
||||
|
@ -1280,10 +1280,11 @@ fn static_assert() {
|
|||
${self_grid}.mRepeatAutoIndex = -1;
|
||||
${self_grid}.set_mIsAutoFill(false);
|
||||
${self_grid}.set_mIsSubgrid(false);
|
||||
// FIXME: mIsSubgrid is false only for <none>, but we don't support subgrid name lists at the moment.
|
||||
|
||||
let max_lines = nsStyleGridLine_kMaxLine as usize - 1; // for accounting the final <line-names>
|
||||
|
||||
match v {
|
||||
Either::First(track) => {
|
||||
GridTemplateComponent::TrackList(track) => {
|
||||
let mut auto_idx = usize::MAX;
|
||||
let mut auto_track_size = None;
|
||||
if let Auto(idx) = track.list_type {
|
||||
|
@ -1314,7 +1315,6 @@ fn static_assert() {
|
|||
num_values += 1;
|
||||
}
|
||||
|
||||
let max_lines = nsStyleGridLine_kMaxLine as usize - 1; // for accounting the final <line-names>
|
||||
num_values = cmp::min(num_values, max_lines);
|
||||
unsafe {
|
||||
bindings::Gecko_SetStyleGridTemplateArrayLengths(&mut ${self_grid}, num_values as u32);
|
||||
|
@ -1341,7 +1341,7 @@ fn static_assert() {
|
|||
let final_names = line_names.next().unwrap();
|
||||
set_line_names(&final_names, ${self_grid}.mLineNameLists.last_mut().unwrap());
|
||||
},
|
||||
Either::Second(_none) => {
|
||||
GridTemplateComponent::None => {
|
||||
unsafe {
|
||||
bindings::Gecko_SetStyleGridTemplateArrayLengths(&mut ${self_grid}, 0);
|
||||
bindings::Gecko_ResizeTArrayForStrings(
|
||||
|
@ -1350,6 +1350,27 @@ fn static_assert() {
|
|||
&mut ${self_grid}.mRepeatAutoLineNameListAfter, 0);
|
||||
}
|
||||
},
|
||||
GridTemplateComponent::Subgrid(list) => {
|
||||
${self_grid}.set_mIsSubgrid(true);
|
||||
let num_values = cmp::min(list.names.len(), max_lines + 1);
|
||||
unsafe {
|
||||
bindings::Gecko_SetStyleGridTemplateArrayLengths(&mut ${self_grid}, 0);
|
||||
bindings::Gecko_SetGridTemplateLineNamesLength(&mut ${self_grid}, num_values as u32);
|
||||
bindings::Gecko_ResizeTArrayForStrings(
|
||||
&mut ${self_grid}.mRepeatAutoLineNameListBefore, 0);
|
||||
bindings::Gecko_ResizeTArrayForStrings(
|
||||
&mut ${self_grid}.mRepeatAutoLineNameListAfter, 0);
|
||||
}
|
||||
|
||||
if let Some(idx) = list.fill_idx {
|
||||
${self_grid}.set_mIsAutoFill(true);
|
||||
${self_grid}.mRepeatAutoIndex = idx as i16;
|
||||
}
|
||||
|
||||
for (servo_names, gecko_names) in list.names.iter().zip(${self_grid}.mLineNameLists.iter_mut()) {
|
||||
set_line_names(servo_names, gecko_names);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue