Repository: servo/servo
File: components/layout/fragment_tree/base_fragment.rs (Rust)

Code before:

/// This data structure stores fields that are common to all non-base
/// Fragment types and should generally be the first member of all
/// concrete fragments.
#[derive(Clone, Debug, MallocSizeOf)]
pub(crate) struct BaseFragment {
    /// A tag which identifies the DOM node and pseudo element of this
    /// Fragment's content. If this fragment is for an anonymous box,
    /// the tag will be None.
    pub tag: Option<Tag>,

    /// Flags which various information about this fragment used during
    /// layout.
    pub flags: FragmentFlags,

    /// The style for this [`BaseFragment`]. Depending on the fragment type this is either
    /// a shared or non-shared style.
    pub style: BaseFragmentStyle,

    /// The content rect of this fragment in the parent fragment's content rectangle. This
    /// does not include padding, border, or margin -- it only includes content. This is
    /// relative to the parent containing block.
    pub rect: PhysicalRect<Au>,

    pub status: FragmentStatus,
}

impl BaseFragment {
    pub(crate) fn new(
        base_fragment_info: BaseFragmentInfo,
        style: BaseFragmentStyle,
        rect: PhysicalRect<Au>,
    ) -> Self {
        Self {
            tag: base_fragment_info.tag,
            flags: base_fragment_info.flags,
            style,
            rect,
            status: Default::default(),
        }
    }

    pub(crate) fn is_anonymous(&self) -> bool {
        self.tag.is_none()
    }

    pub(crate) fn repair_style(&mut self, style: &ServoArc<ComputedValues>) {
        self.style = style.clone().into();
        self.status = FragmentStatus::StyleChanged;
    }


Review comment (suggestion):
```suggestion
    /// A [`FragmentStatus`] used to track fragment reuse when collecting reflow statistics.
    pub status: FragmentStatus,
```

Code after:

/// This data structure stores fields that are common to all non-base
/// Fragment types and should generally be the first member of all
/// concrete fragments.
#[derive(Clone, Debug, MallocSizeOf)]
pub(crate) struct BaseFragment {
    /// A tag which identifies the DOM node and pseudo element of this
    /// Fragment's content. If this fragment is for an anonymous box,
    /// the tag will be None.
    pub tag: Option<Tag>,

    /// Flags which various information about this fragment used during
    /// layout.
    pub flags: FragmentFlags,

    /// The style for this [`BaseFragment`]. Depending on the fragment type this is either
    /// a shared or non-shared style.
    pub style: BaseFragmentStyle,

    /// The content rect of this fragment in the parent fragment's content rectangle. This
    /// does not include padding, border, or margin -- it only includes content. This is
    /// relative to the parent containing block.
    pub rect: PhysicalRect<Au>,

    /// A [`FragmentStatus`] used to track fragment reuse when collecting reflow statistics.
    pub status: FragmentStatus,
}

impl BaseFragment {
    pub(crate) fn new(
        base_fragment_info: BaseFragmentInfo,
        style: BaseFragmentStyle,
        rect: PhysicalRect<Au>,
    ) -> Self {
        Self {
            tag: base_fragment_info.tag,
            flags: base_fragment_info.flags,
            style,
            rect,
            status: Default::default(),
        }
    }

    pub(crate) fn is_anonymous(&self) -> bool {
        self.tag.is_none()
    }

    pub(crate) fn repair_style(&mut self, style: &ServoArc<ComputedValues>) {
        self.style = style.clone().into();
        self.status = FragmentStatus::StyleChanged;
    }