aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow/inline/inline_box.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/flow/inline/inline_box.rs')
-rw-r--r--components/layout/flow/inline/inline_box.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/components/layout/flow/inline/inline_box.rs b/components/layout/flow/inline/inline_box.rs
index 1c953c13074..b547f3b5935 100644
--- a/components/layout/flow/inline/inline_box.rs
+++ b/components/layout/flow/inline/inline_box.rs
@@ -7,8 +7,15 @@ use std::vec::IntoIter;
use app_units::Au;
use fonts::FontMetrics;
use malloc_size_of_derive::MallocSizeOf;
-
-use super::{InlineContainerState, InlineContainerStateFlags, inline_container_needs_strut};
+use script::layout_dom::ServoLayoutNode;
+use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
+use servo_arc::Arc as ServoArc;
+use style::properties::ComputedValues;
+
+use super::{
+ InlineContainerState, InlineContainerStateFlags, SharedInlineStyles,
+ inline_container_needs_strut,
+};
use crate::ContainingBlock;
use crate::cell::ArcRefCell;
use crate::context::LayoutContext;
@@ -20,6 +27,9 @@ use crate::style_ext::{LayoutStyle, PaddingBorderMargin};
#[derive(Debug, MallocSizeOf)]
pub(crate) struct InlineBox {
pub base: LayoutBoxBase,
+ /// The [`SharedInlineStyles`] for this [`InlineBox`] that are used to share styles
+ /// with all [`super::TextRun`] children.
+ pub(super) shared_inline_styles: SharedInlineStyles,
/// The identifier of this inline box in the containing [`super::InlineFormattingContext`].
pub(super) identifier: InlineBoxIdentifier,
/// Whether or not this is the first instance of an [`InlineBox`] before a possible
@@ -37,6 +47,7 @@ impl InlineBox {
pub(crate) fn new(info: &NodeAndStyleInfo) -> Self {
Self {
base: LayoutBoxBase::new(info.into(), info.style.clone()),
+ shared_inline_styles: info.into(),
// This will be assigned later, when the box is actually added to the IFC.
identifier: InlineBoxIdentifier::default(),
is_first_split: true,
@@ -48,6 +59,7 @@ impl InlineBox {
pub(crate) fn split_around_block(&self) -> Self {
Self {
base: LayoutBoxBase::new(self.base.base_fragment_info, self.base.style.clone()),
+ shared_inline_styles: self.shared_inline_styles.clone(),
is_first_split: false,
is_last_split: false,
..*self
@@ -58,6 +70,16 @@ impl InlineBox {
pub(crate) fn layout_style(&self) -> LayoutStyle {
LayoutStyle::Default(&self.base.style)
}
+
+ pub(crate) fn repair_style(
+ &mut self,
+ node: &ServoLayoutNode,
+ new_style: &ServoArc<ComputedValues>,
+ ) {
+ self.base.repair_style(new_style);
+ *self.shared_inline_styles.style.borrow_mut() = new_style.clone();
+ *self.shared_inline_styles.selected.borrow_mut() = node.to_threadsafe().selected_style();
+ }
}
#[derive(Debug, Default, MallocSizeOf)]