style: Don't restrict alignment shorthand parsing now that's not ambiguous.

Bug: 1339656
Reviewed-by: mats
MozReview-Commit-ID: AnYBt6zwnPl
This commit is contained in:
Emilio Cobos Álvarez 2018-03-31 02:37:39 +02:00
parent 7f3b9ca013
commit 725943f383
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 29 additions and 67 deletions

View file

@ -139,6 +139,12 @@ impl ContentDistribution {
Self::new(AlignFlags::NORMAL)
}
/// `start`
#[inline]
pub fn start() -> Self {
Self::new(AlignFlags::START)
}
/// The initial value 'normal'
#[inline]
pub fn new(primary: AlignFlags) -> Self {
@ -155,19 +161,12 @@ impl ContentDistribution {
self.primary.bits() as u16
}
/// Returns whether this value is valid for both axis directions.
pub fn is_valid_on_both_axes(&self) -> bool {
match self.primary.value() {
// <baseline-position> is only allowed on the block axis.
AlignFlags::BASELINE |
AlignFlags::LAST_BASELINE => false,
// left | right are only allowed on the inline axis.
AlignFlags::LEFT |
AlignFlags::RIGHT => false,
_ => true,
}
/// Returns whether this value is a <baseline-position>.
pub fn is_baseline_position(&self) -> bool {
matches!(
self.primary.value(),
AlignFlags::BASELINE | AlignFlags::LAST_BASELINE
)
}
/// The primary alignment
@ -176,12 +175,6 @@ impl ContentDistribution {
self.primary
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.primary().intersects(AlignFlags::FLAG_BITS)
}
/// Parse a value for align-content / justify-content.
pub fn parse<'i, 't>(
input: &mut Parser<'i, 't>,
@ -309,12 +302,6 @@ impl SelfAlignment {
}
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.0.intersects(AlignFlags::FLAG_BITS)
}
/// Parse a self-alignment value on one of the axis.
pub fn parse<'i, 't>(
input: &mut Parser<'i, 't>,
@ -402,12 +389,6 @@ impl AlignItems {
pub fn normal() -> Self {
AlignItems(AlignFlags::NORMAL)
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.0.intersects(AlignFlags::FLAG_BITS)
}
}
@ -449,12 +430,6 @@ impl JustifyItems {
pub fn normal() -> Self {
JustifyItems(AlignFlags::NORMAL)
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.0.intersects(AlignFlags::FLAG_BITS)
}
}
impl Parse for JustifyItems {