mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 20:01:50 +00:00
Bug 1918673: Make parsing of position-try-fallbacks
order-dependent. r=firefox-style-system-reviewers,emilio
Spec currently says canonical order, but this should not be the case (See bug 1918670). Differential Revision: https://phabricator.services.mozilla.com/D222296
This commit is contained in:
parent
d7bb863b88
commit
c90c9255df
@ -495,6 +495,7 @@ impl PositionAnchor {
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
@ -506,19 +507,71 @@ impl PositionAnchor {
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[css(bitflags(mixed = "flip-block,flip-inline,flip-start"))]
|
||||
#[repr(u8)]
|
||||
/// How to swap values for the automatically-generated position tactic.
|
||||
pub enum PositionTryFallbacksTryTacticKeyword {
|
||||
/// Magic value for no change.
|
||||
#[css(skip)]
|
||||
#[default]
|
||||
None,
|
||||
/// Swap the values in the block axis.
|
||||
FlipBlock,
|
||||
/// Swap the values in the inline axis.
|
||||
FlipInline,
|
||||
/// Swap the values in the start properties.
|
||||
FlipStart,
|
||||
}
|
||||
|
||||
impl PositionTryFallbacksTryTacticKeyword {
|
||||
fn is_none(&self) -> bool {
|
||||
*self == Self::None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
Serialize,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(C)]
|
||||
/// Changes for the automatically-generated position option.
|
||||
/// Note that this is order-dependent - e.g. `flip-start flip-inline` != `flip-inline flip-start`.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic
|
||||
/// <try-tactic>
|
||||
pub struct PositionTryFallbacksTryTactic(u8);
|
||||
bitflags! {
|
||||
impl PositionTryFallbacksTryTactic: u8 {
|
||||
/// `flip-block`
|
||||
const FLIP_BLOCK = 1 << 0;
|
||||
/// `flip-inline`
|
||||
const FLIP_INLINE = 1 << 1;
|
||||
/// `flip-start`
|
||||
const FLIP_START = 1 << 2;
|
||||
pub struct PositionTryFallbacksTryTactic(
|
||||
pub PositionTryFallbacksTryTacticKeyword,
|
||||
pub PositionTryFallbacksTryTacticKeyword,
|
||||
pub PositionTryFallbacksTryTacticKeyword,
|
||||
);
|
||||
|
||||
impl Parse for PositionTryFallbacksTryTactic {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let first = input.try_parse(PositionTryFallbacksTryTacticKeyword::parse)?;
|
||||
let second = input.try_parse(PositionTryFallbacksTryTacticKeyword::parse).unwrap_or_default();
|
||||
let third = input.try_parse(PositionTryFallbacksTryTacticKeyword::parse).unwrap_or_default();
|
||||
if first == second || first == third || (!second.is_none() && second == third) {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok(Self(first, second, third))
|
||||
}
|
||||
}
|
||||
|
||||
impl PositionTryFallbacksTryTactic {
|
||||
fn is_empty(&self) -> bool {
|
||||
self.0.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,7 +603,7 @@ impl Parse for DashedIdentAndOrTryTactic {
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let mut result = Self {
|
||||
ident: DashedIdent::empty(),
|
||||
try_tactic: PositionTryFallbacksTryTactic::empty(),
|
||||
try_tactic: PositionTryFallbacksTryTactic::default(),
|
||||
};
|
||||
|
||||
loop {
|
||||
|
@ -1,3 +0,0 @@
|
||||
[position-try-fallbacks-computed.html]
|
||||
[Property position-try-fallbacks value 'flip-start flip-inline flip-block']
|
||||
expected: FAIL
|
@ -1,9 +0,0 @@
|
||||
[position-try-fallbacks-parsing.html]
|
||||
[e.style['position-try-fallbacks'\] = "flip-start flip-inline, flip-block" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['position-try-fallbacks'\] = "flip-start flip-inline flip-block" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['position-try-fallbacks'\] = "--bar flip-inline flip-block" should set the property value]
|
||||
expected: FAIL
|
@ -1,6 +0,0 @@
|
||||
[position-try-parsing.html]
|
||||
[e.style['position-try'\] = "most-block-size flip-inline flip-block, --bar, --baz" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['position-try'\] = "most-inline-size flip-inline flip-block, --foo, --bar" should set position-try-fallbacks]
|
||||
expected: FAIL
|
@ -1,5 +1,4 @@
|
||||
[try-tactic-basic.html]
|
||||
expected: ERROR
|
||||
[--pf flip-block]
|
||||
expected: FAIL
|
||||
|
||||
@ -23,3 +22,27 @@
|
||||
|
||||
[--pf]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-inline flip-block]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-block flip-start flip-inline]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-inline flip-start flip-block]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-start flip-block]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-start flip-inline]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-start flip-block flip-inline]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-start flip-inline flip-block]
|
||||
expected: FAIL
|
||||
|
||||
[--pf flip-inline flip-block flip-start]
|
||||
expected: FAIL
|
||||
|
Loading…
x
Reference in New Issue
Block a user