Truly independent web browser
LibWeb: Paint custom highlights
Tim Ledbettere8401aac929e
diff --git a/Libraries/LibWeb/Bindings/Rust/src/css/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/css/exports.rsindex dd6670b4692..b909b58c2f5 100644--- a/Libraries/LibWeb/Bindings/Rust/src/css/exports.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/css/exports.rs@@ -580,6 +580,63 @@ pub unsafe extern "C" fn web_highlight_registry_create(vm: *mut c_void, documentcell_into_abi(HighlightRegistry::create(vm, document))}+/// # Safety+///+/// `registry` must be a live HighlightRegistry.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn web_highlight_registry_has_highlights(registry: *mut c_void) -> bool {+ // SAFETY: The caller passes a live HighlightRegistry.+ unsafe { cell_from_abi::<HighlightRegistry>(registry) }.has_highlights()+}++/// # Safety+///+/// `registry` must be a live HighlightRegistry.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn web_highlight_registry_has_ranges(registry: *mut c_void) -> bool {+ // SAFETY: The caller passes a live HighlightRegistry.+ unsafe { cell_from_abi::<HighlightRegistry>(registry) }.has_ranges()+}++/// # Safety+///+/// `registry` must be a live HighlightRegistry, and `range` a live AbstractRange.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn web_highlight_registry_contains_range(registry: *mut c_void, range: *mut c_void) -> bool {+ // SAFETY: The caller passes a live HighlightRegistry.+ unsafe { cell_from_abi::<HighlightRegistry>(registry) }.contains_range(range)+}++/// Calls back with the name and the ranges of each registered custom highlight, from the bottom of the stacking order+/// to the top. The callback adopts the name, and the ranges stay alive until it returns.+///+/// # Safety+///+/// `vm` must be the live VM, `registry` a live HighlightRegistry, and `callback` a function that takes `context`.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn web_highlight_registry_for_each_highlight_in_stacking_order(+ vm: *mut c_void,+ registry: *mut c_void,+ context: *mut c_void,+ callback: unsafe extern "C" fn(context: *mut c_void, name: usize, ranges: *const *mut c_void, range_count: usize),+) {+ // SAFETY: The caller passes the live VM and a live HighlightRegistry.+ let (vm, registry) = unsafe { (vm_from_abi(vm), cell_from_abi::<HighlightRegistry>(registry)) };+ for entry in registry.highlights_in_stacking_order(vm).values().iter() {+ let ranges = entry.highlight.ranges(vm);+ let range_cells: Vec<*mut c_void> = ranges.values().iter().map(CppCell::as_ptr).collect();+ // SAFETY: The caller passes a callback that takes the context, and the marked list keeps the ranges alive.+ unsafe {+ callback(+ context,+ entry.name.clone().into_raw(),+ range_cells.as_ptr(),+ range_cells.len(),+ );+ }+ }+}+/// A new StylePropertyMap of the declaration.////// # Safetydiff --git a/Libraries/LibWeb/Bindings/Rust/src/css/highlight.rs b/Libraries/LibWeb/Bindings/Rust/src/css/highlight.rsindex 65a765c2a5a..b778e4e4f34 100644--- a/Libraries/LibWeb/Bindings/Rust/src/css/highlight.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/css/highlight.rs@@ -10,12 +10,13 @@ use core::cell::{Cell, RefCell};use core::ffi::c_void;use std::collections::HashSet;-use libjs_rust::api::{Gc, GcRefCell, MarkedVec, Set, Trace, Value, Vm};+use libjs_rust::api::{EmbedderCell, Gc, GcRefCell, GcWeak, MarkedVec, Set, Trace, Value, Vm};use super::css_rule::wrap_cpp_cell;+use super::highlight_registry::HighlightRegistry;use crate::bindings::conversions::CppInterface;use crate::bindings::cpp_cell::CppCell;-use crate::bindings::interface::{Ref, Wrappable, allocate};+use crate::bindings::interface::{Ref, Wrappable, Wrapped, allocate};use crate::bindings::setlike::context_of_set;use crate::bindings::setlike::{Setlike, WorldEntries, WritableSetlike};use crate::bindings::{CallContext, WebIdlResult};@@ -56,6 +57,9 @@ pub(crate) struct Highlight {#[gc(untraced)]highlight_type: Cell<HighlightType>,set_entries: WorldEntries<Set>,+ /// The registries that the highlight is registered in, once for each name that it is registered under.+ #[gc(untraced)]+ registries: RefCell<Vec<GcWeak<EmbedderCell<Wrapped<HighlightRegistry>>>>>,}impl Wrappable for Highlight {}@@ -75,6 +79,7 @@ impl Highlight {priority: Cell::new(0),highlight_type: Cell::new(HighlightType::Highlight),set_entries: WorldEntries::default(),+ registries: RefCell::new(Vec::new()),});// 4. For each range of initialRanges, let rangeArg be the result of converting range to an ECMAScript value,@@ -93,8 +98,10 @@ impl Highlight {Ok(self.priority.get())}- pub(crate) fn set_priority(&self, _: &mut CallContext, priority: i32) -> WebIdlResult<()> {- self.priority.set(priority);+ pub(crate) fn set_priority(&self, cx: &mut CallContext, priority: i32) -> WebIdlResult<()> {+ if self.priority.replace(priority) != priority {+ self.invalidate_registries(cx.vm());+ }Ok(())}@@ -119,6 +126,44 @@ impl Highlight {ranges}+ pub(crate) fn has_ranges(&self) -> bool {+ !self.ranges.borrow().is_empty()+ }++ /// Whether the highlight has the range whose cell C++ passes.+ pub(crate) fn contains_range(&self, range: *mut c_void) -> bool {+ self.range_addresses.borrow().contains(&(range as usize))+ }++ pub(crate) fn did_register(&self, vm: &Vm, registry: Ref<HighlightRegistry>) {+ let mut registries = self.registries.borrow_mut();+ registries.retain(|registered| registered.get().is_some());+ registries.push(GcWeak::new(vm.heap(), registry));+ }++ pub(crate) fn did_unregister(&self, registry: Ref<HighlightRegistry>) {+ let mut registries = self.registries.borrow_mut();+ if let Some(position) = registries+ .iter()+ .position(|registered| registered.get().is_some_and(|live| live.as_ptr() == registry.as_ptr()))+ {+ registries.remove(position);+ }+ }++ /// Tells each registry that the highlight is registered in that what the highlight paints changed.+ fn invalidate_registries(&self, vm: &Vm) {+ let live = MarkedVec::new(vm);+ for registered in self.registries.borrow().iter() {+ if let Some(registry) = registered.get() {+ live.push(registry);+ }+ }+ for registry in live.values().iter() {+ registry.invalidate_custom_highlights();+ }+ }+fn add_range(&self, cx: &CallContext, range: CppCell) -> bool {if !self.range_addresses.borrow_mut().insert(range.as_ptr() as usize) {return false;@@ -159,9 +204,7 @@ impl WritableSetlike for Highlight {self.set_entries.for_each_live(cx.vm(), |set| {set.set_add(cx.vm(), range_wrapper(&context_of_set(cx, set), &range));});- // FIXME: https://drafts.csswg.org/css-highlight-api-1/#repaint- // The addition or removal of a range in a registered custom highlight must cause the user agent to- // reevaluate the rendering, and to repaint if appropriate. We do not paint custom highlights yet.+ self.invalidate_registries(cx.vm());}fn set_remove(&self, cx: &CallContext, value: Value) -> bool {@@ -175,14 +218,19 @@ impl WritableSetlike for Highlight {self.set_entries.for_each_live(cx.vm(), |set| {set.set_remove(cx.vm(), range_wrapper(&context_of_set(cx, set), &range));});+ self.invalidate_registries(cx.vm());true}fn set_clear(&self, cx: &CallContext) {+ let had_ranges = self.has_ranges();self.range_addresses.borrow_mut().clear();self.ranges.borrow_mut(cx.vm()).clear();self.set_entries.for_each_live(cx.vm(), |set| {set.set_clear(cx.vm());});+ if had_ranges {+ self.invalidate_registries(cx.vm());+ }}}diff --git a/Libraries/LibWeb/Bindings/Rust/src/css/highlight_registry.rs b/Libraries/LibWeb/Bindings/Rust/src/css/highlight_registry.rsindex e80b83a8f5b..58e494691e4 100644--- a/Libraries/LibWeb/Bindings/Rust/src/css/highlight_registry.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/css/highlight_registry.rs@@ -6,6 +6,7 @@//! HighlightRegistry, https://drafts.csswg.org/css-highlight-api-1/#highlightregistry+use core::cell::Cell;use core::ffi::c_void;use ak::Utf16String;@@ -26,6 +27,7 @@ unsafe extern "C" {fn web_css_highlight_registry_shadow_root_at_point(document: *mut c_void, x: f32, y: f32) -> *mut c_void;fn web_css_highlight_registry_range_is_hit(range: *mut c_void, x: f32, y: f32) -> bool;fn web_css_shadow_root_of_wrapper(wrapper: *mut c_void) -> *mut c_void;+ fn web_css_highlight_registry_invalidate_custom_highlights(document: *mut c_void);}/// The dictionary HighlightsFromPointOptions of CSS/HighlightRegistry.idl.@@ -43,10 +45,10 @@ pub(crate) struct HighlightHitResult {#[derive(Clone, Trace)]#[gc(crate = libjs_rust)]-struct RegisteredHighlight {+pub(crate) struct RegisteredHighlight {#[gc(untraced)]- name: Utf16String,- highlight: Ref<Highlight>,+ pub(crate) name: Utf16String,+ pub(crate) highlight: Ref<Highlight>,}// https://drafts.csswg.org/css-highlight-api-1/#highlightregistry@@ -54,6 +56,7 @@ struct RegisteredHighlight {#[gc(crate = libjs_rust)]pub(crate) struct HighlightRegistry {document: CppCell,+ this: Cell<Option<Ref<HighlightRegistry>>>,/// The map entries of this maplike object, in registration order.highlights: GcRefCell<Vec<RegisteredHighlight>>,map_entries: WorldEntries<Map>,@@ -74,11 +77,59 @@ impl HighlightRegistry {}pub(crate) fn create(vm: &Vm, document: CppCell) -> Ref<Self> {- allocate(vm, |_| Self {+ let registry = allocate(vm, |_| Self {document,+ this: Cell::new(None),highlights: GcRefCell::new(Vec::new()),map_entries: WorldEntries::default(),- })+ });+ registry.this.set(Some(registry));+ registry+ }++ fn this(&self) -> Ref<Self> {+ self.this+ .get()+ .expect("a HighlightRegistry knows itself once it is created")+ }++ pub(crate) fn has_highlights(&self) -> bool {+ !self.highlights.borrow().is_empty()+ }++ /// Whether a registered custom highlight has a range.+ pub(crate) fn has_ranges(&self) -> bool {+ self.highlights+ .borrow()+ .iter()+ .any(|entry| entry.highlight.has_ranges())+ }++ /// Whether a registered custom highlight has the range whose cell C++ passes.+ pub(crate) fn contains_range(&self, range: *mut c_void) -> bool {+ self.highlights+ .borrow()+ .iter()+ .any(|entry| entry.highlight.contains_range(range))+ }++ /// The registered custom highlights, from the bottom of the stacking order to the top.+ pub(crate) fn highlights_in_stacking_order<'vm>(&self, vm: &'vm Vm) -> MarkedVec<'vm, RegisteredHighlight> {+ let highlights = self.registered_highlights(vm);+ // https://drafts.csswg.org/css-highlight-api-1/#priorities+ // A higher priority results in being above in the stacking order. [...] When two or more custom highlights+ // have the same numerical priority, the one most recently registered has the higher effective priority.+ // NB: The sort is stable, and the map entries are in registration order.+ highlights+ .values_mut()+ .sort_by_key(|entry| entry.highlight.current_priority());+ highlights+ }++ /// Tells the document that what the custom highlights paint changed.+ pub(crate) fn invalidate_custom_highlights(&self) {+ // SAFETY: The document is live.+ unsafe { web_css_highlight_registry_invalidate_custom_highlights(self.document.as_ptr()) };}// https://drafts.csswg.org/css-highlight-api-1/#dom-highlightregistry-highlightsfrompoint@@ -186,23 +237,28 @@ impl Maplike for HighlightRegistry {impl WritableMaplike for HighlightRegistry {fn map_set(&self, cx: &CallContext, key: Utf16String, value: Value) {- // FIXME: https://drafts.csswg.org/css-highlight-api-1/#repaint- // The addition or removal of a custom highlight in the highlight registry must cause the user agent to- // reevaluate the rendering, and to repaint if appropriate. We do not paint custom highlights yet.let highlight = implementation_of::<Highlight>(value.as_object());- {+ let previous = {let mut highlights = self.highlights.borrow_mut(cx.vm());match highlights.iter_mut().find(|entry| entry.name == key) {- Some(entry) => entry.highlight = highlight,- None => highlights.push(RegisteredHighlight {- name: key.clone(),- highlight,- }),+ Some(entry) => Some(core::mem::replace(&mut entry.highlight, highlight)),+ None => {+ highlights.push(RegisteredHighlight {+ name: key.clone(),+ highlight,+ });+ None+ }}+ };+ if let Some(previous) = previous {+ previous.did_unregister(self.this());}+ highlight.did_register(cx.vm(), self.this());self.map_entries.for_each_live(cx.vm(), |map| {set_map_entry(&context_of_map(cx, map), map, &key, highlight);});+ self.invalidate_custom_highlights();}fn map_remove(&self, cx: &CallContext, key: &Utf16String) -> bool {@@ -210,18 +266,27 @@ impl WritableMaplike for HighlightRegistry {let Some(position) = position else {return false;};- self.highlights.borrow_mut(cx.vm()).remove(position);+ let removed = self.highlights.borrow_mut(cx.vm()).remove(position);+ removed.highlight.did_unregister(self.this());self.map_entries.for_each_live(cx.vm(), |map| {let key = key.clone().to_js(cx).expect("a string converts to a JS value");map.map_remove(cx.vm(), key);});+ self.invalidate_custom_highlights();true}fn map_clear(&self, cx: &CallContext) {+ let removed = self.registered_highlights(cx.vm());self.highlights.borrow_mut(cx.vm()).clear();+ for entry in removed.values().iter() {+ entry.highlight.did_unregister(self.this());+ }self.map_entries.for_each_live(cx.vm(), |map| {map.map_clear(cx.vm());});+ if !removed.is_empty() {+ self.invalidate_custom_highlights();+ }}}diff --git a/Libraries/LibWeb/CSS/HighlightRegistry.cpp b/Libraries/LibWeb/CSS/HighlightRegistry.cppindex b1cfb6f9f73..b14aeafdc41 100644--- a/Libraries/LibWeb/CSS/HighlightRegistry.cpp+++ b/Libraries/LibWeb/CSS/HighlightRegistry.cpp@@ -4,6 +4,7 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <LibGC/RootVector.h>#include <LibJS/HostClassBuilder.h>#include <LibJS/Runtime/VM.h>#include <LibWeb/Bindings/Wrappable.h>@@ -22,6 +23,10 @@ extern "C" {// Defined in Bindings/Rust/src/css/exports.rs.void* web_highlight_registry_create(JSVM*, void* document);+bool web_highlight_registry_has_highlights(void* registry);+bool web_highlight_registry_has_ranges(void* registry);+bool web_highlight_registry_contains_range(void* registry, void* range);+void web_highlight_registry_for_each_highlight_in_stacking_order(JSVM*, void* registry, void* context, void (*callback)(void* context, FlatPtr name, void* const* ranges, size_t range_count));// Declared in Bindings/Rust/src/css/highlight.rs and Bindings/Rust/src/css/highlight_registry.rs.void* web_css_abstract_range_of_wrapper(void* wrapper);@@ -29,6 +34,7 @@ void* web_css_shadow_root_of_wrapper(void* wrapper);bool web_css_highlight_registry_point_is_in_viewport(void* document, float x, float y);void* web_css_highlight_registry_shadow_root_at_point(void* document, float x, float y);bool web_css_highlight_registry_range_is_hit(void* abstract_range, float x, float y);+void web_css_highlight_registry_invalidate_custom_highlights(void* document);}GC::Ref<HighlightRegistry> HighlightRegistry::create(DOM::Document& document)@@ -37,11 +43,62 @@ GC::Ref<HighlightRegistry> HighlightRegistry::create(DOM::Document& document)return GC::Ref { *static_cast<HighlightRegistry*>(registry) };}+bool HighlightRegistry::has_highlights()+{+ return web_highlight_registry_has_highlights(this);+}++bool HighlightRegistry::has_ranges()+{+ return web_highlight_registry_has_ranges(this);+}++bool HighlightRegistry::contains_range(DOM::AbstractRange& range)+{+ return web_highlight_registry_contains_range(this, static_cast<GC::Cell*>(&range));+}++void HighlightRegistry::for_each_highlight_in_stacking_order(Function<void(Utf16String const& name, ReadonlySpan<GC::Ref<DOM::AbstractRange>> ranges)> const& callback)+{+ auto trampoline = [](void* context, FlatPtr raw_name, void* const* raw_ranges, size_t range_count) {+ auto const& callback = *static_cast<Function<void(Utf16String const&, ReadonlySpan<GC::Ref<DOM::AbstractRange>>)> const*>(context);+ auto name = Utf16String::adopt_raw(raw_name);+ GC::RootVector<GC::Ref<DOM::AbstractRange>> ranges;+ ranges.ensure_capacity(range_count);+ for (size_t i = 0; i < range_count; ++i)+ ranges.unchecked_append(*static_cast<DOM::AbstractRange*>(static_cast<GC::Cell*>(raw_ranges[i])));+ callback(name, ranges.span());+ };+ web_highlight_registry_for_each_highlight_in_stacking_order(JS::HostABI::vm_to_abi(JS::VM::the()), this, const_cast<void*>(static_cast<void const*>(&callback)), trampoline);+}++bool HighlightRegistry::range_is_paintable(DOM::Document const& document, DOM::AbstractRange const& range)+{+ // https://drafts.csswg.org/css-highlight-api-1/#range-invalidation+ // When computing how to render a document, if start node or end node of any range in the highlight registry+ // associated with that document’s window refer to a Node whose shadow-including root is not that document, the user+ // agent must ignore that range. If any StaticRange in the highlight registry associated with that document’s window+ // is not valid, the user agent must ignore that range.+ if (&range.start_container()->shadow_including_root() != &document || &range.end_container()->shadow_including_root() != &document)+ return false;+ if (auto const* static_range = as_if<DOM::StaticRange>(range); static_range && !static_range->is_valid())+ return false;++ // https://drafts.csswg.org/css-highlight-api-1/#painting+ // Collapsed ranges are not rendered.+ return !range.collapsed();+}+static DOM::Document& document_from_abi(void* document){return *static_cast<DOM::Document*>(static_cast<GC::Cell*>(document));}+void web_css_highlight_registry_invalidate_custom_highlights(void* raw_document)+{+ document_from_abi(raw_document).invalidate_custom_highlights();+}+void* web_css_abstract_range_of_wrapper(void* wrapper){auto* range = Bindings::impl_from<DOM::AbstractRange>(static_cast<JS::Object*>(wrapper));diff --git a/Libraries/LibWeb/CSS/HighlightRegistry.h b/Libraries/LibWeb/CSS/HighlightRegistry.hindex ee1a143c14b..2001c66a72b 100644--- a/Libraries/LibWeb/CSS/HighlightRegistry.h+++ b/Libraries/LibWeb/CSS/HighlightRegistry.h@@ -6,6 +6,9 @@#pragma once+#include <AK/Function.h>+#include <AK/Span.h>+#include <AK/Utf16String.h>#include <LibGC/Ptr.h>#include <LibWeb/Bindings/HighlightRegistry.h>#include <LibWeb/Bindings/RustInterface.h>@@ -20,6 +23,16 @@ class WEB_API HighlightRegistry final : public Bindings::RustInterfaceCell {public:[[nodiscard]] static GC::Ref<HighlightRegistry> create(DOM::Document&);++ bool has_highlights();+ bool has_ranges();+ bool contains_range(DOM::AbstractRange&);++ // Calls back with the name and the ranges of each registered custom highlight, from the bottom of the stacking+ // order to the top.+ void for_each_highlight_in_stacking_order(Function<void(Utf16String const& name, ReadonlySpan<GC::Ref<DOM::AbstractRange>> ranges)> const&);++ static bool range_is_paintable(DOM::Document const&, DOM::AbstractRange const&);};}diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.cpp b/Libraries/LibWeb/CSS/StyleEngineBridge.cppindex de9b613b963..3af2470fab0 100644--- a/Libraries/LibWeb/CSS/StyleEngineBridge.cpp+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.cpp@@ -422,6 +422,14 @@ void StyleEngine::set_highlight_observing_elements(PseudoElement pseudo_element,StyleEngineFFI::style_engine_set_highlight_observing_elements(host(), to_underlying(pseudo_element), style_nodes);}+void StyleEngine::set_custom_highlight_observing_elements(ReadonlySpan<StyleNodeID> style_nodes, ReadonlySpan<StyleAtomID> names)+{+ VERIFY(style_nodes.size() == names.size());+ flush_deferred_geometry_transaction_before_non_replayable_input(*this, m_style_computer);+ request_frame_for_first_recorded_input(*this, m_style_computer);+ StyleEngineFFI::style_engine_set_custom_highlight_observing_elements(host(), style_nodes, names);+}+void StyleEngine::record_container_query_input_change(StyleNodeID style_node){if (style_node == 0)diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.h b/Libraries/LibWeb/CSS/StyleEngineBridge.hindex d02d2f5371e..3c7b8d9c6a5 100644--- a/Libraries/LibWeb/CSS/StyleEngineBridge.h+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.h@@ -41,6 +41,7 @@ using Layout::RustFFI::DocumentHost;// test there checks each declaration against its row. An AK Span crosses by value as the table's FfiSpan.extern "C" {void style_engine_set_highlight_observing_elements(DocumentHost const*, u8 kind, ReadonlySpan<StyleNodeID> nodes);+void style_engine_set_custom_highlight_observing_elements(DocumentHost const*, ReadonlySpan<StyleNodeID> nodes, ReadonlySpan<StyleAtomID> names);void style_engine_set_fold_id_and_class_name_case(DocumentHost const*, bool fold);void style_engine_set_html_element_namespace(DocumentHost const*, StyleAtomID namespace_atom);void style_engine_mark_relation_only_style_node(DocumentHost const*, StyleNodeID node);@@ -91,7 +92,7 @@ void style_engine_evaluate_size_containers_needing_evaluation_after_layout(Documvoid style_engine_set_element_backing_pseudo_kind(DocumentHost const*, StyleNodeID node, u8 pseudo_kind_plus_one);void style_engine_set_counter_style_environment_identity(DocumentHost const*, TreeScopeID tree_scope, u64 identity);void style_engine_set_held_style_record(DocumentHost const*, StyleNodeID node, void const* record);-void style_engine_set_held_pseudo_style_record(DocumentHost const*, StyleNodeID node, u8 pseudo_kind, u64 style_record, void const* released);+void style_engine_set_held_pseudo_style_record(DocumentHost const*, StyleNodeID node, u8 pseudo_kind, StyleAtomID highlight_name, u64 style_record, void const* released);void style_engine_set_element_css_defined_animations(DocumentHost const*, StyleNodeID node, u8 slot, ReadonlySpan<FlatPtr> names, ReadonlySpan<FfiAppliedAnimationDefinition> definitions);void style_engine_set_tree_scope_root(DocumentHost const*, TreeScopeID tree_scope, StyleNodeID root);void style_engine_set_sheet_conditions_hold(DocumentHost const*, SheetID sheet, bool conditions_hold);@@ -330,6 +331,8 @@ public:// The elements the host shows the highlight pseudo-element of the kind in, which style updates// style that pseudo-element of. Those that start or stop showing it are restyled.void set_highlight_observing_elements(PseudoElement, ReadonlySpan<StyleNodeID>);+ // The elements the host shows custom highlights in, with the name of each at the same index in `names`.+ void set_custom_highlight_observing_elements(ReadonlySpan<StyleNodeID> style_nodes, ReadonlySpan<StyleAtomID> names);// What a container query or container-relative length read of the element's containers moved.void record_container_query_input_change(StyleNodeID style_node);// Records every element whose style a size query or container-relative unit decided against the container.diff --git a/Libraries/LibWeb/CSS/UpdateStyle.cpp b/Libraries/LibWeb/CSS/UpdateStyle.cppindex 714e69edc07..1335df1763d 100644--- a/Libraries/LibWeb/CSS/UpdateStyle.cpp+++ b/Libraries/LibWeb/CSS/UpdateStyle.cpp@@ -332,6 +332,10 @@ void StyleEngineFFI::web_css_install_styles(StyleReactionApplication* applicatioOptional<PseudoElement> pseudo_element;if (swap.slot != NumericLimits<u8>::max())pseudo_element = static_cast<PseudoElement>(swap.slot);+ if (pseudo_element == PseudoElement::Highlight) {+ element->swap_in_custom_highlight_style_record(StyleAtomID { swap.highlight_name }, swap.record);+ continue;+ }// A pseudo-element's transitions may start in a later pass too.if (pseudo_element.has_value()) {DOM::AbstractElement abstract_element { *element, pseudo_element };diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex 4a0e4038d57..3a21d7cd3e7 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -1252,6 +1252,58 @@ void Document::update_highlight_states_if_needed(Layout::BegunRead const& read)recompute_spelling_error_paint_states(read);Node::set_needs_repaint(InvalidateDisplayList::PaintCommands);}+ if (m_has_registered_custom_highlight_ranges && !m_custom_highlight_states_are_stale) {+ auto row_generation = m_layout_node_arena ? Layout::RustFFI::render_state_custom_highlight_row_generation(m_layout_node_arena->host(), &read) : 0;+ m_custom_highlight_states_are_stale = dom_tree_version() != m_custom_highlight_states_dom_tree_version+ || character_data_version() != m_custom_highlight_states_character_data_version+ || row_generation != m_custom_highlight_states_row_generation;+ }+ if (m_custom_highlight_states_are_stale && has_committed_viewport_box()) {+ m_custom_highlight_states_are_stale = false;+ recompute_custom_highlight_paint_states(read);+ Node::set_needs_repaint(InvalidateDisplayList::PaintCommands);+ }+}++bool Document::has_custom_highlights() const+{+ return m_highlight_registry && m_highlight_registry->has_highlights();+}++void Document::invalidate_custom_highlights()+{+ // https://drafts.csswg.org/css-highlight-api-1/#repaint+ // The addition or removal of a custom highlight in the highlight registry, or of a range in a registered custom+ // highlight, must cause the user agent to reevaluate the rendering, and to repaint if appropriate. The user agent+ // must also repaint highlights as needed in response to changes by the author to the priority, or to the boundary+ // points of Ranges of a registered custom highlight.+ m_custom_highlight_states_are_stale = true;+ set_needs_highlight_style_update(CSS::PseudoElement::Highlight);+ bool has_ranges = m_highlight_registry && m_highlight_registry->has_ranges();+ if (has_ranges != m_has_registered_custom_highlight_ranges) {+ m_has_registered_custom_highlight_ranges = has_ranges;+ if (m_layout_node_arena)+ Layout::RustFFI::render_state_set_has_registered_custom_highlight_ranges(m_layout_node_arena->host(), has_ranges);+ }+ // This repaint is asynchronous, and the APIs mentioned above must not block while waiting for the repaint to+ // happen.+ request_frame_for_pending_repaint();+}++void Document::recompute_custom_highlight_paint_states(Layout::BegunRead const& read)+{+ m_custom_highlight_states_dom_tree_version = dom_tree_version();+ m_custom_highlight_states_character_data_version = character_data_version();+ m_custom_highlight_states_row_generation = 0;+ if (m_layout_node_arena) {+ Layout::RustFFI::render_state_set_has_registered_custom_highlight_ranges(m_layout_node_arena->host(), m_has_registered_custom_highlight_ranges);+ m_custom_highlight_states_row_generation = Layout::RustFFI::render_state_custom_highlight_row_generation(m_layout_node_arena->host(), &read);+ }+ if (!has_custom_highlights()) {+ paint_state().reset_custom_highlight_states();+ return;+ }+ paint_state().recompute_custom_highlight_states(read, *this, *m_highlight_registry);}void Document::set_find_in_page_highlighted_matches(GC::RootVector<GC::Ref<Range>> matches)diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.hindex 1d5219a8692..a64412ffc5a 100644--- a/Libraries/LibWeb/DOM/Document.h+++ b/Libraries/LibWeb/DOM/Document.h@@ -377,6 +377,9 @@ public:void recompute_search_text_paint_states(Layout::BegunRead const&);void note_spelling_markers_changed();void recompute_spelling_error_paint_states(Layout::BegunRead const&);+ void recompute_custom_highlight_paint_states(Layout::BegunRead const&);+ void invalidate_custom_highlights();+ bool has_custom_highlights() const;WebIDL::ExceptionOr<Utf16String> cookie();WebIDL::ExceptionOr<void> set_cookie(Utf16View);@@ -693,6 +696,7 @@ public:// https://drafts.csswg.org/css-font-loading/#font-sourceGC::Ref<CSS::FontFaceSet> fonts();GC::Ref<CSS::HighlightRegistry> highlight_registry();+ CSS::HighlightRegistry* highlight_registry_if_exists() const { return m_highlight_registry.ptr(); }void clear();void capture_events();@@ -2249,6 +2253,11 @@ private:bool m_selection_states_are_stale { false };bool m_search_text_states_are_stale { false };bool m_spelling_error_states_are_stale { false };+ bool m_custom_highlight_states_are_stale { false };+ bool m_has_registered_custom_highlight_ranges { false };+ u64 m_custom_highlight_states_dom_tree_version { 0 };+ u64 m_custom_highlight_states_character_data_version { 0 };+ u64 m_custom_highlight_states_row_generation { 0 };Utf16String m_find_in_page_active_match_text;Vector<GC::Ref<Range>> m_find_in_page_highlighted_matches;OwnPtr<Editing::SpellingMarkers> m_spelling_markers;@@ -2262,9 +2271,12 @@ private:bool observable { false };bool needs_update { true };};- Array<HighlightStyleObservability, 3> m_highlight_style_observability;+ Array<HighlightStyleObservability, 4> m_highlight_style_observability;HighlightStyleObservability& highlight_style_observability(CSS::PseudoElement);void update_highlight_style_observability(CSS::PseudoElement);+ bool custom_highlight_static_ranges_may_have_changed() const;+ bool m_custom_highlight_observers_read_static_ranges { false };+ u64 m_custom_highlight_observers_character_data_version { 0 };// NOTE: This is a cache to make finding the first <base href> or <base target> element O(1).GC::Ptr<HTML::HTMLBaseElement> m_first_base_element_with_href_in_tree_order;diff --git a/Libraries/LibWeb/DOM/DocumentHighlightStyles.cpp b/Libraries/LibWeb/DOM/DocumentHighlightStyles.cppindex 124cd406194..82d36488167 100644--- a/Libraries/LibWeb/DOM/DocumentHighlightStyles.cpp+++ b/Libraries/LibWeb/DOM/DocumentHighlightStyles.cpp@@ -11,6 +11,7 @@#include <LibWeb/Animations/AnimationEffect.h>#include <LibWeb/CSS/ComputedValues.h>#include <LibWeb/CSS/CustomPropertyData.h>+#include <LibWeb/CSS/HighlightRegistry.h>#include <LibWeb/CSS/MainEffects.h>#include <LibWeb/CSS/StyleComputer.h>#include <LibWeb/CSS/StyleEngineInput.h>@@ -23,6 +24,7 @@#include <LibWeb/DOM/PseudoElement.h>#include <LibWeb/DOM/Range.h>#include <LibWeb/DOM/ShadowRoot.h>+#include <LibWeb/DOM/StaticRange.h>#include <LibWeb/DOM/Text.h>#include <LibWeb/Editing/SpellingMarkers.h>#include <LibWeb/HTML/FormAssociatedElement.h>@@ -44,6 +46,8 @@ Document::HighlightStyleObservability& Document::highlight_style_observability(Creturn m_highlight_style_observability[0];case CSS::PseudoElement::SpellingError:return m_highlight_style_observability[2];+ case CSS::PseudoElement::Highlight:+ return m_highlight_style_observability[3];default:return m_highlight_style_observability[1];}@@ -56,10 +60,28 @@ void Document::set_needs_highlight_style_update(CSS::PseudoElement pseudo_elemenbool Document::needs_highlight_style_update() const{- return any_of(m_highlight_style_observability, [](auto const& state) { return state.needs_update; });+ return any_of(m_highlight_style_observability, [](auto const& state) { return state.needs_update; })+ || custom_highlight_static_ranges_may_have_changed();}-static void collect_highlight_observing_elements(Vector<CSS::StyleNodeID>& style_nodes, Node& root, Range const* range)+bool Document::custom_highlight_static_ranges_may_have_changed() const+{+ return m_custom_highlight_observers_read_static_ranges && character_data_version() != m_custom_highlight_observers_character_data_version;+}++static bool range_intersects_node(AbstractRange const& range, Node& node)+{+ if (auto const* live_range = as_if<Range>(range))+ return live_range->intersects_node(node);+ auto* parent = node.parent();+ if (!parent)+ return true;+ auto offset = static_cast<WebIDL::UnsignedLong>(node.index());+ return position_of_boundary_point_relative_to_other_boundary_point({ *parent, offset }, range.end()) == RelativeBoundaryPointPosition::Before+ && position_of_boundary_point_relative_to_other_boundary_point({ *parent, offset + 1 }, range.start()) == RelativeBoundaryPointPosition::After;+}++static void collect_highlight_observing_elements(Vector<CSS::StyleNodeID>& style_nodes, Node& root, AbstractRange const* range){auto record_element = [&](Node& node) {if (auto* element = as_if<Element>(node); element && element->style_node_id() != CSS::StyleNodeID {})@@ -71,7 +93,7 @@ static void collect_highlight_observing_elements(Vector<CSS::StyleNodeID>& stylefor (auto* ancestor = root.flat_tree_parent(); ancestor; ancestor = ancestor->flat_tree_parent())record_element(*ancestor);root.for_each_shadow_including_inclusive_descendant([&](Node& node) {- if (range && &node.root() == &range->start_container()->root() && !range->intersects_node(node))+ if (range && &node.root() == &range->start_container()->root() && !range_intersects_node(*range, node))return TraversalDecision::SkipChildrenAndContinue;record_element(node);return TraversalDecision::Continue;@@ -80,7 +102,7 @@ static void collect_highlight_observing_elements(Vector<CSS::StyleNodeID>& stylestruct HighlightStyleInput {GC::Ref<Node> root;- GC::Ptr<Range> range;+ GC::Ptr<AbstractRange> range;};static GC::ConservativeVector<HighlightStyleInput, 2> selection_style_inputs(Document& document)@@ -133,6 +155,62 @@ static GC::ConservativeVector<HighlightStyleInput, 2> spelling_error_style_inputreturn inputs;}+static Node& common_ancestor_container(AbstractRange const& range)+{+ if (auto const* live_range = as_if<Range>(range))+ return *live_range->common_ancestor_container();+ Node* container = range.start_container().ptr();+ while (!container->is_inclusive_ancestor_of(*range.end_container()))+ container = container->parent();+ return *container;+}++static bool collect_custom_highlight_observing_elements(Document& document, Vector<CSS::StyleNodeID>& style_nodes, Vector<CSS::StyleAtomID>& names)+{+ auto* registry = document.highlight_registry_if_exists();+ if (!registry)+ return false;+ bool read_static_ranges = false;+ auto& style_engine = document.style_computer().style_engine();+ registry->for_each_highlight_in_stacking_order([&](Utf16String const& name, ReadonlySpan<GC::Ref<AbstractRange>> ranges) {+ GC::ConservativeVector<HighlightStyleInput, 2> inputs;+ GC::RootHashMap<Node const*, size_t> input_index_by_root;+ for (auto const& range : ranges) {+ read_static_ranges |= is<StaticRange>(*range);+ if (!CSS::HighlightRegistry::range_is_paintable(document, *range))+ continue;+ auto& root = common_ancestor_container(*range);+ if (auto index = input_index_by_root.get(&root); index.has_value()) {+ inputs[*index].range = nullptr;+ continue;+ }+ input_index_by_root.set(&root, inputs.size());+ inputs.append({ root, range });+ }+ if (inputs.is_empty())+ return;+ GC::RootHashTable<Node const*> roots_walked_in_full;+ for (auto const& input : inputs) {+ if (!input.range)+ roots_walked_in_full.set(input.root.ptr());+ }+ inputs.remove_all_matching([&](auto const& input) {+ for (auto* ancestor = input.root->parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host()) {+ if (roots_walked_in_full.contains(ancestor))+ return true;+ }+ return false;+ });+ auto first = style_nodes.size();+ for (auto const& input : inputs)+ collect_highlight_observing_elements(style_nodes, input.root, input.range.ptr());+ auto atom = style_engine.intern_atom(Utf16FlyString { name });+ for (auto i = first; i < style_nodes.size(); ++i)+ names.append(atom);+ });+ return read_static_ranges;+}+void Document::update_highlight_style_observability(CSS::PseudoElement pseudo_element){// NB: Editing commands temporarily select content to restore its formatting. Style reads@@ -145,9 +223,21 @@ void Document::update_highlight_style_observability(CSS::PseudoElement pseudo_el// OPTIMIZATION: Whatever moves what shows a highlight notes that it needs an update, so one that needs none has// nothing to collect.auto& state = highlight_style_observability(pseudo_element);+ if (pseudo_element == CSS::PseudoElement::Highlight && custom_highlight_static_ranges_may_have_changed())+ state.needs_update = true;if (!state.needs_update)return;+ if (pseudo_element == CSS::PseudoElement::Highlight) {+ Vector<CSS::StyleNodeID> style_nodes;+ Vector<CSS::StyleAtomID> names;+ m_custom_highlight_observers_read_static_ranges = collect_custom_highlight_observing_elements(*this, style_nodes, names);+ m_custom_highlight_observers_character_data_version = character_data_version();+ state = { .observable = !style_nodes.is_empty(), .needs_update = false };+ style_computer().style_engine().set_custom_highlight_observing_elements(style_nodes, names);+ return;+ }+auto inputs = [&] {switch (pseudo_element) {case CSS::PseudoElement::Selection:@@ -176,6 +266,7 @@ void Document::update_highlight_style_observability()update_highlight_style_observability(CSS::PseudoElement::Selection);update_highlight_style_observability(CSS::PseudoElement::SearchText);update_highlight_style_observability(CSS::PseudoElement::SpellingError);+ update_highlight_style_observability(CSS::PseudoElement::Highlight);}}diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cppindex 0eae8a5f685..c3e1c6c03c1 100644--- a/Libraries/LibWeb/DOM/Element.cpp+++ b/Libraries/LibWeb/DOM/Element.cpp@@ -1962,6 +1962,37 @@ void Element::swap_in_style_record(Layout::BegunRead const& read, Optional<CSS::layout_node->set_style_record_identity(style_record);}+Element::CustomHighlightStyles const* Element::custom_highlight_styles() const+{+ auto const* rare_data = element_rare_data();+ if (!rare_data || rare_data->custom_highlight_styles.is_empty())+ return nullptr;+ return &rare_data->custom_highlight_styles;+}++void Element::swap_in_custom_highlight_style_record(CSS::StyleAtomID name, void const* record)+{+ if (record) {+ ensure_element_rare_data().custom_highlight_styles.set(name, CSS::InstalledStyle { record });+ return;+ }+ if (auto* rare_data = element_rare_data())+ rare_data->custom_highlight_styles.remove(name);+}++void Element::clear_custom_highlight_styles()+{+ auto* rare_data = element_rare_data();+ if (!rare_data || rare_data->custom_highlight_styles.is_empty())+ return;+ auto styles = move(rare_data->custom_highlight_styles);+ if (style_node_id() == 0)+ return;+ auto& style_engine = document().style_computer().style_engine();+ for (auto const& [name, style] : styles)+ CSS::StyleEngineFFI::style_engine_set_held_pseudo_style_record(style_engine.host(), style_node_id(), to_underlying(CSS::PseudoElement::Highlight), name, 0, style.record_pointer());+}+// The custom-property environment of a style record: what the element inherits, or its own custom declarations over// that.RefPtr<CSS::CustomPropertyData const> Element::style_custom_property_environment(Layout::BegunRead const& read, CSS::InstalledStyle const& style) const@@ -2207,6 +2238,7 @@ void Element::clear_computed_styles_from_display_none_descendants(Layout::BegunRelement->for_each_synthetic_pseudo_element([&](CSS::PseudoElement, SyntheticPseudoElement& pseudo_element) {pseudo_element.clear_computed_style();});+ element->clear_custom_highlight_styles();return TraversalDecision::Continue;});}@@ -3088,6 +3120,7 @@ void Element::removed_from(IsSubtreeRoot is_subtree_root, Node* old_ancestor, Nonote_subtree_style_moved();pseudo_element.clear_computed_style();});+ clear_custom_highlight_styles();// A shadow root's counter style names pass on to the scope its host is in, which a move of the host can change.if (m_shadow_root)@@ -3181,6 +3214,8 @@ void Element::set_style_node_id(CSS::StyleNodeID style_node_id)if (!pseudo_element.scroll_offset().is_zero())pseudo_element.publish_scroll_offset();});+ if (document().has_custom_highlights())+ document().set_needs_highlight_style_update(CSS::PseudoElement::Highlight);}// NB: A newly minted identity holds no style on the render side, whatever the element and its pseudo-elements// still hold: the render side styles the element as it arrives, and swaps in what it computed.diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.hindex 6851f42a138..55b7e733ed1 100644--- a/Libraries/LibWeb/DOM/Element.h+++ b/Libraries/LibWeb/DOM/Element.h@@ -401,6 +401,9 @@ public:// Swaps in the style record the render side installed for the element, or for one of its synthetic// pseudo-elements, in its box too. The side effects of the move are left to apply_style_main_effects().void swap_in_style_record(Layout::BegunRead const& read, Optional<CSS::PseudoElement>, void const* record);+ using CustomHighlightStyles = HashMap<CSS::StyleAtomID, CSS::InstalledStyle>;+ [[nodiscard]] CustomHighlightStyles const* custom_highlight_styles() const;+ void swap_in_custom_highlight_style_record(CSS::StyleAtomID, void const* record);// Moves the animation subtree style generation of the element and its ancestors.void note_subtree_style_moved();[[nodiscard]] RefPtr<CSS::CustomPropertyData const> style_custom_property_environment(Layout::BegunRead const& read, CSS::InstalledStyle const&) const;@@ -976,6 +979,7 @@ protected:private:void bump_dom_tree_version_for_attribute_change();+ void clear_custom_highlight_styles();// The attributes of an element, in order, in the same allocation as their count and capacity.class AttributeList {AK_MAKE_NONCOPYABLE(AttributeList);diff --git a/Libraries/LibWeb/DOM/ElementRareData.h b/Libraries/LibWeb/DOM/ElementRareData.hindex 963aadb400d..38dfce094d4 100644--- a/Libraries/LibWeb/DOM/ElementRareData.h+++ b/Libraries/LibWeb/DOM/ElementRareData.h@@ -32,6 +32,7 @@ struct Element::RareDataGC::Ptr<DOMTokenList> part_list;GC::Ptr<NamedNodeMap> attribute_map;mutable OwnPtr<PseudoElementData> pseudo_element_data;+ CustomHighlightStyles custom_highlight_styles;Optional<CSS::PseudoElement> associated_shadow_host_pseudo_element;Vector<Utf16FlyString> parts;diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cppindex 100c92c5043..9a89229e7ab 100644--- a/Libraries/LibWeb/DOM/Node.cpp+++ b/Libraries/LibWeb/DOM/Node.cpp@@ -524,6 +524,7 @@ void Node::bump_dom_tree_version()document().set_needs_highlight_style_update(CSS::PseudoElement::Selection);document().set_needs_highlight_style_update(CSS::PseudoElement::SearchText);document().set_needs_highlight_style_update(CSS::PseudoElement::SpellingError);+ document().set_needs_highlight_style_update(CSS::PseudoElement::Highlight);if (auto* holder = tree_version_holder(*this))holder->m_dom_tree_version = ++s_last_tree_version;}diff --git a/Libraries/LibWeb/DOM/PseudoElement.cpp b/Libraries/LibWeb/DOM/PseudoElement.cppindex e9c8e5e6a7b..ec64cecf2d4 100644--- a/Libraries/LibWeb/DOM/PseudoElement.cpp+++ b/Libraries/LibWeb/DOM/PseudoElement.cpp@@ -93,7 +93,7 @@ void SyntheticPseudoElement::replace_installed_style(Layout::BegunRead const& reif (auto* layout_node = unsafe_layout_node(read))layout_node->set_style_record_identity(m_installed_style.record());if (auto style_node_id = m_originating_element->style_node_id(); style_node_id != 0)- CSS::StyleEngineFFI::style_engine_set_held_pseudo_style_record(style_computer.style_engine().host(), style_node_id, to_underlying(type()), style_record_identity.value(), held_before.record_pointer());+ CSS::StyleEngineFFI::style_engine_set_held_pseudo_style_record(style_computer.style_engine().host(), style_node_id, to_underlying(type()), {}, style_record_identity.value(), held_before.record_pointer());}void SyntheticPseudoElement::swap_in_style_record(Layout::BegunRead const& read, void const* record)@@ -129,7 +129,7 @@ void SyntheticPseudoElement::clear_computed_style(RefPtr<CSS::ComputedValues conlayout_node->pin_style_record_for_detachment();}if (auto style_node_id = m_originating_element->style_node_id(); style_node_id != 0 && !!m_installed_style.record())- CSS::StyleEngineFFI::style_engine_set_held_pseudo_style_record(m_originating_element->document().style_computer().style_engine().host(), style_node_id, to_underlying(type()), 0, m_installed_style.record_pointer());+ CSS::StyleEngineFFI::style_engine_set_held_pseudo_style_record(m_originating_element->document().style_computer().style_engine().host(), style_node_id, to_underlying(type()), {}, 0, m_installed_style.record_pointer());}m_installed_style = {};}diff --git a/Libraries/LibWeb/DOM/Range.cpp b/Libraries/LibWeb/DOM/Range.cppindex 0a13e194c2f..85fd6772576 100644--- a/Libraries/LibWeb/DOM/Range.cpp+++ b/Libraries/LibWeb/DOM/Range.cpp@@ -10,6 +10,7 @@#include <AK/AllOf.h>#include <LibGC/Heap.h>+#include <LibWeb/CSS/HighlightRegistry.h>#include <LibWeb/DOM/Comment.h>#include <LibWeb/DOM/Document.h>#include <LibWeb/DOM/DocumentFragment.h>@@ -101,6 +102,18 @@ void Range::update_owner_document()document.attach_range({}, *this);}+void Range::update_associated_highlights(GC::Ptr<Document> previous_owner_document)+{+ auto invalidate_if_registered_in = [&](GC::Ptr<Document> document) {+ auto* registry = document ? document->highlight_registry_if_exists() : nullptr;+ if (registry && registry->contains_range(*this))+ document->invalidate_custom_highlights();+ };+ invalidate_if_registered_in(previous_owner_document);+ if (m_owner_document != previous_owner_document)+ invalidate_if_registered_in(m_owner_document);+}+void Range::set_associated_selection(Badge<Selection::Selection>, GC::Ptr<Selection::Selection> selection){auto had_selection = m_associated_selection != nullptr;@@ -297,6 +310,7 @@ WebIDL::ExceptionOr<void> Range::set_start_or_end(GC::Ref<Node> node, u32 offsetreturn WebIDL::IndexSizeError::create(Utf16String::formatted("Node does not contain a child at offset {}", offset));// 3. Let bp be the boundary point (node, offset).+ GC::Ptr<Document> previous_owner_document = m_owner_document;if (start_or_end == StartOrEnd::Start) {// -> If these steps were invoked as "set the start"@@ -327,6 +341,7 @@ WebIDL::ExceptionOr<void> Range::set_start_or_end(GC::Ref<Node> node, u32 offsetupdate_owner_document();update_associated_selection();+ update_associated_highlights(previous_owner_document);return {};}@@ -499,6 +514,7 @@ WebIDL::ExceptionOr<void> Range::select(GC::Ref<Node> node)// 3. Let index be node’s index.auto index = node->index();+ GC::Ptr<Document> previous_owner_document = m_owner_document;// 4. Set range’s start to boundary point (parent, index).m_start_container = *parent;@@ -510,6 +526,7 @@ WebIDL::ExceptionOr<void> Range::select(GC::Ref<Node> node)update_owner_document();update_associated_selection();+ update_associated_highlights(previous_owner_document);return {};}@@ -532,6 +549,7 @@ void Range::collapse(bool to_start)m_start_offset = m_end_offset;}update_associated_selection();+ update_associated_highlights(m_owner_document);}// https://dom.spec.whatwg.org/#dom-range-selectnodecontents@@ -543,6 +561,7 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(GC::Ref<Node> node)// 2. Let length be the length of node.auto length = node->length();+ GC::Ptr<Document> previous_owner_document = m_owner_document;// 3. Set start to the boundary point (node, 0).m_start_container = node;@@ -554,6 +573,7 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(GC::Ref<Node> node)update_owner_document();update_associated_selection();+ update_associated_highlights(previous_owner_document);return {};}diff --git a/Libraries/LibWeb/DOM/Range.h b/Libraries/LibWeb/DOM/Range.hindex 595ff7026ca..63c2bbb4323 100644--- a/Libraries/LibWeb/DOM/Range.h+++ b/Libraries/LibWeb/DOM/Range.h@@ -145,6 +145,7 @@ private:GC::Ref<Node> root() const;void update_associated_selection();+ void update_associated_highlights(GC::Ptr<Document> previous_owner_document);enum class StartOrEnd {Start,diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cppindex 7e5ba799aab..48308591c0d 100644--- a/Libraries/LibWeb/Layout/Node.cpp+++ b/Libraries/LibWeb/Layout/Node.cpp@@ -671,7 +671,7 @@ void NodeWithStyle::adopt_style_record_installed_by_render_state()void NodeWithStyle::did_update_style_record(){- if (auto const* element = as_if<DOM::Element>(dom_node()); element && (element->has_style(CSS::PseudoElement::Selection) || element->has_style(CSS::PseudoElement::SearchText) || element->has_style(CSS::PseudoElement::SearchTextCurrent) || element->has_style(CSS::PseudoElement::SpellingError)))+ if (auto const* element = as_if<DOM::Element>(dom_node()); element && (element->has_style(CSS::PseudoElement::Selection) || element->has_style(CSS::PseudoElement::SearchText) || element->has_style(CSS::PseudoElement::SearchTextCurrent) || element->has_style(CSS::PseudoElement::SpellingError) || element->custom_highlight_styles()))Painting::push_highlight_pseudo_styles(*element);if (style_group<CSS::ComputedValues::MiscInteractionValues>().scroll_snap_strictness_value() != CSS::ScrollSnapStrictness::None)diff --git a/Libraries/LibWeb/Painting/BoxViews.cpp b/Libraries/LibWeb/Painting/BoxViews.cppindex 30f82d24995..cc57739de52 100644--- a/Libraries/LibWeb/Painting/BoxViews.cpp+++ b/Libraries/LibWeb/Painting/BoxViews.cpp@@ -767,8 +767,19 @@ DOM::NodeIdentity node_identity_of(Layout::RustFFI::FfiNodeIdentity identity)void push_highlight_pseudo_styles(DOM::Element const& element){- if (auto* arena = const_cast<DOM::Document&>(element.document()).layout_node_arena_if_created())- Layout::RustFFI::render_state_sync_highlight_pseudo_styles(arena->host(), element.style_node_id().value(), element.style_record_identity(CSS::PseudoElement::Selection).value(), element.style_record_identity(CSS::PseudoElement::SearchText).value(), element.style_record_identity(CSS::PseudoElement::SearchTextCurrent).value(), element.style_record_identity(CSS::PseudoElement::SpellingError).value());+ auto* arena = const_cast<DOM::Document&>(element.document()).layout_node_arena_if_created();+ if (!arena)+ return;+ Layout::RustFFI::render_state_sync_highlight_pseudo_styles(arena->host(), element.style_node_id().value(), element.style_record_identity(CSS::PseudoElement::Selection).value(), element.style_record_identity(CSS::PseudoElement::SearchText).value(), element.style_record_identity(CSS::PseudoElement::SearchTextCurrent).value(), element.style_record_identity(CSS::PseudoElement::SpellingError).value());+ Vector<u32, 4> names;+ Vector<u64, 4> style_records;+ if (auto const* styles = element.custom_highlight_styles()) {+ for (auto const& [name, style] : *styles) {+ names.append(name.value());+ style_records.append(style.record().value());+ }+ }+ Layout::RustFFI::render_state_sync_custom_highlight_pseudo_styles(arena->host(), element.style_node_id().value(), names.span(), style_records.span());}class BoxViewRepaintAccess {diff --git a/Libraries/LibWeb/Painting/DocumentPaintState.cpp b/Libraries/LibWeb/Painting/DocumentPaintState.cppindex ef3f7e8c08b..cb3121f5cac 100644--- a/Libraries/LibWeb/Painting/DocumentPaintState.cpp+++ b/Libraries/LibWeb/Painting/DocumentPaintState.cpp@@ -4,6 +4,8 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <LibWeb/CSS/HighlightRegistry.h>+#include <LibWeb/CSS/StyleComputer.h>#include <LibWeb/DOM/Document.h>#include <LibWeb/DOM/EventTarget.h>#include <LibWeb/DOM/Range.h>@@ -178,7 +180,7 @@ static void append_highlight_entry(Layout::BegunRead const& read, Vector<Layout:}template<typename IsExcluded, typename Callback>-static void for_each_node_in_highlight_range(Layout::BegunRead const& read, DOM::Range& range, IsExcluded is_excluded, Callback callback)+static void for_each_node_in_highlight_range(Layout::BegunRead const& read, DOM::AbstractRange const& range, IsExcluded is_excluded, Callback callback){auto start_container = range.start_container();auto end_container = range.end_container();@@ -285,6 +287,71 @@ void DocumentPaintState::recompute_search_text_states(Layout::BegunRead const& rLayout::RustFFI::render_state_apply_search_text(m_layout_node_arena->host(), viewport_row_slot(read, document), ranges.span(), entries.span());}+// https://dom.spec.whatwg.org/#contained+// A node node is contained in a live range range if node’s root is range’s root, and (node, 0) is after range’s+// start, and (node, node’s length) is before range’s end.+static bool range_contains_node(DOM::AbstractRange const& range, DOM::Node& node)+{+ if (&node.root() != &range.start_container()->root())+ return false;+ auto length = static_cast<WebIDL::UnsignedLong>(node.length());+ return DOM::position_of_boundary_point_relative_to_other_boundary_point({ node, 0 }, range.start()) == DOM::RelativeBoundaryPointPosition::After+ && DOM::position_of_boundary_point_relative_to_other_boundary_point({ node, length }, range.end()) == DOM::RelativeBoundaryPointPosition::Before;+}++void DocumentPaintState::reset_custom_highlight_states()+{+ Layout::RustFFI::render_state_clear_custom_highlights(m_layout_node_arena->host());+}++void DocumentPaintState::recompute_custom_highlight_states(Layout::BegunRead const& read, DOM::Document& document, CSS::HighlightRegistry& registry)+{+ auto& style_engine = document.style_computer().style_engine();+ Vector<u32> layers;+ Vector<Layout::RustFFI::FfiCustomHighlightTextEntry> text_entries;+ Vector<Layout::RustFFI::FfiCustomHighlightReplacedEntry> replaced_entries;+ auto is_excluded = [](DOM::Node const&) { return false; };+ registry.for_each_highlight_in_stacking_order([&](Utf16String const& name, ReadonlySpan<GC::Ref<DOM::AbstractRange>> ranges) {+ auto layer = static_cast<u32>(layers.size());+ bool covers_something = false;+ for (auto const& range : ranges) {+ if (!CSS::HighlightRegistry::range_is_paintable(document, *range))+ continue;+ for_each_node_in_highlight_range(read, *range, is_excluded, [&](DOM::Node& node, SelectionState state) {+ auto* layout_node = node.unsafe_layout_node(read);+ if (!layout_node)+ return;+ if (is<DOM::Text>(node)) {+ bool starts_in_node = state == SelectionState::Start || state == SelectionState::StartAndEnd;+ bool ends_in_node = state == SelectionState::End || state == SelectionState::StartAndEnd;+ text_entries.append({+ .layer = layer,+ .layout_node = Layout::Node::slot_id(layout_node),+ .start_offset = starts_in_node ? range->start_offset() : 0,+ .end_offset = ends_in_node ? range->end_offset() : NumericLimits<size_t>::max(),+ });+ covers_something = true;+ return;+ }+ if (layout_node->kind() == Layout::RustFFI::NodeKind::ImageBox && has_committed_box(*layout_node) && range_contains_node(*range, node)) {+ replaced_entries.append({+ .layer = layer,+ .layout_node = Layout::Node::slot_id(layout_node),+ });+ covers_something = true;+ }+ });+ }+ if (covers_something)+ layers.append(style_engine.intern_atom(Utf16FlyString { name }).value());+ });+ if (text_entries.is_empty() && replaced_entries.is_empty()) {+ reset_custom_highlight_states();+ return;+ }+ Layout::RustFFI::render_state_apply_custom_highlights(m_layout_node_arena->host(), viewport_row_slot(read, document), layers.span(), text_entries.span(), replaced_entries.span());+}+void DocumentPaintState::reset_spelling_error_states(){Layout::RustFFI::render_state_clear_spelling_errors(m_layout_node_arena->host());diff --git a/Libraries/LibWeb/Painting/DocumentPaintState.h b/Libraries/LibWeb/Painting/DocumentPaintState.hindex 9bf967208ba..5e8c8808e63 100644--- a/Libraries/LibWeb/Painting/DocumentPaintState.h+++ b/Libraries/LibWeb/Painting/DocumentPaintState.h@@ -66,6 +66,8 @@ public:void reset_search_text_states();void recompute_spelling_error_states(Layout::BegunRead const& read, DOM::Document&, Editing::SpellingMarkers&);void reset_spelling_error_states();+ void recompute_custom_highlight_states(Layout::BegunRead const& read, DOM::Document&, CSS::HighlightRegistry&);+ void reset_custom_highlight_states();Compositing::ScrollStateSnapshot const& scroll_state_snapshot() const { return m_scroll_state_snapshot; }diff --git a/Libraries/LibWeb/Rust/src/css/style/boundary.rs b/Libraries/LibWeb/Rust/src/css/style/boundary.rsindex b3a1c21be35..2fccdc60b8b 100644--- a/Libraries/LibWeb/Rust/src/css/style/boundary.rs+++ b/Libraries/LibWeb/Rust/src/css/style/boundary.rs@@ -329,6 +329,9 @@ style_boundary! {writes {set_highlight_observing_elements => SetHighlightObservingElements { kind: u8, nodes: Box<[StyleNodeID]> } =>engine.set_highlight_observing_elements(kind, &nodes);+ set_custom_highlight_observing_elements => SetCustomHighlightObservingElements {+ nodes: Box<[StyleNodeID]>, names: Box<[StyleAtomID]>+ } => engine.set_custom_highlight_observing_elements(&nodes, &names);set_fold_id_and_class_name_case => SetFoldIdAndClassNameCase { fold: bool };set_html_element_namespace => SetHtmlElementNamespace { namespace_atom: StyleAtomID };mark_relation_only_style_node => MarkRelationOnlyStyleNode { node: StyleNodeID };@@ -402,9 +405,13 @@ style_boundary! {set_held_style_record => SetHeldStyleRecord { node: StyleNodeID, record: HeldHostRecord }=> engine.set_held_style_record(node, record.0);set_held_pseudo_style_record => SetHeldPseudoStyleRecord {- node: StyleNodeID, pseudo_kind: u8, style_record: u64, released: ReleasedHostRecord+ node: StyleNodeID, pseudo_kind: u8, highlight_name: StyleAtomID, style_record: u64, released: ReleasedHostRecord} => {- engine.set_held_pseudo_style_record(node, pseudo_kind, style_record);+ let target = super::pipeline::PseudoElementTarget {+ kind: pseudo_kind,+ highlight_name,+ };+ engine.set_held_pseudo_style_record(node, target, style_record);drop(released);};set_element_css_defined_animations => SetElementCssDefinedAnimations {diff --git a/Libraries/LibWeb/Rust/src/css/style/computed.rs b/Libraries/LibWeb/Rust/src/css/style/computed.rsindex 480a4d5636e..9974b4279b1 100644--- a/Libraries/LibWeb/Rust/src/css/style/computed.rs+++ b/Libraries/LibWeb/Rust/src/css/style/computed.rs@@ -664,6 +664,7 @@ mod animation_overlay_slots {#[derive(Clone, Copy)]struct PseudoComputedRow {kind: u8,+ highlight_name: StyleAtomID,published: bool,/// The installed record the pseudo-element is assigned.installed: Option<InstalledRecordID>,@@ -707,9 +708,10 @@ impl AnimationOverlayColumn {}impl PseudoComputedRow {- fn new(kind: u8) -> Self {+ fn new(target: super::pipeline::PseudoElementTarget) -> Self {Self {- kind,+ kind: target.kind,+ highlight_name: target.highlight_name,published: false,installed: None,installed_overlay_slot: None,@@ -719,6 +721,13 @@ impl PseudoComputedRow {fn is_empty(&self) -> bool {!self.published && self.installed.is_none()}++ fn target(&self) -> super::pipeline::PseudoElementTarget {+ super::pipeline::PseudoElementTarget {+ kind: self.kind,+ highlight_name: self.highlight_name,+ }+ }}#[derive(Clone, Copy)]struct AnimationOverlayPublication {@@ -1019,33 +1028,49 @@ impl ComputedGroupSets {self.pseudo_rows_by_node.get(&node).map_or(&[], |rows| rows.as_slice())}- fn pseudo_row(&self, node: StyleNodeID, kind: u8) -> Option<&PseudoComputedRow> {- self.pseudo_rows(node).iter().find(|row| row.kind == kind)+ fn pseudo_row(+ &self,+ node: StyleNodeID,+ target: super::pipeline::PseudoElementTarget,+ ) -> Option<&PseudoComputedRow> {+ self.pseudo_rows(node).iter().find(|row| row.target() == target)}- fn pseudo_row_mut(&mut self, node: StyleNodeID, kind: u8) -> Option<&mut PseudoComputedRow> {+ fn pseudo_row_mut(+ &mut self,+ node: StyleNodeID,+ target: super::pipeline::PseudoElementTarget,+ ) -> Option<&mut PseudoComputedRow> {self.pseudo_rows_moved.push(node);self.pseudo_rows_by_node.get_mut(&node)- .and_then(|rows| rows.iter_mut().find(|row| row.kind == kind))+ .and_then(|rows| rows.iter_mut().find(|row| row.target() == target))}- fn ensure_pseudo_row(&mut self, node: StyleNodeID, kind: u8) -> &mut PseudoComputedRow {+ fn ensure_pseudo_row(+ &mut self,+ node: StyleNodeID,+ target: super::pipeline::PseudoElementTarget,+ ) -> &mut PseudoComputedRow {self.pseudo_rows_moved.push(node);let rows = self.pseudo_rows_by_node.entry(node).or_default();- let row_index = rows.iter().position(|row| row.kind == kind).unwrap_or_else(|| {- rows.push(PseudoComputedRow::new(kind));+ let row_index = rows.iter().position(|row| row.target() == target).unwrap_or_else(|| {+ rows.push(PseudoComputedRow::new(target));rows.len() - 1});&mut rows[row_index]}- fn remove_empty_pseudo_row(&mut self, node: StyleNodeID, kind: u8) {+ fn remove_empty_pseudo_row(&mut self, node: StyleNodeID, target: super::pipeline::PseudoElementTarget) {self.pseudo_rows_moved.push(node);let std::collections::hash_map::Entry::Occupied(mut entry) = self.pseudo_rows_by_node.entry(node) else {return;};- let Some(row_index) = entry.get().iter().position(|row| row.kind == kind && row.is_empty()) else {+ let Some(row_index) = entry+ .get()+ .iter()+ .position(|row| row.target() == target && row.is_empty())+ else {return;};entry.get_mut().remove(row_index);@@ -1134,10 +1159,23 @@ impl ComputedGroupSets {node: StyleNodeID,pseudo_kind: u8,record: FinalStyleRecordID,+ ) {+ self.assign_installed_pseudo_record_of(+ node,+ super::pipeline::PseudoElementTarget::of_kind(pseudo_kind),+ record,+ );+ }++ pub(super) fn assign_installed_pseudo_record_of(+ &mut self,+ node: StyleNodeID,+ target: super::pipeline::PseudoElementTarget,+ record: FinalStyleRecordID,) {let installed = record.installed_record().expect("an installed record");self.installed.hold(installed);- let row = self.ensure_pseudo_row(node, pseudo_kind);+ let row = self.ensure_pseudo_row(node, target);row.published = true;let previous = row.installed.replace(installed);let overlay = row.installed_overlay_slot.take();@@ -1162,6 +1200,7 @@ impl ComputedGroupSets {let styles: InstalledPseudoStyles = self.pseudo_rows(node).iter()+ .filter(|row| row.highlight_name.is_none()).filter_map(|row| {let id = row.installed?;Some(InstalledPseudoStyle {@@ -1251,7 +1290,7 @@ impl ComputedGroupSets {target: ComputedStyleTarget,) -> Option<(InstalledRecordID, Option<u32>)> {if target.is_pseudo() {- let row = self.pseudo_row(target.node, target.pseudo_kind)?;+ let row = self.pseudo_row(target.node, target.pseudo_element())?;return Some((row.installed?, row.installed_overlay_slot));}let index = target.node.element_index()? as usize;@@ -1309,7 +1348,7 @@ impl ComputedGroupSets {fn set_animation_overlay_slot_of(&mut self, target: ComputedStyleTarget, slot: Option<u32>) {if target.is_pseudo() {- let Some(row) = self.pseudo_row_mut(target.node, target.pseudo_kind) else {+ let Some(row) = self.pseudo_row_mut(target.node, target.pseudo_element()) else {return;};if row.installed.is_some() {@@ -1594,10 +1633,33 @@ impl ComputedGroupSets {}pub fn pseudo_style_record(&self, node: StyleNodeID, pseudo_kind: u8) -> Option<FinalStyleRecordID> {- let row = self.pseudo_row(node, pseudo_kind)?;+ self.pseudo_style_record_of(node, super::pipeline::PseudoElementTarget::of_kind(pseudo_kind))+ }++ pub(super) fn pseudo_style_record_of(+ &self,+ node: StyleNodeID,+ target: super::pipeline::PseudoElementTarget,+ ) -> Option<FinalStyleRecordID> {+ let row = self.pseudo_row(node, target)?;Some(self.final_style_record(row.installed?, row.installed_overlay_slot))}+ pub(super) fn custom_highlight_records(+ &self,+ node: StyleNodeID,+ ) -> impl Iterator<Item = (StyleAtomID, FinalStyleRecordID)> + '_ {+ self.pseudo_rows(node).iter().filter_map(move |row| {+ if row.highlight_name.is_none() {+ return None;+ }+ Some((+ row.highlight_name,+ self.final_style_record(row.installed?, row.installed_overlay_slot),+ ))+ })+ }+/// Each record a pseudo-element holds, with the node it belongs to.pub(super) fn pseudo_style_records(&self) -> impl Iterator<Item = (StyleNodeID, FinalStyleRecordID)> + '_ {self.pseudo_rows_by_node.iter().flat_map(move |(&node, rows)| {@@ -1613,7 +1675,7 @@ impl ComputedGroupSets {pub fn assigned_pseudo_kinds(&self, node: StyleNodeID) -> impl Iterator<Item = u8> + '_ {self.pseudo_rows(node).iter()- .filter_map(|row| row.published.then_some(row.kind))+ .filter_map(|row| (row.published && row.highlight_name.is_none()).then_some(row.kind))}/// The groups whose values read, from `values`, the recorded specified values of the longhands@@ -1702,8 +1764,12 @@ impl ComputedGroupSets {}}- pub fn remove_pseudo(&mut self, node: StyleNodeID, pseudo_kind: u8) -> Option<FinalStyleRecordID> {- let row = self.pseudo_row_mut(node, pseudo_kind)?;+ pub(super) fn remove_pseudo_of(+ &mut self,+ node: StyleNodeID,+ target: super::pipeline::PseudoElementTarget,+ ) -> Option<FinalStyleRecordID> {+ let row = self.pseudo_row_mut(node, target)?;let installed = row.installed.take()?;let overlay = row.installed_overlay_slot.take();row.published = false;@@ -1712,7 +1778,7 @@ impl ComputedGroupSets {self.release_animation_overlay_assignment(slot);}self.installed.release(installed);- self.remove_empty_pseudo_row(node, pseudo_kind);+ self.remove_empty_pseudo_row(node, target);Some(final_style_record)}#[must_use]@@ -1978,8 +2044,14 @@ mod tests {assert_eq!(pseudo_record, first_record);assert_eq!(sets.pseudo_style_record(pseudo.node, 2), Some(pseudo_record));assert_eq!(sets.assigned_pseudo_kinds(pseudo.node).collect::<Vec<_>>(), [2]);- assert_eq!(sets.remove_pseudo(pseudo.node, 2), Some(pseudo_record));- assert_eq!(sets.remove_pseudo(pseudo.node, 2), None);+ assert_eq!(+ sets.remove_pseudo_of(pseudo.node, super::super::pipeline::PseudoElementTarget::of_kind(2)),+ Some(pseudo_record)+ );+ assert_eq!(+ sets.remove_pseudo_of(pseudo.node, super::super::pipeline::PseudoElementTarget::of_kind(2)),+ None+ );}#[test]diff --git a/Libraries/LibWeb/Rust/src/css/style/inputs.rs b/Libraries/LibWeb/Rust/src/css/style/inputs.rsindex 6056aaaacdb..edd4643d61d 100644--- a/Libraries/LibWeb/Rust/src/css/style/inputs.rs+++ b/Libraries/LibWeb/Rust/src/css/style/inputs.rs@@ -604,6 +604,14 @@ impl RetainedState {.map(computed::FinalStyleRecordID::raw)}+ #[must_use]+ pub fn pseudo_published_custom_highlight_records(&self, node: StyleNodeID) -> SmallVec<[(StyleAtomID, u64); 2]> {+ self.computed_group_sets+ .custom_highlight_records(node)+ .map(|(name, record)| (name, record.raw()))+ .collect()+ }+/// The box facts the element's published style record holds. `None` while the element has no/// record.#[must_use]@@ -1266,19 +1274,24 @@ impl RetainedState {}}- /// Record the style record the pseudo-element of `pseudo_kind` of an element holds; zero is+ /// Record the style record the pseudo-element `target` of an element holds; zero is/// none. The host's reference to the record keeps its identity naming it, even when the engine/// publishes a newer assignment.- pub fn set_held_pseudo_style_record(&mut self, node: StyleNodeID, pseudo_kind: u8, style_record: u64) {+ pub(in crate::css::style) fn set_held_pseudo_style_record(+ &mut self,+ node: StyleNodeID,+ target: pipeline::PseudoElementTarget,+ style_record: u64,+ ) {let held = self.held_pseudo_style_records.entry(node).or_default();- let slot = held.iter().position(|&(kind, _)| kind == pseudo_kind);+ let slot = held.iter().position(|&(held_target, _)| held_target == target);match slot {Some(slot) if style_record == 0 => {held.swap_remove(slot);}Some(slot) => held[slot].1 = style_record,None if style_record == 0 => {}- None => held.push((pseudo_kind, style_record)),+ None => held.push((target, style_record)),}if held.is_empty() {self.held_pseudo_style_records.remove(&node);@@ -1949,6 +1962,23 @@ impl StyleEngine {}}+ pub fn set_custom_highlight_observing_elements(&mut self, nodes: &[StyleNodeID], names: &[StyleAtomID]) {+ let mut moved = Vec::new();+ self.retained.highlight_observers.replace_custom_highlights(+ nodes.iter().copied().zip(names.iter().copied()),+ |node| {+ moved.push(node);+ },+ );+ for node in moved {+ self.record_derived_element_style_input(+ node,+ input_types::STYLE_REACTION_PSEUDO_INPUTS_MAY_HAVE_CHANGED,+ 0,+ );+ }+ }+pub fn record_derived_element_style_input(&mut self, node: StyleNodeID, reaction: u8, inherited_style_groups: u8) {if reaction == 0 {return;diff --git a/Libraries/LibWeb/Rust/src/css/style/mod.rs b/Libraries/LibWeb/Rust/src/css/style/mod.rsindex 4d0f71e1b70..f864ba05fad 100644--- a/Libraries/LibWeb/Rust/src/css/style/mod.rs+++ b/Libraries/LibWeb/Rust/src/css/style/mod.rs@@ -131,8 +131,9 @@ use std::sync::Mutex;/// Attribute names a document's selectors read, which its engine shares with its host.pub(crate) type SelectorAttributeNames = Arc<HashSet<StyleAtomID>>;-/// The style record each pseudo-element of an element holds, by its kind.-type HeldPseudoStyleRecords = crate::fork::ForkShared<HashMap<StyleNodeID, smallvec::SmallVec<[(u8, u64); 1]>>>;+/// The style record each pseudo-element of an element holds.+type HeldPseudoStyleRecords =+ crate::fork::ForkShared<HashMap<StyleNodeID, smallvec::SmallVec<[(pipeline::PseudoElementTarget, u64); 1]>>>;/// What an element's arrival has to carry to reach the anchor of a `:has()` argument: a name whose raw identity is/// among `names` as its tag, ID, class or attribute name, or a state among `states`. Where an argument can be reached@@ -277,7 +278,7 @@ pub struct RetainedState {/// every record it installs or clears./// Copied on write in chunks of its own, which a fork shares.held_style_records: inputs::HeldStyleRecords,- /// The style record each pseudo-element holds, by its kind, for the elements whose pseudo-elements+ /// The style record each pseudo-element holds, for the elements whose pseudo-elements/// hold one, as the host reports every record it installs or clears.held_pseudo_style_records: HeldPseudoStyleRecords,/// The records a clock frame shows in place of the ones the host installed, which it lends the published readsdiff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/highlight_observers.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/highlight_observers.rsindex d4c799a4279..5a656346f00 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/highlight_observers.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/highlight_observers.rs@@ -15,6 +15,8 @@ use super::super::*;pub(crate) struct HighlightObservers {/// Shared with a fork until either side writes it.kinds: crate::fork::ForkShared<HashMap<StyleNodeID, u8>>,+ /// Shared with a fork until either side writes it.+ custom_highlights: crate::fork::ForkShared<HashMap<StyleNodeID, SmallVec<[StyleAtomID; 2]>>>,}fn bit_of(kind: u8) -> Option<u8> {@@ -58,10 +60,53 @@ impl HighlightObservers {}}+ pub(crate) fn custom_highlights_of(&self, node: StyleNodeID) -> &[StyleAtomID] {+ self.custom_highlights.get(&node).map_or(&[], |names| names.as_slice())+ }++ pub(in crate::css::style) fn observes_target(&self, node: StyleNodeID, target: super::PseudoElementTarget) -> bool {+ match target.is_custom_highlight() {+ true => self.custom_highlights_of(node).contains(&target.highlight_name),+ false => self.observes(node, target.kind),+ }+ }++ pub(crate) fn replace_custom_highlights(+ &mut self,+ observed: impl Iterator<Item = (StyleNodeID, StyleAtomID)>,+ mut moved: impl FnMut(StyleNodeID),+ ) {+ let mut incoming: HashMap<StyleNodeID, SmallVec<[StyleAtomID; 2]>> = HashMap::default();+ for (node, name) in observed {+ let names = incoming.entry(node).or_default();+ if !names.contains(&name) {+ names.push(name);+ }+ }+ for names in incoming.values_mut() {+ names.sort_unstable();+ }+ self.custom_highlights.retain(|node, names| {+ if incoming.get(node) != Some(names) {+ moved(*node);+ }+ incoming.contains_key(node)+ });+ for (node, names) in incoming {+ if !self.custom_highlights.contains_key(&node) {+ moved(node);+ }+ self.custom_highlights.insert(node, names);+ }+ }+/// Forget `node`, whose identity retires.pub(crate) fn retire(&mut self, node: StyleNodeID) {if self.kinds.contains_key(&node) {self.kinds.remove(&node);}+ if self.custom_highlights.contains_key(&node) {+ self.custom_highlights.remove(&node);+ }}}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rsindex 43decb80c55..2f25d45a594 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs@@ -39,6 +39,7 @@ impl PseudoSlot {pub struct StyleSwap {style_node: u32,slot: PseudoSlot,+ highlight_name: u32,record: *const std::ffi::c_void,}@@ -53,6 +54,7 @@ impl StyleSwap {state: &RetainedState,node: StyleNodeID,slot: PseudoSlot,+ highlight_name: StyleAtomID,style_record: computed::FinalStyleRecordID,) -> Self {let record = match style_record.raw() {@@ -68,6 +70,7 @@ impl StyleSwap {Self {style_node: node.raw(),slot,+ highlight_name: highlight_name.0,record,}}@@ -133,7 +136,13 @@ impl StyleInstallation {PseudoSlot::ELEMENT => {state.set_held_style_record(node, unsafe { bridge::retain_host_record(swap.record) });}- PseudoSlot(kind) => state.set_held_pseudo_style_record(node, kind, swap.style_record()),+ PseudoSlot(kind) => {+ let target = super::PseudoElementTarget {+ kind,+ highlight_name: StyleAtomID(swap.highlight_name),+ };+ state.set_held_pseudo_style_record(node, target, swap.style_record());+ }}}};@@ -369,9 +378,13 @@ impl RetainedState {// display:none.let main_holds_new = self.held_style_record(node) == Some(new);if !main_holds_new {- installation- .swaps- .push(StyleSwap::new(self, node, PseudoSlot::ELEMENT, new_record));+ installation.swaps.push(StyleSwap::new(+ self,+ node,+ PseudoSlot::ELEMENT,+ StyleAtomID::NONE,+ new_record,+ ));}let record_damage = match old != 0 && old != new {true => element_damage | bridge::FfiStyleInvalidationField::EngineComputed as u32,@@ -407,11 +420,11 @@ impl RetainedState {});// The pseudo-elements follow their element, the ones that no longer generate a box// with no record.- let main_holds_pseudo = |state: &Self, kind: u8| {+ let main_holds_pseudo = |state: &Self, target: super::PseudoElementTarget| {state.held_pseudo_style_records.get(&node)- .and_then(|held| held.iter().find(|&&(held_kind, _)| held_kind == kind))+ .and_then(|held| held.iter().find(|&&(held_target, _)| held_target == target)).map_or(0, |&(_, record)| record)};for kind in super::PSEUDO_ELEMENT_KINDS {@@ -449,16 +462,22 @@ impl RetainedState {}// The main thread may hold a record a read demanded for a pseudo-element that generates no// box, which goes as the element's styles move.- None if old_pseudo == 0 && main_holds_pseudo(self, kind) == 0 => continue,+ None if old_pseudo == 0+ && main_holds_pseudo(self, super::PseudoElementTarget::of_kind(kind)) == 0 =>+ {+ continue;+ }None => computed::FinalStyleRecordID::NONE,};let new_pseudo = new_pseudo_record.raw();- let main_holds_new_pseudo = main_holds_pseudo(self, kind) == new_pseudo;+ let main_holds_new_pseudo =+ main_holds_pseudo(self, super::PseudoElementTarget::of_kind(kind)) == new_pseudo;if !main_holds_new_pseudo {installation.swaps.push(StyleSwap::new(self,node,PseudoSlot::pseudo_element(kind),+ StyleAtomID::NONE,new_pseudo_record,));}@@ -535,6 +554,83 @@ impl RetainedState {composed_by_the_host: composition.composed_by_the_host,});}+ let custom_highlights = self+ .computed_group_sets+ .custom_highlight_records(node)+ .map(|(name, _)| super::PseudoElementTarget::custom_highlight(name))+ .chain(+ pseudo_element_records+ .iter()+ .map(|&(target, _)| target)+ .filter(|target| target.is_custom_highlight()),+ )+ .fold(+ SmallVec::<[super::PseudoElementTarget; 2]>::new(),+ |mut targets, target| {+ if !targets.contains(&target) {+ targets.push(target);+ }+ targets+ },+ );+ for target in custom_highlights {+ let old_pseudo_record = self+ .computed_group_sets+ .pseudo_style_record_of(node, target)+ .unwrap_or(computed::FinalStyleRecordID::NONE);+ let old_pseudo = old_pseudo_record.raw();+ let new_pseudo_record = match pseudo_element_records.iter().find(|(held, _)| *held == target) {+ Some((_, pseudo_record)) => {+ self.note_container_unit_reads(node, pseudo_record, true);+ let pseudo_environment = self.pseudo_element_environment(+ node,+ pseudo_record,+ record,+ environment,+ &mut scratch.minted,+ );+ let pseudo_record: &Arc<Record> =+ &self.record_in_environment(pseudo_record, pseudo_environment);+ let new_pseudo_record = self.install_record(pseudo_record, &mut scratch.installed);+ if old_pseudo != 0 && old_pseudo != new_pseudo_record.raw() {+ self.computed_group_sets.pin_style_record(old_pseudo);+ installation.pinned_records.push(old_pseudo);+ }+ self.computed_group_sets+ .assign_installed_pseudo_record_of(node, target, new_pseudo_record);+ new_pseudo_record+ }+ None if old_pseudo == 0 && main_holds_pseudo(self, target) == 0 => continue,+ None => computed::FinalStyleRecordID::NONE,+ };+ let new_pseudo = new_pseudo_record.raw();+ if main_holds_pseudo(self, target) != new_pseudo {+ installation.swaps.push(StyleSwap::new(+ self,+ node,+ PseudoSlot::pseudo_element(target.kind),+ target.highlight_name,+ new_pseudo_record,+ ));+ }+ if old_pseudo == new_pseudo {+ continue;+ }+ let record_damage =+ self.pseudo_element_record_damage(node, target.kind, old_pseudo, new_pseudo, new, false)+ | bridge::FfiStyleInvalidationField::EngineComputed as u32;+ self.note_pseudo_element_move(+ &mut pseudo_elements,+ node,+ target.kind,+ (old_pseudo, new_pseudo, new),+ record_damage,+ below_display_none,+ );+ if new_pseudo_record == computed::FinalStyleRecordID::NONE {+ self.remove_computed_pseudo_of(node, target);+ }+ }if old != new|| !main_holds_new|| plan_oweddiff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rsindex 82da09a02fe..6d128e04e5f 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs@@ -2325,14 +2325,14 @@ impl Live {// anew.for &node in &kept {let holds_demanded = state.held_pseudo_style_records.get(&node).is_some_and(|held| {- held.iter().any(|&(kind, record)| {+ held.iter().any(|&(target, record)| {record != 0- && super::PSEUDO_ELEMENT_KINDS.contains(&kind)+ && super::PSEUDO_ELEMENT_KINDS.contains(&target.kind)&& !self.records.pseudo_element_records(node).iter()- .any(|(generated, _)| *generated == super::PseudoElementTarget::of_kind(kind))+ .any(|(generated, _)| *generated == target)})});if holds_demanded {diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rsindex 35284c81698..bc64df5517f 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs@@ -311,7 +311,8 @@ impl RetainedState {).with(MainEffects::HIGHLIGHTS,- self.holds_pseudo_element_records_of(node, &HIGHLIGHT_PSEUDO_ELEMENTS),+ self.holds_pseudo_element_records_of(node, &HIGHLIGHT_PSEUDO_ELEMENTS)+ || self.computed_group_sets.custom_highlight_records(node).next().is_some(),).with(MainEffects::ANIMATED,@@ -440,7 +441,7 @@ mod tests {let marker_record = held(state.computed_group_sets.pseudo_style_record(node, MARKER));let element_held = state.computed_group_sets.host_record(element_record).cloned();state.set_held_style_record(node, element_held);- state.set_held_pseudo_style_record(node, MARKER, marker_record);+ state.set_held_pseudo_style_record(node, super::super::PseudoElementTarget::of_kind(MARKER), marker_record);installation.effects_of(node).is_some_and(|effects| effects.effects.intersects(MainEffects::REBUILD))diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rsindex 11351f03b87..6377e4e7bd2 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rs@@ -152,6 +152,13 @@ impl PseudoElementTarget {}}+ pub(in super::super) const fn custom_highlight(name: StyleAtomID) -> Self {+ Self {+ kind: super::super::publication::pseudo_kind::HIGHLIGHT,+ highlight_name: name,+ }+ }+pub(in super::super) fn is_custom_highlight(self) -> bool {!self.highlight_name.is_none()}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/sharing.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/sharing.rsindex 30e1e2d73d2..037859c3a6c 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/sharing.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/sharing.rs@@ -94,6 +94,7 @@ pub(super) fn key_of(// NB: A pseudo-element's record substitutes the custom properties its own animations sampled, which are not the// same for two elements with the same rules: their animations can stand at different times.|| state.pseudo_element_samples_custom_properties(node)+ || !state.highlight_observers.custom_highlights_of(node).is_empty(){return None;}diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rsindex 8140f25fd2d..fb278481d87 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs@@ -1225,17 +1225,23 @@ impl<'a> Scratch<'a> {}}}- if kinds == 0 {+ let custom_highlights = context.state.highlight_observers.custom_highlights_of(node);+ if kinds == 0 && custom_highlights.is_empty() {return Some((pseudo_element_records, element_dependent));}let inherited = PseudoElementInheritance::of(context, node, &element);// The conditions of a pseudo-element's rules ask about its element's record first.self.apply_container_gates(context, node, true);- for kind in super::PSEUDO_ELEMENT_KINDS {- if kinds & (1 << kind) == 0 {- continue;- }- let target = super::PseudoElementTarget::of_kind(kind);+ let targets = super::PSEUDO_ELEMENT_KINDS+ .into_iter()+ .filter(|&kind| kinds & (1 << kind) != 0)+ .map(super::PseudoElementTarget::of_kind)+ .chain(+ custom_highlights+ .iter()+ .map(|&name| super::PseudoElementTarget::custom_highlight(name)),+ );+ for target in targets {match self.compute_pseudo_element(context,node,@@ -1285,7 +1291,7 @@ impl<'a> Scratch<'a> {let highlight = super::super::publication::pseudo_kind::is_highlight(kind);// A pass styles the highlight pseudo-elements of the elements the host shows a highlight// of their kind in, and a read of their styles those of any other.- if generating && highlight && !state.highlight_observers.observes(node, kind) {+ if generating && highlight && !state.highlight_observers.observes_target(node, target) {return PseudoElementOutcome::Unstyled;}// https://drafts.csswg.org/css-position-4/#backdropdiff --git a/Libraries/LibWeb/Rust/src/css/style/publication.rs b/Libraries/LibWeb/Rust/src/css/style/publication.rsindex 0202767c307..113625b271b 100644--- a/Libraries/LibWeb/Rust/src/css/style/publication.rs+++ b/Libraries/LibWeb/Rust/src/css/style/publication.rs@@ -53,10 +53,7 @@ impl RetainedState {node: StyleNodeID,target: pipeline::PseudoElementTarget,) -> Option<computed::FinalStyleRecordID> {- match target.is_custom_highlight() {- true => None,- false => self.computed_group_sets.pseudo_style_record(node, target.kind),- }+ self.computed_group_sets.pseudo_style_record_of(node, target)}#[cfg(test)]@@ -664,9 +661,17 @@ impl RetainedState {&mut self,node: StyleNodeID,pseudo_kind: u8,+ ) -> Option<computed::FinalStyleRecordID> {+ self.remove_computed_pseudo_of(node, pipeline::PseudoElementTarget::of_kind(pseudo_kind))+ }++ pub(in crate::css::style) fn remove_computed_pseudo_of(+ &mut self,+ node: StyleNodeID,+ target: pipeline::PseudoElementTarget,) -> Option<computed::FinalStyleRecordID> {let live_animation_overlays_before = self.computed_group_sets.live_animation_overlay_records();- let removed_style_record = self.computed_group_sets.remove_pseudo(node, pseudo_kind);+ let removed_style_record = self.computed_group_sets.remove_pseudo_of(node, target);let live_animation_overlays_after = self.computed_group_sets.live_animation_overlay_records();let removed_style_record = removed_style_record?;self.counters.bump(Counter::ComputedPseudoAssignmentsRemoved);diff --git a/Libraries/LibWeb/Rust/src/css/style/tests.rs b/Libraries/LibWeb/Rust/src/css/style/tests.rsindex b3c95f8a4eb..87ab71b62d8 100644--- a/Libraries/LibWeb/Rust/src/css/style/tests.rs+++ b/Libraries/LibWeb/Rust/src/css/style/tests.rs@@ -1205,7 +1205,7 @@ fn pseudo_element_records_the_host_references_outlive_engine_assignments() {};let held_record = publish(&mut engine, BEFORE, 1);let host_reference = engine.computed_group_sets.host_record(held_record).cloned();- engine.set_held_pseudo_style_record(node, BEFORE, held_record);+ engine.set_held_pseudo_style_record(node, pipeline::PseudoElementTarget::of_kind(BEFORE), held_record);// The engine can publish a replacement before the host installs it.let replacement = publish(&mut engine, BEFORE, 2);@@ -1213,7 +1213,7 @@ fn pseudo_element_records_the_host_references_outlive_engine_assignments() {assert!(engine.computed_group_sets.final_style_record_is_live(held_record));drop(host_reference);- engine.set_held_pseudo_style_record(node, BEFORE, replacement);+ engine.set_held_pseudo_style_record(node, pipeline::PseudoElementTarget::of_kind(BEFORE), replacement);engine.computed_group_sets.reclaim_unreachable();assert!(!engine.computed_group_sets.final_style_record_is_live(held_record));assert!(engine.computed_group_sets.final_style_record_is_live(replacement));diff --git a/Libraries/LibWeb/Rust/src/layout/host_tables.rs b/Libraries/LibWeb/Rust/src/layout/host_tables.rsindex 02ac80cd7a9..13e67ed926d 100644--- a/Libraries/LibWeb/Rust/src/layout/host_tables.rs+++ b/Libraries/LibWeb/Rust/src/layout/host_tables.rs@@ -58,6 +58,8 @@ pub(crate) struct HostTables {pub(crate) shows_search_text: Cell<bool>,/// Whether the host gave the rows spelling-error highlights that it has not cleared since.pub(crate) shows_spelling_errors: Cell<bool>,+ /// Whether the host gave the rows custom highlights that it has not cleared since.+ pub(crate) shows_custom_highlights: Cell<bool>,/// The rows the host gave layer image paint facts, which the arena drops with the row.pub(crate) rows_with_layer_image_paint_facts: RefCell<HashSet<NodeSlotId>>,/// The image resources the tree builds of the rounds the host was paid for owe the rows they stamped, which thediff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex fb8f23b9232..a54886721cc 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -1668,6 +1668,24 @@ impl LayoutNodeArena {Arc::make_mut(styles).remove(&id);}}+ if self+ .paint_state+ .custom_highlight_pseudo_styles+ .values()+ .any(|styles| styles.contains_key(&id))+ {+ let table = Arc::make_mut(&mut self.paint_state.custom_highlight_pseudo_styles);+ for styles in table.values_mut() {+ if styles.contains_key(&id) {+ Arc::make_mut(styles).remove(&id);+ }+ }+ table.retain(|_, styles| !styles.is_empty());+ }+ if self.paint_state.custom_highlights.covers_row(id) {+ Arc::make_mut(&mut self.paint_state.custom_highlights).forget_row(id);+ self.paint_state.bump_custom_highlight_row_generation();+ }let data = self.data_mut(index);debug_assert!(data.parent.get().is_invalid()diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 3d2e6d0a752..46e161de44d 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -4118,6 +4118,11 @@ impl<'a> TreeBuilderHost<'a> {fn create_element_box(&mut self, element: StyleNodeID, kind: NodeKind, record: u64) -> NodeSlotId {let slot = self.stamp_dom_box(kind, Some(element));self.arena_mut().stamp_published_style(slot, record);+ if kind == NodeKind::ImageBox {+ self.arena_mut()+ .paint_state_mut()+ .bump_custom_highlight_row_generation();+ }match kind {// https://html.spec.whatwg.org/multipage/rendering.html#the-fieldset-and-legend-elements// If the computed outer display type is inline, the fieldset is expected to behave as inline-block.@@ -4169,6 +4174,9 @@ impl<'a> TreeBuilderHost<'a> {fn create_text_box(&mut self, style_node: StyleNodeID) -> NodeSlotId {let slot = self.stamp_dom_box(NodeKind::TextNode, Some(style_node));self.stamp_text_row_facts(slot, style_node);+ self.arena_mut()+ .paint_state_mut()+ .bump_custom_highlight_row_generation();slot}@@ -4233,6 +4241,7 @@ impl<'a> TreeBuilderHost<'a> {.pseudo_published_style_record(element, highlight.pseudo_kind()).is_some()})+ || !engine.pseudo_published_custom_highlight_records(element).is_empty()})}diff --git a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs b/Libraries/LibWeb/Rust/src/painting/paint_changes.rsindex 67522c1cb7a..4a4dbe5a8f7 100644--- a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs+++ b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs@@ -15,12 +15,16 @@ use super::host::{use super::image_map_areas::{AreaCoverage, AreaShape, PublishedImageMapArea};use super::layer_image_paint_facts::{LayerImagePaintFacts, LayerImagePaintFactsEntry};use super::paint_read::GeometryRead;-use super::paintable_data::{FfiSearchTextRange, FfiSelectionEntry, FfiSpellingError, PaintableFlag};+use super::paintable_data::{+ FfiCustomHighlightReplacedEntry, FfiCustomHighlightTextEntry, FfiSearchTextRange, FfiSelectionEntry,+ FfiSpellingError, PaintableFlag,+};use super::record::damage::PaintDamage;use super::replaced_paint_facts::{ImagePaintFacts, ReplacedPaintFacts, VideoPaintFacts};use super::selection::HighlightStyleRecords;use super::visual_context::dirty::VisualContextBoxDirtyKind;use crate::css::css_pixels::{CssPixelPoint, FfiCssPixelPoint};+use crate::css::style::index::StyleAtomID;use crate::css::style::tree::StyleNodeID;use crate::layout::LayoutNodeArena;use crate::layout::node_data::NodeSlotId;@@ -57,6 +61,17 @@ pub(crate) enum PaintChange {},/// No text is flagged as misspelled.ClearSpellingErrors,+ /// The registered custom highlights and what of the document they cover.+ ApplyCustomHighlights {+ viewport: NodeSlotId,+ layers: Box<[StyleAtomID]>,+ text_entries: Box<[FfiCustomHighlightTextEntry]>,+ replaced_entries: Box<[FfiCustomHighlightReplacedEntry]>,+ },+ /// No custom highlight covers anything.+ ClearCustomHighlights,+ /// Whether a registered custom highlight holds a range.+ SetHasRegisteredCustomHighlightRanges(bool),/// The element's style changed: the rows that paint text under it take what `style_records`, the `::selection`,/// `::search-text` and `::spelling-error` records the host holds for it (zero for none), say highlighted text/// paints with.@@ -64,6 +79,11 @@ pub(crate) enum PaintChange {element: StyleNodeID,style_records: HighlightStyleRecords,},+ /// The element's style changed. The rows that paint text under it take its `::highlight()` records by name.+ SyncCustomHighlightPseudoStyles {+ element: StyleNodeID,+ style_records: Box<[(StyleAtomID, u64)]>,+ },/// Whether the overlay scrollbar of the row in `direction` has faded out, so that it takes no pointer input.SetScrollbarHidden {node: NodeSlotId,@@ -157,9 +177,31 @@ impl PaintChange {}}Self::ClearSpellingErrors => super::selection::clear_spelling_errors(&mut arena.paintable_rows_mut()),+ Self::ApplyCustomHighlights {+ viewport,+ layers,+ text_entries,+ replaced_entries,+ } => {+ if arena.paintable_row_is_populated(viewport) {+ super::selection::apply_custom_highlights(+ &mut arena.paintable_rows_mut(),+ &layers,+ &text_entries,+ &replaced_entries,+ );+ }+ }+ Self::ClearCustomHighlights => super::selection::clear_custom_highlights(&mut arena.paintable_rows_mut()),+ Self::SetHasRegisteredCustomHighlightRanges(has_ranges) => {+ arena.paint_state_mut().has_registered_custom_highlight_ranges = has_ranges;+ }Self::SyncHighlightPseudoStyles { element, style_records } => {super::selection::sync_highlight_pseudo_styles(arena, element, style_records);}+ Self::SyncCustomHighlightPseudoStyles { element, style_records } => {+ super::selection::sync_custom_highlight_pseudo_styles(arena, element, &style_records);+ }Self::SetScrollbarHidden {node,direction,@@ -285,6 +327,73 @@ pub extern "C" fn render_state_clear_spelling_errors(host: &DocumentHost) {queue(host, PaintChange::ClearSpellingErrors);}+#[unsafe(no_mangle)]+pub extern "C" fn render_state_apply_custom_highlights(+ host: &DocumentHost,+ viewport: NodeSlotId,+ layers: ak::Span<'_, u32>,+ text_entries: ak::Span<'_, FfiCustomHighlightTextEntry>,+ replaced_entries: ak::Span<'_, FfiCustomHighlightReplacedEntry>,+) {+ let tables = host.host_tables();+ tables+ .shows_custom_highlights+ .set(!text_entries.as_slice().is_empty() || !replaced_entries.as_slice().is_empty());+ let change = PaintChange::ApplyCustomHighlights {+ viewport,+ layers: layers.as_slice().iter().copied().map(StyleAtomID).collect(),+ text_entries: text_entries.as_slice().into(),+ replaced_entries: replaced_entries.as_slice().into(),+ };+ queue(host, change);+}++#[unsafe(no_mangle)]+pub extern "C" fn render_state_clear_custom_highlights(host: &DocumentHost) {+ // Rows that show no custom highlights have none to clear.+ if !host.host_tables().shows_custom_highlights.replace(false) {+ return;+ }+ queue(host, PaintChange::ClearCustomHighlights);+}++#[unsafe(no_mangle)]+pub extern "C" fn render_state_set_has_registered_custom_highlight_ranges(host: &DocumentHost, has_ranges: bool) {+ queue(host, PaintChange::SetHasRegisteredCustomHighlightRanges(has_ranges));+}++#[unsafe(no_mangle)]+pub extern "C" fn render_state_custom_highlight_row_generation(+ host: &DocumentHost,+ read: &crate::render_state::BegunRead,+) -> u64 {+ super::ffi::read_arena(host, read, (), |arena, ()| {+ arena.paint_state().custom_highlight_row_generation+ })+}++#[unsafe(no_mangle)]+pub extern "C" fn render_state_sync_custom_highlight_pseudo_styles(+ host: &DocumentHost,+ element: u32,+ names: ak::Span<'_, u32>,+ style_records: ak::Span<'_, u64>,+) {+ let Some(element) = StyleNodeID::from_raw(element) else {+ return;+ };+ let style_records = names+ .as_slice()+ .iter()+ .zip(style_records.as_slice())+ .map(|(&name, &record)| (StyleAtomID(name), record))+ .collect();+ queue(+ host,+ PaintChange::SyncCustomHighlightPseudoStyles { element, style_records },+ );+}+#[unsafe(no_mangle)]pub extern "C" fn render_state_sync_highlight_pseudo_styles(host: &DocumentHost,diff --git a/Libraries/LibWeb/Rust/src/painting/paint_state.rs b/Libraries/LibWeb/Rust/src/painting/paint_state.rsindex 7918467333a..ba68335b1f2 100644--- a/Libraries/LibWeb/Rust/src/painting/paint_state.rs+++ b/Libraries/LibWeb/Rust/src/painting/paint_state.rs@@ -4,11 +4,12 @@* SPDX-License-Identifier: BSD-2-Clause*/+use crate::css::style::index::StyleAtomID;use crate::layout::node_data::NodeSlotId;use crate::painting::paint_read::GeometryRead;use crate::painting::record::paint::text::SelectionStyleAnswer;use crate::painting::selection::{- HighlightPseudoElement, SearchTextHighlights, SelectionRange, SpellingErrorHighlights,+ CustomHighlights, HighlightPseudoElement, SearchTextHighlights, SelectionRange, SpellingErrorHighlights,};use std::collections::HashMap;use std::sync::Arc;@@ -48,11 +49,22 @@ pub struct PaintState {pub(crate) spelling_errors: Arc<SpellingErrorHighlights>,/// The `::spelling-error` styles, shared as the `::selection` styles are.pub(crate) spelling_error_pseudo_styles: Arc<SelectionPseudoStyles>,+ /// The registered custom highlights and what they cover, shared with the frames published while they hold.+ pub(crate) custom_highlights: Arc<CustomHighlights>,+ /// The `::highlight()` styles of each custom highlight name, shared as the `::selection` styles are.+ pub(crate) custom_highlight_pseudo_styles: Arc<CustomHighlightPseudoStyles>,+ /// Whether a registered custom highlight holds a range.+ pub(crate) has_registered_custom_highlight_ranges: bool,+ /// Counts the rows tree builds made or retired that a registered custom highlight may cover.+ pub(crate) custom_highlight_row_generation: u64,}/// Each row's committed style for one highlight pseudo-element.pub(crate) type SelectionPseudoStyles = HashMap<NodeSlotId, Arc<SelectionStyleAnswer>>;+/// Each row's committed `::highlight()` style, for each custom highlight name.+pub(crate) type CustomHighlightPseudoStyles = HashMap<StyleAtomID, Arc<SelectionPseudoStyles>>;+impl PaintState {pub(crate) fn highlight_pseudo_styles_mut(&mut self,@@ -66,6 +78,12 @@ impl PaintState {}}+ pub(crate) fn bump_custom_highlight_row_generation(&mut self) {+ if self.has_registered_custom_highlight_ranges {+ self.custom_highlight_row_generation += 1;+ }+ }+pub(crate) fn reset_visual_context_state(&mut self) {self.visual_context = crate::painting::visual_context::VisualContextState {needs_to_refresh_scroll_state: true,diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_data.rs b/Libraries/LibWeb/Rust/src/painting/paintable_data.rsindex 067215492b2..2b315f2a7bf 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_data.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_data.rs@@ -132,6 +132,22 @@ pub struct FfiSpellingError {pub end_offset: usize,}+#[derive(Clone, Copy)]+#[repr(C)]+pub struct FfiCustomHighlightTextEntry {+ pub layer: u32,+ pub layout_node: NodeSlotId,+ pub start_offset: usize,+ pub end_offset: usize,+}++#[derive(Clone, Copy)]+#[repr(C)]+pub struct FfiCustomHighlightReplacedEntry {+ pub layer: u32,+ pub layout_node: NodeSlotId,+}+pub const SELECTION_STATE_NONE: u8 = 0;pub const SELECTION_STATE_START: u8 = 1;pub const SELECTION_STATE_END: u8 = 2;diff --git a/Libraries/LibWeb/Rust/src/painting/published_frame.rs b/Libraries/LibWeb/Rust/src/painting/published_frame.rsindex c8ec459941f..c048a5ae799 100644--- a/Libraries/LibWeb/Rust/src/painting/published_frame.rs+++ b/Libraries/LibWeb/Rust/src/painting/published_frame.rs@@ -22,13 +22,13 @@ use crate::layout::fragment_tree::FragmentLink;use crate::layout::node_data::{NodeSlotId, PaintNode};use crate::layout::tree_shape::PUBLISHED_ROWS_PER_CHUNK;use crate::painting::layer_image_paint_facts::LayerImagePaintFactsTable;-use crate::painting::paint_state::{PaintState, SelectionPseudoStyles};+use crate::painting::paint_state::{CustomHighlightPseudoStyles, PaintState, SelectionPseudoStyles};use crate::painting::paintable_data::{CommittedSideData, PaintableData};use crate::painting::paintable_rows::{CommittedFragmentLinkSlot, PAINTABLE_SLOTS_PER_CHUNK};use crate::painting::record::damage::FrameDamage;use crate::painting::replaced_paint_facts::ReplacedPaintFactsTable;use crate::painting::selection::{- HighlightPseudoElement, SearchTextHighlights, SelectionRange, SpellingErrorHighlights,+ CustomHighlights, HighlightPseudoElement, SearchTextHighlights, SelectionRange, SpellingErrorHighlights,};use crate::painting::stacking_context::entries::StackingContextEntries;use crate::painting::svg_paint_resources::SvgPaintResourceRows;@@ -168,6 +168,8 @@ pub(crate) struct PublishedPaintState {pub(crate) search_text_current_pseudo_styles: Arc<SelectionPseudoStyles>,pub(crate) spelling_errors: Arc<SpellingErrorHighlights>,pub(crate) spelling_error_pseudo_styles: Arc<SelectionPseudoStyles>,+ pub(crate) custom_highlights: Arc<CustomHighlights>,+ pub(crate) custom_highlight_pseudo_styles: Arc<CustomHighlightPseudoStyles>,pub(crate) hit_test_list_generation: u64,/// How many items the document's hit-test list held, which the recording's list reserves.pub(crate) hit_test_item_capacity_hint: usize,@@ -198,6 +200,8 @@ impl PublishedPaintState {search_text_current_pseudo_styles: paint_state.search_text_current_pseudo_styles.clone(),spelling_errors: paint_state.spelling_errors.clone(),spelling_error_pseudo_styles: paint_state.spelling_error_pseudo_styles.clone(),+ custom_highlights: paint_state.custom_highlights.clone(),+ custom_highlight_pseudo_styles: paint_state.custom_highlight_pseudo_styles.clone(),hit_test_list_generation: paint_state.hit_test_list_generation,hit_test_item_capacity_hint,}diff --git a/Libraries/LibWeb/Rust/src/painting/record/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/mod.rsindex 8bfff95c871..4ab029bfc16 100644--- a/Libraries/LibWeb/Rust/src/painting/record/mod.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/mod.rs@@ -390,11 +390,37 @@ impl<O: Observer> PaintRecorder<'_, O> {let answer = Self::highlight_style_answer(committed, || paint::text::SelectionStyleAnswer {facts: crate::painting::host::FfiSelectionStyleFacts::default(),shadows: Vec::new(),+ decoration_metrics: None,});self.scratch.spelling_error_style_cache.insert(key, answer.clone());answer}+ pub(crate) fn custom_highlight_style(+ &mut self,+ node: crate::layout::node_data::NodeSlotId,+ layer: u32,+ ) -> Option<Arc<paint::text::SelectionStyleAnswer>> {+ let name = *self.paint_state.custom_highlights.layers.get(layer as usize)?;+ let key = (node.index, name);+ if let Some(answer) = self.scratch.custom_highlight_style_cache.get(&key) {+ return answer.clone();+ }+ // https://drafts.csswg.org/css-highlight-api-1/#default-styles+ // UAs must not define any default UA stylesheet rules or paired default highlight colors for any custom+ // highlight pseudo-elements.+ let answer = self+ .paint_state+ .custom_highlight_pseudo_styles+ .get(&name)+ .and_then(|styles| {+ let element_row = self.first_non_anonymous_ancestor_row(node)?;+ self.committed_highlight_pseudo_style_in(styles, node, element_row)+ });+ self.scratch.custom_highlight_style_cache.insert(key, answer.clone());+ answer+ }+/// A committed style that authored neither color takes the paired default colors and keeps/// its shadows and decorations.fn highlight_style_answer(@@ -413,6 +439,7 @@ impl<O: Observer> PaintRecorder<'_, O> {..answer.facts};defaults.shadows = answer.shadows.clone();+ defaults.decoration_metrics = answer.decoration_metrics;Arc::new(defaults)}}@@ -424,7 +451,15 @@ impl<O: Observer> PaintRecorder<'_, O> {node: crate::layout::node_data::NodeSlotId,element_row: crate::layout::node_data::NodeSlotId,) -> Option<Arc<paint::text::SelectionStyleAnswer>> {- let styles = self.paint_state.highlight_pseudo_styles(highlight);+ self.committed_highlight_pseudo_style_in(self.paint_state.highlight_pseudo_styles(highlight), node, element_row)+ }++ fn committed_highlight_pseudo_style_in(+ &self,+ styles: &crate::painting::paint_state::SelectionPseudoStyles,+ node: crate::layout::node_data::NodeSlotId,+ element_row: crate::layout::node_data::NodeSlotId,+ ) -> Option<Arc<paint::text::SelectionStyleAnswer>> {if let Some(answer) = styles.get(&node) {return Some(answer.clone());}@@ -469,6 +504,7 @@ impl<O: Observer> PaintRecorder<'_, O> {..Default::default()},shadows: Vec::new(),+ decoration_metrics: None,}}@@ -487,6 +523,7 @@ impl<O: Observer> PaintRecorder<'_, O> {..Default::default()},shadows: Vec::new(),+ decoration_metrics: None,};}let background_color = libgfx_rust::Color::from_rgb(255, 255, 0);@@ -498,6 +535,7 @@ impl<O: Observer> PaintRecorder<'_, O> {..Default::default()},shadows: Vec::new(),+ decoration_metrics: None,}}diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rsindex fdd6c8b50f1..4fd3dea7c92 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs@@ -312,6 +312,8 @@ pub(crate) fn paint_image_foreground<O: Observer>(recorder: &mut PaintRecorder<'}}+ paint_custom_highlight_washes(recorder, paintable, image_rect_device_pixels);+if recorder.data(paintable).selection_state != 0 {let selection_wash_color = recorder.element_selection_style(paintable).facts.wash_color;if selection_wash_color.alpha() > 0 {@@ -328,6 +330,56 @@ pub(crate) fn paint_image_foreground<O: Observer>(recorder: &mut PaintRecorder<'}}+// https://drafts.csswg.org/css-pseudo-4/#highlight-replaced+// [...] for replaced content, the UA should create a semi-transparent wash to coat the content so that it can show+// through the selection. This wash should be of the specified background-color if that is not transparent, else of the+// specified color; however the UA may adjust the alpha channel.+fn paint_custom_highlight_washes<O: Observer>(+ recorder: &mut PaintRecorder<'_, O>,+ paintable: NodeSlotId,+ rect: libgfx_rust::IntRect,+) {+ let Some(layers) = recorder.paint_state.custom_highlights.replaced.get(&paintable).cloned() else {+ return;+ };+ let Some(style) = recorder.source.node_style_if_live(paintable) else {+ return;+ };+ let backdrop = libgfx_rust::Color(style.background_color());+ // https://drafts.csswg.org/css-pseudo-4/#highlight-text+ // [...] currentColor on a highlight pseudo-element’s color property represents the color of the next active+ // highlight pseudo-element layer below, falling back finally to the colors that would otherwise have been+ // used [...].+ let mut current_color = libgfx_rust::Color(style.inherited_text().color);+ for layer in layers {+ let Some(answer) = recorder.custom_highlight_style(paintable, layer) else {+ continue;+ };+ let facts = &answer.facts;+ if !facts.colors_authored {+ continue;+ }+ let color = facts.text_color.get().unwrap_or(current_color);+ current_color = color;+ let background_color = if facts.background_color_is_current_color {+ color+ } else {+ facts.background_color+ };+ let wash_color = if background_color.alpha() > 0 {+ background_color+ } else {+ color+ };+ if wash_color.alpha() == 0 {+ continue;+ }+ let previous = recorder.recorder.set_contrast_backdrop(Some(backdrop));+ recorder.recorder.fill_rect(rect, wash_color, ForceDarkRole::Selection);+ recorder.recorder.set_contrast_backdrop(previous);+ }+}+pub(crate) fn paint_canvas_foreground<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable: NodeSlotId) {let facts = recorder.sourcediff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/text.rsindex 48ac09b199a..e108a168870 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/text.rs@@ -39,10 +39,44 @@ pub(crate) struct SpanTextDecoration {pub line_count: u32,pub style: u8,pub color: u32,+ pub metrics: Option<HighlightDecorationMetrics>,+}++#[derive(Clone, Copy)]+pub(crate) struct HighlightDecorationMetrics {+ pub thickness: Option<CssPixels>,+ pub underline_offset: CssPixels,+ pub underline_position_horizontal: u8,+ pub skip_ink: u8,+}++#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) enum HighlightLayer {+ Custom(u32),+ BuiltIn(HighlightPseudoElement),+ TextFragmentIndication,+}++impl HighlightLayer {+ // https://drafts.csswg.org/css-pseudo-4/#highlight-backgrounds+ // The ::selection overlay is drawn over the ::target-text overlay which is drawn over the ::spelling-error overlay+ // which is drawn over the ::grammar-error overlay which is drawn over the ::highlight overlays.+ // The ::search-text overlay is drawn directly over or below the ::selection overlay depending on the UA, and drawn+ // over all other overlays.+ fn stacking_order(self) -> (u8, u32) {+ match self {+ Self::Custom(layer) => (0, layer),+ Self::BuiltIn(HighlightPseudoElement::SpellingError) => (1, 0),+ Self::TextFragmentIndication => (2, 0),+ Self::BuiltIn(HighlightPseudoElement::Selection) => (3, 0),+ Self::BuiltIn(HighlightPseudoElement::SearchText) => (4, 0),+ Self::BuiltIn(HighlightPseudoElement::SearchTextCurrent) => (5, 0),+ }+ }}pub(crate) struct HighlightOverlay {- pub highlight: HighlightPseudoElement,+ pub highlight: HighlightLayer,pub background_color: u32,pub shadow_layers: Vec<ShadowLayer>,pub text_decoration: Option<SpanTextDecoration>,@@ -60,7 +94,6 @@ pub(crate) struct RenderSpan {/// The highlight's color when it has one of its own, which its redraw of the text's original/// decorations takes as well.pub decoration_color: Option<u32>,- pub text_fragment_indication_background_color: Option<u32>,}impl RenderSpan {@@ -69,7 +102,6 @@ impl RenderSpan {.iter().map(|overlay| overlay.highlight).eq(other.highlights.iter().map(|overlay| overlay.highlight))- && self.text_fragment_indication_background_color == other.text_fragment_indication_background_color&& self.text_color == other.text_color}}@@ -77,20 +109,35 @@ impl RenderSpan {pub(crate) struct SelectionStyleAnswer {pub facts: crate::painting::host::FfiSelectionStyleFacts,pub shadows: Vec<HighlightShadowLayer>,+ pub decoration_metrics: Option<HighlightDecorationMetrics>,}-// https://drafts.csswg.org/css-pseudo-4/#highlight-backgrounds-// The ::selection overlay is drawn over the ::target-text overlay which is drawn over the ::spelling-error overlay-// which is drawn over the ::grammar-error overlay which is drawn over the ::highlight overlays.-// The ::search-text overlay is drawn directly over or below the ::selection overlay depending on the UA, and drawn-// over all other overlays.-const HIGHLIGHT_OVERLAY_ORDER: [HighlightPseudoElement; 4] = [- HighlightPseudoElement::SpellingError,- HighlightPseudoElement::Selection,- HighlightPseudoElement::SearchText,- HighlightPseudoElement::SearchTextCurrent,+const BUILT_IN_HIGHLIGHT_LAYERS: [HighlightLayer; 5] = [+ HighlightLayer::BuiltIn(HighlightPseudoElement::SpellingError),+ HighlightLayer::TextFragmentIndication,+ HighlightLayer::BuiltIn(HighlightPseudoElement::Selection),+ HighlightLayer::BuiltIn(HighlightPseudoElement::SearchText),+ HighlightLayer::BuiltIn(HighlightPseudoElement::SearchTextCurrent),];+fn highlight_layers_for_fragment<O: Observer>(+ recorder: &PaintRecorder<'_, O>,+ fragment: &FragmentRecord,+) -> Vec<HighlightLayer> {+ let mut layers: Vec<HighlightLayer> = recorder+ .paint_state+ .custom_highlights+ .text_runs+ .get(&fragment.layout_node)+ .into_iter()+ .flatten()+ .map(|&(layer, ..)| HighlightLayer::Custom(layer))+ .collect();+ layers.dedup();+ layers.extend(BUILT_IN_HIGHLIGHT_LAYERS);+ layers+}+fn range_offsets_for_fragment<O: Observer>(recorder: &PaintRecorder<'_, O>,range: &SelectionRange,@@ -108,9 +155,65 @@ fn range_offsets_for_fragment<O: Observer>(fn highlight_offsets_for_fragment<O: Observer>(recorder: &mut PaintRecorder<'_, O>,- highlight: HighlightPseudoElement,+ layer: HighlightLayer,fragment: &FragmentRecord,) -> Vec<SelectionOffsets> {+ let highlight = match layer {+ HighlightLayer::BuiltIn(highlight) => highlight,+ HighlightLayer::Custom(layer) => {+ let Some(runs) = recorder+ .paint_state+ .custom_highlights+ .text_runs+ .get(&fragment.layout_node)+ else {+ return Vec::new();+ };+ return runs+ .iter()+ .filter(|&&(run_layer, start, end)| {+ run_layer == layer+ && end >= fragment.dom_start_offset_in_node+ && start <= fragment.dom_end_offset_with_trailing_whitespace+ })+ .filter_map(|&(_, start, end)| {+ text_fragment::compute_selection_offsets(+ recorder.source,+ fragment,+ SELECTION_STATE_START_AND_END,+ start,+ end,+ )+ })+ .map(|offsets| SelectionOffsets {+ start: offsets.start.min(fragment.length_in_code_units),+ end: offsets.end.min(fragment.length_in_code_units),+ })+ .filter(|offsets| offsets.start != offsets.end)+ .collect();+ }+ HighlightLayer::TextFragmentIndication => {+ let mut offsets: Vec<SelectionOffsets> = recorder+ .inputs+ .text_fragment_indications+ .iter()+ .filter(|range| range.text_node == fragment.layout_node)+ .filter_map(|range| {+ text_fragment::selection_offsets_for_dom_range(recorder.source, fragment, range.start, range.end)+ })+ .filter(|offsets| offsets.start != offsets.end)+ .collect();+ offsets.sort_unstable_by_key(|offsets| offsets.start);+ let mut merged: Vec<SelectionOffsets> = Vec::with_capacity(offsets.len());+ for offsets in offsets {+ match merged.last_mut() {+ Some(last) if offsets.start <= last.end => last.end = last.end.max(offsets.end),+ _ => merged.push(offsets),+ }+ }+ return merged;+ }+ };let offsets: Vec<SelectionOffsets> = match highlight {HighlightPseudoElement::Selection => {let offsets = if let Some((start, end)) = recorder.text_control_selection(fragment.layout_node) {@@ -189,16 +292,29 @@ fn highlight_offsets_for_fragment<O: Observer>(fn highlight_style<O: Observer>(recorder: &mut PaintRecorder<'_, O>,- highlight: HighlightPseudoElement,+ layer: HighlightLayer,node: NodeSlotId,-) -> Arc<SelectionStyleAnswer> {- match highlight {- HighlightPseudoElement::Selection => recorder.selection_style(node),- HighlightPseudoElement::SearchText | HighlightPseudoElement::SearchTextCurrent => {- recorder.search_text_style(node, highlight)- }- HighlightPseudoElement::SpellingError => recorder.spelling_error_style(node),- }+) -> Option<Arc<SelectionStyleAnswer>> {+ Some(match layer {+ HighlightLayer::BuiltIn(HighlightPseudoElement::Selection) => recorder.selection_style(node),+ HighlightLayer::BuiltIn(+ highlight @ (HighlightPseudoElement::SearchText | HighlightPseudoElement::SearchTextCurrent),+ ) => recorder.search_text_style(node, highlight),+ HighlightLayer::BuiltIn(HighlightPseudoElement::SpellingError) => recorder.spelling_error_style(node),+ HighlightLayer::Custom(layer) => recorder.custom_highlight_style(node, layer)?,+ HighlightLayer::TextFragmentIndication => Arc::new(SelectionStyleAnswer {+ facts: crate::painting::host::FfiSelectionStyleFacts {+ colors_authored: true,+ background_color: recorder.inputs.mark_color,+ text_color: crate::painting::display_list::commands::OptionalColor::some(+ recorder.inputs.mark_text_color,+ ),+ ..Default::default()+ },+ shadows: Vec::new(),+ decoration_metrics: None,+ }),+ })}fn compute_render_spans<O: Observer>(@@ -242,22 +358,16 @@ fn compute_render_spans<O: Observer>(};let mut highlights = Vec::new();- for highlight in HIGHLIGHT_OVERLAY_ORDER {- let ranges = highlight_offsets_for_fragment(recorder, highlight, fragment);- if !ranges.is_empty() {- let answer = highlight_style(recorder, highlight, fragment.layout_node);- highlights.push((highlight, ranges, answer));+ for layer in highlight_layers_for_fragment(recorder, fragment) {+ let ranges = highlight_offsets_for_fragment(recorder, layer, fragment);+ if ranges.is_empty() {+ continue;+ }+ if let Some(answer) = highlight_style(recorder, layer, fragment.layout_node) {+ highlights.push((layer, ranges, answer));}}- let indication_offsets: Vec<SelectionOffsets> = recorder- .inputs- .text_fragment_indications- .iter()- .filter(|range| range.text_node == fragment.layout_node)- .filter_map(|range| text_fragment::selection_offsets_for_dom_range(arena, fragment, range.start, range.end))- .filter(|offsets| offsets.start != offsets.end)- .collect();- if highlights.is_empty() && indication_offsets.is_empty() {+ if highlights.is_empty() {spans.push(RenderSpan {fragment_index,start_code_unit: 0,@@ -266,17 +376,11 @@ fn compute_render_spans<O: Observer>(shadow_layers: base_shadows(),highlights: Vec::new(),decoration_color: None,- text_fragment_indication_background_color: None,});continue;}let mut boundaries = vec![0, fragment.length_in_code_units];- boundaries.extend(- indication_offsets- .iter()- .flat_map(|offsets| [offsets.start, offsets.end]),- );for (_, ranges, _) in &highlights {boundaries.extend(ranges.iter().flat_map(|offsets| [offsets.start, offsets.end]));}@@ -285,7 +389,7 @@ fn compute_render_spans<O: Observer>(let first_span_of_fragment = spans.len();// The ranges of one highlight come in order without overlapping, and so do the pieces, so each highlight// only needs to look at the first of its ranges that does not end before the piece.- let mut next_ranges = [0usize; HIGHLIGHT_OVERLAY_ORDER.len()];+ let mut next_ranges = vec![0usize; highlights.len()];for piece in boundaries.windows(2) {let (start, end) = (piece[0], piece[1]);let mut span = RenderSpan {@@ -296,15 +400,7 @@ fn compute_render_spans<O: Observer>(shadow_layers: base_shadows(),highlights: Vec::new(),decoration_color: None,- text_fragment_indication_background_color: None,};- if indication_offsets- .iter()- .any(|offsets| start >= offsets.start && end <= offsets.end)- {- span.text_color = recorder.inputs.mark_text_color.0;- span.text_fragment_indication_background_color = Some(recorder.inputs.mark_color.0);- }for ((highlight, ranges, answer), next_range) in highlights.iter().zip(&mut next_ranges) {while ranges.get(*next_range).is_some_and(|offsets| offsets.end <= start) {*next_range += 1;@@ -347,6 +443,7 @@ fn compute_render_spans<O: Observer>(facts.text_decoration_color.0,facts.text_decoration_color_is_current_color,),+ metrics: answer.decoration_metrics,}),});}@@ -438,19 +535,6 @@ pub(crate) fn paint_fragments<O: Observer>(recorder: &mut PaintRecorder<'_, O>,for span in &spans {paint_text_shadow(recorder, block, span, &span.shadow_layers);}- for span in spans- .iter()- .filter(|span| span.text_fragment_indication_background_color.is_some())- {- let background_color = span.text_fragment_indication_background_color.unwrap();- let indication_rect = highlight_rect(recorder, block, span);- let converter = recorder.converter;- recorder.recorder.fill_rect(- converter.rounded_device_rect(indication_rect),- Color(background_color),- ForceDarkRole::Selection,- );- }for span in spans.iter().filter(|span| span.highlights.is_empty()) {let sets = crate::painting::record::paint::text_decoration::decoration_sets_for_span(recorder, block, span);paint_text_fragment(recorder, block, span, &sets);@@ -460,7 +544,13 @@ pub(crate) fn paint_fragments<O: Observer>(recorder: &mut PaintRecorder<'_, O>,.source.node_style_if_live(block).map(|style| Color(style.background_color()));- for highlight in HIGHLIGHT_OVERLAY_ORDER {+ let mut layers: Vec<HighlightLayer> = spans+ .iter()+ .flat_map(|span| span.highlights.iter().map(|overlay| overlay.highlight))+ .collect();+ layers.sort_unstable_by_key(|layer| layer.stacking_order());+ layers.dedup();+ for highlight in layers {let overlays = || {spans.iter().flat_map(move |span| {span.highlightsdiff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rsindex e263e7f5c97..7e8eff50846 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs@@ -132,7 +132,10 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(lines: &[u8],style_code: u8,color: u32,- thickness: CssPixels| {+ thickness: CssPixels,+ highlight_metrics: Option<+ &crate::painting::record::paint::text::HighlightDecorationMetrics,+ >| {let Some(decorating_style) = arena.node_style_if_live(decorating_node) else {return;};@@ -163,12 +166,21 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(set.decorating_font_descent = decorating_font.facts().descent;set.decorating_font_point_size = decorating_font.facts().point_size as i32;set.text_font_pixel_size = text_font.facts().pixel_size;- let inherited_text = decorating_style.inherited_text();- set.text_underline_offset = inherited_text.text_underline_offset.used_value;- set.text_underline_position_horizontal = inherited_text.text_underline_position.horizontal;- set.skip_ink = arena- .node_style_if_live(text_parent)- .map_or(0, |style| style.inherited_text().text_decoration_skip_ink);+ match highlight_metrics {+ Some(metrics) => {+ set.text_underline_offset = metrics.underline_offset;+ set.text_underline_position_horizontal = metrics.underline_position_horizontal;+ set.skip_ink = metrics.skip_ink;+ }+ None => {+ let inherited_text = decorating_style.inherited_text();+ set.text_underline_offset = inherited_text.text_underline_offset.used_value;+ set.text_underline_position_horizontal = inherited_text.text_underline_position.horizontal;+ set.skip_ink = arena+ .node_style_if_live(text_parent)+ .map_or(0, |style| style.inherited_text().text_decoration_skip_ink);+ }+ }sets.push(set);};@@ -196,6 +208,7 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(text_reset.text_decoration_style,span.decoration_color.unwrap_or(style.text_decoration_color()),thickness,+ None,);}}@@ -232,6 +245,7 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(text_reset.text_decoration_style,span.decoration_color.unwrap_or(style.text_decoration_color()),thickness,+ None,);}}@@ -253,13 +267,19 @@ pub(crate) fn decoration_sets_for_span<O: Observer>(let glyph_height = first_available_font(arena, text_parent).map_or(CssPixels::from_raw(0), |font| {CssPixels::nearest_value_for_f32(font.facts().pixel_size)});- let thickness = resolve_text_decoration_thickness(arena, text_parent, text_parent, glyph_height);+ let thickness = match text_decoration.metrics {+ Some(metrics) => metrics+ .thickness+ .unwrap_or_else(|| glyph_height.scaled(0.1).max(CssPixels::from_integer(1))),+ None => resolve_text_decoration_thickness(arena, text_parent, text_parent, glyph_height),+ };push_set(text_parent,&text_decoration.lines[..text_decoration.line_count as usize],text_decoration.style,text_decoration.color,thickness,+ text_decoration.metrics.as_ref(),);}setsdiff --git a/Libraries/LibWeb/Rust/src/painting/record/scratch.rs b/Libraries/LibWeb/Rust/src/painting/record/scratch.rsindex aa7bf58d4ba..0b0b04dc62a 100644--- a/Libraries/LibWeb/Rust/src/painting/record/scratch.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/scratch.rs@@ -43,6 +43,8 @@ pub(crate) struct RecordingScratch {pub(super) search_text_style_cache: HashMap<u32, Arc<SelectionStyleAnswer>>,pub(super) search_text_current_style_cache: HashMap<u32, Arc<SelectionStyleAnswer>>,pub(super) spelling_error_style_cache: HashMap<u32, Arc<SelectionStyleAnswer>>,+ pub(super) custom_highlight_style_cache:+ HashMap<(u32, crate::css::style::index::StyleAtomID), Option<Arc<SelectionStyleAnswer>>>,pub(super) wheel_hit_test_target_cache: HashMap<NodeSlotId, SpatialNodeIndex>,}@@ -106,6 +108,7 @@ impl RecordingScratch {self.search_text_style_cache.clear();self.search_text_current_style_cache.clear();self.spelling_error_style_cache.clear();+ self.custom_highlight_style_cache.clear();self.wheel_hit_test_target_cache.clear();}diff --git a/Libraries/LibWeb/Rust/src/painting/selection.rs b/Libraries/LibWeb/Rust/src/painting/selection.rsindex 56b3aa808b9..5984407d6f2 100644--- a/Libraries/LibWeb/Rust/src/painting/selection.rs+++ b/Libraries/LibWeb/Rust/src/painting/selection.rs@@ -5,6 +5,7 @@*/use crate::css::css_pixels::CssPixels;+use crate::css::style::index::StyleAtomID;use crate::css::style::tree::StyleNodeID;use crate::layout::LayoutNodeArena;use crate::layout::node_data::{@@ -16,12 +17,14 @@ use crate::painting::fragment_ownership;use crate::painting::host::FfiSelectionStyleFacts;use crate::painting::paint_read::GeometryRead;use crate::painting::paintable_data::{- FfiSearchTextRange, FfiSelectionEntry, FfiSpellingError, SELECTION_STATE_END, SELECTION_STATE_NONE,- SELECTION_STATE_START, SELECTION_STATE_START_AND_END,+ FfiCustomHighlightReplacedEntry, FfiCustomHighlightTextEntry, FfiSearchTextRange, FfiSelectionEntry,+ FfiSpellingError, SELECTION_STATE_END, SELECTION_STATE_NONE, SELECTION_STATE_START, SELECTION_STATE_START_AND_END,};use crate::painting::paintable_rows::PaintableRowsMut;use crate::painting::record::damage::PaintDamage;-use crate::painting::record::paint::text::{HighlightShadowLayer, SelectionStyleAnswer, ShadowLayer};+use crate::painting::record::paint::text::{+ HighlightDecorationMetrics, HighlightShadowLayer, SelectionStyleAnswer, ShadowLayer,+};use crate::painting::text_fragment;use libgfx_rust::Color;use std::sync::Arc;@@ -257,6 +260,126 @@ pub(crate) fn apply_spelling_errors(layout_arena: &mut PaintableRowsMut<'_>, errlayout_arena.paint_state_mut().spelling_errors = Arc::new(highlights);}+#[derive(Clone, Debug, Default)]+pub(crate) struct CustomHighlights {+ /// The custom highlight name of each layer, from bottom to top.+ pub layers: Vec<StyleAtomID>,+ /// For each text fragment row, the runs of its DOM text each layer covers, as layer and start and end offsets.+ pub text_runs: std::collections::HashMap<NodeSlotId, Vec<(u32, usize, usize)>>,+ /// For each replaced row, the layers whose ranges contain its element, from bottom to top.+ pub replaced: std::collections::HashMap<NodeSlotId, Vec<u32>>,+}++impl CustomHighlights {+ fn text_signature(&self, node: NodeSlotId) -> Vec<(StyleAtomID, usize, usize)> {+ self.text_runs+ .get(&node)+ .into_iter()+ .flatten()+ .map(|&(layer, start, end)| (self.layers[layer as usize], start, end))+ .collect()+ }++ fn replaced_signature(&self, node: NodeSlotId) -> Vec<StyleAtomID> {+ self.replaced+ .get(&node)+ .into_iter()+ .flatten()+ .map(|&layer| self.layers[layer as usize])+ .collect()+ }++ pub(crate) fn forget_row(&mut self, node: NodeSlotId) {+ self.text_runs.remove(&node);+ self.replaced.remove(&node);+ }++ pub(crate) fn covers_row(&self, node: NodeSlotId) -> bool {+ self.text_runs.contains_key(&node) || self.replaced.contains_key(&node)+ }+}++fn damage_custom_highlight_changes(+ layout_arena: &mut PaintableRowsMut<'_>,+ previous: &CustomHighlights,+ highlights: &CustomHighlights,+) {+ for node in previous.text_runs.keys().chain(highlights.text_runs.keys()) {+ if previous.text_signature(*node) != highlights.text_signature(*node) {+ invalidate_text_node(layout_arena, *node);+ }+ }+ for &node in previous.replaced.keys().chain(highlights.replaced.keys()) {+ if previous.replaced_signature(node) != highlights.replaced_signature(node)+ && layout_arena.paintable_row_is_populated(node)+ {+ layout_arena.push_paint_damage(node, PaintDamage::ALL_DRAW);+ }+ }+}++pub(crate) fn clear_custom_highlights(layout_arena: &mut PaintableRowsMut<'_>) {+ let previous = std::mem::take(&mut layout_arena.paint_state_mut().custom_highlights);+ damage_custom_highlight_changes(layout_arena, &previous, &CustomHighlights::default());+}++pub(crate) fn apply_custom_highlights(+ layout_arena: &mut PaintableRowsMut<'_>,+ layers: &[StyleAtomID],+ text_entries: &[FfiCustomHighlightTextEntry],+ replaced_entries: &[FfiCustomHighlightReplacedEntry],+) {+ let mut highlights = CustomHighlights {+ layers: layers.to_vec(),+ ..CustomHighlights::default()+ };+ for entry in text_entries+ .iter()+ .filter(|entry| (entry.layer as usize) < layers.len())+ {+ for &node in layout_arena.text_fragments(entry.layout_node).as_slice() {+ highlights+ .text_runs+ .entry(node)+ .or_default()+ .push((entry.layer, entry.start_offset, entry.end_offset));+ }+ }+ // https://drafts.csswg.org/css-highlight-api-1/#painting+ // Overlapping ranges within a single custom highlight are rendered as if a single range representing the union+ // of the overlapping ones had been specified.+ for runs in highlights.text_runs.values_mut() {+ runs.sort_unstable();+ let mut merged: Vec<(u32, usize, usize)> = Vec::with_capacity(runs.len());+ for &(layer, start, end) in runs.iter() {+ match merged.last_mut() {+ Some(last) if last.0 == layer && start <= last.2 => last.2 = last.2.max(end),+ _ => merged.push((layer, start, end)),+ }+ }+ *runs = merged;+ }+ for entry in replaced_entries+ .iter()+ .filter(|entry| (entry.layer as usize) < layers.len())+ {+ if layout_arena.paintable_row_is_populated(entry.layout_node) {+ highlights+ .replaced+ .entry(entry.layout_node)+ .or_default()+ .push(entry.layer);+ }+ }+ for layers in highlights.replaced.values_mut() {+ layers.sort_unstable();+ layers.dedup();+ }+ let previous = std::mem::take(&mut layout_arena.paint_state_mut().custom_highlights);+ damage_custom_highlight_changes(layout_arena, &previous, &highlights);+ layout_arena.paint_state_mut().custom_highlights = Arc::new(highlights);+}+/// https://drafts.csswg.org/css-pseudo-4/#highlight-styling/// What text under `element` paints with inside a highlight pseudo-element, read from/// `style_record`, the element's record for that pseudo-element (zero for none), or `None` when@@ -265,6 +388,7 @@ fn highlight_pseudo_style_of_record(engine: &crate::css::style::RetainedState,element: StyleNodeID,style_record: u64,+ takes_own_decoration_metrics: bool,) -> Option<SelectionStyleAnswer> {use crate::css::computed_longhand_table::{HIGHLIGHT_COLOR_IS_CURRENT_COLOR, HIGHLIGHT_COLORS_AUTHORED};use crate::css::property_metadata::property_id;@@ -330,6 +454,25 @@ fn highlight_pseudo_style_of_record(let text_reset = style.text_reset();let lines = text_reset.text_decoration_lines.as_slice();+ let mut decoration_metrics = None;+ if !lines.is_empty() && takes_own_decoration_metrics {+ let inherited_text = style.inherited_text();+ let element_font_size = engine+ .published_style_view(element, None)+ .map_or(CssPixels::from_raw(0), |element_style| element_style.font_size());+ decoration_metrics = Some(HighlightDecorationMetrics {+ thickness: (text_reset.text_decoration_thickness_kind == 2).then(|| {+ text_reset+ .text_decoration_thickness+ .length_percentage()+ .map_or(CssPixels::from_integer(1), |value| value.to_px(element_font_size))+ .max(CssPixels::from_integer(1))+ }),+ underline_offset: inherited_text.text_underline_offset.used_value,+ underline_position_horizontal: inherited_text.text_underline_position.horizontal,+ skip_ink: inherited_text.text_decoration_skip_ink,+ });+ }if !lines.is_empty() {facts.has_text_decoration = true;let count = lines.len().min(facts.text_decoration_lines.len());@@ -340,8 +483,11 @@ fn highlight_pseudo_style_of_record(facts.text_decoration_color_is_current_color = specified_as_current_color(property_id::TEXT_DECORATION_COLOR);}- (facts.colors_authored || facts.has_text_shadow || facts.has_text_decoration)- .then_some(SelectionStyleAnswer { facts, shadows })+ (facts.colors_authored || facts.has_text_shadow || facts.has_text_decoration).then_some(SelectionStyleAnswer {+ facts,+ shadows,+ decoration_metrics,+ })}/// The UA's adjustment of a selection wash's alpha channel: an opaque color becomes the most@@ -383,7 +529,8 @@ fn highlight_pseudo_styles_of_records(style_records: HighlightStyleRecords,) -> HighlightStyleAnswers {arena.with_style_store(|engine| {- style_records.map(|style_record| highlight_pseudo_style_of_record(engine, element, style_record).map(Arc::new))+ style_records+ .map(|style_record| highlight_pseudo_style_of_record(engine, element, style_record, false).map(Arc::new))})}@@ -403,15 +550,7 @@ pub(crate) fn sync_highlight_pseudo_styles(} else {HighlightStyleAnswers::default()};- let text_rows: Vec<NodeSlotId> = arena.with_style_store(|engine| {- engine- .dom_children(element)- .filter(|child| child.text_index().is_some())- .map(|text| arena.bound_row(text))- .filter(|row| !row.is_invalid())- .collect()- });- for row in text_rows {+ for row in text_child_rows(arena, element) {let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(row).collect();set_highlight_pseudo_styles_of_rows(arena, &rows, &text_rows_answers);}@@ -435,6 +574,93 @@ pub(crate) fn sync_selection_style(arena: &mut LayoutNodeArena, element: StyleNosync_highlight_pseudo_styles(arena, element, style_records);}+fn text_child_rows(arena: &LayoutNodeArena, element: StyleNodeID) -> Vec<NodeSlotId> {+ arena.with_style_store(|engine| {+ engine+ .dom_children(element)+ .filter(|child| child.text_index().is_some())+ .map(|text| arena.bound_row(text))+ .filter(|row| !row.is_invalid())+ .collect()+ })+}++type CustomHighlightStyleAnswers = Vec<(StyleAtomID, Arc<SelectionStyleAnswer>)>;++fn custom_highlight_pseudo_styles_of_records(+ arena: &LayoutNodeArena,+ element: StyleNodeID,+ style_records: &[(StyleAtomID, u64)],+) -> CustomHighlightStyleAnswers {+ arena.with_style_store(|engine| {+ style_records+ .iter()+ .filter_map(|&(name, style_record)| {+ // Custom highlights take their decoration metrics from their own style, matching other engines.+ Some((+ name,+ Arc::new(highlight_pseudo_style_of_record(engine, element, style_record, true)?),+ ))+ })+ .collect()+ })+}++pub(crate) fn sync_custom_highlight_pseudo_styles(+ arena: &mut LayoutNodeArena,+ element: StyleNodeID,+ style_records: &[(StyleAtomID, u64)],+) {+ let answers = custom_highlight_pseudo_styles_of_records(arena, element, style_records);+ let element_row = arena.bound_row(element);+ for row in text_child_rows(arena, element) {+ let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(row).collect();+ let text_rows_answers = if element_row.is_invalid() { &answers[..] } else { &[] };+ set_custom_highlight_pseudo_styles_of_rows(arena, &rows, text_rows_answers);+ }+ if !element_row.is_invalid() {+ let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(element_row).collect();+ set_custom_highlight_pseudo_styles_of_rows(arena, &rows, &answers);+ }+}++fn set_custom_highlight_pseudo_styles_of_rows(+ arena: &mut LayoutNodeArena,+ rows: &[NodeSlotId],+ answers: &[(StyleAtomID, Arc<SelectionStyleAnswer>)],+) {+ let paint_state = arena.paint_state_mut();+ let unstyled: Vec<StyleAtomID> = paint_state+ .custom_highlight_pseudo_styles+ .iter()+ .filter(|(name, styles)| {+ !answers.iter().any(|(answered, _)| answered == *name) && rows.iter().any(|row| styles.contains_key(row))+ })+ .map(|(name, _)| *name)+ .collect();+ if unstyled.is_empty() && answers.is_empty() {+ return;+ }+ let table = Arc::make_mut(&mut paint_state.custom_highlight_pseudo_styles);+ for name in unstyled {+ if let Some(styles) = table.get_mut(&name) {+ let styles = Arc::make_mut(styles);+ for row in rows {+ styles.remove(row);+ }+ if styles.is_empty() {+ table.remove(&name);+ }+ }+ }+ for (name, answer) in answers {+ let styles = Arc::make_mut(table.entry(*name).or_default());+ for &row in rows {+ styles.insert(row, answer.clone());+ }+ }+}+/// Gives a row the tree build made what the published highlight pseudo-element records of/// `element` say highlighted text paints with: `element`'s own row, or a text row whose parent/// element has no box.@@ -443,16 +669,21 @@ pub(crate) fn note_built_row_highlight_pseudo_styles(row: NodeSlotId,element: StyleNodeID,) {- let style_records = arena.with_style_store(|engine| {- HighlightPseudoElement::ALL.map(|highlight| {- engine- .pseudo_published_style_record(element, highlight.pseudo_kind())- .unwrap_or(0)- })+ let (style_records, custom_style_records) = arena.with_style_store(|engine| {+ (+ HighlightPseudoElement::ALL.map(|highlight| {+ engine+ .pseudo_published_style_record(element, highlight.pseudo_kind())+ .unwrap_or(0)+ }),+ engine.pseudo_published_custom_highlight_records(element),+ )});let answers = highlight_pseudo_styles_of_records(arena, element, style_records);+ let custom_answers = custom_highlight_pseudo_styles_of_records(arena, element, &custom_style_records);let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(row).collect();set_highlight_pseudo_styles_of_rows(arena, &rows, &answers);+ set_custom_highlight_pseudo_styles_of_rows(arena, &rows, &custom_answers);}fn set_highlight_pseudo_styles_of_rows(diff --git a/Tests/LibWeb/Ref/expected/custom-highlight-green-text-ref.html b/Tests/LibWeb/Ref/expected/custom-highlight-green-text-ref.htmlnew file mode 100644index 00000000000..891a6b04ca2--- /dev/null+++ b/Tests/LibWeb/Ref/expected/custom-highlight-green-text-ref.html@@ -0,0 +1,7 @@+<!DOCTYPE html>+<style>+span {+ background-color: green;+}+</style>+<p><span>text</span></p>diff --git a/Tests/LibWeb/Ref/expected/custom-highlight-image-in-range-ref.html b/Tests/LibWeb/Ref/expected/custom-highlight-image-in-range-ref.htmlnew file mode 100644index 00000000000..e1b47b2c3bd--- /dev/null+++ b/Tests/LibWeb/Ref/expected/custom-highlight-image-in-range-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<style>+img {+ display: block;+ width: 50px;+ height: 50px;+}+#contained {+ position: relative;+ width: 50px;+}+#wash {+ position: absolute;+ inset: 0;+ background-color: rgba(0, 0, 255, 0.5);+}+</style>+<div id="contained"><img src="../data/50x50-green.svg"><div id="wash"></div></div>+<div><img src="../data/50x50-green.svg"></div>diff --git a/Tests/LibWeb/Ref/expected/custom-highlight-image-in-range-without-colors-ref.html b/Tests/LibWeb/Ref/expected/custom-highlight-image-in-range-without-colors-ref.htmlnew file mode 100644index 00000000000..c1cfd581fb6--- /dev/null+++ b/Tests/LibWeb/Ref/expected/custom-highlight-image-in-range-without-colors-ref.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<style>+img {+ display: block;+ width: 50px;+ height: 50px;+}+</style>+<div><img src="../data/50x50-green.svg"></div>diff --git a/Tests/LibWeb/Ref/expected/custom-highlight-registered-after-first-paint-ref.html b/Tests/LibWeb/Ref/expected/custom-highlight-registered-after-first-paint-ref.htmlnew file mode 100644index 00000000000..58bcb86cd99--- /dev/null+++ b/Tests/LibWeb/Ref/expected/custom-highlight-registered-after-first-paint-ref.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<style>+span {+ background-color: green;+}+</style>+<p><span>one</span> <span>two</span></p>+<p><span>three</span> <span>four</span></p>+<p>other</p>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-009-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-009-ref.htmlnew file mode 100644index 00000000000..fe6fbb140b3--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-009-ref.html@@ -0,0 +1,4 @@+<!DOCTYPE html>+<title>CSS Test Reference</title>+<span style="color: green">Selection</span>+<span style="color: green">Highlight</span>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-010-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-010-ref.htmlnew file mode 100644index 00000000000..a98a4023284--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-010-ref.html@@ -0,0 +1,3 @@+<!DOCTYPE html>+<title>CSS Test Reference</title>+<span style="color: green">Highlight</span>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/custom-highlight-universal-painting-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/custom-highlight-universal-painting-001-ref.htmlnew file mode 100644index 00000000000..5f45835b6bd--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/custom-highlight-universal-painting-001-ref.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset="utf-8">+<style>+ .highlighted {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span class="highlighted">One two </span><span>three…</span>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-currentcolor-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-currentcolor-ref.htmlnew file mode 100644index 00000000000..2d5adb255e6--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-currentcolor-ref.html@@ -0,0 +1,10 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>Custom highlight: currentColor over a replaced element (reference)</title>+<link rel="author" title="Fernando Fiori" href="mailto:[email protected]">+<style>+ #tint { width: 100px; height: 100px; background-color: green; }+</style>+<body>+<div id="d"><div id="tint"></div></div>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-notref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-notref.htmlnew file mode 100644index 00000000000..0f4e21fc3d6--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-notref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<html>+<body>+ <div id="style1"><img src="../../images/blank-highlight.png"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-stacked-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-stacked-ref.htmlnew file mode 100644index 00000000000..b41f7f16d0c--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-image-stacked-ref.html@@ -0,0 +1,10 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>Custom highlight: stacked highlights over a replaced element (reference)</title>+<link rel="author" title="Fernando Fiori" href="mailto:[email protected]">+<style>+ #tint { width: 100px; height: 100px; background-color: green; }+</style>+<body>+<div id="d"><div id="tint"></div></div>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-priority-painting-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-priority-painting-ref.htmlnew file mode 100644index 00000000000..1865f1e1049--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-priority-painting-ref.html@@ -0,0 +1,23 @@+<!DOCTYPE html>+<html>+<head>+ <title>Highlight priority attribute painting</title>+ <style>+ #green-highlight {+ background-color: green;+ }+ .yellow-highlight {+ background-color: yellow;+ }+ .blue-highlight {+ background-color: blue;+ }+ </style>+</head>+<body>+ <span id="green-highlight">Green</span>+ <span class="yellow-highlight">Yellow</span>+ <span class="blue-highlight">Blue</span>+ <span class="yellow-highlight">Yellow</span><span class="blue-highlight">-Blue</span>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-across-elements-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-across-elements-ref.htmlnew file mode 100644index 00000000000..b82bb805535--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-across-elements-ref.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<html>+<head>+ <style>+ :root {+ font-family: monospace;+ }+ #style1 {+ background-color: yellow;+ color:green;+ }+ #style2 {+ background-color: blue;+ color:red;+ }+ #style3 {+ background-color: purple;+ color:pink;+ }+ </style>+</head>+<body>+ One <span id="style1">two</span> th<span id="style2">ree+ four</span> five <span id="style2">six+ seven</span> eigh<span id="style3">t nine+ ten eleven twelve+ thirteen fou</span>rteen fifteen+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-decorations-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-decorations-ref.htmlnew file mode 100644index 00000000000..8120ae34da2--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-decorations-ref.html@@ -0,0 +1,47 @@+<!DOCTYPE html>+<html>+<head>+ <style>+ html {+ font-size: 24pt;+ }+ .style1 {+ text-decoration: underline;+ text-decoration-color: red;+ color: blue;+ }+ .style2 {+ text-decoration: line-through;+ text-decoration-color: violet;+ text-decoration-style: double;+ }+ .style3 {+ text-decoration: overline;+ text-decoration-color: orange;+ text-decoration-style: dotted;+ }+ /* FIXME: There is a discrepency for how the underlines are displayed at the end of the line, leading to a pixel different in this text. Find a real fix, but in the meantime, obscure the offending pixel <rdar://problem/59327965> https://bugs.webkit.org/show_bug.cgi?id=207512*/+ .obscurer1 {+ position: absolute;+ top: 25px;+ left: 95px;+ width: 10px;+ height: 10px;+ background: grey;+ }+ .obscurer2 {+ position: absolute;+ top: 35px;+ left: 180px;+ width: 10px;+ height: 10px;+ background: grey;+ }+ </style>+</head>+<body>+ O<span class="style1">n</span>e t<span class="style2">w</span>o th<span class="style3">ree</span>+ <div class='obscurer1'></div>+ <div class='obscurer2'></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-dynamic-notref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-dynamic-notref.htmlnew file mode 100644index 00000000000..0489cb6e8c9--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-dynamic-notref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<html>+<body>+ <span id="text1">One two three</span>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-ref.htmlnew file mode 100644index 00000000000..780facd7846--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/highlight-text-ref.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<html>+<head>+ <style>+ :root {+ font-family: monospace;+ letter-spacing: 2px;+ }+ #style1 {+ background-color: yellow;+ color:green;+ }+ #style2 {+ background-color: blue;+ color:red;+ }+ #style3 {+ background-color: purple;+ color:pink;+ }+ </style>+</head>+<body>+ O<span id="style1">n</span>e<span id="style2"> </span>t<span id="style2">w</span>o<span id="style3"> </span>t<span id="style3">h</span>re<span id="style3">e</span>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001-ref.htmlnew file mode 100644index 00000000000..3d01bccf55d--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001-ref.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html>+<meta charset="utf-8">+<title>CSS Highlight API Test: ::highlight with text-underline-offset, reference</title>+<style>+ #target {+ text-decoration: wavy underline green 5px;+ text-underline-offset: 20px;+ }+</style>+<p id="target">The underline should be offset.</p>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001-ref.htmlnew file mode 100644index 00000000000..92751144a26--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test Reference</title>+<head>+ <style>+ div {+ width: 200px;+ height: 100px;+ }+ #h1 {+ text-underline-offset: 1svw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 2svh;+ }+ </style>+</head>+<body>+ <div id="h1">With container size</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002-ref.htmlnew file mode 100644index 00000000000..98ccfa5b11c--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002-ref.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test Reference</title>+<head>+ <style>+ .wrapper {+ width: 200px;+ height: 100px;+ text-underline-offset: 4px;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4px;+ }+ #h2 {+ text-underline-offset: 2svw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4svh;+ }+ </style>+</head>+<body>+ <div class="wrapper">With container size</div>+ <div id="h2">Without container size</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.htmlnew file mode 100644index 00000000000..d3d75333f8a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test Reference</title>+<head>+ <style>+ .wrapper {+ width: 200px;+ height: 100px;+ text-underline-offset: 4px;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4px;+ }+ </style>+</head>+<body>+ <div class="wrapper">With container size</div>+ <div>Should be no highlight</div>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004-ref.htmlnew file mode 100644index 00000000000..98ccfa5b11c--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004-ref.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test Reference</title>+<head>+ <style>+ .wrapper {+ width: 200px;+ height: 100px;+ text-underline-offset: 4px;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4px;+ }+ #h2 {+ text-underline-offset: 2svw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4svh;+ }+ </style>+</head>+<body>+ <div class="wrapper">With container size</div>+ <div id="h2">Without container size</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001-ref.htmlnew file mode 100644index 00000000000..76b7317caab--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001-ref.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<head>+ <style>+ div {+ margin: 50px;+ font-size: 40px;+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ #h2 {+ font-size: 20px;+ }+ </style>+</head>+<body>+ <div id="h1">Font relative units with 40px font</div>+ <div id="h2">Font relative units with 20px font</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002-ref.htmlnew file mode 100644index 00000000000..13b38d8bbf8--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<head>+ <style>+ div {+ margin: 40px;+ font-size: 20px;+ }+ #h1 {+ text-underline-offset: 10px;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4px;+ }+ #h2 {+ text-underline-offset: 20px;+ text-decoration-line: underline;+ text-decoration-color: blue;+ text-decoration-thickness: 2px;+ }+ </style>+</head>+<body>+ <div id="h1">A green 10px offset underline 4px thick</div>+ <div id="h2">A blue 20px offset underline 2px thick</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004-ref.htmlnew file mode 100644index 00000000000..c1a04b0803a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004-ref.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<head>+ <style>+ div {+ margin: 40px;+ font-size: 20px;+ text-underline-offset: 10px;+ text-decoration-line: underline overline;+ text-decoration-color: green;+ text-decoration-thickness: 4px;+ }+ </style>+</head>+<body>+ <div id="h1">A green 10px offset underline 4px thick and green overline 4px thick</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005-ref.htmlnew file mode 100644index 00000000000..bbfc952116f--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<head>+ <style>+ div {+ margin: 50px;+ font-size: 20px;+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ </style>+</head>+<body>+ <div id="h1">Font relative units with 20px font</div>+ <div id="h2">Font relative units with 20px font</div>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001-ref.htmlnew file mode 100644index 00000000000..09bc7fac5e5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test Reference</title>+<head>+ <style>+ div {+ width: 200px;+ height: 100px;+ line-height: 3em;+ text-underline-offset: 1svb;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 1svi;+ }+</style>+</head>+<body>+ <div>With viewport size</div>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002-ref.htmlnew file mode 100644index 00000000000..eaed1580f9f--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test Reference</title>+<head>+ <style>+ div {+ width: 100px;+ height: 200px;+ writing-mode: vertical-lr;+ line-height: 3em;+ text-underline-offset: 1svb;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 1svi;+ }+</style>+</head>+<body>+ <div id="h1">With viewport size</div>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.htmlnew file mode 100644index 00000000000..b058789f6de--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html@@ -0,0 +1,9 @@+<!doctype html>+<meta charset="utf-8">+<style>+ .highlighted {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span class="highlighted">One two </span><span>three…</span>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002-ref.htmlnew file mode 100644index 00000000000..d063bbd497e--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002-ref.html@@ -0,0 +1,8 @@+<!doctype html>+<meta charset="utf-8">+<style>+ div {+ color: red;+ }+</style>+<body><div>abc</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003-ref.htmlnew file mode 100644index 00000000000..b2dccfa59ff--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003-ref.html@@ -0,0 +1,6 @@+<!doctype html>+<meta charset="utf-8">+<style>+ span { background-color: rgba(0, 0, 255, 0.3); }+</style>+<body>L<span>orem I</span>psum.\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2-ref.htmlnew file mode 100644index 00000000000..4ad1de63dfc--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2-ref.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset="utf-8">+<style>+ .foo {+ color:blue;+ background-color:yellow;+ }+ .bar {+ color:orange;+ }+ .bar-over-foo {+ color:orange;+ background-color:yellow;+ }+</style>+<body><span class="foo">Som</span><span class="bar-over-foo">e t</span><span class="bar">ext</span>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-ref.htmlnew file mode 100644index 00000000000..8cb5b69d98c--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-ref.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset="utf-8">+<style>+ .foo {+ color:blue;+ background-color:yellow;+ }+ .bar {+ background-color:orange;+ }+ .bar-over-foo {+ color:blue;+ background-color:orange;+ }+</style>+<body><span class="foo">Som</span><span class="bar-over-foo">e t</span><span class="bar">ext</span>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001-ref.htmlnew file mode 100644index 00000000000..74ad6444ae7--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001-ref.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css">+<style>+ #target {+ font: 40px/1 Ahem;+ }+ span {+ background-color: yellow;+ }+</style>+<body>+<div id="target"><div><span>X X X X</span></div><div>X</div></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-ref.htmlnew file mode 100644index 00000000000..5c7bd9361bf--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-ref.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ #highlighted {+ background: cyan;+ color: blue;+ }+ ::selection {+ background: blue;+ color: cyan;+ }+</style>+<body><span id="highlighted">Text should be blue over cyan here and <span id="selected">cyan over blue here</span>.</span>+<script>+ getSelection().setBaseAndExtent(selected, 0, selected, 1);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency-ref.htmlnew file mode 100644index 00000000000..2f45cdcd75a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency-ref.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ #highlighted {+ background: yellow;+ }+</style>++<body><span id="highlighted">This should be yellow, <span id="selected">this should mix with the+ selection,</span></span> this should have no background.+ <script>+ getSelection().setBaseAndExtent(selected, 0, selected, 1);+ </script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types-ref.htmlnew file mode 100644index 00000000000..341730ab371--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types-ref.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<link rel="author" title="Karl Dubost" href="https://otsukare.info/">+<style>+ .highlighted {+ background-color: yellow;+ color: blue;+ }+ body {+ font-family: monospace;+ font-size: 16px;+ }+ .container {+ margin: 10px 0;+ }+</style>+<div class="container"><div>Block: <span class="highlighted">text content</span></div></div></div>+<div class="container" style="display: flex;"><div>Flex: <span class="highlighted">text content</span></div></div>+<div class="container" style="display: inline-flex;"><div>Inline-flex: <span class="highlighted">text content</span></div></div>+<div class="container" style="display: grid;"><div>Grid: <span class="highlighted">text content</span></div></div>+<div class="container" style="display: table;"><div>Table: <span class="highlighted">text content</span></div></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-001-ref.htmlnew file mode 100644index 00000000000..aa8915c1d78--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-001-ref.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<body>+<iframe+ id="iframe"+ srcdoc="+ <style>+ span {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003-ref.htmlnew file mode 100644index 00000000000..9d80a9f005f--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003-ref.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ #span-doc {+ color: green;+ background-color: greenyellow;+ }+</style>+<body>+<iframe+ id="iframe"+ srcdoc="+ <style>+ span {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>+<br>+<span id="span-doc">abc</span>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004-ref.htmlnew file mode 100644index 00000000000..622ea40c80a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004-ref.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ #span-doc {+ color: green;+ background-color: greenyellow;+ }+</style>+<body>+<iframe+ id="iframe"+ srcdoc="<span id='span-iframe'>abc</span>"+ >+</iframe>+<br>+<span id="span-doc">abc</span>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005-ref.htmlnew file mode 100644index 00000000000..7a492e32c0d--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005-ref.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<body>+<iframe+ id="iframe"+ srcdoc="+ <style>+ span {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>+<br>+<span id="span-doc">abc</span>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001-ref.htmlnew file mode 100644index 00000000000..0d5385287ca--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001-ref.html@@ -0,0 +1,10 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ span {+ background-color: green;+ }+</style>+<body>+<div>There should be only one green rectangle below from [ to ]:</div>+<div>[<span> <strong> </strong> </span>]</div>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001-ref.htmlnew file mode 100644index 00000000000..d538c550bad--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001-ref.html@@ -0,0 +1,3 @@+<!DOCTYPE html>+<meta charset="utf-8">+<pre>Hello <span style="color: red;">world</span></pre>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007-ref.htmlnew file mode 100644index 00000000000..88f3d0f3d65--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007-ref.html@@ -0,0 +1,10 @@+<!doctype html>+<meta charset="utf-8">+<style>+ .highlighted {+ background: blue;+ }+</style>+<body>+ <span class="highlighted">Hello</span>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001-ref.htmlnew file mode 100644index 00000000000..3c08ad55aef--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001-ref.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ body {+ font-size: 3em;+ font-weight: bolder;++ }+ #affected1 {+ color: red;+ }+ #affected2 {+ color: green;+ }+</style>+<body><span id="affected1">This should have 'highlight1' style (red).</span><span id="affected2">This should have 'highlight2' style (green).</span>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002-ref.htmlnew file mode 100644index 00000000000..2907681b75a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002-ref.html@@ -0,0 +1,17 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<style>+ div {+ font-size: 3em;+ font-weight: bolder;+ }+ #affected1 {+ color: green;+ background-color: rgb(0, 255, 0, 0.5);+ }+ #affected2 {+ color: red;+ background-color: rgba(100, 0, 100, 0.5);+ }+</style>+<body><div><span id="affected1">Green on lime.</span><span id="affected2">Red on maroon.</span></div>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003-ref.htmlnew file mode 100644index 00000000000..9d3e3b00b08--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003-ref.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Non-conflicting attributes</title>+<style>+ #blue {+ background-color: blue;+ color: white;+ }+ #yellow {+ background-color: yellow;+ }+</style>+<body>+ <p>This <span id="blue">is an</span><span id="yellow"> example</span> of two overlapping highlights</p>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001-ref.htmlnew file mode 100644index 00000000000..aa76cf08b46--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001-ref.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Highlight API Test: ::highlight text-decoration paints over higher priority when not clashing</title>+ <style>+ #yellow-highlight {+ background-color: yellow;+ text-decoration: underline;+ text-decoration-color: red;+ }+ </style>+</head>+<body>+ <span id="yellow-highlight">Yellow</span>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor-ref.htmlnew file mode 100644index 00000000000..138ac9829e0--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor-ref.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Highlight API Test: Reference for ::highlight text-decoration with currentColor</title>+<style>+ #target {+ font-size: 50px;+ color: green;+ text-decoration: overline;+ }+</style>+<p>The test passes if the text below has a green overline.</p>+<p id="target">Highlighted text</p>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004-ref.htmlnew file mode 100644index 00000000000..41e66ccc1d3--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004-ref.html@@ -0,0 +1,10 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<style>+ span {+ background-color: rgba(0, 128, 0, 0.5);+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>one-point-five </span><span>three…</span>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001-ref.htmlnew file mode 100644index 00000000000..568e5f93213--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001-ref.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Highlight API Test: Reference ::highlight painting text-decoration</title>+<style>+ div {+ float: left;+ margin: 0.5em;+ /* Setting transparent color is a workaround to avoid hitting the following Chromium bug: https://crbug.com/1179938.+ This could be removed once that bug is fixed. */+ color: transparent;+ }+</style>+<p>The test passes if it matches the reference file.</p>+<script>+ let textDecorationStyles = [+ "solid green underline", "double green underline", "dotted green underline", "dashed green underline", "wavy green underline",+ "solid blue overline", "double blue overline", "dotted blue overline", "dashed blue overline", "wavy blue overline",+ "solid magenta line-through", "double magenta line-through", "dotted magenta line-through", "dashed magenta line-through", "wavy magenta line-through",+ "solid brown underline overline line-through", "double brown underline overline line-through", "dotted brown underline overline line-through", "dashed brown underline overline line-through", "wavy brown underline overline line-through",+ ];++ textDecorationStyles.forEach((textDecorationStyle, index) => {+ document.styleSheets[0].insertRule(`#id${index} { text-decoration: ${textDecorationStyle}; }`);+ let element = document.createElement("div");+ element.id = `id${index}`;+ element.innerHTML = textDecorationStyle;+ document.body.appendChild(element);+ });+</script>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-ref.htmlnew file mode 100644index 00000000000..066d65f083c--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-ref.html@@ -0,0 +1,12 @@+<!doctype html>+<meta charset="utf-8">+<style>+ .highlighted {+ background-color: yellow;+ color: blue;+ text-shadow: 5px 10px rgba(0, 255, 0, 0.5);+ }+</style>+<body>+ <span class="highlighted">One two </span><span>three…</span>+</body>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001-ref.htmlnew file mode 100644index 00000000000..a5ec6a59ae0--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001-ref.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Highlight API Test: ::highlight dynamic remove text decoration - reference</title>+<style>+ #upper {+ text-decoration: wavy underline overline green 5px;+ text-underline-offset: 20px;+ }+ div {+ border: solid 1px black;+ padding: 50px;+ }+</style>+<div id="upper">This line starts with under/over lines that remain.</div>+<div id="lower">This line starts with under/over lines that are removed.</div>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001-ref.htmlnew file mode 100644index 00000000000..d3a3d49797a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001-ref.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<html lang="en">+<meta charset="utf-8" />+<title>CSS Pseudo-Elements Test: Reference</title>+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="stylesheet" href="../support/highlights.css">+<style>+div {+ color: lime;+ background: green;+ margin: 10px;+}+#empty > span {+}+#color-currentcolor > span {+ color: currentcolor;+}+#backgroundcolor-currentcolor > span {+ background-color: currentcolor;+}+#textdecorationcolor-currentcolor > span {+ text-decoration-line: underline;+ text-decoration-color: currentcolor;+}+#color-currentcolor-backgroundcolor-currentcolor > span {+ color: currentcolor;+ background-color: currentcolor;+}+#color-currentcolor-backgroundcolor-blue > span {+ color: currentcolor;+ background-color: blue;+}+#color-blue-backgroundcolor-currentcolor > span {+ color: blue;+ background-color: currentcolor;+}+</style>++<div id="empty" class="highlight_reftest"><span>example</span> - empty</div>+<div id="color-currentcolor" class="highlight_reftest"><span>example</span> - color-currentcolor</div>+<div id="backgroundcolor-currentcolor" class="highlight_reftest"><span>example</span> - backgroundcolor-currentcolor</div>+<div id="textdecorationcolor-currentcolor" class="highlight_reftest"><span>example</span> - textdecorationcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-currentcolor" class="highlight_reftest"><span>example</span> - color-currentcolor-backgroundcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-blue" class="highlight_reftest"><span>example</span> - color-currentcolor-backgroundcolor-blue</div>+<div id="color-blue-backgroundcolor-currentcolor" class="highlight_reftest"><span>example</span> - color-blue-backgroundcolor-currentcolor</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002-ref.htmlnew file mode 100644index 00000000000..6f9066cba8a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002-ref.html@@ -0,0 +1,49 @@+<!DOCTYPE html>+<html lang="en">+<meta charset="utf-8" />+<title>CSS Pseudo-Elements Test: Reference</title>+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="stylesheet" href="../support/highlights.css">+<style>+div {+ color: lime;+ background: green;+ margin: 10px;+}+div > span {+ color: yellow;+ background: maroon;+}+#empty > span > span {+}+#color-currentcolor > span > span {+ color: currentcolor;+}+#backgroundcolor-currentcolor > span > span {+ background-color: currentcolor;+}+#textdecorationcolor-currentcolor > span > span {+ text-decoration-line: underline;+ text-decoration-color: currentcolor;+}+#color-currentcolor-backgroundcolor-currentcolor > span > span {+ color: currentcolor;+ background-color: currentcolor;+}+#color-currentcolor-backgroundcolor-blue > span > span {+ color: currentcolor;+ background-color: blue;+}+#color-blue-backgroundcolor-currentcolor > span > span {+ color: blue;+ background-color: currentcolor;+}+</style>++<div id="empty" class="highlight_reftest"><span><span>ex</span>ample</span> - empty</div>+<div id="color-currentcolor" class="highlight_reftest"><span><span>ex</span>ample</span> - color-currentcolor</div>+<div id="backgroundcolor-currentcolor" class="highlight_reftest"><span><span>ex</span>ample</span> - backgroundcolor-currentcolor</div>+<div id="textdecorationcolor-currentcolor" class="highlight_reftest"><span><span>ex</span>ample</span> - textdecorationcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-currentcolor" class="highlight_reftest"><span><span>ex</span>ample</span> - color-currentcolor-backgroundcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-blue" class="highlight_reftest"><span><span>ex</span>ample</span> - color-currentcolor-backgroundcolor-blue</div>+<div id="color-blue-backgroundcolor-currentcolor" class="highlight_reftest"><span><span>ex</span>ample</span> - color-blue-backgroundcolor-currentcolor</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002-ref.htmlnew file mode 100644index 00000000000..b64b007c64b--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<html lang="en">+<meta charset="utf-8" />+<title>CSS Pseudo-Elements Test: Reference</title>+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="stylesheet" href="../support/highlights.css">+<style>+.highlight_reftest {+ color: green;+ margin: 10px;+}+.color-blue {+ color: blue;+}+</style>++<div class="highlight_reftest">green</div>+<div class="highlight_reftest">green</div>+<div class="highlight_reftest color-blue">blue</div>+<div class="highlight_reftest color-blue">blue</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001-ref.htmlnew file mode 100644index 00000000000..699f559c6aa--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: black;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a-ref.htmlnew file mode 100644index 00000000000..114487e478f--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: black;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002-ref.htmlnew file mode 100644index 00000000000..35891efedd4--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: currentColor;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a-ref.htmlnew file mode 100644index 00000000000..c58b5f48e6f--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a-ref.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: currentColor;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003-ref.htmlnew file mode 100644index 00000000000..f2d14a4cd63--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: black;+ text-decoration: /* currentColor */ underline;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a-ref.htmlnew file mode 100644index 00000000000..be16f519c0f--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: black;+ text-decoration: /* currentColor */ underline;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004-ref.htmlnew file mode 100644index 00000000000..0963a7d831c--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: black;+ text-shadow: 0 2em red, 0 4em currentColor;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a-ref.htmlnew file mode 100644index 00000000000..a29a035dc64--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a-ref.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="stylesheet" href="support/highlights.css">+<style>+ .a {+ color: yellow;+ background-color: blue;+ }+ .b {+ color: lime;+ background-color: blue;+ }+ .selection {+ color: currentColor;+ background-color: black;+ text-shadow: 0 2em red, 0 4em currentColor;+ }+</style>+<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001-ref.htmlnew file mode 100644index 00000000000..f1485ca9226--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001-ref.html@@ -0,0 +1,15 @@+<!doctype html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: highlight painting: soft hyphens</title>+<link rel="stylesheet" href="support/highlights.css">+<style>+ main {+ width: 13em;+ color: transparent;+ }+ main > span {+ color: green;+ }+</style>+<p>Pass if only the letter T is visible below, not the hyphens.+<main class="highlight_reftest"><span>T</span>he­Quick­Brown­Fox­Jumps­Over­The­Lazy­Dog­The­Quick­Brown­Fox­Jumps­Over­The­Lazy­Dog­The­Quick­Brown­Fox­Jumps­Over­The­Lazy­Dog</main>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/selection-over-highlight-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/selection-over-highlight-001-ref.htmlnew file mode 100644index 00000000000..f75017d5ec5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/selection-over-highlight-001-ref.html@@ -0,0 +1,12 @@+<!doctype html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: selected highlight highlight painting - reference</title>+<link rel="author" name="Stephen Chenney" href="mailto:[email protected]">+<style>+ div {+ background-color: lightblue;+ color: green;+ width: fit-content;+ }+</style>+<div id="content">When selected, the highlight color should remain.</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/images/blank-highlight.png b/Tests/LibWeb/Ref/expected/wpt-import/images/blank-highlight.pngnew file mode 100644index 00000000000..6dbee091749Binary files /dev/null and b/Tests/LibWeb/Ref/expected/wpt-import/images/blank-highlight.png differdiff --git a/Tests/LibWeb/Ref/input/custom-highlight-image-in-range-without-colors.html b/Tests/LibWeb/Ref/input/custom-highlight-image-in-range-without-colors.htmlnew file mode 100644index 00000000000..fcbd208cb17--- /dev/null+++ b/Tests/LibWeb/Ref/input/custom-highlight-image-in-range-without-colors.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<link rel="match" href="../expected/custom-highlight-image-in-range-without-colors-ref.html">+<style>+::highlight(underline) {+ text-decoration: underline;+}+img {+ display: block;+ width: 50px;+ height: 50px;+}+</style>+<div id="container"><img src="../data/50x50-green.svg"></div>+<script>+const range = new Range();+range.selectNodeContents(container);+CSS.highlights.set("underline", new Highlight(range));+</script>diff --git a/Tests/LibWeb/Ref/input/custom-highlight-image-in-range.html b/Tests/LibWeb/Ref/input/custom-highlight-image-in-range.htmlnew file mode 100644index 00000000000..f177699d563--- /dev/null+++ b/Tests/LibWeb/Ref/input/custom-highlight-image-in-range.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<link rel="match" href="../expected/custom-highlight-image-in-range-ref.html">+<style>+::highlight(wash) {+ background-color: rgba(0, 0, 255, 0.5);+}+img {+ display: block;+ width: 50px;+ height: 50px;+}+</style>+<div id="contained"><img src="../data/50x50-green.svg"></div>+<div id="starting"><img id="starting_image" src="../data/50x50-green.svg"></div>+<script>+const whole = new Range();+whole.selectNodeContents(contained);+const image = new Range();+image.selectNode(contained.firstChild);+const from_image = new Range();+from_image.setStart(starting_image, 0);+from_image.setEnd(starting, 1);+CSS.highlights.set("wash", new Highlight(whole, image, from_image));+</script>diff --git a/Tests/LibWeb/Ref/input/custom-highlight-range-moved-from-iframe.html b/Tests/LibWeb/Ref/input/custom-highlight-range-moved-from-iframe.htmlnew file mode 100644index 00000000000..1a4c575013a--- /dev/null+++ b/Tests/LibWeb/Ref/input/custom-highlight-range-moved-from-iframe.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="match" href="../expected/custom-highlight-green-text-ref.html">+<style>+::highlight(green) {+ background-color: green;+}+iframe {+ display: none;+}+</style>+<p id="target">text</p>+<iframe id="frame" srcdoc="frame text"></iframe>+<script>+frame.addEventListener("load", () => {+ const range = new Range();+ range.selectNodeContents(frame.contentDocument.body);+ CSS.highlights.set("green", new Highlight(range));+ requestAnimationFrame(() => {+ range.selectNodeContents(target);+ requestAnimationFrame(() => document.documentElement.classList.remove("reftest-wait"));+ });+});+</script>+</html>diff --git a/Tests/LibWeb/Ref/input/custom-highlight-registered-after-first-paint.html b/Tests/LibWeb/Ref/input/custom-highlight-registered-after-first-paint.htmlnew file mode 100644index 00000000000..9c0d5fca0f5--- /dev/null+++ b/Tests/LibWeb/Ref/input/custom-highlight-registered-after-first-paint.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<link rel="match" href="../expected/custom-highlight-registered-after-first-paint-ref.html">+<style>+#first::highlight(green), #second::highlight(green), #third::highlight(green), #fourth::highlight(green) {+ background-color: green;+}+</style>+<p id="shared"><span id="first">one</span> <span id="second">two</span></p>+<p id="outer"><span id="third">three</span> <span id="fourth">four</span></p>+<p id="other">other</p>+<script>+const other = new Range();+other.selectNodeContents(document.getElementById("other"));+CSS.highlights.set("other", new Highlight(other));+requestAnimationFrame(() => {+ requestAnimationFrame(() => {+ const first = new Range();+ first.setStart(shared, 0);+ first.setEnd(shared, 1);+ const second = new Range();+ second.setStart(shared, 2);+ second.setEnd(shared, 3);+ const third = new Range();+ third.setStart(outer, 0);+ third.setEnd(outer, 1);+ const fourth = new Range();+ fourth.selectNodeContents(document.getElementById("fourth"));+ CSS.highlights.set("green", new Highlight(first, second, third, fourth));+ });+});+</script>+</html>diff --git a/Tests/LibWeb/Ref/input/custom-highlight-revealed-by-class-change.html b/Tests/LibWeb/Ref/input/custom-highlight-revealed-by-class-change.htmlnew file mode 100644index 00000000000..054663f3381--- /dev/null+++ b/Tests/LibWeb/Ref/input/custom-highlight-revealed-by-class-change.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="match" href="../expected/custom-highlight-green-text-ref.html">+<style>+#target {+ display: none;+}+#target.shown {+ display: block;+}+::highlight(green) {+ background-color: green;+}+</style>+<p id="target">text</p>+<script>+const range = new Range();+range.selectNodeContents(target);+CSS.highlights.set("green", new Highlight(range));+requestAnimationFrame(() => {+ target.className = "shown";+ requestAnimationFrame(() => document.documentElement.classList.remove("reftest-wait"));+});+</script>+</html>diff --git a/Tests/LibWeb/Ref/input/custom-highlight-static-range-made-valid-by-text-change.html b/Tests/LibWeb/Ref/input/custom-highlight-static-range-made-valid-by-text-change.htmlnew file mode 100644index 00000000000..da80aa59e89--- /dev/null+++ b/Tests/LibWeb/Ref/input/custom-highlight-static-range-made-valid-by-text-change.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<link rel="match" href="../expected/custom-highlight-green-text-ref.html">+<style>+::highlight(green) {+ background-color: green;+}+</style>+<p id="target">te</p>+<script>+const text = target.firstChild;+CSS.highlights.set("green", new Highlight(new StaticRange({ startContainer: text, startOffset: 0, endContainer: text, endOffset: 4 })));+requestAnimationFrame(() => {+ document.body.offsetWidth;+ text.appendData("xt");+});+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-009.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-009.htmlnew file mode 100644index 00000000000..fbb176758b6--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-009.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<title>CSS Container Queries Test: Container for highlight pseudo elements</title>+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#query-container">+<link rel="match" href="../../../../../expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-009-ref.html">+<style>+ #container {+ container-type: inline-size;+ width: 500px;+ }++ ::selection { color: red; background: transparent; }+ ::highlight(hi) { color: red; background: transparent; }++ @container (width >= 400px) {+ ::selection { color: green }+ ::highlight(hi) { color: green }+ }+</style>+<div id="container">+ <span id="sel">Selection</span>+ <span id="hi">Highlight</span>+</div>+<script>+ getSelection().selectAllChildren(sel);+ let highlight_range = document.createRange();+ highlight_range.selectNode(hi);+ CSS.highlights.set("hi", new Highlight(highlight_range));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-010.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-010.htmlnew file mode 100644index 00000000000..4808d94d8d4--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-010.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<html class="reftest-wait">+<title>CSS Container Queries Test: Container for highlight pseudo elements</title>+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#query-container">+<link rel="match" href="../../../../../expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-010-ref.html">+<script src="../../../common/reftest-wait.js"></script>+<style>+ .container { container-type: inline-size; }+ #outer { width: 300px; }+ #inner { width: 500px; }++ #inner::highlight(hi) {+ color: red;+ background: transparent;+ }+ @container (width >= 400px) {+ #inner.green::highlight(hi) {+ color: green;+ background: transparent;+ }+ }+</style>+<div id="outer" class="container">+ <div id="inner" class="container">+ <span id="hi">Highlight</span>+ </div>+</div>+<script>+ let highlight_range = document.createRange();+ highlight_range.selectNode(hi);+ CSS.highlights.set("hi", new Highlight(highlight_range));++ requestAnimationFrame(() => {+ requestAnimationFrame(() => {+ inner.classList.add("green");+ takeScreenshot();+ });+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-011.htmlnew file mode 100644index 00000000000..6522ffe54de--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-011.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<title>CSS Container Queries Test: ::highlight pseudo element on size container</title>+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#query-container">+<link rel="match" href="../../../../../expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-010-ref.html">+<style>+ #container {+ width: 500px;+ container-type: inline-size;+ }+ #container::highlight(hi) {+ color: red;+ background: transparent;+ }+ @container (width >= 400px) {+ #container::highlight(hi) {+ color: green;+ background: transparent;+ }+ }+</style>+<div id="container">Highlight</div>+<script>+ let highlight_range = document.createRange();+ highlight_range.selectNode(container);+ CSS.highlights.set("hi", new Highlight(highlight_range));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-012.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-012.htmlnew file mode 100644index 00000000000..574fccc8d98--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/container-queries/pseudo-elements-012.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<html class="reftest-wait">+<title>CSS Container Queries Test: ::highlight pseudo size container change</title>+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#query-container">+<link rel="match" href="../../../../../expected/wpt-import/css/css-conditional/container-queries/pseudo-elements-010-ref.html">+<script src="../../../common/reftest-wait.js"></script>+<style>+ #container {+ width: 300px;+ container-type: inline-size;+ }+ #container::highlight(hi) {+ color: red;+ background: transparent;+ }+ @container (width >= 400px) {+ #container::highlight(hi) {+ color: green;+ background: transparent;+ }+ }+</style>+<div id="container">Highlight</div>+<script>+ let highlight_range = document.createRange();+ highlight_range.selectNode(container);+ CSS.highlights.set("hi", new Highlight(highlight_range));++ requestAnimationFrame(() => {+ requestAnimationFrame(() => {+ container.style.width = "500px";+ takeScreenshot();+ });+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/custom-highlight-escaped-star-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/custom-highlight-escaped-star-001.htmlnew file mode 100644index 00000000000..b94cfa7c143--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/custom-highlight-escaped-star-001.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>Custom Highlight: a highlight registered as * is styled by the escaped ::highlight(\*)</title>+<link rel="author" href="mailto:[email protected]">+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/9091">+<link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/custom-highlight-universal-painting-001-ref.html">+<meta name="assert" value="The registry name * pairs with the escaped selector \*; the escaped form is an ordinary name, not the universal selector.">+<style>+ ::highlight(\*) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);++ CSS.highlights.set("*", new Highlight(r));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image-currentcolor.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image-currentcolor.htmlnew file mode 100644index 00000000000..ef4019a9d9d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image-currentcolor.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>Custom highlight: currentColor over a replaced element resolves against the previous layer</title>+<link rel="author" title="Fernando Fiori" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-cascade">+<link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-image-currentcolor-ref.html">+<meta name="assert" content="A higher-priority ::highlight() with background-color: currentColor over a replaced element resolves currentColor against the previous (lower) layer's resolved color, not the host element's color.">+<style>+ body { color: blue; }+ /* Lower layer paints red and sets the resolved current color to green. */+ ::highlight(low) { background-color: red; color: green; }+ /* Higher layer's currentColor must resolve to the low layer's green,+ NOT the host's blue. */+ ::highlight(high) { background-color: currentColor; }+</style>+<body>+<div id="d"><img src="../../images/blank-highlight.png"></div>+<script>+ const d = document.getElementById('d');+ const makeHighlight = () => new Highlight(new StaticRange({+ startContainer: d, startOffset: 0, endContainer: d, endOffset: 1,+ }));+ const low = makeHighlight();+ const high = makeHighlight();+ low.priority = 0;+ high.priority = 1;+ CSS.highlights.set("low", low);+ CSS.highlights.set("high", high);+</script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image-stacked.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image-stacked.htmlnew file mode 100644index 00000000000..eaa74f1a5c1--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image-stacked.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>Custom highlight: stacked highlights over a replaced element</title>+<link rel="author" title="Fernando Fiori" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-bounds">+<link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-image-stacked-ref.html">+<meta name="assert" content="Two custom highlights covering a replaced element stack by priority; the higher-priority opaque background paints on top of the lower one.">+<style>+ ::highlight(under) { background-color: blue; }+ ::highlight(over) { background-color: green; }+</style>+<body>+<div id="d"><img src="../../images/blank-highlight.png"></div>+<script>+ const d = document.getElementById('d');+ const makeHighlight = () => new Highlight(new StaticRange({+ startContainer: d, startOffset: 0, endContainer: d, endOffset: 1,+ }));+ const under = makeHighlight();+ const over = makeHighlight();+ under.priority = 0;+ over.priority = 1;+ CSS.highlights.set("under", under);+ CSS.highlights.set("over", over);+</script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image.htmlnew file mode 100644index 00000000000..e4d72420145--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-image.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8">+ <title>Custom highlight pseudo elements over images.</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#creating-highlights">+ <link rel="mismatch" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-image-notref.html">+ <meta name="assert" content="Highlights should be able to be specified over images.">+ <style>+ ::highlight(example-highlight1) {+ background-color: rgba(200,0,0,.5);+ color:green;+ }+ </style>+</head>+<body>+ <div id="img1"><img src="../../images/blank-highlight.png"></div>++ <script>+ let imageElement1 = document.getElementById('img1');+ let highlight1 = new Highlight(new StaticRange({startContainer: imageElement1, startOffset: 0, endContainer: imageElement1, endOffset: 1}));+++ CSS.highlights.set("example-highlight1", highlight1);+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-priority-painting.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-priority-painting.htmlnew file mode 100644index 00000000000..dce3caf86e8--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-priority-painting.html@@ -0,0 +1,66 @@+<!DOCTYPE html>+<html>+<head>+ <title>Highlight priority attribute painting correctness</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#priorities">+ <link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-priority-painting-ref.html">+ <meta name="fuzzy" content="0-255;0-16">+ <style>+ ::highlight(yellow-highlight) {+ background-color: yellow;+ }+ ::highlight(green-highlight) {+ background-color: green;+ }+ ::highlight(blue-highlight) {+ background-color: blue;+ }+ </style>+</head>+<body>+ <span id="green-highlight">Green</span>+ <span id="yellow-highlight">Yellow</span>+ <span id="blue-highlight">Blue</span>+ <span id="yellow-blue-highlight">Yellow-Blue</span>++ <script>+ let yellowBlue = document.getElementById("yellow-blue-highlight");+ let green = document.getElementById("green-highlight");+ let highlightGreen = new Highlight(new StaticRange({+ startContainer: green.childNodes[0],+ startOffset: 0,+ endContainer: green.childNodes[0],+ endOffset: 5+ }));+ let yellow = document.getElementById("yellow-highlight");+ let highlightYellow = new Highlight(new StaticRange({+ startContainer: yellow.childNodes[0],+ startOffset: 0,+ endContainer: yellow.childNodes[0],+ endOffset: 6+ }), new StaticRange({+ startContainer: yellowBlue.childNodes[0],+ startOffset: 0,+ endContainer: yellowBlue.childNodes[0],+ endOffset: 6+ }));+ let blue = document.getElementById("blue-highlight");+ let highlightBlue = new Highlight(new StaticRange({+ startContainer: blue.childNodes[0],+ startOffset: 0,+ endContainer: blue.childNodes[0],+ endOffset: 4+ }), new StaticRange({+ startContainer: yellowBlue.childNodes[0],+ startOffset: 0,+ endContainer: yellowBlue.childNodes[0],+ endOffset: 11+ }));+ CSS.highlights.set("yellow-highlight", highlightYellow);+ CSS.highlights.set("green-highlight", highlightGreen);+ CSS.highlights.set("blue-highlight", highlightBlue);+ highlightYellow.priority = 10;+ highlightBlue.priority = -1;+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-across-elements.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-across-elements.htmlnew file mode 100644index 00000000000..f7159161a7d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-across-elements.html@@ -0,0 +1,56 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8">+ <title>Custom highlight pseudo elements across elements.</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#painting">+ <link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-text-across-elements-ref.html">+ <meta name="assert" content="Highlights should be able to be specified across elements.">+ <style>+ :root {+ /* This reduces the likelihood that a highlight background-area+ will overlap with the previous glyph. That overlap is worth+ avoiding, because the previous glyph's overlapping part will get+ clipped in the reference case, but might not in the testcase. */+ font-family: monospace;+ }+ ::highlight(example-highlight1) {+ background-color: yellow;+ color:green;+ }+ ::highlight(example-highlight2) {+ background-color: blue;+ color:red;+ }+ ::highlight(example-highlight3) {+ background-color: purple;+ color:pink;+ }+ </style>+</head>+<body>+ <span id="text1">One two three</span>+ <span id="text2">four five six</span>+ <span id="text3">seven eight nine</span>+ <span id="text4">ten eleven twelve</span>+ <span id="text5">thirteen fourteen fifteen</span>++ <script>+ let textElement1 = document.getElementById('text1');+ let textElement2 = document.getElementById('text2');+ let textElement3 = document.getElementById('text3');+ let textElement4 = document.getElementById('text4');+ let textElement5 = document.getElementById('text5');+ let highlight1 = new Highlight(new StaticRange({startContainer: textElement1.childNodes[0], startOffset: 4, endContainer: textElement1.childNodes[0], endOffset: 7}));++ let highlight2 = new Highlight(new StaticRange({startContainer: textElement1.childNodes[0], startOffset: 10, endContainer: textElement2.childNodes[0], endOffset: 4}));+ highlight2.add(new StaticRange({startContainer: textElement2.childNodes[0], startOffset: 10, endContainer: textElement3.childNodes[0], endOffset: 5}));++ let highlight3 = new Highlight(new StaticRange({startContainer: textElement3.childNodes[0], startOffset: 10, endContainer: textElement5.childNodes[0], endOffset: 12}));++ CSS.highlights.set("example-highlight1", highlight1);+ CSS.highlights.set("example-highlight2", highlight2);+ CSS.highlights.set("example-highlight3", highlight3);+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-decorations.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-decorations.htmlnew file mode 100644index 00000000000..b3a5438fb33--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-decorations.html@@ -0,0 +1,63 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8">+ <title>Text decorations in custom highlight pseudo elements.</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#applicable-properties">+ <link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-text-decorations-ref.html">+ <meta name="assert" content="Text decorations in highlights should be displayed.">+ <style>+ html {+ font-size: 24pt;+ }+ ::highlight(example-highlight1) {+ text-decoration: underline;+ text-decoration-color: red;+ color: blue;+ }+ ::highlight(example-highlight2) {+ text-decoration: line-through;+ text-decoration-color: violet;+ text-decoration-style: double;+ }+ ::highlight(example-highlight3) {+ text-decoration: overline;+ text-decoration-color: orange;+ text-decoration-style: dotted;+ }+ /* FIXME: There is a discrepency for how the underlines are displayed at the end of the line, leading to a pixel different in this text. Find a real fix, but in the meantime, obscure the offending pixel https://bugs.webkit.org/show_bug.cgi?id=207512 <rdar://problem/59327965> */+ .obscurer1 {+ position: absolute;+ top: 25px;+ left: 95px;+ width: 10px;+ height: 10px;+ background: grey;+ }+ .obscurer2 {+ position: absolute;+ top: 35px;+ left: 180px;+ width: 10px;+ height: 10px;+ background: grey;+ }+ </style>+</head>+<body>+ <span id="text1">One two three</span>+ <div class='obscurer1'></div>+ <div class='obscurer2'></div>++ <script>+ let textElement = document.getElementById('text1');+ let highlight1 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 1, endContainer: textElement.childNodes[0], endOffset: 2}));+ let highlight2 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 5, endContainer: textElement.childNodes[0], endOffset: 6}));+ let highlight3 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 10, endContainer: textElement.childNodes[0], endOffset: 13}));++ CSS.highlights.set("example-highlight1", highlight1);+ CSS.highlights.set("example-highlight2", highlight2);+ CSS.highlights.set("example-highlight3", highlight3);+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-dynamic.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-dynamic.htmlnew file mode 100644index 00000000000..816154c829c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text-dynamic.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8">+ <title>Highlights Paint after dynamic creation.</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#creating-highlights">+ <link rel="mismatch" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-text-dynamic-notref.html">+ <meta name="assert" content="Highlight should paint after being created after first paint.">+ <style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color:green;+ }+ </style>+</head>+<body>+ <span id="text1">One two three</span>++ <script>+ function setHighlight(timestamp) {+ let textElement = document.getElementById('text1');+ let highlight1 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 1, endContainer: textElement.childNodes[0], endOffset: 2}));+ CSS.highlights.set("example-highlight", highlight1);+ }++ document.body.offsetLeft;+ window.requestAnimationFrame(setHighlight);+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text.htmlnew file mode 100644index 00000000000..2a0357e7864--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/highlight-text.html@@ -0,0 +1,51 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8">+ <title>Multiple custom highlight pseudo elements.</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#creating-highlights">+ <link rel="match" href="../../../../expected/wpt-import/css/css-highlight-api/highlight-text-ref.html">+ <meta name="assert" content="Multiple highlights should be able to be specified.">+ <style>+ :root {+ /* These reduce the likelihood that a highlight background-area+ will overlap with the previous glyph. That overlap is worth+ avoiding, because the previous glyph's overlapping part will get+ clipped in the reference case, but might not in the testcase. */+ font-family: monospace;+ letter-spacing: 2px;+ }+ ::highlight(example-highlight1) {+ background-color: yellow;+ color:green;+ }+ ::highlight(example-highlight2) {+ background-color: blue;+ color:red;+ }+ ::highlight(example-highlight3) {+ background-color: purple;+ color:pink;+ }+ </style>+</head>+<body>+ <span id="text1">One two three</span>++ <script>+ let textElement = document.getElementById('text1');+ let highlight1 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 1, endContainer: textElement.childNodes[0], endOffset: 2}));++ let highlight2 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 3, endContainer: textElement.childNodes[0], endOffset: 4}));+ highlight2.add(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 5, endContainer: textElement.childNodes[0], endOffset: 6}));++ let highlight3 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 7, endContainer: textElement.childNodes[0], endOffset: 8}));+ highlight3.add(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 9, endContainer: textElement.childNodes[0], endOffset: 10}));+ highlight3.add(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 12, endContainer: textElement.childNodes[0], endOffset: 13}));++ CSS.highlights.set("example-highlight1", highlight1);+ CSS.highlights.set("example-highlight2", highlight2);+ CSS.highlights.set("example-highlight3", highlight3);+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001.htmlnew file mode 100644index 00000000000..4a68dfeebd8--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<html>+<meta charset="utf-8">+<title>CSS Highlight API Test: ::highlight with text-underline-offset</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/css-highlight-painting-underline-offset-001-ref.html">+<meta name="assert" content="Verify that text-underline-offset works in a ::highlight pseudo-element.">+<meta name="fuzzy" content="0-56;0-10">+<style>+ ::highlight(example) {+ text-decoration: wavy underline green 5px;+ text-underline-offset: 20px;+ }+</style>+<p id="target">The underline should be offset.</p>+<script>+ let range = new Range();+ range.setStart(target, 0);+ range.setEnd(target, 1);+ CSS.highlights.set(`example`, new Highlight(range));+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001.htmlnew file mode 100644index 00000000000..1aa6c35f5c9--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-001-ref.html">+<meta name="assert" value="lengths depending on containers take the correct values in a universal highlight with no container">+<head>+ <style>+ div {+ width: 200px;+ height: 100px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 1cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 2cqh;+ }+</style>+</head>+<body>+ <div id="h1">With container size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ CSS.highlights.set("highlight1", new Highlight(r1));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002.htmlnew file mode 100644index 00000000000..d9654d0116c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002-ref.html">+<meta name="assert" value="lengths depending on containers take the correct values inside and outside a container">+<meta name="fuzzy" content="0-60;0-25">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 200px;+ height: 100px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+</style>+</head>+<body>+ <div class="wrapper">+ <div id="h1">With container size</div>+ </div>+ <div id="h2">Without container size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003.htmlnew file mode 100644index 00000000000..27cceee8eec--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003.html@@ -0,0 +1,40 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.html">+<meta name="assert" value="lengths depending on containers take the correct values and a highlight defined inside the container renders only within the container">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 200px;+ height: 100px;+ }+ @container (width > 100px) {+ ::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+ }+ </style>+</head>+<body>+ <div class="wrapper">+ <div id="h1">With container size</div>+ </div>+ <div id="h2">Should be no highlight</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004.htmlnew file mode 100644index 00000000000..869cd47ac7d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004.html@@ -0,0 +1,41 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-004-ref.html">+<meta name="assert" value="lengths depending on containers take the correct values inside and outside a container">+<meta name="fuzzy" content="0-60;0-25">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 200px;+ height: 100px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+</style>+</head>+<body>+ <div class="wrapper">+ <div>+ <div id="h1">With container size</div>+ </div>+ </div>+ <div id="h2">Without container size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-005.htmlnew file mode 100644index 00000000000..e90dec732a7--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-005.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.html">+<meta name="assert" value="a highlight on a container itself renders at the correct size">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 200px;+ height: 100px;+ }+ @container (width > 100px) {+ .wrapper::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+ }+ </style>+</head>+<body>+ <div id="h1" class="wrapper">With container size</div>+ <div id="h2">Should be no highlight</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-006.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-006.htmlnew file mode 100644index 00000000000..8cf73d5427d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-006.html@@ -0,0 +1,37 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002-ref.html">+<meta name="assert" value="lengths depending on containers take the correct values inside and outside a container">+<meta name="fuzzy" content="0-60;0-25">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 200px;+ height: 100px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+</style>+</head>+<body>+ <div id="h1" class="wrapper">With container size</div>+ <div id="h2">Without container size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-002.htmlnew file mode 100644index 00000000000..8aeb782bb25--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-002.html@@ -0,0 +1,50 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using dynamic container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-002-ref.html">+<meta name="assert" value="lengths depending on containers take the correct values when the container size chnages">+<meta name="fuzzy" content="0-60;0-25">+<script src="../../../common/reftest-wait.js"></script>+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 400px;+ height: 200px;+ }+ .resize {+ width: 200px;+ height: 100px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+</style>+</head>+<body>+ <div id="container" class="wrapper">+ <div id="h1">With container size</div>+ </div>+ <div id="h2">Without container size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ requestAnimationFrame(() => {+ container.classList.add('resize');+ requestAnimationFrame(() => takeScreenshot());+ });+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-003.htmlnew file mode 100644index 00000000000..7495701985e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-003.html@@ -0,0 +1,48 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using dynamic container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.html">+<meta name="assert" value="lengths depending on containers update correctly for a highlight defined only inside a container query">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 400px;+ height: 200px;+ }+ .resize {+ width: 200px;+ height: 100px;+ }+ @container (width < 300px) {+ ::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+ }+ </style>+</head>+<body>+ <div id="container" class="wrapper">+ <div id="h1">With container size</div>+ </div>+ <div id="h2">Should be no highlight</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ requestAnimationFrame(() => {+ container.classList.add('resize');+ requestAnimationFrame(() => takeScreenshot());+ });+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-004.htmlnew file mode 100644index 00000000000..492eb23acc4--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-container-metrics-004.html@@ -0,0 +1,47 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlights using container sizes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-container-metrics-003-ref.html">+<meta name="assert" value="a highlight on a container itself renders at the correct size when the container changes">+<head>+ <style>+ .wrapper {+ container: wrapper / size;+ width: 400px;+ height: 200px;+ }+ .resize {+ width: 200px;+ height: 100px;+ }+ @container (width < 300px) {+ .wrapper::highlight(highlight1) {+ text-underline-offset: 2cqw;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 4cqh;+ }+ }+ </style>+</head>+<body>+ <div id="h1" class="wrapper">With container size</div>+ <div id="h2">Should be no highlight</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ requestAnimationFrame(() => {+ h1.classList.add('resize');+ requestAnimationFrame(() => takeScreenshot());+ });+ </script>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-font-metrics-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-font-metrics-001.htmlnew file mode 100644index 00000000000..aa3a076bd86--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-font-metrics-001.html@@ -0,0 +1,47 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001-ref.html">+<meta name="assert" value="fonts relative units take the correct values, with correct cascade">+<meta name="fuzzy" content="0-80;0-4">+<head>+ <style>+ :root {+ font-size: 8px;+ }+ div {+ margin: 50px;+ font-size: 10px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ </style>+</head>+<body>+ <div id="h1">Font relative units with 40px font</div>+ <div id="h2">Font relative units with 20px font</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ requestAnimationFrame(() => {+ requestAnimationFrame(() => {+ h1.style.fontSize = '40px';+ h2.style.fontSize = '20px';+ document.documentElement.style.fontSize = '16px';+ requestAnimationFrame(() => takeScreenshot());+ });+ });+ </script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-logical-metrics-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-logical-metrics-001.htmlnew file mode 100644index 00000000000..2068604f113--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-dynamic-logical-metrics-001.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Length relative to a changing logical direction</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002-ref.html">+<meta name="assert" value="lengths depending on viewports and logical direction when the direction changes">+<meta name="fuzzy" content="0-30;0-10">+<head>+ <style>+ div {+ width: 100px;+ height: 200px;+ line-height: 3em;+ }+ .vertical {+ writing-mode: vertical-lr;+ }+ ::highlight(highlight1) {+ text-underline-offset: 1svb;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 1svi;+ }+</style>+</head>+<body>+ <div id="h1">With viewport size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ CSS.highlights.set("highlight1", new Highlight(r1));+ requestAnimationFrame(() => {+ h1.classList.add('vertical');+ requestAnimationFrame(() => takeScreenshot());+ });+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001.htmlnew file mode 100644index 00000000000..9b57a8e803f--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001.html@@ -0,0 +1,42 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-001-ref.html">+<meta name="assert" value="lengths depending on fonts take the correct values in a universal highlight">+<meta name="fuzzy" content="0-80;0-4">+<head>+ <style>+ :root {+ font-size: 16px;+ }+ div {+ margin: 50px;+ font-size: 40px;+ }+ #h2 {+ font-size: 20px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ </style>+</head>+<body>+ <div id="h1">Font relative units with 40px font</div>+ <div id="h2">Font relative units with 20px font</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002.htmlnew file mode 100644index 00000000000..c894da70efc--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-002-ref.html">+<meta name="assert" value="fonts relative units take the correct values, with correct cascade">+<meta name="fuzzy" content="0-128;0-8">+<head>+ <style>+ :root {+ font-size: 16px;+ }+ div {+ margin: 40px;+ font-size: 20px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ #h2::highlight(highlight1) {+ text-underline-offset: 1.0em;+ text-decoration-line: underline;+ text-decoration-color: blue;+ text-decoration-thickness: 0.125rem;+ }+ </style>+</head>+<body>+ <div id="h1">A green 10px offset underline 4px thick</div>+ <div id="h2">A blue 20px offset underline 2px thick</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));+ </script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004.htmlnew file mode 100644index 00000000000..5d66b6c9cb7--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004.html@@ -0,0 +1,38 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-004-ref.html">+<meta name="assert" value="combining a font relative highlight with another highlight">+<meta name="fuzzy" content="0-120;0-8">+<head>+ <style>+ div {+ margin: 40px;+ font-size: 20px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ ::highlight(highlight2) {+ text-decoration-line: overline;+ text-decoration-color: green;+ text-decoration-thickness: 4px;+ }+ </style>+</head>+<body>+ <div id="h1">A green 10px offset underline 4px thick and green overline 4px thick</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ CSS.highlights.set("highlight1", new Highlight(r1));+ CSS.highlights.set("highlight2", new Highlight(r1));+ </script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005.htmlnew file mode 100644index 00000000000..70049e7d260--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005.html@@ -0,0 +1,49 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-font-metrics-005-ref.html">+<meta name="assert" value="dynmamic font size changes with highlights and font relative metrics">+<meta name="fuzzy" content="0-80;0-10">+<script src="../../../common/reftest-wait.js"></script>+<head>+ <style>+ :root {+ font-size: 16px;+ }+ div {+ margin: 50px;+ font-size: 40px;+ }+ #h2 {+ font-size: 20px;+ }+ ::highlight(highlight1) {+ text-underline-offset: 0.5em;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 0.25rem;+ }+ </style>+</head>+<body>+ <div id="h1">Font relative units with 20px font</div>+ <div id="h2">Font relative units with 20px font</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ let r2 = new Range();+ r2.setStart(h2, 0);+ r2.setEnd(h2, 1);+ CSS.highlights.set("highlight1", new Highlight(r1, r2));++ requestAnimationFrame(() => {+ h1.style.fontSize = "20px";+ requestAnimationFrame(() => { takeScreenshot() }+ )});+ </script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001.htmlnew file mode 100644index 00000000000..ada1b89ef4e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Length relative to the logical direction</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-001-ref.html">+<meta name="assert" value="lengths depending on viewports take the correct values with vertical text">+<meta name="fuzzy" content="0-30;0-10">+<head>+ <style>+ div {+ width: 200px;+ height: 100px;+ line-height: 3em;+ }+ ::highlight(highlight1) {+ text-underline-offset: 1svb;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 1svi;+ }+</style>+</head>+<body>+ <div id="h1">With viewport size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ CSS.highlights.set("highlight1", new Highlight(r1));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002.htmlnew file mode 100644index 00000000000..bc112e56f40--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002.html@@ -0,0 +1,33 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Length relative to the logical direction</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-logical-metrics-002-ref.html">+<meta name="assert" value="lengths depending on viewports and logical direction with vertical text">+<meta name="fuzzy" content="0-30;0-10">+<head>+ <style>+ div {+ width: 100px;+ height: 200px;+ writing-mode: vertical-lr;+ line-height: 3em;+ }+ ::highlight(highlight1) {+ text-underline-offset: 1svb;+ text-decoration-line: underline;+ text-decoration-color: green;+ text-decoration-thickness: 1svi;+ }+</style>+</head>+<body>+ <div id="h1">With viewport size</div>+ <script>+ let r1 = new Range();+ r1.setStart(h1, 0);+ r1.setEnd(h1, 1);+ CSS.highlights.set("highlight1", new Highlight(r1));+ </script>+</body>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001.htmlnew file mode 100644index 00000000000..896587534ae--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="::highlight overlay is painted">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);++ CSS.highlights.set("example-highlight", new Highlight(r));+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002.htmlnew file mode 100644index 00000000000..ba16448d695--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-002-ref.html">+<meta name="assert" value="Latest Highlight added to CSS.highlights has higher priority than the previous ones if there were no priorities explicitly set">+<style>+ div::highlight(bar) {+ color: red;+ }+ div::highlight(foo) {+ color: green;+ }+</style>+<body><div>abc</div>+<script>+ let div = document.body.firstChild;+ let r = new Range();+ r.setStart(div, 0);+ r.setEnd(div, 1);+ let h = new Highlight(r);+ CSS.highlights.set('foo', h);+ CSS.highlights.set('bar', h);+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003.htmlnew file mode 100644index 00000000000..44c3b81ffd7--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003.html@@ -0,0 +1,23 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-003-ref.html">+<meta name="assert" value="Intersections of overlapping ranges contained in the same Highlight are painted only once">+<style>+ ::highlight(sample) { background-color: rgba(0, 0, 255, 0.3); }+</style>+<body>Lorem Ipsum.+<script>+ let textNode = document.body.firstChild;++ let r1 = new Range();+ r1.setStart(textNode, 1);+ r1.setEnd(textNode, 5);++ let r2 = new Range();+ r2.setStart(textNode, 3);+ r2.setEnd(textNode, 7);++ CSS.highlights.set("sample", new Highlight(r1, r2));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2.htmlnew file mode 100644index 00000000000..83ad711fbd8--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-2-ref.html">+<meta name="assert" value="When painting overlapping highlights with the same .priority, the one added last should be painted on top; and style properties not defined by the one on top (background-color in this case) should follow the rules of the next Highlight from top to bottom until there's one that overwrites default (or use default value otherwise).">+<meta name="fuzzy" content="0-88;0-4">+<style>+ ::highlight(foo) {+ color:blue;+ background-color:yellow;+ }+ ::highlight(bar) {+ color:orange;+ }+</style>+<body>Some text+<script>+ let textNode = document.body.firstChild;++ let r1 = new Range();+ r1.setStart(textNode, 0);+ r1.setEnd(textNode, 6);++ let r2 = new Range();+ r2.setStart(textNode, 3);+ r2.setEnd(textNode, 9);++ let h1 = new Highlight(r1);+ let h2 = new Highlight(r2);++ CSS.highlights.set("foo", h1);+ CSS.highlights.set("bar", h2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004.htmlnew file mode 100644index 00000000000..6ebce2e8d5a--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-004-ref.html">+<meta name="assert" value="When painting overlapping highlights with the same .priority, the one added last should be painted on top; and style properties not defined by the one on top (color in this case) should follow the rules of the next Highlight from top to bottom until there's one that overwrites default (or use default value otherwise).">+<meta name="fuzzy" content="0-255;0-110">+<style>+ ::highlight(foo) {+ color:blue;+ background-color:yellow;+ }+ ::highlight(bar) {+ background-color:orange;+ }+</style>+<body>Some text+<script>+ let textNode = document.body.firstChild;++ let r1 = new Range();+ r1.setStart(textNode, 0);+ r1.setEnd(textNode, 6);++ let r2 = new Range();+ r2.setStart(textNode, 3);+ r2.setEnd(textNode, 9);++ let h1 = new Highlight(r1);+ let h2 = new Highlight(r2);++ CSS.highlights.set("foo", h1);+ CSS.highlights.set("bar", h2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-005.htmlnew file mode 100644index 00000000000..5c3737b5b2a--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-005.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted after modifying (setEnd()) a Range contained in it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 1);+ CSS.highlights.set("example-highlight", new Highlight(r));+ r.setEnd(document.body, 2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-006.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-006.htmlnew file mode 100644index 00000000000..4723396858c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-006.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted after modifying (setStart()) a Range contained in it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 1);+ r.setEnd(document.body, 2);+ CSS.highlights.set("example-highlight", new Highlight(r));+ r.setStart(document.body, 0);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-007.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-007.htmlnew file mode 100644index 00000000000..fb2d2dc6ea4--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-007.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted after adding a Range to it after registering it in the HighlightRegistry">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r1 = new Range();+ r1.setStart(document.body, 0);+ r1.setEnd(document.body, 1);+ let h = new Highlight(r1);+ let r2 = new Range();+ r2.setStart(document.body, 1);+ r2.setEnd(document.body, 2);+ CSS.highlights.set("example-highlight", h);+ h.add(r2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-008.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-008.htmlnew file mode 100644index 00000000000..73fe004bc20--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-008.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted after deleting a Range from it after registering it in the HighlightRegistry">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r1 = new Range();+ r1.setStart(document.body, 0);+ r1.setEnd(document.body, 2);+ let r2 = new Range();+ r2.setStart(document.body, 1);+ r2.setEnd(document.body, 3);+ let h = new Highlight(r1, r2);+ CSS.highlights.set("example-highlight", h);+ h.delete(r2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-009.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-009.htmlnew file mode 100644index 00000000000..c48fd832a76--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-009.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted correctly when collapsing a Range after registering a Highlight that contains it in the HighlightRegistry">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ ::highlight(another-highlight) {+ background-color: red;+ color: orange;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r1 = new Range();+ r1.setStart(document.body, 0);+ r1.setEnd(document.body, 2);+ let r2 = new Range();+ r2.setStart(document.body, 1);+ r2.setEnd(document.body, 3);+ let h1 = new Highlight(r1);+ let h2 = new Highlight(r2);+ CSS.highlights.set("example-highlight", h1);+ CSS.highlights.set("another-highlight", h2);+ r2.collapse();+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-010.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-010.htmlnew file mode 100644index 00000000000..e3e230d93fe--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-010.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted correctly after inserting a node in the middle of a Range contained in it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 1);+ CSS.highlights.set("example-highlight", new Highlight(r));+ let newNode = document.createElement("span");+ newNode.innerText = "One ";+ document.body.insertBefore(newNode, document.body.firstChild);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-011.htmlnew file mode 100644index 00000000000..9c27952ae2f--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-011.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted correctly after removing a node included in a Range contained in it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>two-point-five </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 3);+ CSS.highlights.set("example-highlight", new Highlight(r));+ document.body.removeChild(document.body.children[2]);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-012.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-012.htmlnew file mode 100644index 00000000000..99eb5e8d7d6--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-012.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted correctly after modifying the inner text of a node included in a Range contained in it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>Zero </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);+ CSS.highlights.set("example-highlight", new Highlight(r));+ document.body.firstChild.innerText = "One ";+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-013.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-013.htmlnew file mode 100644index 00000000000..4fdac74211c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-013.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted correctly after modifying text content of a node included in a Range contained in it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span id="first">One </span><span id="second">two-point-five </span><span id="third">three…</span>+<script>+ let r = new Range();+ r.setStart(document.querySelector("#first").firstChild, 0);+ r.setEnd(document.querySelector("#third").firstChild, 0);+ CSS.highlights.set("example-highlight", new Highlight(r));+ document.querySelector("#second").firstChild.textContent = "two ";+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-014.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-014.htmlnew file mode 100644index 00000000000..15c677a0643--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-014.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Registering the same Highlight under different names and again with a used name works as it should.">+<style>+ ::highlight(foo) {+ color: blue;+ }+ ::highlight(bar) {+ background-color: yellow;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);++ let h = new Highlight(r);++ CSS.highlights.set("foo", h);+ CSS.highlights.set("bar", h);+ CSS.highlights.set("foo", h);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-015.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-015.htmlnew file mode 100644index 00000000000..54e3dd8a907--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-015.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Unregistering only once a Highlight that was registered under different names works as it should and is still being painted.">+<style>+ ::highlight(foo) {+ color: red;+ }+ ::highlight(bar) {+ color: blue;+ background-color: yellow;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);++ let h = new Highlight(r);++ CSS.highlights.set("foo", h);+ CSS.highlights.set("bar", h);+ CSS.highlights.delete("foo");+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-016.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-016.htmlnew file mode 100644index 00000000000..384a8af3749--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-016.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Painting</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlighted elements must be correctly painted and there should be no caching that doesn't take highlight names into account">+<style>+ #affected::highlight(foo) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span></span><span id="affected">One </span><span id="affected">two </span><span>three…</span>+<script>+ // The first <span> style resolution shouldn't cause caching an empty set of matched properties that could be used with the spans that should be highlighted later.+ const node = document.body;+ let r = new Range();+ r.setStart(node, 1);+ r.setEnd(node, 3);+ CSS.highlights.set("foo", new Highlight(r));+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-017.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-017.htmlnew file mode 100644index 00000000000..1d15674af49--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-017.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="utf-8" />+<title>CSS Highlight API Test: ::highlight color with transparent originating color</title>+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#custom-highlight-pseudo">+<link rel="help" href="https://crbug.com/1273943">+<meta name="assert" content="This test checks that ::highlight pseudo-element uses the specified color even when the originating element text color was trasnparent.">+<link rel="match" href="../../../../../expected/wpt-import//css/reference/pass_if_pass_below.html">+<style>+ div {+ color: transparent;+ }+ ::highlight(example-highlight) {+ color: black;+ }+</style>++<p>Test passes if there is the word "PASS" below.</p>+<div id="target">PASS</div>++<script>+ let r = new Range();+ r.setStart(target, 0);+ r.setEnd(target, 1);++ CSS.highlights.set("example-highlight", new Highlight(r));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-018.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-018.htmlnew file mode 100644index 00000000000..3eb7d58224e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-018.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Range across contain boundary is painted</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight should be painted even though a Range that crosses a css-contain boundary is a part of it">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ #target {+ contain: paint;+ }+</style>+<body><span>One </span><span id="target"><span>two </span><span>three…</span></span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.querySelector("#target"), 1);+ CSS.highlights.set("example-highlight", new Highlight(r));+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001.htmlnew file mode 100644index 00000000000..8794c2ed86b--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlighting a text node inside an anonymous block box</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-anonymous-block-001-ref.html">+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css">+<meta name="assert" value="::highlight background is painted on a text node that sits in an anonymous block box (the text is followed by a block-level sibling).">+<style>+ #target {+ font: 40px/1 Ahem;+ }+ ::highlight(example-highlight) {+ background-color: yellow;+ }+</style>+<body>+<div id="target">X X X X<div>X</div></div>+<script>+ const textNode = document.getElementById("target").firstChild;+ const range = new Range();+ range.setStart(textNode, 0);+ range.setEnd(textNode, textNode.length);+ CSS.highlights.set("example-highlight", new Highlight(range));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency.htmlnew file mode 100644index 00000000000..a0a345fbb49--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-transparency-ref.html">+<meta name="assert"+ value="Highlight overlay is painted below selection overlay. If selection uses transparency, colors are combined.">+<style>+ ::highlight(foo) {+ background: yellow;+ }+</style>++<body><span id="highlighted">This should be yellow, <span id="selected">this should mix with the+ selection,</span></span> this should have no background.+ <script>+ let highlightRange = new Range();+ highlightRange.setStart(document.body.firstChild, 0);+ highlightRange.setEnd(document.body.firstChild, 2);+ CSS.highlights.set("foo", new Highlight(highlightRange));+ getSelection().setBaseAndExtent(selected, 0, selected, 1);+ </script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection.htmlnew file mode 100644index 00000000000..7d4aca0d2ca--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-below-selection-ref.html">+<meta name="assert" value="Highlight overlay is painted below selection overlay">+<style>+ ::highlight(foo) {+ background: cyan;+ color: blue;+ }+ ::selection {+ background: blue;+ color: cyan;+ }+</style>+<body>Text should be blue over cyan here and <span id="selected">cyan over blue here</span>.+<script>+ let highlightRange = new Range();+ highlightRange.setStart(document.body.firstChild, 0);+ highlightRange.setEnd(document.body.lastChild, 0);+ CSS.highlights.set("foo", new Highlight(highlightRange));+ getSelection().setBaseAndExtent(selected, 0, selected, 1);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types.htmlnew file mode 100644index 00000000000..a1e9c3ee920--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types.html@@ -0,0 +1,44 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Highlighting text in elements with different display types</title>+<link rel="author" title="Karl Dubost" href="https://otsukare.info/">+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-display-types-ref.html">+<link rel="issue" href="https://bugs.webkit.org/show_bug.cgi?id=307455">+<meta name="assert" value="::highlight overlay is painted on elements with display: flex, inline-flex, grid, and table">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ body {+ font-family: monospace;+ font-size: 16px;+ }+ .container {+ margin: 10px 0;+ }+</style>+<body>+ <div class="container" id="block">Block: text content</div>+ <div class="container" id="flex" style="display: flex;">Flex: text content</div>+ <div class="container" id="inline-flex" style="display: inline-flex;">Inline-flex: text content</div>+ <div class="container" id="grid" style="display: grid;">Grid: text content</div>+ <div class="container" id="table" style="display: table;">Table: text content</div>+<script>+ // Highlight "text content" in each container+ const containers = ['block', 'flex', 'inline-flex', 'grid', 'table'];+ const ranges = [];++ containers.forEach(id => {+ const element = document.getElementById(id);+ const textNode = element.firstChild;+ const range = new Range();+ // Highlight "text content" part+ range.setStart(textNode, textNode.textContent.indexOf('text'));+ range.setEnd(textNode, textNode.textContent.length);+ ranges.push(range);+ });++ CSS.highlights.set("example-highlight", new Highlight(...ranges));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-002.htmlnew file mode 100644index 00000000000..0d3f77b21c0--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-002.html@@ -0,0 +1,33 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-001-ref.html">+<meta name="assert" value="Creating a Highlight in the root Document and registering it in an iframe's CSS.highlights is painted correctly.">+<body>+ <iframe+ id="iframe"+ srcdoc="+ <style>+ ::highlight(foo) {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>+<script>+ let iframe = document.querySelector("#iframe");+ iframe.onload = () => {+ let spanIframe = iframe.contentDocument.querySelector("#span-iframe");+ let rangeIframe = new Range();+ rangeIframe.setStart(spanIframe, 0);+ rangeIframe.setEnd(spanIframe, 1);++ let h = new Highlight();+ h.add(rangeIframe);+ iframe.contentWindow.CSS.highlights.set("foo", h);+ }+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003.htmlnew file mode 100644index 00000000000..6f4003d787c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003.html@@ -0,0 +1,46 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-003-ref.html">+<meta name="assert" value="Creating a Highlight in the root Document with a Range in the root document and another one in an iframe is correctly painted when added to both CSS.highlights (root document's and iframe's).">+<style>+ ::highlight(foo) {+ color: green;+ background-color: greenyellow;+ }+</style>+<body>+ <iframe+ id="iframe"+ srcdoc="+ <style>+ ::highlight(foo) {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>+<br>+<span id="span-doc">abc</span>+<script>+ let spanDoc = document.querySelector("#span-doc");+ let rangeDoc = new Range();+ rangeDoc.setStart(spanDoc, 0);+ rangeDoc.setEnd(spanDoc, 1);++ let iframe = document.querySelector("#iframe");+ iframe.onload = () => {+ let spanIframe = iframe.contentDocument.querySelector("#span-iframe");+ let rangeIframe = new Range();+ rangeIframe.setStart(spanIframe, 0);+ rangeIframe.setEnd(spanIframe, 1);++ let h = new Highlight(rangeDoc, rangeIframe);+ iframe.contentWindow.CSS.highlights.set("foo", h);+ CSS.highlights.set("foo", h);+ }+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004.htmlnew file mode 100644index 00000000000..31b7c79c567--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-004-ref.html">+<meta name="assert" value="Creating a Highlight in the root Document with a Range in the root document and another one in an iframe is correctly painted when added to the root document's CSS.highlights (only root document's range is painted).">+<style>+ ::highlight(foo) {+ color: green;+ background-color: greenyellow;+ }+</style>+<body>+ <iframe+ id="iframe"+ srcdoc="+ <style>+ ::highlight(foo) {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>+<br>+<span id="span-doc">abc</span>+<script>+ let spanDoc = document.querySelector("#span-doc");+ let rangeDoc = new Range();+ rangeDoc.setStart(spanDoc, 0);+ rangeDoc.setEnd(spanDoc, 1);++ let iframe = document.querySelector("#iframe");+ iframe.onload = () => {+ let spanIframe = iframe.contentDocument.querySelector("#span-iframe");+ let rangeIframe = new Range();+ rangeIframe.setStart(spanIframe, 0);+ rangeIframe.setEnd(spanIframe, 1);++ let h = new Highlight(rangeDoc, rangeIframe);+ CSS.highlights.set("foo", h);+ }+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005.htmlnew file mode 100644index 00000000000..da2e5f451c8--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-iframe-005-ref.html">+<meta name="assert" value="Creating a Highlight in the root Document with a Range in the root document and another one in an iframe is correctly painted when added to the iframe's CSS.highlights (only the iframe's range is painted).">+<style>+ ::highlight(foo) {+ color: green;+ background-color: greenyellow;+ }+</style>+<body>+ <iframe+ id="iframe"+ srcdoc="+ <style>+ ::highlight(foo) {+ color: blue;+ background-color: cyan;+ }+ </style>+ <span id='span-iframe'>abc</span>+ "+ >+</iframe>+<br>+<span id="span-doc">abc</span>+<script>+ let spanDoc = document.querySelector("#span-doc");+ let rangeDoc = new Range();+ rangeDoc.setStart(spanDoc, 0);+ rangeDoc.setEnd(spanDoc, 1);++ let iframe = document.querySelector("#iframe");+ iframe.onload = () => {+ let spanIframe = iframe.contentDocument.querySelector("#span-iframe");+ let rangeIframe = new Range();+ rangeIframe.setStart(spanIframe, 0);+ rangeIframe.setEnd(spanIframe, 1);++ let h = new Highlight(rangeDoc, rangeIframe);+ iframe.contentWindow.CSS.highlights.set("foo", h);+ }+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001.htmlnew file mode 100644index 00000000000..44c0e38a24c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Inheritance</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001-ref.html">+<meta name="assert" value="Highlighted elements inherit style properties from their parent if they're not set">+<style>+ div::highlight(div-highlight) {+ background-color: green;+ color: red;+ }+ span::highlight(span-highlight) {+ color: blue;+ }+</style>+<body>+<div>There should be only one green rectangle below from [ to ]:</div>+<div id="target">[<span> <strong> </strong> </span>]</div>+<script>+ let r = new Range();+ const node = document.getElementById("target");+ r.setStart(node, 1);+ r.setEnd(node, 2);++ CSS.highlights.set("div-highlight", new Highlight(r));+ CSS.highlights.set("span-highlight", new Highlight(r));+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-002.htmlnew file mode 100644index 00000000000..d651a7788b0--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-002.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Inheritance</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001-ref.html">+<meta name="assert" value="Highlighted elements inherit style properties from their parent even if there's not a ::highlight selector directly applying to them or their parent.">+<style>+ div::highlight(div-highlight) {+ background-color: green;+ }+</style>+<body>+<div>There should be only one green rectangle below from [ to ]:</div>+<div id="target">[<span> <strong> </strong> </span>]</div>+<script>+ const node = document.getElementById("target");+ let r = new Range();+ r.setStart(node, 1);+ r.setEnd(node, 2);+ CSS.highlights.set("div-highlight", new Highlight(r));+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001.htmlnew file mode 100644index 00000000000..30af89a682f--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="utf-8">+<title>CSS Highlight API Test: highlight renders on text node inserted after highlight registration</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001-ref.html">+<meta name="assert" content="Highlights on ranges of detached text nodes are painted after the text node is inserted into the document.">+<script src="../../../common/reftest-wait.js"></script>+<style>+ ::highlight(example) {+ color: red;+ }+</style>+<body>+<pre></pre>+<script>+ const pre = document.querySelector('pre');+ const text = document.createTextNode('Hello world');+ const range = new Range();+ range.setStart(text, 6);+ range.setEnd(text, 11);+ CSS.highlights.set('example', new Highlight(range));+ pre.append(text);+ requestAnimationFrame(() => requestAnimationFrame(() => takeScreenshot()));+</script>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-002.htmlnew file mode 100644index 00000000000..da118730c96--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-002.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="utf-8">+<title>CSS Highlight API Test: highlight renders when subtree containing highlighted range is inserted</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-insert-node-001-ref.html">+<meta name="assert" content="Highlights on ranges inside a detached subtree are painted after the subtree root is inserted into the document.">+<script src="../../../common/reftest-wait.js"></script>+<style>+ ::highlight(example) {+ color: red;+ }+</style>+<body>+<script>+ const pre = document.createElement('pre');+ const text = document.createTextNode('Hello world');+ pre.append(text);+ const range = new Range();+ range.setStart(text, 6);+ range.setEnd(text, 11);+ CSS.highlights.set('example', new Highlight(range));+ document.body.append(pre);+ requestAnimationFrame(() => requestAnimationFrame(() => takeScreenshot()));+</script>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-001.htmlnew file mode 100644index 00000000000..3c9a8e7ede1--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-001.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="::highlight overlay is correctly invalidated and repainted">+<script src="resources/run-after-layout-and-paint.js"></script>+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);++ // Force frame paint before registering the Highlight.+ runAfterLayoutAndPaint(()=>{+ CSS.highlights.set("example-highlight", new Highlight(r));+ document.documentElement.removeAttribute("class");+ });+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-003.htmlnew file mode 100644index 00000000000..8b04fae8785--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-003.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="::highlight overlay is correctly invalidated and repainted after modifying its range">+<script src="resources/run-after-layout-and-paint.js"></script>+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ CSS.highlights.set("example-highlight", new Highlight(r));++ // Force frame paint before modifying the Highlight's range.+ runAfterLayoutAndPaint(()=>{+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);+ document.documentElement.removeAttribute("class");+ });+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-004.htmlnew file mode 100644index 00000000000..486fc9f771e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-004.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="::highlight overlay is correctly invalidated and repainted after adding a range to it">+<script src="resources/run-after-layout-and-paint.js"></script>+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);+ let h = new Highlight();+ CSS.highlights.set("example-highlight", h);++ // Force frame paint before modifying the Highlight.+ runAfterLayoutAndPaint(()=>{+ h.add(r);+ document.documentElement.removeAttribute("class");+ });+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-005.htmlnew file mode 100644index 00000000000..967d01b84c1--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-005.html@@ -0,0 +1,37 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="::highlight overlay is correctly invalidated and repainted after modifying its priority">+<script src="resources/run-after-layout-and-paint.js"></script>+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ ::highlight(another-highlight) {+ background-color: red;+ color: orange;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);+ let h1 = new Highlight(r);+ let h2 = new Highlight(r);+ h1.priority = 1;+ h2.priority = 2;+ CSS.highlights.set("example-highlight", h1);+ CSS.highlights.set("another-highlight", h2);++ // Force frame paint before modifying the Highlight.+ runAfterLayoutAndPaint(()=>{+ h1.priority = 3;+ document.documentElement.removeAttribute("class");+ });+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-006.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-006.htmlnew file mode 100644index 00000000000..cc0310fc6f8--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-006.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="::highlight overlay is correctly invalidated and repainted after inserting a new node inside one of its ranges">+<script src="resources/run-after-layout-and-paint.js"></script>+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 1);+ CSS.highlights.set("example-highlight", new Highlight(r));+ let newNode = document.createElement("span");+ newNode.innerText = "One ";++ // Force frame paint before inserting a new node.+ runAfterLayoutAndPaint(()=>{+ document.body.insertBefore(newNode, document.body.firstChild);+ document.documentElement.removeAttribute("class");+ });+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007.htmlnew file mode 100644index 00000000000..5d14a772440--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="UTF-8">+<title>CSS Highlight API Test: CSS Rule change</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-invalidation-007-ref.html">+<meta name="assert" value="::highlight overlay is correctly invalidated and repainted after CSS rule is changed">+<script src="resources/run-after-layout-and-paint.js"></script>+<style>+ span::highlight(example-highlight) {+ background: yellow;+ }++ .blue::highlight(example-highlight) {+ background: blue;+ }+</style>+<body>+ <span>Hello</span>+<script>+ const range = new Range();+ const span = document.querySelector("span");+ range.setStart(span, 0);+ range.setEnd(span, 1);+ CSS.highlights.set("example-highlight", new Highlight(range));++ // Force frame paint before changing style+ runAfterLayoutAndPaint(() => {+ span.className = "blue";+ document.documentElement.removeAttribute("class");+ });+</script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001.htmlnew file mode 100644index 00000000000..85a80615cf1--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001.html@@ -0,0 +1,44 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<meta name="fuzzy" content="maxDifference=0-255; totalPixels=0-2">+<title>CSS Highlight API Test: Overlapping Highlights</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-001-ref.html">+<meta name="assert" value="UAs must not define any styles for custom highlight pseudo-elements in the default UA stylesheet.">+<style>+ body {+ font-size: 3em;+ font-weight: bolder;+ }+ #affected1::highlight(highlight1) {+ color: red;+ }+ #affected2::highlight(highlight2) {+ color: green;+ }+</style>+<body><span id="affected1">This should have 'highlight1' style (red).</span><span id="affected2">This should have 'highlight2' style (green).</span>+<script>+ /*+ This test is meant to verify that:+ - UAs must not define any styles for custom highlight pseudo-elements in+ the default UA stylesheet.+ - UAs do not paint unstyled custom highlights.++ In this test, highlight2 has higher priority because it was registered+ later, so it is painted over highlight1. This includes painting for+ span#affected1, where there is no CSS rule for highlight2. But since unstyled+ custom highlights are not painted, span#affected1 is still painted with the+ styles for highlight1.++ See https://drafts.csswg.org/css-highlight-api-1/#default-styles+ */++ const node = document.body;+ let r = new Range();+ r.setStart(node, 0);+ r.setEnd(node, 2);++ CSS.highlights.set("highlight1", new Highlight(r));+ CSS.highlights.set("highlight2", new Highlight(r));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002.htmlnew file mode 100644index 00000000000..e775a0b0545--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002.html@@ -0,0 +1,53 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Overlapping Highlights</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-overlapping-highlights-002-ref.html">+<meta name="assert" value="UAs must not define any styles for custom highlight pseudo-elements in the default UA stylesheet.">+<style>+ div {+ font-size: 3em;+ font-weight: bolder;+ }+ #affected1::highlight(highlight1) {+ color: green;+ background-color: rgb(0, 255, 0, 0.5);+ }+ #affected2::highlight(highlight2) {+ color: red;+ background-color: rgba(100, 0, 100, 0.5);+ }+</style>+<body><div><span id="affected1">Green on lime.</span><span id="affected2">Red on maroon.</span></div>+<script>+ /*+ This test is meant to verify that:+ - UAs must not define any styles for custom highlight pseudo-elements in+ the default UA stylesheet.+ - UAs do not paint unstyled custom highlights.++ In this test, highlight1 has higher priority, so it is painted over+ highlight2. This includes painting for span#affected2, where there is no CSS+ rule for highlight1. But since unstyled custom highlights are not painted,+ span#affected2 is still painted with the styles for highlight2.++ See https://drafts.csswg.org/css-highlight-api-1/#default-styles+ */++ const div = document.querySelector("div");++ let r = new Range();+ r.setStart(div, 0);+ r.setEnd(div, 2);+ let r2 = new Range();+ r2.setStart(div, 0);+ r2.setEnd(div, 2);++ let h = new Highlight(r);+ h.priority = 3;+ let h2 = new Highlight(r2);+ h2.priority = 2;++ CSS.highlights.set("highlight1", h);+ CSS.highlights.set("highlight2", h2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-001.htmlnew file mode 100644index 00000000000..63ddb18d722--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-001.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlights are prioritized correctly by changing their .priority (higher priority is painted on top no matter the order of insertion into the HighlightRegistry)">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ ::highlight(another-highlight) {+ background-color: red;+ color: orange;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);+ let h1 = new Highlight(r);+ let h2 = new Highlight(r);+ h1.priority = 2;+ h2.priority = 1;+ CSS.highlights.set("example-highlight", h1);+ CSS.highlights.set("another-highlight", h2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-002.htmlnew file mode 100644index 00000000000..3922e5773bc--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-002.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlights are repainted correctly when changing their priority after adding them to the HighlightRegistry">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ ::highlight(another-highlight) {+ background-color: red;+ color: orange;+ }+</style>+<body><span>One </span><span>two </span><span>three…</span>+<script>+ let r = new Range();+ r.setStart(document.body, 0);+ r.setEnd(document.body, 2);+ let h1 = new Highlight(r);+ let h2 = new Highlight(r);+ CSS.highlights.set("example-highlight", h1);+ CSS.highlights.set("another-highlight", h2);+ h1.priority = 1;+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003.htmlnew file mode 100644index 00000000000..0450e83c055--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003.html@@ -0,0 +1,36 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: Non-conflicting attributes</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#priorities">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-prioritization-003-ref.html">+<meta name="assert" value="Non-conflicting attributes for highlights will be painted even if lower priority">+<style>+ ::highlight(highlight-1) {+ background-color: blue;+ color: white;+ }+ ::highlight(highlight-2) {+ background-color: yellow;+ }+</style>+<body>+ <p>This is an example of two overlapping highlights</p>+</body>+<script>+ const text = document.querySelector("p").firstChild;++ // Create two overlapping highlights+ const range1 = new Range();+ range1.setStart(text, 5);+ range1.setEnd(text, 10);++ const range2 = new Range();+ range2.setStart(text, 10);+ range2.setEnd(text, 18);++ const highlight1 = new Highlight(range1);+ const highlight2 = new Highlight(range2);++ CSS.highlights.set("highlight-1", highlight1);+ CSS.highlights.set("highlight-2", highlight2);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001.htmlnew file mode 100644index 00000000000..87940d24314--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Highlight API Test: ::highlight text-decoration paints over higher priority when not clashing</title>+ <link rel="help" href="https://www.w3.org/TR/css-highlight-api-1/#priorities">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001-ref.html">+ <style>+ ::highlight(yellow-highlight) {+ background-color: yellow;+ }+ ::highlight(underline-highlight) {+ text-decoration: underline;+ text-decoration-color: red;+ }+ </style>+</head>+<body>+ <span id="yellow-highlight">Yellow</span>++ <script>+ let yellow = document.getElementById("yellow-highlight");+ let highlightYellow = new Highlight(new StaticRange({+ startContainer: yellow.childNodes[0],+ startOffset: 0,+ endContainer: yellow.childNodes[0],+ endOffset: 6+ }));+ let highlightUnderline = new Highlight(new StaticRange({+ startContainer: yellow.childNodes[0],+ startOffset: 0,+ endContainer: yellow.childNodes[0],+ endOffset: 6+ }));+ CSS.highlights.set("yellow-highlight", highlightYellow);+ CSS.highlights.set("underline-highlight", highlightUnderline);+ highlightYellow.priority = 10;+ </script>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor.htmlnew file mode 100644index 00000000000..385e8348c2e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor.html@@ -0,0 +1,23 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Highlight API Test: ::highlight text-decoration with currentColor</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-selection-text-decoration-currentcolor-ref.html">+<meta name="assert" content="This test checks that ::highlight text-decoration-color defaults to currentColor.">+<style>+ #target {+ font-size: 50px;+ }+ ::highlight(test-highlight) {+ color: green;+ text-decoration: overline;+ }+</style>+<p>The test passes if the text below has a green overline.</p>+<p id="target">Highlighted text</p>+<script>+ let range = new Range();+ range.setStart(target.firstChild, 0);+ range.setEnd(target.firstChild, target.firstChild.length);+ CSS.highlights.set("test-highlight", new Highlight(range));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-002.htmlnew file mode 100644index 00000000000..253a1a235ec--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-002.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: StaticRange across contain boundary is painted</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="A StaticRange crossing a contain boundary should be painted">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+ #contained {+ contain: paint;+ }+</style>+<body><span>One <span id="contained">two </span>three…</span>+<script>+ let h = new Highlight();+ h.add(new StaticRange({startContainer: document.body.firstChild.childNodes[0], startOffset: 0, endContainer: document.body.firstChild.childNodes[1], endOffset: 1}));+ CSS.highlights.set("example-highlight", h);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-003.htmlnew file mode 100644index 00000000000..6edc7a94268--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-003.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="Highlight is repainted correctly after removing a node included in a StaticRange contained in it (StaticRange not modified)">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One </span><span>one-point-five </span><span>two </span><span>three…</span>+<script>+ let r = new StaticRange({startContainer: document.body, startOffset: 0, endContainer: document.body, endOffset: 2});+ CSS.highlights.set("example-highlight", new Highlight(r));+ document.body.removeChild(document.body.children[1]);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004.htmlnew file mode 100644index 00000000000..826cdfb16b6--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: </title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-004-ref.html">+<meta name="assert" value="Highlight is repainted correctly after re-arranging nodes in StaticRange such that highlights go from overlapping to not">+<style>+ ::highlight(example-highlight) {+ background-color: rgba(0, 128, 0, 0.5);+ color: blue;+ }+</style>+<body><span>One </span><span>one-point-five </span><span>two </span><span>three…</span>+<script>+ let r1 = new StaticRange({startContainer: document.body.children[0], startOffset: 0, endContainer: document.body.children[2], endOffset: 1});+ let r2 = new StaticRange({startContainer: document.body.children[1], startOffset: 0, endContainer: document.body.children[3], endOffset: 1});+ CSS.highlights.set("example-highlight", new Highlight(r1,r2));+ document.body.appendChild(document.body.children[1]);+ document.body.appendChild(document.body.children[2]);+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-005.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-005.htmlnew file mode 100644index 00000000000..7da8758f679--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-staticrange-005.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: StaticRange is repainted correctly after deleting and re-adding it.</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-001-ref.html">+<meta name="assert" value="A StaticRange is repainted correctly after deleting and re-adding it.">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ }+</style>+<body><span>One two three…</span>+<script>+ let h = new Highlight();+ const range = new StaticRange({+ startContainer: document.body.firstChild.childNodes[0],+ startOffset: 0,+ endContainer: document.body.firstChild.childNodes[0],+ endOffset: 8+ })+ h.add(range);+ CSS.highlights.set("example-highlight", h);+ document.body.onload = () => {+ h.delete(range);+ h.add(range);+ };+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001.htmlnew file mode 100644index 00000000000..58f90c31c32--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001.html@@ -0,0 +1,36 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Highlight API Test: ::highlight painting text-decoration</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-decoration-001-ref.html">+<meta name="assert" content="This test checks that ::highlight pseudo-element paints text-decorations defined by it.">+<meta name="fuzzy" content="0-255;0-27">+<style>+ div {+ float: left;+ margin: 0.5em;+ /* Setting transparent color is a workaround to avoid hitting the following Chromium bug: https://crbug.com/1179938.+ This could be removed once that bug is fixed. */+ color: transparent;+ }+</style>+<p>The test passes if it matches the reference file.</p>+<script>+ let textDecorationStyles = [+ "solid green underline", "double green underline", "dotted green underline", "dashed green underline", "wavy green underline",+ "solid blue overline", "double blue overline", "dotted blue overline", "dashed blue overline", "wavy blue overline",+ "solid magenta line-through", "double magenta line-through", "dotted magenta line-through", "dashed magenta line-through", "wavy magenta line-through",+ "solid brown underline overline line-through", "double brown underline overline line-through", "dotted brown underline overline line-through", "dashed brown underline overline line-through", "wavy brown underline overline line-through",+ ];++ textDecorationStyles.forEach((textDecorationStyle, index) => {+ document.styleSheets[0].insertRule(`::highlight(h${index}) { text-decoration: ${textDecorationStyle}; }`);+ let element = document.createElement("div");+ element.innerHTML = textDecorationStyle;+ document.body.appendChild(element);+ let range = new Range();+ range.setStart(element, 0);+ range.setEnd(element, 1);+ CSS.highlights.set(`h${index}`, new Highlight(range));+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-invalidation.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-invalidation.htmlnew file mode 100644index 00000000000..03b7886ac7a--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-invalidation.html@@ -0,0 +1,38 @@+<!DOCTYPE html>+<html class="reftest-wait">+ <meta charset="UTF-8">+ <title>CSS Highlight API Test: text-decoration</title>+ <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-ref.html">+ <meta name="assert" value="A change to text shadow size in a highlight is correctly rendered">+ <meta name="fuzzy" content="0-64;0-2">+<script src="resources/run-after-layout-and-paint.js"></script>+ <style>+ ::root {+ --shadow-offset-x: 15px;+ --shadow_offset-y: 20px;+ }+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ text-shadow: var(--shadow-offset-x, 5px) var(--shadow-offset-y, 10px) rgba(0, 255, 0, 0.5);+ }+ </style>+ <body>+ <span>One </span><span>two </span><span>three…</span>+ <script>+ let r = new Range();+ r.setStart(document.body, 1);+ r.setEnd(document.body, 3);+ CSS.highlights.set("example-highlight", new Highlight(r));++ runAfterLayoutAndPaint(()=>{+ document.documentElement.style.setProperty("--shadow-offset-x", "5px");+ document.documentElement.style.setProperty("--shadow-offset-y", "10px");+ runAfterLayoutAndPaint(()=>{+ document.documentElement.removeAttribute("class");+ });+ });+ </script>+ </body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow.htmlnew file mode 100644index 00000000000..9fd52608ec0--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<meta charset="UTF-8">+<title>CSS Highlight API Test: text-decoration</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../expected/wpt-import/css/css-highlight-api/painting/custom-highlight-painting-text-shadow-ref.html">+<meta name="assert" value="::highlight overlay paints text-shadow">+<meta name="fuzzy" content="0-64;0-2">+<style>+ ::highlight(example-highlight) {+ background-color: yellow;+ color: blue;+ text-shadow: 5px 10px rgba(0, 255, 0, 0.5);+ }+</style>+<body>+ <span>One </span><span>two </span><span>three…</span>+ <script>+ let r = new Range();+ r.setStart(document.body, 1);+ r.setEnd(document.body, 3);++ CSS.highlights.set("example-highlight", new Highlight(r));+ </script>+</body>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001.htmlnew file mode 100644index 00000000000..97edc624d68--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001.html@@ -0,0 +1,36 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="utf-8">+<title>CSS Highlight API Test: ::highlight dynamic change text-decoration</title>+<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">+<link rel="match" href="../../../../../../expected/wpt-import/css/css-highlight-api/painting/invalidation/css-highlight-invalidation-001-ref.html">+<meta name="assert" content="This test checks that it's possible to modify dynamically the text-decoration of a custom highlight through ::highlight pseudo-element.">+<meta name="fuzzy" content="0-56;0-10">+<script src="../../../../common/reftest-wait.js"></script>+<style>+ ::highlight(example) {+ text-decoration: wavy underline overline green 5px;+ text-underline-offset: 20px;+ }+ div {+ border: solid 1px black;+ padding: 50px;+ }+</style>+<div id="upper">This line starts with under/over lines that remain.</div>+<div id="lower">This line starts with under/over lines that are removed.</div>+<script>+ let range_upper = new Range();+ range_upper.setStart(upper, 0);+ range_upper.setEnd(upper, 1);+ let range_lower = new Range();+ range_lower.setStart(lower, 0);+ range_lower.setEnd(lower, 1);+ CSS.highlights.set(`example`, new Highlight(range_lower));++ requestAnimationFrame(() => requestAnimationFrame(() => {+ CSS.highlights.set(`example`, new Highlight(range_upper));+ requestAnimationFrame(() => takeScreenshot());+ }));+</script>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/resources/run-after-layout-and-paint.js b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/resources/run-after-layout-and-paint.jsnew file mode 100644index 00000000000..75d3e279a4c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-highlight-api/painting/resources/run-after-layout-and-paint.js@@ -0,0 +1,11 @@+// This is inspired in runAfterLayoutAndPaint() from+// third_party/blink/web_tests/resources/run-after-layout-and-paint.js.+function runAfterLayoutAndPaint(callback) {+ // See http://crrev.com/c/1395193/10/third_party/blink/web_tests/http/tests/resources/run-after-layout-and-paint.js+ // for more discussions.+ requestAnimationFrame(function() {+ requestAnimationFrame(function() {+ callback();+ });+ });+}\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001.htmlnew file mode 100644index 00000000000..03759d65fd4--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001.html@@ -0,0 +1,63 @@+<!DOCTYPE html>+<meta charset="utf-8" />+<title>CSS Pseudo-Elements Test: Custom Highlights currentcolor painting single layer</title>+<meta name="assert" content="Checks the painting for highlight pseudos (using ::highlight), when other properties are set to ‘currentColor’ (and ‘color’ is also ‘currentColor’, via implicit defaulting up to the root). The color of each property should equal the originating element ‘color’.">+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-text">+<link rel="match" href="../../../../../expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-001-ref.html">+<link rel="stylesheet" href="../support/highlights.css">+<meta name="fuzzy" content="0-50;0-150">+<style>+div {+ color: lime;+ background: green;+ margin: 10px;+}+::highlight(empty) {+}+::highlight(color-currentcolor) {+ color: currentcolor;+}+::highlight(backgroundcolor-currentcolor) {+ background-color: currentcolor;+}+::highlight(textdecorationcolor-currentcolor) {+ text-decoration-line: underline;+ text-decoration-color: currentcolor;+}+::highlight(color-currentcolor-backgroundcolor-currentcolor) {+ color: currentcolor;+ background-color: currentcolor;+}+::highlight(color-currentcolor-backgroundcolor-blue) {+ color: currentcolor;+ background-color: blue;+}+::highlight(color-blue-backgroundcolor-currentcolor) {+ color: blue;+ background-color: currentcolor;+}+</style>++<div id="empty" class="highlight_reftest">example - empty</div>+<div id="color-currentcolor" class="highlight_reftest">example - color-currentcolor</div>+<div id="backgroundcolor-currentcolor" class="highlight_reftest">example - backgroundcolor-currentcolor</div>+<div id="textdecorationcolor-currentcolor" class="highlight_reftest">example - textdecorationcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-currentcolor" class="highlight_reftest">example - color-currentcolor-backgroundcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-blue" class="highlight_reftest">example - color-currentcolor-backgroundcolor-blue</div>+<div id="color-blue-backgroundcolor-currentcolor" class="highlight_reftest">example - color-blue-backgroundcolor-currentcolor</div>++<script>+ function range(node, start, end) {+ let range = new Range();+ range.setStart(node, start);+ range.setEnd(node, end);+ return range;+ }++ const divs = document.getElementsByTagName("div");+ for (let div of divs) {+ CSS.highlights.set(div.id, new Highlight(range(div.firstChild, 0, 7)));+ }+</script>+diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002.htmlnew file mode 100644index 00000000000..6e6921405a0--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002.html@@ -0,0 +1,72 @@+<!DOCTYPE html>+<meta charset="utf-8" />+<title>CSS Pseudo-Elements Test: Custom Highlights currentcolor painting two layers</title>+<meta name="assert" content="Checks the painting for highlight pseudos (using ::highlight), when other properties are set to ‘currentColor’ (and ‘color’ is also ‘currentColor’, via implicit defaulting up to the root), and there is another active highlight below. The color of each property should equal the underlying highlight ‘color’.">+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-text">+<link rel="match" href="../../../../../expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-painting-properties-002-ref.html">+<link rel="stylesheet" href="../support/highlights.css">+<meta name="fuzzy" content="0-50;0-150">+<style>+div {+ color: lime;+ background: green;+ margin: 10px;+}+::highlight(below) {+ color: yellow;+ background: maroon;+}+::highlight(empty) {+}+::highlight(color-currentcolor) {+ color: currentcolor;+}+::highlight(backgroundcolor-currentcolor) {+ background-color: currentcolor;+}+::highlight(textdecorationcolor-currentcolor) {+ text-decoration-line: underline;+ text-decoration-color: currentcolor;+}+::highlight(color-currentcolor-backgroundcolor-currentcolor) {+ color: currentcolor;+ background-color: currentcolor;+}+::highlight(color-currentcolor-backgroundcolor-blue) {+ color: currentcolor;+ background-color: blue;+}+::highlight(color-blue-backgroundcolor-currentcolor) {+ color: blue;+ background-color: currentcolor;+}+</style>++<div id="empty" class="highlight_reftest">example - empty</div>+<div id="color-currentcolor" class="highlight_reftest">example - color-currentcolor</div>+<div id="backgroundcolor-currentcolor" class="highlight_reftest">example - backgroundcolor-currentcolor</div>+<div id="textdecorationcolor-currentcolor" class="highlight_reftest">example - textdecorationcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-currentcolor" class="highlight_reftest">example - color-currentcolor-backgroundcolor-currentcolor</div>+<div id="color-currentcolor-backgroundcolor-blue" class="highlight_reftest">example - color-currentcolor-backgroundcolor-blue</div>+<div id="color-blue-backgroundcolor-currentcolor" class="highlight_reftest">example - color-blue-backgroundcolor-currentcolor</div>++<script>+ function range(node, start, end) {+ let range = new Range();+ range.setStart(node, start);+ range.setEnd(node, end);+ return range;+ }++ const divs = document.getElementsByTagName("div");+ let ranges = [];+ for (let div of divs) {+ ranges.push(range(div.firstChild, 0, 7));+ }+ CSS.highlights.set("below", new Highlight(...ranges));++ for (let div of divs) {+ CSS.highlights.set(div.id, new Highlight(range(div.firstChild, 0, 2)));+ }+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002.htmlnew file mode 100644index 00000000000..20dbda1dc8c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<meta charset="utf-8" />+<title>CSS Pseudo-Elements Test: Custom Highlights color inherit painting</title>+<meta name="assert" content="Checks the painting for highlight pseudos (using ::highlight), when ‘color’ is universally set to ‘inherit’. When the parent is explicitly set to ‘blue’, inheritance stops there, yielding blue. Otherwise inheritance reaches the root element, where the inherited value is defined as ‘currentColor’ for highlights, yielding green.">+<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-text">+<link rel="match" href="../../../../../expected/wpt-import/css/css-pseudo/highlight-cascade/highlight-currentcolor-root-explicit-default-002-ref.html">+<link rel="stylesheet" href="../support/highlights.css">+<style>+.highlight_reftest {+ color: green;+ margin: 10px;+}+::highlight(color-inherit) {+ color: inherit;+}+#wrapper::highlight(color-inherit) {+ color: blue;+}+</style>+<div class="highlight_reftest">green</div>+<div class="highlight_reftest">g<span>ree</span>n</div>+<div id="wrapper">+ <div class="highlight_reftest">blue</div>+ <div class="highlight_reftest">b<span>lu</span>e</div>+</div>++<script>+ function range(node, start, end) {+ let range = new Range();+ range.setStart(node, start);+ range.setEnd(node, end);+ return range;+ }++ const divs = document.getElementsByClassName("highlight_reftest");+ let ranges = [];+ for (let div of divs) {+ if (div.childElementCount == 0)+ ranges.push(range(div, 0, 1));+ else+ ranges.push(range(div, 0, 3));+ }+ CSS.highlights.set("color-inherit", new Highlight(...ranges));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001.htmlnew file mode 100644index 00000000000..a47a3b44792--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: black;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectNodeContents(target);+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a.htmlnew file mode 100644index 00000000000..144cd10c7df--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-001a-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: black;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectRangeWith(range => {+ range.selectNodeContents(target);+ range.setStart(target.firstChild, 2);+ range.setEnd(target.firstChild, 7);+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002.htmlnew file mode 100644index 00000000000..20d38b3e87b--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘background-color’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘background-color’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: currentColor;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectNodeContents(target);+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a.htmlnew file mode 100644index 00000000000..eb35b163863--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘background-color’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘background-color’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-002a-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: currentColor;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectRangeWith(range => {+ range.selectNodeContents(target);+ range.setStart(target.firstChild, 2);+ range.setEnd(target.firstChild, 7);+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003.htmlnew file mode 100644index 00000000000..e120da178b7--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘text-decoration-color’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘text-decoration-color’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: black;+ text-decoration: /* currentColor */ underline;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectNodeContents(target);+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a.htmlnew file mode 100644index 00000000000..1a26e9f1dea--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘text-decoration-color’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘text-decoration-color’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-003a-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: black;+ text-decoration: /* currentColor */ underline;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectRangeWith(range => {+ range.selectNodeContents(target);+ range.setStart(target.firstChild, 2);+ range.setEnd(target.firstChild, 7);+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004.htmlnew file mode 100644index 00000000000..8ff2b002ad9--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘text-shadow’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘text-shadow’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: black;+ text-shadow: 0 2em red, 0 4em currentColor;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectNodeContents(target);+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a.htmlnew file mode 100644index 00000000000..3dc43f7e350--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘text-shadow’ of overlapping highlights</title>+<link rel="author" title="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘text-shadow’.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-currentcolor-004a-ref.html">+<meta name="fuzzy" content="0-120;0-10">+<link rel="stylesheet" href="support/highlights.css">+<script src="support/selections.js"></script>+<style>+ ::highlight(a) {+ color: yellow;+ background-color: blue;+ }+ ::highlight(b) {+ color: lime;+ background-color: blue;+ }+ ::selection {+ color: currentColor;+ background-color: black;+ text-shadow: 0 2em red, 0 4em currentColor;+ }+</style>+<div class="highlight_reftest" id="target">test test</div>+<script>+ CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));+ CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));+ selectRangeWith(range => {+ range.selectNodeContents(target);+ range.setStart(target.firstChild, 2);+ range.setEnd(target.firstChild, 7);+ });+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001.htmlnew file mode 100644index 00000000000..1f4a1d42e4e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001.html@@ -0,0 +1,28 @@+<!doctype html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: highlight painting: soft hyphens</title>+<link rel="author" name="Delan Azabani" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#painting">+<link rel="help" href="https://www.w3.org/TR/CSS22/zindex.html#painting-order">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/highlight-painting-soft-hyphens-001-ref.html">+<meta name="assert" value="::highlight overlay is not painted under soft hyphens in a text node with [0,1) highlighted and no other ranges highlighted">+<link rel="stylesheet" href="support/highlights.css">+<style>+ main {+ width: 13em;+ color: transparent;+ }+ main::highlight(foo) {+ color: green;+ }+</style>+<p>Pass if only the letter T is visible below, not the hyphens.+<main class="highlight_reftest">The­Quick­Brown­Fox­Jumps­Over­The­Lazy­Dog­The­Quick­Brown­Fox­Jumps­Over­The­Lazy­Dog­The­Quick­Brown­Fox­Jumps­Over­The­Lazy­Dog</main>+<script>+ const main = document.querySelector("main");+ const range = new Range;+ range.setStart(main.firstChild, 0);+ range.setEnd(main.firstChild, 1);+ CSS.highlights.set("foo", new Highlight(range));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/selection-over-highlight-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/selection-over-highlight-001.htmlnew file mode 100644index 00000000000..0bb2a0311bc--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/selection-over-highlight-001.html@@ -0,0 +1,24 @@+<!doctype html>+<meta charset="utf-8">+<title>CSS Pseudo-Elements Test: selected highlight highlight painting</title>+<link rel="author" name="Stephen Chenney" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">+<meta name="assert" value="Checks that the highlight colors persist when selected.">+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/selection-over-highlight-001-ref.html">+<style>+ ::selection {+ background-color: lightblue;+ }+ ::highlight(green) {+ color: green;+ }+</style>+<div id="content">When selected, the highlight color should remain.</div>+<script>+ let range = new Range();+ range.setStart(content, 0);+ range.setEnd(content, 1);+ CSS.highlights.set("green", new Highlight(range));++ document.execCommand("selectAll");+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/images/blank-highlight.png b/Tests/LibWeb/Ref/input/wpt-import/images/blank-highlight.pngnew file mode 100644index 00000000000..6dbee091749Binary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/images/blank-highlight.png differ