mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Allow layouts to customize their used style (#35012)
Some layouts like table need some style overrides. We were handling this in `ComputedValuesExt`, but it was messy, unreliable and too limited. For example, we were assuming that a style with `display: table` would belong to a table wrapper box or table grid box. However, certain HTML elements can ignore their `display` value and generate a different kind of box. I think we aren't doing that yet, but we will need this. Also, resolving the used border of a table needs layout information, which we don't have in `ComputedValuesExt`. This patch will allow to improve border collapsing in a follow-up. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
7e7792dfbd
commit
60dc3b26fb
11 changed files with 368 additions and 238 deletions
|
@ -15,7 +15,7 @@ use crate::context::LayoutContext;
|
|||
use crate::dom::NodeExt;
|
||||
use crate::dom_traversal::NodeAndStyleInfo;
|
||||
use crate::fragment_tree::BaseFragmentInfo;
|
||||
use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin};
|
||||
use crate::style_ext::{LayoutStyle, PaddingBorderMargin};
|
||||
use crate::ContainingBlock;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -52,6 +52,11 @@ impl InlineBox {
|
|||
..*self
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
LayoutStyle::Default(&self.style)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -214,7 +219,9 @@ impl InlineBoxContainerState {
|
|||
font_metrics: Option<&FontMetrics>,
|
||||
) -> Self {
|
||||
let style = inline_box.style.clone();
|
||||
let pbm = style.padding_border_margin(containing_block);
|
||||
let pbm = inline_box
|
||||
.layout_style()
|
||||
.padding_border_margin(containing_block);
|
||||
|
||||
let mut flags = InlineContainerStateFlags::empty();
|
||||
if inline_container_needs_strut(&style, layout_context, Some(&pbm)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue