mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
layout: Convert layout internal display to inline for replaced elements (#31133)
Replaced elements should never be able to have a layout internal display, according to the specification. This change makes it so that the used value of replaced element's display is always inline, as the specification says.
This commit is contained in:
parent
890588945d
commit
54fb381a0a
5 changed files with 22 additions and 79 deletions
|
@ -172,6 +172,7 @@ fn traverse_element<'dom, Node>(
|
||||||
},
|
},
|
||||||
Display::GeneratingBox(display) => {
|
Display::GeneratingBox(display) => {
|
||||||
let contents = replaced.map_or(Contents::OfElement, Contents::Replaced);
|
let contents = replaced.map_or(Contents::OfElement, Contents::Replaced);
|
||||||
|
let display = display.used_value_for_contents(&contents);
|
||||||
let box_slot = element.element_box_slot();
|
let box_slot = element.element_box_slot();
|
||||||
let info = NodeAndStyleInfo::new(element, style);
|
let info = NodeAndStyleInfo::new(element, style);
|
||||||
handler.handle_element(&info, display, contents, box_slot);
|
handler.handle_element(&info, display, contents, box_slot);
|
||||||
|
|
|
@ -21,6 +21,7 @@ use style::values::specified::{box_ as stylo, Overflow};
|
||||||
use style::Zero;
|
use style::Zero;
|
||||||
use webrender_api as wr;
|
use webrender_api as wr;
|
||||||
|
|
||||||
|
use crate::dom_traversal::Contents;
|
||||||
use crate::geom::{
|
use crate::geom::{
|
||||||
LengthOrAuto, LengthPercentageOrAuto, LogicalSides, LogicalVec2, PhysicalSides, PhysicalSize,
|
LengthOrAuto, LengthPercentageOrAuto, LogicalSides, LogicalVec2, PhysicalSides, PhysicalSize,
|
||||||
};
|
};
|
||||||
|
@ -52,6 +53,23 @@ impl DisplayGeneratingBox {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn used_value_for_contents(&self, contents: &Contents) -> Self {
|
||||||
|
// From <https://www.w3.org/TR/css-display-3/#layout-specific-display>:
|
||||||
|
// > When the display property of a replaced element computes to one of
|
||||||
|
// > the layout-internal values, it is handled as having a used value of
|
||||||
|
// > inline.
|
||||||
|
if matches!(self, Self::LayoutInternal(_)) && contents.is_replaced() {
|
||||||
|
Self::OutsideInside {
|
||||||
|
outside: DisplayOutside::Inline,
|
||||||
|
inside: DisplayInside::Flow {
|
||||||
|
is_list_item: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*self
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||||
|
|
|
@ -679,7 +679,7 @@ where
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
Err(_replaced) => {
|
Err(_replaced) => {
|
||||||
panic!("We don't handle this yet.");
|
unreachable!("Replaced should not have a LayoutInternal display type.");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
[table-anonymous-objects-211.xht]
|
[table-anonymous-objects-211.xht]
|
||||||
expected: CRASH
|
expected: FAIL
|
||||||
|
|
|
@ -1,85 +1,9 @@
|
||||||
[table-model-fixup-2.html]
|
[table-model-fixup-2.html]
|
||||||
expected: CRASH
|
|
||||||
[Replaced elements inside a table cannot be table-row and are considered inline -- input elements (top)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-row and are considered inline -- img elements (top)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-column and are considered inline -- input elements (width)]
|
[Replaced elements inside a table cannot be table-column and are considered inline -- input elements (width)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-column and are considered inline -- input elements (top)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-column and are considered inline -- img elements (top)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-cell and are considered inline -- input elements (width)]
|
[Replaced elements inside a table cannot be table-cell and are considered inline -- input elements (width)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-cell and are considered inline -- input elements (top)]
|
[Replaced elements inside a table cannot be table-row and are considered inline -- input elements (width)]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements inside a table cannot be table-cell and are considered inline -- img elements (top)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row and are considered inline -- input=text elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row and are considered inline -- input=button elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row and are considered inline -- input=file elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row and are considered inline -- img elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row-group and are considered inline -- input=text elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row-group and are considered inline -- input=button elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row-group and are considered inline -- input=file elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-row-group and are considered inline -- img elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-column and are considered inline inline -- input=text elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-column and are considered inline -- input=button elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-column and are considered inline -- input=file elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-column and are considered inline -- img elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-cell and are considered inline -- input=text elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-cell and are considered inline -- input=button elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-cell and are considered inline -- input=file elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-cell and are considered inline -- img elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-caption and are considered inline -- input=text elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-caption and are considered inline -- input=button elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-caption and are considered inline -- input=file elements]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Replaced elements outside a table cannot be table-caption and are considered inline -- img elements]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue