aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/inline.rs
diff options
context:
space:
mode:
authorbors-servo <infra@servo.org>2023-05-04 11:35:25 +0200
committerGitHub <noreply@github.com>2023-05-04 11:35:25 +0200
commit4e37d07ea4f2bba124f78f17873fbb02c66d1cdb (patch)
tree7dc272f33fa36faf34423d42dfa2e4654be09843 /components/layout_2020/flow/inline.rs
parentf29834608aee21c1845737067c16f92adfb77f08 (diff)
parent72302e2dae6c4726ae657f7b5b8b048f9f64ccf2 (diff)
downloadservo-4e37d07ea4f2bba124f78f17873fbb02c66d1cdb.tar.gz
servo-4e37d07ea4f2bba124f78f17873fbb02c66d1cdb.zip
Auto merge of #29699 - mrobinson:add-html-body-tag, r=mukilan
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. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because it does not change behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/layout_2020/flow/inline.rs')
-rw-r--r--components/layout_2020/flow/inline.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs
index 498a63e88b0..740c34cf7c0 100644
--- a/components/layout_2020/flow/inline.rs
+++ b/components/layout_2020/flow/inline.rs
@@ -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,