It was removed from the spec and it's disabled everywhere.

This also removes the meta viewport support (which was implemented on top), but that also had a single test and is disabled everywhere, so I'm not too concerned, it can be implemented again if / when needed.
This commit is contained in:
Emilio Cobos Álvarez 2023-06-30 16:20:59 +02:00 committed by Martin Robinson
parent 7412e28349
commit 349edff768
No known key found for this signature in database
GPG key ID: D56AA4FA55EFE6F8
34 changed files with 35 additions and 1139 deletions

View file

@ -3,38 +3,25 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::attr::Attr;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::cssstylesheet::CSSStyleSheet;
use crate::dom::document::Document;
use crate::dom::element::{AttributeMutation, Element};
use crate::dom::htmlelement::HTMLElement;
use crate::dom::htmlheadelement::HTMLHeadElement;
use crate::dom::node::{
document_from_node, stylesheets_owner_from_node, window_from_node, BindContext, Node,
UnbindContext,
};
use crate::dom::node::{BindContext, Node, UnbindContext};
use crate::dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
use js::rust::HandleObject;
use servo_arc::Arc;
use servo_config::pref;
use std::sync::atomic::AtomicBool;
use style::media_queries::MediaList;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{CssRule, CssRules, Origin, Stylesheet, StylesheetContents, ViewportRule};
#[dom_struct]
pub struct HTMLMetaElement {
htmlelement: HTMLElement,
#[ignore_malloc_size_of = "Arc"]
stylesheet: DomRefCell<Option<Arc<Stylesheet>>>,
cssom_stylesheet: MutNullableDom<CSSStyleSheet>,
}
impl HTMLMetaElement {
@ -45,8 +32,6 @@ impl HTMLMetaElement {
) -> HTMLMetaElement {
HTMLMetaElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
stylesheet: DomRefCell::new(None),
cssom_stylesheet: MutNullableDom::new(None),
}
}
@ -64,73 +49,17 @@ impl HTMLMetaElement {
)
}
pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> {
self.stylesheet.borrow().clone()
}
pub fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> {
self.get_stylesheet().map(|sheet| {
self.cssom_stylesheet.or_init(|| {
CSSStyleSheet::new(
&window_from_node(self),
self.upcast::<Element>(),
"text/css".into(),
None, // todo handle location
None, // todo handle title
sheet,
)
})
})
}
fn process_attributes(&self) {
let element = self.upcast::<Element>();
if let Some(ref name) = element.get_name() {
let name = name.to_ascii_lowercase();
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
if name == "viewport" {
self.apply_viewport();
}
if name == "referrer" {
self.apply_referrer();
}
}
}
#[allow(unrooted_must_root)]
fn apply_viewport(&self) {
if !pref!(layout.viewport.enabled) {
return;
}
let element = self.upcast::<Element>();
if let Some(ref content) = element.get_attribute(&ns!(), &local_name!("content")) {
let content = content.value();
if !content.is_empty() {
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
let stylesheets_owner = stylesheets_owner_from_node(self);
let document = document_from_node(self);
let shared_lock = document.style_shared_lock();
let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule)));
let sheet = Arc::new(Stylesheet {
contents: StylesheetContents::from_data(
CssRules::new(vec![rule], shared_lock),
Origin::Author,
window_from_node(self).get_url(),
document.quirks_mode(),
),
media: Arc::new(shared_lock.wrap(MediaList::empty())),
shared_lock: shared_lock.clone(),
disabled: AtomicBool::new(false),
});
*self.stylesheet.borrow_mut() = Some(sheet.clone());
stylesheets_owner.add_stylesheet(self.upcast(), sheet);
}
}
}
}
fn process_referrer_attribute(&self) {
let element = self.upcast::<Element>();
if let Some(ref name) = element.get_name() {
@ -197,10 +126,6 @@ impl VirtualMethods for HTMLMetaElement {
if context.tree_connected {
self.process_referrer_attribute();
if let Some(s) = self.stylesheet.borrow_mut().take() {
stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s);
}
}
}
}