Skip to content

Truly independent web browser

LibWeb: Remove unreachable branches from SVG painting

Aliaksandr Kalenikd1c43d3cac44
diff --git a/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs b/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs
index 7bd93297996..263a07ef625 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs
@@ -165,21 +165,7 @@ impl<'a, O: Observer> PaintRecorder<'a, O> {
self.source.node_is_generated_for_pseudo_element(paintable)
}
- pub(crate) fn record_foreign_object_descendant_hit_test_items(&mut self, paintable: NodeSlotId) {
- let mut next_child = crate::painting::paint_order::first_paint_child(self.source, paintable);
- while let Some(child) = next_child {
- next_child = crate::painting::paint_order::next_paint_sibling(self.source, child);
- self.record_hit_test_items(child, PaintPhase::Background);
- self.record_foreign_object_descendant_hit_test_items(child);
- self.record_hit_test_items(child, PaintPhase::Foreground);
- self.record_hit_test_items(child, PaintPhase::Overlay);
- }
- }
-
pub(crate) fn record_hit_test_items(&mut self, paintable: NodeSlotId, phase: PaintPhase) {
- if self.is_recording_svg_resource_content() {
- return;
- }
if node_painting::is_fragmented_inline(self.source, paintable) {
self.record_inline_hit_test_items(paintable, phase);
} else if node_painting::has_lines(self.source, paintable) {
diff --git a/Libraries/LibWeb/Rust/src/painting/record/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/mod.rs
index 78c0078198a..2621e6c14c1 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/mod.rs
@@ -28,8 +28,7 @@ pub(crate) mod vector_images;
use crate::css::css_enums;
use crate::css::css_pixels::CssPixelRect;
use crate::css::style::fast_hash::FastSet;
-use crate::layout::node_data::NodeSlotId;
-use crate::layout::node_data::{NodeFlag, NodeKind};
+use crate::layout::node_data::{NodeFlag, NodeSlotId};
use crate::painting::border_radii::BorderRadii;
use crate::painting::display_list::builder::{PendingInlineClip, RecordedDisplayList};
use crate::painting::display_list::commands::{ContextRef, SpatialNodeIndex};
@@ -690,10 +689,6 @@ impl<O: Observer> PaintRecorder<'_, O> {
self.data(paintable).establishes_stacking_context
}
- fn layout_kind(&self, paintable: NodeSlotId) -> Option<NodeKind> {
- self.source.node_kind_if_live(paintable)
- }
-
fn display(&self, paintable: NodeSlotId) -> crate::css::display::FfiDisplay {
crate::painting::style_queries::display(self.source, paintable)
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
index 058efbf51db..2ea6d182a0b 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
@@ -280,7 +280,7 @@ impl<O: Observer> PaintRecorder<'_, O> {
self.recorder.set_accumulated_visual_context(walk.enclosing_context);
}
- pub(crate) fn paint_svg_box_inside_resource(
+ fn paint_svg_box_inside_resource(
&mut self,
svg_box: NodeSlotId,
parent_to_enclosing_space: AffineTransform,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
index 353ad13449a..8ec0bbbe023 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
@@ -8,8 +8,7 @@ use crate::painting::record::trace::Observer;
use super::{PaintPhase, PaintRecorder};
use crate::css::style::fast_hash::FastSet;
-use crate::layout::node_data::{NodeKind, NodeSlotId};
-use crate::layout::node_facts;
+use crate::layout::node_data::NodeSlotId;
use crate::painting::display_list::commands::ContextRef;
use crate::painting::display_list::device_pixels::DevicePixelConverter;
use crate::painting::display_list::recorder::DisplayListRecorder;
@@ -214,14 +213,6 @@ impl<O: Observer> PaintRecorder<'_, O> {
}
pub(crate) fn paint_svg_box_impl(&mut self, svg_box: NodeSlotId) {
- if self.is_recording_svg_resource_content() {
- let parent_to_enclosing_space = self
- .recorder
- .ambient_inline_transform()
- .unwrap_or_else(libgfx_rust::AffineTransform::identity);
- self.paint_svg_box_inside_resource(svg_box, parent_to_enclosing_space, true);
- return;
- }
let context = self.own_context(svg_box);
self.recorder.set_accumulated_visual_context(context);
@@ -246,18 +237,6 @@ impl<O: Observer> PaintRecorder<'_, O> {
self.list.items.len() == before,
);
});
- if self.layout_kind(svg_box) == Some(NodeKind::SVGForeignObjectBox) {
- self.record_foreign_object_descendant_hit_test_items(svg_box);
- }
- let kind = self.layout_kind(svg_box);
- if kind != Some(NodeKind::SVGSVGBox)
- && !kind.is_some_and(node_painting::is_svg)
- && kind.is_some_and(node_facts::kind_is_replaced_box)
- {
- self.trace_paint(Operation::Producer(svg_box, ProducerKind::DrawBackground), |this| {
- crate::painting::record::paint::paint(this, svg_box, PaintPhase::Background);
- });
- }
self.trace_paint(Operation::Producer(svg_box, ProducerKind::DrawForeground), |this| {
crate::painting::record::paint::paint(this, svg_box, PaintPhase::Foreground);
});