aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/formatting_contexts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout_2020/formatting_contexts.rs')
-rw-r--r--components/layout_2020/formatting_contexts.rs38
1 files changed, 17 insertions, 21 deletions
diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs
index a721b54ba0f..189ec36cb9a 100644
--- a/components/layout_2020/formatting_contexts.rs
+++ b/components/layout_2020/formatting_contexts.rs
@@ -3,10 +3,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::context::LayoutContext;
-use crate::dom_traversal::{Contents, NodeExt};
+use crate::dom_traversal::{Contents, NodeAndStyleInfo, NodeExt};
use crate::flexbox::FlexContainer;
use crate::flow::BlockFormattingContext;
-use crate::fragments::Fragment;
+use crate::fragments::{Fragment, Tag};
use crate::positioned::PositioningContext;
use crate::replaced::ReplacedContent;
use crate::sizing::{BoxContentSizes, ContentSizesRequest};
@@ -14,7 +14,6 @@ use crate::style_ext::DisplayInside;
use crate::ContainingBlock;
use servo_arc::Arc;
use std::convert::TryInto;
-use style::dom::OpaqueNode;
use style::properties::ComputedValues;
use style::values::computed::Length;
use style::values::specified::text::TextDecorationLine;
@@ -22,7 +21,7 @@ use style::values::specified::text::TextDecorationLine;
/// https://drafts.csswg.org/css-display/#independent-formatting-context
#[derive(Debug, Serialize)]
pub(crate) struct IndependentFormattingContext {
- pub tag: OpaqueNode,
+ pub tag: Tag,
#[serde(skip_serializing)]
pub style: Arc<ComputedValues>,
@@ -61,8 +60,7 @@ enum NonReplacedIFCKind<'a> {
impl IndependentFormattingContext {
pub fn construct<'dom>(
context: &LayoutContext,
- node: impl NodeExt<'dom>,
- style: Arc<ComputedValues>,
+ info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
display_inside: DisplayInside,
contents: Contents,
content_sizes: ContentSizesRequest,
@@ -73,15 +71,14 @@ impl IndependentFormattingContext {
DisplayInside::Flow | DisplayInside::FlowRoot => {
let (bfc, content_sizes) = BlockFormattingContext::construct(
context,
- node,
- &style,
+ info,
non_replaced,
content_sizes,
propagated_text_decoration_line,
);
Self {
- tag: node.as_opaque(),
- style,
+ tag: Tag::from_node_and_style_info(info),
+ style: Arc::clone(&info.style),
content_sizes,
contents: IndependentFormattingContextContents::Flow(bfc),
}
@@ -89,25 +86,25 @@ impl IndependentFormattingContext {
DisplayInside::Flex => {
let (fc, content_sizes) = FlexContainer::construct(
context,
- node,
- &style,
+ info,
non_replaced,
content_sizes,
propagated_text_decoration_line,
);
Self {
- tag: node.as_opaque(),
- style,
+ tag: Tag::from_node_and_style_info(info),
+ style: Arc::clone(&info.style),
content_sizes,
contents: IndependentFormattingContextContents::Flex(fc),
}
},
},
Err(replaced) => {
- let content_sizes = content_sizes.compute(|| replaced.inline_content_sizes(&style));
+ let content_sizes =
+ content_sizes.compute(|| replaced.inline_content_sizes(&info.style));
Self {
- tag: node.as_opaque(),
- style,
+ tag: Tag::from_node_and_style_info(info),
+ style: Arc::clone(&info.style),
content_sizes,
contents: IndependentFormattingContextContents::Replaced(replaced),
}
@@ -117,8 +114,7 @@ impl IndependentFormattingContext {
pub fn construct_for_text_runs<'dom>(
context: &LayoutContext,
- node: impl NodeExt<'dom>,
- style: Arc<ComputedValues>,
+ info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
runs: impl Iterator<Item = crate::flow::inline::TextRun>,
content_sizes: ContentSizesRequest,
propagated_text_decoration_line: TextDecorationLine,
@@ -130,8 +126,8 @@ impl IndependentFormattingContext {
propagated_text_decoration_line,
);
Self {
- tag: node.as_opaque(),
- style,
+ tag: Tag::from_node_and_style_info(info),
+ style: Arc::clone(&info.style),
content_sizes,
contents: IndependentFormattingContextContents::Flow(bfc),
}