зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1841330 - Use CustomIdent for GridLine. r=emilio
So we can avoid calling clone() in to_css(). Differential Revision: https://phabricator.services.mozilla.com/D193838
This commit is contained in:
Родитель
513ac4c5d7
Коммит
d19e95ee2e
|
@ -5019,7 +5019,7 @@ void nsGridContainerFrame::Grid::PlaceGridItems(
|
|||
// name of the lines, knowing that the line placement algorithm will
|
||||
// add the -start and -end suffixes as appropriate for layout.
|
||||
StyleGridLine lineStartAndEnd;
|
||||
lineStartAndEnd.ident = areaInfo.name;
|
||||
lineStartAndEnd.ident._0 = areaInfo.name;
|
||||
|
||||
LineRange columnLines =
|
||||
ResolveLineRange(lineStartAndEnd, lineStartAndEnd, colLineNameMap,
|
||||
|
|
|
@ -475,7 +475,7 @@ StyleGradient::ColorInterpolationMethod() const {
|
|||
|
||||
template <typename Integer>
|
||||
inline StyleGenericGridLine<Integer>::StyleGenericGridLine()
|
||||
: ident(do_AddRef(static_cast<nsAtom*>(nsGkAtoms::_empty))),
|
||||
: ident{StyleAtom(do_AddRef(static_cast<nsAtom*>(nsGkAtoms::_empty)))},
|
||||
line_num(0),
|
||||
is_span(false) {}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::values::specified;
|
||||
use crate::values::{CSSFloat, CustomIdent};
|
||||
use crate::{Atom, One, Zero};
|
||||
use crate::{One, Zero};
|
||||
use cssparser::Parser;
|
||||
use std::fmt::{self, Write};
|
||||
use std::{cmp, usize};
|
||||
|
@ -40,7 +40,7 @@ pub struct GenericGridLine<Integer> {
|
|||
/// A custom identifier for named lines, or the empty atom otherwise.
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-grid/#grid-placement-slot>
|
||||
pub ident: Atom,
|
||||
pub ident: CustomIdent,
|
||||
/// Denotes the nth grid line from grid item's placement.
|
||||
///
|
||||
/// This is clamped by MIN_GRID_LINE and MAX_GRID_LINE.
|
||||
|
@ -64,18 +64,18 @@ where
|
|||
Self {
|
||||
is_span: false,
|
||||
line_num: Zero::zero(),
|
||||
ident: atom!(""),
|
||||
ident: CustomIdent(atom!("")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check whether this `<grid-line>` represents an `auto` value.
|
||||
pub fn is_auto(&self) -> bool {
|
||||
self.ident == atom!("") && self.line_num.is_zero() && !self.is_span
|
||||
self.ident.0 == atom!("") && self.line_num.is_zero() && !self.is_span
|
||||
}
|
||||
|
||||
/// Check whether this `<grid-line>` represents a `<custom-ident>` value.
|
||||
pub fn is_ident_only(&self) -> bool {
|
||||
self.ident != atom!("") && self.line_num.is_zero() && !self.is_span
|
||||
self.ident.0 != atom!("") && self.line_num.is_zero() && !self.is_span
|
||||
}
|
||||
|
||||
/// Check if `self` makes `other` omittable according to the rules at:
|
||||
|
@ -105,11 +105,11 @@ where
|
|||
|
||||
// 2. `<custom-ident>`
|
||||
if self.is_ident_only() {
|
||||
return CustomIdent(self.ident.clone()).to_css(dest);
|
||||
return self.ident.to_css(dest);
|
||||
}
|
||||
|
||||
// 3. `[ span && [ <integer [1,∞]> || <custom-ident> ] ]`
|
||||
let has_ident = self.ident != atom!("");
|
||||
let has_ident = self.ident.0 != atom!("");
|
||||
if self.is_span {
|
||||
dest.write_str("span")?;
|
||||
debug_assert!(!self.line_num.is_zero() || has_ident);
|
||||
|
@ -125,7 +125,7 @@ where
|
|||
|
||||
if has_ident {
|
||||
dest.write_char(' ')?;
|
||||
CustomIdent(self.ident.clone()).to_css(dest)?;
|
||||
self.ident.to_css(dest)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ where
|
|||
self.line_num.to_css(dest)?;
|
||||
if has_ident {
|
||||
dest.write_char(' ')?;
|
||||
CustomIdent(self.ident.clone()).to_css(dest)?;
|
||||
self.ident.to_css(dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl Parse for GridLine<specified::Integer> {
|
|||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
if !grid_line.line_num.is_zero() || grid_line.ident != atom!("") {
|
||||
if !grid_line.line_num.is_zero() || grid_line.ident.0 != atom!("") {
|
||||
val_before_span = true;
|
||||
}
|
||||
|
||||
|
@ -182,12 +182,12 @@ impl Parse for GridLine<specified::Integer> {
|
|||
cmp::min(value, MAX_GRID_LINE),
|
||||
));
|
||||
} else if let Ok(name) = input.try_parse(|i| CustomIdent::parse(i, &["auto"])) {
|
||||
if val_before_span || grid_line.ident != atom!("") {
|
||||
if val_before_span || grid_line.ident.0 != atom!("") {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
// NOTE(emilio): `span` is consumed above, so we only need to
|
||||
// reject `auto`.
|
||||
grid_line.ident = name.0;
|
||||
grid_line.ident = name;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ impl Parse for GridLine<specified::Integer> {
|
|||
// disallow negative integers for grid spans
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
} else if grid_line.ident == atom!("") {
|
||||
} else if grid_line.ident.0 == atom!("") {
|
||||
// integer could be omitted
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
|
|
@ -508,6 +508,7 @@ impl<A: Debug, B: Debug> Debug for Either<A, B> {
|
|||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
Hash,
|
||||
MallocSizeOf,
|
||||
|
|
Загрузка…
Ссылка в новой задаче