Skip to content

Truly independent web browser

LibWeb: Remove painting of HTML content in SVG resources

Aliaksandr Kalenikc67d6da9b470
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs
index 02a2f500170..3327899168f 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/inline_box.rs
@@ -20,7 +20,7 @@ use crate::painting::style_queries;
pub(crate) fn paint<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable: NodeSlotId, phase: PaintPhase) {
// Inline decorations are interleaved with text by the containing line's plan.
- if matches!(phase, PaintPhase::Background | PaintPhase::Border) && !recorder.is_recording_svg_resource_content() {
+ if matches!(phase, PaintPhase::Background | PaintPhase::Border) {
return;
}
paint_pieces(recorder, paintable, phase, None);
@@ -254,9 +254,6 @@ fn paint_pieces<O: Observer>(
// visible: descendants may set visibility: visible again under a hidden box, so each
// fragment is filtered by its own node's visibility.
if crate::painting::fragment_ownership::is_self_painting_inline(layout_arena, paintable) {
- if recorder.is_recording_svg_resource_content() {
- text::paint_fragments_foreground(recorder, root, Some(paintable));
- }
text::paint_cursor(recorder, root, Some(paintable));
}
if facts.is_visible
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
index 43658a89924..3e1845600e0 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
@@ -113,15 +113,14 @@ pub(crate) fn paint<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable:
}
if math_paint_data.is_some_and(|data| data.replaces_text) {
// NB: The glyph of a stretched or large operator is painted instead of its text.
- } else if recorder.is_recording_svg_resource_content()
- || recorder
- .source
- .committed_side_data(paintable)
- .inline_content
- .as_ref()
- .is_none_or(|content| content.items.is_empty())
+ } else if recorder
+ .source
+ .committed_side_data(paintable)
+ .inline_content
+ .as_ref()
+ .is_none_or(|content| content.items.is_empty())
{
- text::paint_fragments_foreground(recorder, paintable, None);
+ text::paint_fragments_foreground(recorder, paintable);
}
// visibility: hidden on this block does not hide descendants that set visibility:
// visible again, so fragments (and the caret between their glyphs) are filtered by
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs
index 58559d5b095..9b4c7fe50bc 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs
@@ -432,7 +432,6 @@ pub(crate) fn paint_navigable_container_foreground<O: Observer>(
if destination_rect.is_empty()
|| !recorder.visible_for_hit_testing(paintable)
|| recorder.recorder.is_recording_inside_group()
- || recorder.is_recording_svg_resource_content()
{
return;
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs
index 079890a6e72..2d3f1394ad8 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs
@@ -515,12 +515,8 @@ pub(crate) fn glyph_run_emission(
}
}
-pub(crate) fn paint_fragments_foreground<O: Observer>(
- recorder: &mut PaintRecorder<'_, O>,
- block: NodeSlotId,
- owner: Option<NodeSlotId>,
-) {
- let filter = crate::painting::fragment_ownership::effective_filter(recorder.source, owner.unwrap_or(block));
+pub(crate) fn paint_fragments_foreground<O: Observer>(recorder: &mut PaintRecorder<'_, O>, block: NodeSlotId) {
+ let filter = crate::painting::fragment_ownership::effective_filter(recorder.source, block);
let fragment_count = recorder.source.committed_side_data(block).fragments().len();
let mut indices = Vec::with_capacity(fragment_count);
filter.for_each_owned_fragment_index(fragment_count, |index| indices.push(index as u32));
diff --git a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
index a50d91afe16..058efbf51db 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
@@ -9,8 +9,7 @@ use crate::layout::node_data::{NodeKind, NodeSlotId};
use crate::painting::display_list::builder::PendingInlineClip;
use crate::painting::display_list::commands::ContextRef;
use crate::painting::display_list::recorder::{IsolatedGroupEffects, OpenRecorderGroup};
-use crate::painting::node_painting;
-use crate::painting::paint_read::{GeometryRead, PaintRead};
+use crate::painting::paint_read::PaintRead;
use crate::painting::record::order_tree::ProducerKind;
use crate::painting::record::trace::{Action, Observer, Operation};
use crate::painting::record::{PaintPhase, PaintRecorder};
@@ -416,23 +415,8 @@ impl<O: Observer> PaintRecorder<'_, O> {
.enclosing_device_rect(crate::css::css_pixels::CssPixelRect::from(svg_filter_bounds));
self.recorder.fill_rect_transparent(device_rect);
}
- let kind = self.source.node_kind_if_live(svg_box);
- if kind != Some(NodeKind::SVGSVGBox)
- && !kind.is_some_and(node_painting::is_svg)
- && kind.is_some_and(crate::layout::node_facts::kind_is_replaced_box)
- {
- self.paint_svg_box_phase_inside_resource(svg_box, PaintPhase::Background);
- }
- self.paint_svg_box_phase_inside_resource(svg_box, PaintPhase::Foreground);
- }
-
- fn paint_svg_box_phase_inside_resource(&mut self, svg_box: NodeSlotId, phase: PaintPhase) {
- let kind = match phase {
- PaintPhase::Background => ProducerKind::DrawBackground,
- _ => ProducerKind::DrawForeground,
- };
- self.trace_paint(Operation::Producer(svg_box, kind), |this| {
- crate::painting::record::paint::paint(this, svg_box, phase);
+ self.trace_paint(Operation::Producer(svg_box, ProducerKind::DrawForeground), |this| {
+ crate::painting::record::paint::paint(this, svg_box, PaintPhase::Foreground);
});
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
index fcbcfc25259..353ad13449a 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
@@ -277,9 +277,6 @@ impl<O: Observer> PaintRecorder<'_, O> {
}
pub(crate) fn for_descendants_context(&self, paintable: NodeSlotId) -> ContextRef {
- if let Some(walk) = &self.svg_resource_walk {
- return walk.enclosing_context;
- }
self.data(paintable).accumulated_visual_context_for_descendants
}