mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement basics of link preloading (#37036)
These changes allow a minimal set of checks for font-src CSP checks to pass. Part of #4577 Part of #35035 --------- Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
parent
9dc1391bef
commit
36e4886da1
174 changed files with 2814 additions and 1097 deletions
|
@ -13,7 +13,7 @@ use std::str::FromStr;
|
|||
use std::{fmt, mem};
|
||||
|
||||
use content_security_policy as csp;
|
||||
use cssparser::match_ignore_ascii_case;
|
||||
use cssparser::{Parser as CssParser, ParserInput as CssParserInput, match_ignore_ascii_case};
|
||||
use devtools_traits::AttrInfo;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::InputMethodType;
|
||||
|
@ -36,6 +36,8 @@ use style::applicable_declarations::ApplicableDeclarationBlock;
|
|||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||
use style::context::QuirksMode;
|
||||
use style::invalidation::element::restyle_hints::RestyleHint;
|
||||
use style::media_queries::MediaList;
|
||||
use style::parser::ParserContext as CssParserContext;
|
||||
use style::properties::longhands::{
|
||||
self, background_image, border_spacing, font_family, font_size,
|
||||
};
|
||||
|
@ -50,13 +52,14 @@ use style::selector_parser::{
|
|||
};
|
||||
use style::shared_lock::{Locked, SharedRwLock};
|
||||
use style::stylesheets::layer_rule::LayerOrder;
|
||||
use style::stylesheets::{CssRuleType, UrlExtraData};
|
||||
use style::stylesheets::{CssRuleType, Origin as CssOrigin, UrlExtraData};
|
||||
use style::values::computed::Overflow;
|
||||
use style::values::generics::NonNegative;
|
||||
use style::values::generics::position::PreferredRatio;
|
||||
use style::values::generics::ratio::Ratio;
|
||||
use style::values::{AtomIdent, AtomString, CSSFloat, computed, specified};
|
||||
use style::{ArcSlice, CaseSensitivityExt, dom_apis, thread_state};
|
||||
use style_traits::ParsingMode as CssParsingMode;
|
||||
use stylo_atoms::Atom;
|
||||
use stylo_dom::ElementState;
|
||||
use xml5ever::serialize::TraversalScope::{
|
||||
|
@ -781,6 +784,33 @@ impl Element {
|
|||
.registered_intersection_observers
|
||||
.retain(|reg_obs| *reg_obs.observer != *observer)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#matches-the-environment>
|
||||
pub(crate) fn matches_environment(&self, media_query: &str) -> bool {
|
||||
let document = self.owner_document();
|
||||
let quirks_mode = document.quirks_mode();
|
||||
let document_url_data = UrlExtraData(document.url().get_arc());
|
||||
// FIXME(emilio): This should do the same that we do for other media
|
||||
// lists regarding the rule type and such, though it doesn't really
|
||||
// matter right now...
|
||||
//
|
||||
// Also, ParsingMode::all() is wrong, and should be DEFAULT.
|
||||
let context = CssParserContext::new(
|
||||
CssOrigin::Author,
|
||||
&document_url_data,
|
||||
Some(CssRuleType::Style),
|
||||
CssParsingMode::all(),
|
||||
quirks_mode,
|
||||
/* namespaces = */ Default::default(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
let mut parser_input = CssParserInput::new(media_query);
|
||||
let mut parser = CssParser::new(&mut parser_input);
|
||||
let media_list = MediaList::parse(&context, &mut parser);
|
||||
let result = media_list.evaluate(document.window().layout().device(), quirks_mode);
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#valid-shadow-host-name>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue