mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Detect body elements during layout
During layout it is often useful, for various specification reasons, to know if an element is the `<body>` element of an `<html>` element root. There are a couple places where a brittle heuristic is used to detect `<body>` elements. This information is going to be even more important to properly handle `<html>` elements that inherit their overflow property from their `<body>` children. Implementing this properly requires updating the DOM wrapper interface. This check does reach up to the parent of thread-safe nodes, but this is essentially the same kind of operation that `parent_style()` does, so is ostensibly safe. This change should not change any behavior and is just a preparation step for properly handle `<body>` overflow.
This commit is contained in:
parent
77a184a0e7
commit
72302e2dae
26 changed files with 487 additions and 277 deletions
|
@ -7,9 +7,9 @@ use crate::context::LayoutContext;
|
|||
use crate::flow::float::FloatBox;
|
||||
use crate::flow::FlowLayout;
|
||||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::fragment_tree::BaseFragmentInfo;
|
||||
use crate::fragments::{
|
||||
AnonymousFragment, BoxFragment, CollapsedBlockMargins, DebugId, FontMetrics, Fragment, Tag,
|
||||
TextFragment,
|
||||
AnonymousFragment, BoxFragment, CollapsedBlockMargins, FontMetrics, Fragment, TextFragment,
|
||||
};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::positioned::{
|
||||
|
@ -51,7 +51,7 @@ pub(crate) enum InlineLevelBox {
|
|||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub(crate) struct InlineBox {
|
||||
pub tag: Tag,
|
||||
pub base_fragment_info: BaseFragmentInfo,
|
||||
#[serde(skip_serializing)]
|
||||
pub style: Arc<ComputedValues>,
|
||||
pub first_fragment: bool,
|
||||
|
@ -62,7 +62,7 @@ pub(crate) struct InlineBox {
|
|||
/// https://www.w3.org/TR/css-display-3/#css-text-run
|
||||
#[derive(Debug, Serialize)]
|
||||
pub(crate) struct TextRun {
|
||||
pub tag: Tag,
|
||||
pub base_fragment_info: BaseFragmentInfo,
|
||||
#[serde(skip_serializing)]
|
||||
pub parent_style: Arc<ComputedValues>,
|
||||
pub text: String,
|
||||
|
@ -82,7 +82,7 @@ struct InlineNestingLevelState<'box_tree> {
|
|||
}
|
||||
|
||||
struct PartialInlineBoxFragment<'box_tree> {
|
||||
tag: Tag,
|
||||
base_fragment_info: BaseFragmentInfo,
|
||||
style: Arc<ComputedValues>,
|
||||
start_corner: Vec2<Length>,
|
||||
padding: Sides<Length>,
|
||||
|
@ -471,7 +471,7 @@ impl InlineBox {
|
|||
let text_decoration_line =
|
||||
ifc.current_nesting_level.text_decoration_line | style.clone_text_decoration_line();
|
||||
PartialInlineBoxFragment {
|
||||
tag: self.tag,
|
||||
base_fragment_info: self.base_fragment_info,
|
||||
style,
|
||||
start_corner,
|
||||
padding,
|
||||
|
@ -512,7 +512,7 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> {
|
|||
};
|
||||
|
||||
let mut fragment = BoxFragment::new(
|
||||
self.tag,
|
||||
self.base_fragment_info,
|
||||
self.style.clone(),
|
||||
std::mem::take(&mut nesting_level.fragments_so_far),
|
||||
content_rect,
|
||||
|
@ -580,7 +580,7 @@ fn layout_atomic(
|
|||
.make_fragments(&replaced.style, size.clone());
|
||||
let content_rect = Rect { start_corner, size };
|
||||
BoxFragment::new(
|
||||
replaced.tag,
|
||||
replaced.base_fragment_info,
|
||||
replaced.style.clone(),
|
||||
fragments,
|
||||
content_rect,
|
||||
|
@ -655,7 +655,7 @@ fn layout_atomic(
|
|||
},
|
||||
};
|
||||
BoxFragment::new(
|
||||
non_replaced.tag,
|
||||
non_replaced.base_fragment_info,
|
||||
non_replaced.style.clone(),
|
||||
independent_layout.fragments,
|
||||
content_rect,
|
||||
|
@ -836,8 +836,7 @@ impl TextRun {
|
|||
ifc.current_nesting_level
|
||||
.fragments_so_far
|
||||
.push(Fragment::Text(TextFragment {
|
||||
tag: self.tag,
|
||||
debug_id: DebugId::new(),
|
||||
base: self.base_fragment_info.into(),
|
||||
parent_style: self.parent_style.clone(),
|
||||
rect,
|
||||
font_metrics,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue