aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow/root.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/flow/root.rs')
-rw-r--r--components/layout/flow/root.rs70
1 files changed, 2 insertions, 68 deletions
diff --git a/components/layout/flow/root.rs b/components/layout/flow/root.rs
index e813777b6fe..ec85f3574dc 100644
--- a/components/layout/flow/root.rs
+++ b/components/layout/flow/root.rs
@@ -12,7 +12,7 @@ use script_layout_interface::wrapper_traits::{
};
use script_layout_interface::{LayoutElementType, LayoutNodeType};
use servo_arc::Arc;
-use style::dom::{NodeInfo, OpaqueNode, TNode};
+use style::dom::{NodeInfo, TNode};
use style::properties::ComputedValues;
use style::values::computed::Overflow;
use style_traits::CSSPixel;
@@ -30,7 +30,7 @@ use crate::fragment_tree::FragmentTree;
use crate::geom::{LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSize};
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
use crate::replaced::ReplacedContents;
-use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayInside};
+use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside};
use crate::taffy::{TaffyItemBox, TaffyItemBoxInner};
use crate::{DefiniteContainingBlock, PropagatedBoxTreeData};
@@ -40,9 +40,6 @@ pub struct BoxTree {
/// There may be zero if that element has `display: none`.
root: BlockFormattingContext,
- /// <https://drafts.csswg.org/css-backgrounds/#special-backgrounds>
- canvas_background: CanvasBackground,
-
/// Whether or not the viewport should be sensitive to scrolling input events in two axes
viewport_scroll_sensitivity: AxesScrollSensitivity,
}
@@ -96,7 +93,6 @@ impl BoxTree {
contents,
contains_floats,
},
- canvas_background: CanvasBackground::for_root_element(context, root_element),
// From https://www.w3.org/TR/css-overflow-3/#overflow-propagation:
// > If visible is applied to the viewport, it must be interpreted as auto.
// > If clip is applied to the viewport, it must be interpreted as hidden.
@@ -425,69 +421,7 @@ impl BoxTree {
root_fragments,
scrollable_overflow,
physical_containing_block,
- self.canvas_background.clone(),
self.viewport_scroll_sensitivity,
)
}
}
-
-/// <https://drafts.csswg.org/css-backgrounds/#root-background>
-#[derive(Clone, MallocSizeOf)]
-pub struct CanvasBackground {
- /// DOM node for the root element
- pub root_element: OpaqueNode,
-
- /// The element whose style the canvas takes background properties from (see next field).
- /// This can be the root element (same as the previous field), or the HTML `<body>` element.
- /// See <https://drafts.csswg.org/css-backgrounds/#body-background>
- pub from_element: OpaqueNode,
-
- /// The computed styles to take background properties from.
- #[conditional_malloc_size_of]
- pub style: Option<Arc<ComputedValues>>,
-}
-
-impl CanvasBackground {
- fn for_root_element(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
- let root_style = root_element.style(context);
-
- let mut style = root_style;
- let mut from_element = root_element;
-
- // https://drafts.csswg.org/css-backgrounds/#body-background
- // “if the computed value of background-image on the root element is none
- // and its background-color is transparent”
- if style.background_is_transparent() &&
- // “For documents whose root element is an HTML `HTML` element
- // or an XHTML `html` element”
- root_element.type_id() == LayoutNodeType::Element(LayoutElementType::HTMLHtmlElement) &&
- // Don’t try to access styles for an unstyled subtree
- !matches!(style.clone_display().into(), Display::None)
- {
- // “that element’s first HTML `BODY` or XHTML `body` child element”
- if let Some(body) = iter_child_nodes(root_element).find(|child| {
- child.is_element() &&
- child.type_id() ==
- LayoutNodeType::Element(LayoutElementType::HTMLBodyElement)
- }) {
- style = body.style(context);
- from_element = body;
- }
- }
-
- Self {
- root_element: root_element.opaque(),
- from_element: from_element.opaque(),
-
- // “However, if no boxes are generated for the element
- // whose background would be used for the canvas
- // (for example, if the root element has display: none),
- // then the canvas background is transparent.”
- style: if let Display::GeneratingBox(_) = style.clone_display().into() {
- Some(style)
- } else {
- None
- },
- }
- }
-}