aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/formatting_contexts.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/formatting_contexts.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/formatting_contexts.rs')
-rw-r--r--components/layout_2020/formatting_contexts.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs
index a311eb8a3a2..98326692b27 100644
--- a/components/layout_2020/formatting_contexts.rs
+++ b/components/layout_2020/formatting_contexts.rs
@@ -6,7 +6,8 @@ use crate::context::LayoutContext;
use crate::dom_traversal::{Contents, NodeAndStyleInfo, NodeExt};
use crate::flexbox::FlexContainer;
use crate::flow::BlockFormattingContext;
-use crate::fragments::{Fragment, Tag};
+use crate::fragment_tree::BaseFragmentInfo;
+use crate::fragments::Fragment;
use crate::positioned::PositioningContext;
use crate::replaced::ReplacedContent;
use crate::sizing::{self, ContentSizes};
@@ -28,7 +29,7 @@ pub(crate) enum IndependentFormattingContext {
#[derive(Debug, Serialize)]
pub(crate) struct NonReplacedFormattingContext {
- pub tag: Tag,
+ pub base_fragment_info: BaseFragmentInfo,
#[serde(skip_serializing)]
pub style: Arc<ComputedValues>,
/// If it was requested during construction
@@ -38,7 +39,7 @@ pub(crate) struct NonReplacedFormattingContext {
#[derive(Debug, Serialize)]
pub(crate) struct ReplacedFormattingContext {
- pub tag: Tag,
+ pub base_fragment_info: BaseFragmentInfo,
#[serde(skip_serializing)]
pub style: Arc<ComputedValues>,
pub contents: ReplacedContent,
@@ -63,7 +64,7 @@ pub(crate) struct IndependentLayout {
impl IndependentFormattingContext {
pub fn construct<'dom>(
context: &LayoutContext,
- info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
+ node_and_style_info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
display_inside: DisplayInside,
contents: Contents,
propagated_text_decoration_line: TextDecorationLine,
@@ -76,7 +77,7 @@ impl IndependentFormattingContext {
NonReplacedFormattingContextContents::Flow(
BlockFormattingContext::construct(
context,
- info,
+ node_and_style_info,
non_replaced,
propagated_text_decoration_line,
is_list_item,
@@ -86,37 +87,37 @@ impl IndependentFormattingContext {
DisplayInside::Flex => {
NonReplacedFormattingContextContents::Flex(FlexContainer::construct(
context,
- info,
+ node_and_style_info,
non_replaced,
propagated_text_decoration_line,
))
},
};
Self::NonReplaced(NonReplacedFormattingContext {
- tag: Tag::from_node_and_style_info(info),
- style: Arc::clone(&info.style),
+ base_fragment_info: node_and_style_info.into(),
+ style: Arc::clone(&node_and_style_info.style),
content_sizes: None,
contents,
})
},
Err(contents) => Self::Replaced(ReplacedFormattingContext {
- tag: Tag::from_node_and_style_info(info),
- style: Arc::clone(&info.style),
+ base_fragment_info: node_and_style_info.into(),
+ style: Arc::clone(&node_and_style_info.style),
contents,
}),
}
}
pub fn construct_for_text_runs<'dom>(
- info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
+ node_and_style_info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
runs: impl Iterator<Item = crate::flow::inline::TextRun>,
propagated_text_decoration_line: TextDecorationLine,
) -> Self {
let bfc =
BlockFormattingContext::construct_for_text_runs(runs, propagated_text_decoration_line);
Self::NonReplaced(NonReplacedFormattingContext {
- tag: Tag::from_node_and_style_info(info),
- style: Arc::clone(&info.style),
+ base_fragment_info: node_and_style_info.into(),
+ style: Arc::clone(&node_and_style_info.style),
content_sizes: None,
contents: NonReplacedFormattingContextContents::Flow(bfc),
})
@@ -129,10 +130,10 @@ impl IndependentFormattingContext {
}
}
- pub fn tag(&self) -> Tag {
+ pub fn base_fragment_info(&self) -> BaseFragmentInfo {
match self {
- Self::NonReplaced(inner) => inner.tag,
- Self::Replaced(inner) => inner.tag,
+ Self::NonReplaced(inner) => inner.base_fragment_info,
+ Self::Replaced(inner) => inner.base_fragment_info,
}
}