script: Support legacy "background" presentational hint on more elements (#41272)

Testing: New tests start to pass
Fixes https://github.com/servo/servo/issues/41269

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker
2025-12-16 05:22:42 +01:00
committed by GitHub
parent 399e6d4d6a
commit 9cbb522606
4 changed files with 64 additions and 66 deletions

View File

@@ -6,7 +6,6 @@ use dom_struct::dom_struct;
use embedder_traits::{EmbedderMsg, LoadStatus};
use html5ever::{LocalName, Prefix, local_name, ns};
use js::rust::HandleObject;
use servo_url::ServoUrl;
use style::attr::AttrValue;
use style::color::AbsoluteColor;
@@ -88,7 +87,6 @@ impl HTMLBodyElementMethods<crate::DomTypeHolder> for HTMLBodyElement {
pub(crate) trait HTMLBodyElementLayoutHelpers {
fn get_background_color(self) -> Option<AbsoluteColor>;
fn get_color(self) -> Option<AbsoluteColor>;
fn get_background(self) -> Option<ServoUrl>;
}
impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
@@ -105,14 +103,6 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
.and_then(AttrValue::as_color)
.cloned()
}
fn get_background(self) -> Option<ServoUrl> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("background"))
.and_then(AttrValue::as_resolved_url)
.cloned()
.map(Into::into)
}
}
impl VirtualMethods for HTMLBodyElement {
@@ -154,10 +144,6 @@ impl VirtualMethods for HTMLBodyElement {
local_name!("bgcolor") | local_name!("text") => {
AttrValue::from_legacy_color(value.into())
},
local_name!("background") => AttrValue::from_resolved_url(
&self.owner_document().base_url().get_arc(),
value.into(),
),
_ => self
.super_type()
.unwrap()