mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fix parsing of "center left" in parse_origin (fixes #15750)
This commit is contained in:
parent
bb66bf81d5
commit
ff2cf2c62f
2 changed files with 24 additions and 2 deletions
|
@ -439,7 +439,7 @@ pub struct OriginParseResult {
|
|||
|
||||
pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<OriginParseResult,()> {
|
||||
use values::specified::{LengthOrPercentage, Percentage};
|
||||
let (mut horizontal, mut vertical, mut depth) = (None, None, None);
|
||||
let (mut horizontal, mut vertical, mut depth, mut horizontal_is_center) = (None, None, None, false);
|
||||
loop {
|
||||
if let Err(_) = input.try(|input| {
|
||||
let token = try!(input.expect_ident());
|
||||
|
@ -448,12 +448,16 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<Origi
|
|||
"left" => {
|
||||
if horizontal.is_none() {
|
||||
horizontal = Some(LengthOrPercentage::Percentage(Percentage(0.0)))
|
||||
} else if horizontal_is_center && vertical.is_none() {
|
||||
vertical = Some(LengthOrPercentage::Percentage(Percentage(0.5)));
|
||||
horizontal = Some(LengthOrPercentage::Percentage(Percentage(0.0)));
|
||||
} else {
|
||||
return Err(())
|
||||
}
|
||||
},
|
||||
"center" => {
|
||||
if horizontal.is_none() {
|
||||
horizontal_is_center = true;
|
||||
horizontal = Some(LengthOrPercentage::Percentage(Percentage(0.5)))
|
||||
} else if vertical.is_none() {
|
||||
vertical = Some(LengthOrPercentage::Percentage(Percentage(0.5)))
|
||||
|
@ -464,6 +468,9 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<Origi
|
|||
"right" => {
|
||||
if horizontal.is_none() {
|
||||
horizontal = Some(LengthOrPercentage::Percentage(Percentage(1.0)))
|
||||
} else if horizontal_is_center && vertical.is_none() {
|
||||
vertical = Some(LengthOrPercentage::Percentage(Percentage(0.5)));
|
||||
horizontal = Some(LengthOrPercentage::Percentage(Percentage(1.0)));
|
||||
} else {
|
||||
return Err(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue