Miscellaneous build / tidy fixes.

This commit is contained in:
Emilio Cobos Álvarez 2021-02-26 12:40:48 +01:00
parent 5158f65810
commit 31e8e418ea
66 changed files with 566 additions and 294 deletions

7
Cargo.lock generated
View file

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "accountable-refcell"
version = "0.2.0"
@ -1171,9 +1173,9 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.27.2"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a"
checksum = "1db8599a9761b371751fbf13e076fa03c6e1a78f8c5288e6ab9467f10a2322c1"
dependencies = [
"cssparser-macros",
"dtoa-short",
@ -5214,7 +5216,6 @@ dependencies = [
"precomputed-hash",
"servo_arc",
"smallvec 1.6.1",
"thin-slice",
"to_shmem",
"to_shmem_derive",
]

View file

@ -20,7 +20,7 @@ bitflags = "1.0"
byteorder = "1"
canvas_traits = { path = "../canvas_traits" }
crossbeam-channel = "0.4"
cssparser = "0.27"
cssparser = "0.28"
euclid = "0.20"
font-kit = "0.10"
fnv = "1.0"

View file

@ -16,7 +16,7 @@ xr-profile = ["webxr-api/profile", "time"]
[dependencies]
crossbeam-channel = "0.4"
cssparser = "0.27"
cssparser = "0.28"
euclid = "0.20"
ipc-channel = "0.14"
lazy_static = "1"

View file

@ -222,7 +222,12 @@ where
}
}
fn map_type_params_in_path<F>(path: &Path, params: &[&TypeParam], self_type: &Path, f: &mut F) -> Path
fn map_type_params_in_path<F>(
path: &Path,
params: &[&TypeParam],
self_type: &Path,
f: &mut F,
) -> Path
where
F: FnMut(&Ident) -> Type,
{
@ -241,9 +246,9 @@ where
.iter()
.map(|arg| match arg {
ty @ &GenericArgument::Lifetime(_) => ty.clone(),
&GenericArgument::Type(ref data) => {
GenericArgument::Type(map_type_params(data, params, self_type, f))
},
&GenericArgument::Type(ref data) => GenericArgument::Type(
map_type_params(data, params, self_type, f),
),
&GenericArgument::Binding(ref data) => {
GenericArgument::Binding(Binding {
ty: map_type_params(&data.ty, params, self_type, f),

View file

@ -71,8 +71,8 @@ use style::logical_geometry::Direction;
use style::properties::ComputedValues;
use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::Image;
use style::values::generics::counters::ContentItem;
use style::values::generics::url::UrlOrNone as ImageUrlOrNone;
/// The results of flow construction for a DOM node.
#[derive(Clone)]
@ -1506,9 +1506,9 @@ where
) -> ConstructionResult {
let flotation = FloatKind::from_property(flotation);
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
ImageUrlOrNone::Url(ref url_value) => {
Image::Url(ref url_value) => {
let image_info = Box::new(ImageFragmentInfo::new(
url_value.url().map(|u| u.clone()),
url_value.url().cloned(),
None,
node,
&self.layout_context,
@ -1519,7 +1519,13 @@ where
self.layout_context,
)]
},
ImageUrlOrNone::None => match ListStyleTypeContent::from_list_style_type(
// XXX: Non-None image types unimplemented.
Image::ImageSet(..) |
Image::Rect(..) |
Image::Gradient(..) |
Image::PaintWorklet(..) |
Image::CrossFade(..) |
Image::None => match ListStyleTypeContent::from_list_style_type(
node.style(self.style_context()).get_list().list_style_type,
) {
ListStyleTypeContent::None => Vec::new(),

View file

@ -792,6 +792,9 @@ impl Fragment {
);
}
},
Image::CrossFade(..) | Image::ImageSet(..) => {
unreachable!("Shouldn't be parsed by Servo for now")
},
Image::Rect(ref rect) => {
// This is a (boxed) empty enum on non-Gecko
match **rect {}

View file

@ -47,6 +47,7 @@ use style::properties::{
};
use style::selector_parser::PseudoElement;
use style::shared_lock::SharedRwLock;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::{CSSPixel, ParsingMode, ToCss};
use webrender_api::ExternalScrollId;
@ -762,10 +763,12 @@ fn create_font_declaration(
&mut declarations,
property.clone(),
value,
Origin::Author,
url_data,
None,
ParsingMode::DEFAULT,
quirks_mode,
CssRuleType::Style,
);
let declarations = match result {
Ok(()) => {

View file

@ -16,7 +16,7 @@ doctest = false
app_units = "0.7"
atomic_refcell = "0.1.6"
canvas_traits = { path = "../canvas_traits" }
cssparser = "0.27"
cssparser = "0.28"
embedder_traits = { path = "../embedder_traits" }
euclid = "0.20"
fnv = "1.0"

View file

@ -474,6 +474,9 @@ impl<'a> BuilderForBoxFragment<'a> {
},
// Gecko-only value, represented as a (boxed) empty enum on non-Gecko.
Image::Rect(ref rect) => match **rect {},
Image::ImageSet(..) | Image::CrossFade(..) => {
unreachable!("Shouldn't be parsed on Servo for now")
},
}
}
}

View file

@ -7,7 +7,7 @@ use crate::dom_traversal::{NodeAndStyleInfo, NodeExt, PseudoElementContentItem};
use crate::replaced::ReplacedContent;
use style::properties::longhands::list_style_type::computed_value::T as ListStyleType;
use style::properties::style_structs;
use style::values::computed::url::UrlOrNone;
use style::values::computed::Image;
/// https://drafts.csswg.org/css-lists/#content-property
pub(crate) fn make_marker<'dom, Node>(
@ -21,13 +21,18 @@ where
// https://drafts.csswg.org/css-lists/#marker-image
let marker_image = || match &style.list_style_image {
UrlOrNone::Url(url) => Some(vec![
Image::Url(url) => Some(vec![
PseudoElementContentItem::Replaced(ReplacedContent::from_image_url(
info.node, context, url,
)?),
PseudoElementContentItem::Text(" ".into()),
]),
UrlOrNone::None => None,
// XXX: Non-None image types unimplemented.
Image::ImageSet(..) |
Image::Rect(..) |
Image::Gradient(..) |
Image::CrossFade(..) |
Image::None => None,
};
marker_image().or_else(|| {
Some(vec![PseudoElementContentItem::Text(

View file

@ -90,6 +90,7 @@ use style::shared_lock::{
};
use style::str::is_whitespace;
use style::stylist::CascadeData;
use style::values::{AtomIdent, AtomString};
use style::CaseSensitivityExt;
#[derive(Clone, Copy)]
@ -500,8 +501,8 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
#[inline]
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool {
self.get_attr(namespace, attr).is_some()
fn has_attr(&self, namespace: &style::Namespace, attr: &style::LocalName) -> bool {
self.get_attr(&**namespace, &**attr).is_some()
}
#[inline]
@ -512,11 +513,11 @@ impl<'le> TElement for ServoLayoutElement<'le> {
#[inline(always)]
fn each_class<F>(&self, mut callback: F)
where
F: FnMut(&Atom),
F: FnMut(&AtomIdent),
{
if let Some(ref classes) = self.element.get_classes_for_layout() {
for class in *classes {
callback(class)
callback(AtomIdent::cast(class))
}
}
}
@ -640,7 +641,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
fn lang_attr(&self) -> Option<SelectorAttrValue> {
self.get_attr(&ns!(xml), &local_name!("lang"))
.or_else(|| self.get_attr(&ns!(), &local_name!("lang")))
.map(|v| String::from(v as &str))
.map(|v| SelectorAttrValue::from(v as &str))
}
fn match_element_lang(
@ -663,8 +664,8 @@ impl<'le> TElement for ServoLayoutElement<'le> {
// so we can decide when to fall back to the Content-Language check.
let element_lang = match override_lang {
Some(Some(lang)) => lang,
Some(None) => String::new(),
None => self.element.get_lang_for_layout(),
Some(None) => AtomString::default(),
None => AtomString::from(&*self.element.get_lang_for_layout()),
};
extended_filtering(&element_lang, &*value)
}
@ -813,9 +814,9 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>,
ns: &NamespaceConstraint<&style::Namespace>,
local_name: &style::LocalName,
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
@ -945,7 +946,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
}
#[inline]
fn has_id(&self, id: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_id(&self, id: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
unsafe {
(*self.element.id_attribute())
.as_ref()
@ -954,16 +955,16 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
}
#[inline]
fn is_part(&self, _name: &Atom) -> bool {
fn is_part(&self, _name: &AtomIdent) -> bool {
false
}
fn imported_part(&self, _: &Atom) -> Option<Atom> {
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
None
}
#[inline]
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
self.element.has_class_for_layout(name, case_sensitivity)
}
@ -1434,9 +1435,9 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>,
ns: &NamespaceConstraint<&style::Namespace>,
local_name: &style::LocalName,
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
@ -1470,23 +1471,23 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
false
}
fn has_id(&self, _id: &Atom, _case_sensitivity: CaseSensitivity) -> bool {
fn has_id(&self, _id: &AtomIdent, _case_sensitivity: CaseSensitivity) -> bool {
debug!("ServoThreadSafeLayoutElement::has_id called");
false
}
#[inline]
fn is_part(&self, _name: &Atom) -> bool {
fn is_part(&self, _name: &AtomIdent) -> bool {
debug!("ServoThreadSafeLayoutElement::is_part called");
false
}
fn imported_part(&self, _: &Atom) -> Option<Atom> {
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
debug!("ServoThreadSafeLayoutElement::imported_part called");
None
}
fn has_class(&self, _name: &Atom, _case_sensitivity: CaseSensitivity) -> bool {
fn has_class(&self, _name: &AtomIdent, _case_sensitivity: CaseSensitivity) -> bool {
debug!("ServoThreadSafeLayoutElement::has_class called");
false
}

View file

@ -506,6 +506,7 @@ impl LayoutThread {
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
window_size.initial_viewport,
window_size.device_pixel_ratio,
);
@ -1267,7 +1268,12 @@ impl LayoutThread {
};
let had_used_viewport_units = self.stylist.device().used_viewport_units();
let device = Device::new(MediaType::screen(), initial_viewport, device_pixel_ratio);
let device = Device::new(
MediaType::screen(),
self.stylist.quirks_mode(),
initial_viewport,
device_pixel_ratio,
);
let sheet_origins_affected_by_device_change = self.stylist.set_device(device, &guards);
self.stylist

View file

@ -90,6 +90,7 @@ use style::shared_lock::{
};
use style::str::is_whitespace;
use style::stylist::CascadeData;
use style::values::{AtomIdent, AtomString};
use style::CaseSensitivityExt;
#[derive(Clone, Copy)]
@ -508,7 +509,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
#[inline]
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool {
fn has_attr(&self, namespace: &style::Namespace, attr: &style::LocalName) -> bool {
self.get_attr(namespace, attr).is_some()
}
@ -520,11 +521,11 @@ impl<'le> TElement for ServoLayoutElement<'le> {
#[inline(always)]
fn each_class<F>(&self, mut callback: F)
where
F: FnMut(&Atom),
F: FnMut(&AtomIdent),
{
if let Some(ref classes) = self.element.get_classes_for_layout() {
for class in *classes {
callback(class)
callback(AtomIdent::cast(class))
}
}
}
@ -648,7 +649,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
fn lang_attr(&self) -> Option<SelectorAttrValue> {
self.get_attr(&ns!(xml), &local_name!("lang"))
.or_else(|| self.get_attr(&ns!(), &local_name!("lang")))
.map(|v| String::from(v as &str))
.map(|v| SelectorAttrValue::from(v as &str))
}
fn match_element_lang(
@ -671,8 +672,8 @@ impl<'le> TElement for ServoLayoutElement<'le> {
// so we can decide when to fall back to the Content-Language check.
let element_lang = match override_lang {
Some(Some(lang)) => lang,
Some(None) => String::new(),
None => self.element.get_lang_for_layout(),
Some(None) => AtomString::default(),
None => AtomString::from(&*self.element.get_lang_for_layout()),
};
extended_filtering(&element_lang, &*value)
}
@ -821,9 +822,9 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>,
ns: &NamespaceConstraint<&style::Namespace>,
local_name: &style::LocalName,
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
@ -953,7 +954,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
}
#[inline]
fn has_id(&self, id: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_id(&self, id: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
unsafe {
(*self.element.id_attribute())
.as_ref()
@ -962,16 +963,16 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
}
#[inline]
fn is_part(&self, _name: &Atom) -> bool {
fn is_part(&self, _name: &AtomIdent) -> bool {
false
}
fn imported_part(&self, _: &Atom) -> Option<Atom> {
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
None
}
#[inline]
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
self.element.has_class_for_layout(name, case_sensitivity)
}
@ -1445,9 +1446,9 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>,
ns: &NamespaceConstraint<&style::Namespace>,
local_name: &style::LocalName,
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
@ -1479,23 +1480,23 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
false
}
fn has_id(&self, _id: &Atom, _case_sensitivity: CaseSensitivity) -> bool {
fn has_id(&self, _id: &AtomIdent, _case_sensitivity: CaseSensitivity) -> bool {
debug!("ServoThreadSafeLayoutElement::has_id called");
false
}
#[inline]
fn is_part(&self, _name: &Atom) -> bool {
fn is_part(&self, _name: &AtomIdent) -> bool {
debug!("ServoThreadSafeLayoutElement::is_part called");
false
}
fn imported_part(&self, _: &Atom) -> Option<Atom> {
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
debug!("ServoThreadSafeLayoutElement::imported_part called");
None
}
fn has_class(&self, _name: &Atom, _case_sensitivity: CaseSensitivity) -> bool {
fn has_class(&self, _name: &AtomIdent, _case_sensitivity: CaseSensitivity) -> bool {
debug!("ServoThreadSafeLayoutElement::has_class called");
false
}

View file

@ -474,6 +474,7 @@ impl LayoutThread {
// but it will be set correctly when the initial reflow takes place.
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
window_size.initial_viewport,
window_size.device_pixel_ratio,
);
@ -952,7 +953,12 @@ impl LayoutThread {
ua_or_user: &ua_or_user_guard,
};
let device = Device::new(MediaType::screen(), initial_viewport, device_pixel_ratio);
let device = Device::new(
MediaType::screen(),
self.stylist.quirks_mode(),
initial_viewport,
device_pixel_ratio,
);
let sheet_origins_affected_by_device_change = self.stylist.set_device(device, &guards);
self.stylist

View file

@ -31,8 +31,8 @@ accountable-refcell = { version = "0.2.0", optional = true }
app_units = "0.7"
content-security-policy = { version = "0.4.0", features = ["serde"], optional = true }
crossbeam-channel = { version = "0.4", optional = true }
cssparser = "0.27"
euclid = "0.22"
cssparser = "0.28"
euclid = "0.20"
hashglobe = { path = "../hashglobe" }
hyper = { version = "0.12", optional = true }
hyper_serde = { version = "0.11", optional = true }

View file

@ -42,7 +42,7 @@ chrono = "0.4"
content-security-policy = { version = "0.4.0", features = ["serde"] }
cookie = "0.11"
crossbeam-channel = "0.4"
cssparser = "0.27"
cssparser = "0.28"
data-url = "0.1.0"
deny_public_fields = { path = "../deny_public_fields" }
devtools_traits = { path = "../devtools_traits" }

View file

@ -21,6 +21,7 @@ use servo_atoms::Atom;
use std::borrow::ToOwned;
use std::mem;
use style::attr::{AttrIdentifier, AttrValue};
use style::values::GenericAtomIdent;
// https://dom.spec.whatwg.org/#interface-attr
#[dom_struct]
@ -46,10 +47,10 @@ impl Attr {
Attr {
node_: Node::new_inherited(document),
identifier: AttrIdentifier {
local_name: local_name,
name: name,
namespace: namespace,
prefix: prefix,
local_name: GenericAtomIdent(local_name),
name: GenericAtomIdent(name),
namespace: GenericAtomIdent(namespace),
prefix: prefix.map(GenericAtomIdent),
},
value: DomRefCell::new(value),
owner: MutNullableDom::new(owner),
@ -75,17 +76,17 @@ impl Attr {
#[inline]
pub fn name(&self) -> &LocalName {
&self.identifier.name
&self.identifier.name.0
}
#[inline]
pub fn namespace(&self) -> &Namespace {
&self.identifier.namespace
&self.identifier.namespace.0
}
#[inline]
pub fn prefix(&self) -> Option<&Prefix> {
self.identifier.prefix.as_ref()
Some(&self.identifier.prefix.as_ref()?.0)
}
}
@ -105,7 +106,7 @@ impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-value
fn SetValue(&self, value: DOMString) {
if let Some(owner) = self.owner() {
let value = owner.parse_attribute(&self.identifier.namespace, self.local_name(), value);
let value = owner.parse_attribute(self.namespace(), self.local_name(), value);
self.set_value(value, &owner);
} else {
*self.value.borrow_mut() = AttrValue::String(value.into());
@ -115,12 +116,12 @@ impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-name
fn Name(&self) -> DOMString {
// FIXME(ajeffrey): convert directly from LocalName to DOMString
DOMString::from(&*self.identifier.name)
DOMString::from(&**self.name())
}
// https://dom.spec.whatwg.org/#dom-attr-namespaceuri
fn GetNamespaceURI(&self) -> Option<DOMString> {
match self.identifier.namespace {
match *self.namespace() {
ns!() => None,
ref url => Some(DOMString::from(&**url)),
}
@ -170,7 +171,7 @@ impl Attr {
assert_eq!(Some(owner), self.owner().as_deref());
owner.will_mutate_attr(self);
self.swap_value(&mut value);
if self.identifier.namespace == ns!() {
if *self.namespace() == ns!() {
vtable_for(owner.upcast())
.attribute_mutated(self, AttributeMutation::Set(Some(&value)));
}
@ -196,7 +197,7 @@ impl Attr {
/// Sets the owner element. Should be called after the attribute is added
/// or removed from its older parent.
pub fn set_owner(&self, owner: Option<&Element>) {
let ns = &self.identifier.namespace;
let ns = self.namespace();
match (self.owner(), owner) {
(Some(old), None) => {
// Already gone from the list of attributes of old owner.
@ -218,7 +219,7 @@ impl Attr {
pub fn summarize(&self) -> AttrInfo {
AttrInfo {
namespace: (*self.identifier.namespace).to_owned(),
namespace: (**self.namespace()).to_owned(),
name: String::from(self.Name()),
value: String::from(self.Value()),
}
@ -263,11 +264,11 @@ impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
#[inline]
fn local_name(self) -> &'dom LocalName {
unsafe { &self.unsafe_get().identifier.local_name }
unsafe { &self.unsafe_get().identifier.local_name.0 }
}
#[inline]
fn namespace(self) -> &'dom Namespace {
unsafe { &self.unsafe_get().identifier.namespace }
unsafe { &self.unsafe_get().identifier.namespace.0 }
}
}

View file

@ -14,7 +14,7 @@ use dom_struct::dom_struct;
use style::context::QuirksMode;
use style::parser::ParserContext;
use style::stylesheets::supports_rule::{parse_condition_or_declaration, Declaration};
use style::stylesheets::CssRuleType;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::ParsingMode;
#[dom_struct]
@ -39,7 +39,8 @@ impl CSS {
decl.push_str(&value);
let decl = Declaration(decl);
let url = win.Document().url();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
@ -60,7 +61,8 @@ impl CSS {
};
let url = win.Document().url();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,

View file

@ -18,7 +18,7 @@ use servo_arc::Arc;
use style::media_queries::MediaList as StyleMediaList;
use style::parser::ParserContext;
use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylesheets::{CssRuleType, MediaRule};
use style::stylesheets::{CssRuleType, MediaRule, Origin};
use style_traits::{ParsingMode, ToCss};
#[dom_struct]
@ -82,7 +82,8 @@ impl CSSMediaRule {
let window = global.as_window();
let url = window.get_url();
let quirks_mode = window.Document().quirks_mode();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,

View file

@ -63,7 +63,7 @@ impl CSSNamespaceRuleMethods for CSSNamespaceRule {
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri
fn NamespaceURI(&self) -> DOMString {
let guard = self.cssrule.shared_lock().read();
(*self.namespacerule.read_with(&guard).url).into()
(**self.namespacerule.read_with(&guard).url).into()
}
}

View file

@ -25,6 +25,7 @@ use style::properties::{
};
use style::selector_parser::PseudoElement;
use style::shared_lock::Locked;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::ParsingMode;
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
@ -302,10 +303,12 @@ impl CSSStyleDeclaration {
&mut declarations,
id,
&value,
Origin::Author,
&self.owner.base_url(),
window.css_error_reporter(),
ParsingMode::DEFAULT,
quirks_mode,
CssRuleType::Style,
);
// Step 6
@ -461,6 +464,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
&self.owner.base_url(),
window.css_error_reporter(),
quirks_mode,
CssRuleType::Style,
);
});

View file

@ -16,7 +16,7 @@ use servo_arc::Arc;
use style::parser::ParserContext;
use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylesheets::supports_rule::SupportsCondition;
use style::stylesheets::{CssRuleType, SupportsRule};
use style::stylesheets::{CssRuleType, Origin, SupportsRule};
use style_traits::{ParsingMode, ToCss};
#[dom_struct]
@ -71,7 +71,8 @@ impl CSSSupportsRule {
let win = global.as_window();
let url = win.Document().url();
let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Supports),
ParsingMode::DEFAULT,

View file

@ -3454,7 +3454,12 @@ impl Document {
let window_size = self.window().window_size();
let viewport_size = window_size.initial_viewport;
let device_pixel_ratio = window_size.device_pixel_ratio;
Device::new(MediaType::screen(), viewport_size, device_pixel_ratio)
Device::new(
MediaType::screen(),
self.quirks_mode(),
viewport_size,
device_pixel_ratio,
)
}
pub fn salvageable(&self) -> bool {
@ -3551,8 +3556,9 @@ impl Document {
} else {
snapshot.other_attributes_changed = true;
}
if !snapshot.changed_attrs.contains(attr.local_name()) {
snapshot.changed_attrs.push(attr.local_name().clone());
let local_name = style::LocalName::cast(attr.local_name());
if !snapshot.changed_attrs.contains(local_name) {
snapshot.changed_attrs.push(local_name.clone());
}
if snapshot.attrs.is_none() {
let attrs = el

View file

@ -129,9 +129,10 @@ use style::selector_parser::{
NonTSPseudoClass, PseudoElement, RestyleDamage, SelectorImpl, SelectorParser,
};
use style::shared_lock::{Locked, SharedRwLock};
use style::stylesheets::CssRuleType;
use style::thread_state;
use style::values::generics::NonNegative;
use style::values::{computed, specified, CSSFloat};
use style::values::{computed, specified, AtomIdent, AtomString, CSSFloat};
use style::CaseSensitivityExt;
use xml5ever::serialize as xmlSerialize;
use xml5ever::serialize::SerializeOpts as XmlSerializeOpts;
@ -568,7 +569,7 @@ pub fn get_attr_for_layout<'dom>(
pub trait LayoutElementHelpers<'dom> {
fn attrs(self) -> &'dom [LayoutDom<'dom, Attr>];
fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
fn has_class_for_layout(self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool;
fn get_classes_for_layout(self) -> Option<&'dom [Atom]>;
fn synthesize_presentational_hints_for_legacy_attributes<V>(self, hints: &mut V)
@ -616,7 +617,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
}
#[inline]
fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_class_for_layout(self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
get_attr_for_layout(self, &ns!(), &local_name!("class")).map_or(false, |attr| {
attr.as_tokens()
.unwrap()
@ -2851,6 +2852,7 @@ impl VirtualMethods for Element {
&doc.base_url(),
win.css_error_reporter(),
doc.quirks_mode(),
CssRuleType::Style,
)))
};
@ -3135,16 +3137,16 @@ impl<'a> SelectorsElement for DomRoot<Element> {
fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>,
ns: &NamespaceConstraint<&style::Namespace>,
local_name: &style::LocalName,
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
.get_attribute(ns, local_name)
.map_or(false, |attr| attr.value().eval_selector(operation)),
NamespaceConstraint::Any => self.attrs.borrow().iter().any(|attr| {
attr.local_name() == local_name && attr.value().eval_selector(operation)
*attr.local_name() == **local_name && attr.value().eval_selector(operation)
}),
}
}
@ -3240,23 +3242,23 @@ impl<'a> SelectorsElement for DomRoot<Element> {
}
}
fn has_id(&self, id: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_id(&self, id: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
self.id_attribute
.borrow()
.as_ref()
.map_or(false, |atom| case_sensitivity.eq_atom(id, atom))
.map_or(false, |atom| case_sensitivity.eq_atom(&*id, atom))
}
fn is_part(&self, _name: &Atom) -> bool {
fn is_part(&self, _name: &AtomIdent) -> bool {
false
}
fn imported_part(&self, _: &Atom) -> Option<Atom> {
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
None
}
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
Element::has_class(&**self, name, case_sensitivity)
fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
Element::has_class(&**self, &name, case_sensitivity)
}
fn is_html_element_in_html_document(&self) -> bool {

View file

@ -39,7 +39,7 @@ use style::attr::AttrValue;
use style::media_queries::MediaList;
use style::parser::ParserContext as CssParserContext;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{CssRuleType, Stylesheet};
use style::stylesheets::{CssRuleType, Origin, Stylesheet};
use style_traits::ParsingMode;
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
@ -310,7 +310,8 @@ impl HTMLLinkElement {
// FIXME(emilio): This looks somewhat fishy, since we use the context
// only to parse the media query list, CssRuleType::Media doesn't make
// much sense.
let context = CssParserContext::new_for_cssom(
let context = CssParserContext::new(
Origin::Author,
&doc_url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,

View file

@ -96,7 +96,8 @@ impl HTMLStyleElement {
.expect("Element.textContent must be a string");
let url = window.get_url();
let css_error_reporter = window.css_error_reporter();
let context = CssParserContext::new_for_cssom(
let context = CssParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,

View file

@ -16,7 +16,7 @@ use style::media_queries::MediaList as StyleMediaList;
use style::media_queries::MediaQuery;
use style::parser::ParserContext;
use style::shared_lock::{Locked, SharedRwLock};
use style::stylesheets::CssRuleType;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::{ParsingMode, ToCss};
#[dom_struct]
@ -81,7 +81,8 @@ impl MediaListMethods for MediaList {
let window = global.as_window();
let url = window.get_url();
let quirks_mode = window.Document().quirks_mode();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,
@ -122,7 +123,8 @@ impl MediaListMethods for MediaList {
let win = global.as_window();
let url = win.get_url();
let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,
@ -159,7 +161,8 @@ impl MediaListMethods for MediaList {
let win = global.as_window();
let url = win.get_url();
let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,

View file

@ -142,7 +142,7 @@ use style::properties::style_structs::Font;
use style::properties::{PropertyId, ShorthandId};
use style::selector_parser::PseudoElement;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::CssRuleType;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::{CSSPixel, DevicePixel, ParsingMode};
use url::Position;
use webrender_api::units::{DeviceIntPoint, DeviceIntSize, LayoutPixel};
@ -1307,7 +1307,8 @@ impl WindowMethods for Window {
let mut parser = Parser::new(&mut input);
let url = self.get_url();
let quirks_mode = self.Document().quirks_mode();
let context = CssParserContext::new_for_cssom(
let context = CssParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,

View file

@ -19,7 +19,7 @@ bench = []
[dependencies]
bitflags = "1.0"
cssparser = "0.27"
cssparser = "0.28"
derive_more = "0.99"
fxhash = "0.2"
log = "0.4"

View file

@ -908,12 +908,7 @@ where
let index = if let Some(i) = cache.as_mut().and_then(|c| c.lookup(element.opaque())) {
i
} else {
let i = nth_child_index(
element,
is_of_type,
is_from_end,
cache.as_deref_mut(),
);
let i = nth_child_index(element, is_of_type, is_from_end, cache.as_deref_mut());
if let Some(c) = cache.as_mut() {
c.insert(element.opaque(), i)
}

View file

@ -353,7 +353,12 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
where
P: Parser<'i, Impl = Impl>,
{
Self::parse_with_state(parser, input, SelectorParsingState::empty(), ParseErrorRecovery::DiscardList)
Self::parse_with_state(
parser,
input,
SelectorParsingState::empty(),
ParseErrorRecovery::DiscardList,
)
}
#[inline]
@ -387,7 +392,7 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
Ok(&Token::Comma) => break,
Ok(_) => {
debug_assert!(!was_ok, "Shouldn't have got a selector if getting here");
}
},
}
}
}
@ -490,7 +495,9 @@ where
// :where and :is OR their selectors, so we can't put any hash
// in the filter if there's more than one selector, as that'd
// exclude elements that may match one of the other selectors.
if list.len() == 1 && !collect_ancestor_hashes(list[0].iter(), quirks_mode, hashes, len) {
if list.len() == 1 &&
!collect_ancestor_hashes(list[0].iter(), quirks_mode, hashes, len)
{
return false;
}
continue;
@ -1106,13 +1113,11 @@ impl<Impl: SelectorImpl> Component<Impl> {
Component::NonTSPseudoClass(..) => true,
Component::Negation(ref selectors) |
Component::Is(ref selectors) |
Component::Where(ref selectors) => {
selectors.iter().all(|selector| {
Component::Where(ref selectors) => selectors.iter().all(|selector| {
selector
.iter_raw_match_order()
.all(|c| c.maybe_allowed_after_pseudo_element())
})
},
}),
_ => false,
}
}
@ -1130,13 +1135,11 @@ impl<Impl: SelectorImpl> Component<Impl> {
*self
);
match *self {
Component::Negation(ref selectors) => {
!selectors.iter().all(|selector| {
Component::Negation(ref selectors) => !selectors.iter().all(|selector| {
selector
.iter_raw_match_order()
.all(|c| c.matches_for_stateless_pseudo_element())
})
},
}),
Component::Is(ref selectors) | Component::Where(ref selectors) => {
selectors.iter().any(|selector| {
selector
@ -2114,8 +2117,10 @@ where
let list = SelectorList::parse_with_state(
parser,
input,
state | SelectorParsingState::SKIP_DEFAULT_NAMESPACE | SelectorParsingState::DISALLOW_PSEUDOS,
ParseErrorRecovery::DiscardList
state |
SelectorParsingState::SKIP_DEFAULT_NAMESPACE |
SelectorParsingState::DISALLOW_PSEUDOS,
ParseErrorRecovery::DiscardList,
)?;
Ok(Component::Negation(list.0.into_vec().into_boxed_slice()))
@ -2179,8 +2184,8 @@ where
//
// (Similar quotes for :where() / :not())
//
let ignore_default_ns =
state.intersects(SelectorParsingState::SKIP_DEFAULT_NAMESPACE) ||
let ignore_default_ns = state
.intersects(SelectorParsingState::SKIP_DEFAULT_NAMESPACE) ||
matches!(
result,
SimpleSelectorParseResult::SimpleSelector(Component::Host(..))
@ -2239,7 +2244,9 @@ where
let inner = SelectorList::parse_with_state(
parser,
input,
state | SelectorParsingState::SKIP_DEFAULT_NAMESPACE | SelectorParsingState::DISALLOW_PSEUDOS,
state |
SelectorParsingState::SKIP_DEFAULT_NAMESPACE |
SelectorParsingState::DISALLOW_PSEUDOS,
parser.is_and_where_error_recovery(),
)?;
Ok(component(inner.0.into_vec().into_boxed_slice()))
@ -3038,13 +3045,12 @@ pub mod tests {
vec![
Component::DefaultNamespace(MATHML.into()),
Component::Negation(
vec![
Selector::from_vec(
vec![Selector::from_vec(
vec![Component::Class(DummyAtom::from("cl"))],
specificity(0, 1, 0),
Default::default(),
)
].into_boxed_slice()
)]
.into_boxed_slice()
),
],
specificity(0, 1, 0),
@ -3057,16 +3063,14 @@ pub mod tests {
vec![
Component::DefaultNamespace(MATHML.into()),
Component::Negation(
vec![
Selector::from_vec(
vec![Selector::from_vec(
vec![
Component::DefaultNamespace(MATHML.into()),
Component::ExplicitUniversalType,
],
specificity(0, 0, 0),
Default::default(),
)
]
)]
.into_boxed_slice(),
),
],
@ -3080,8 +3084,7 @@ pub mod tests {
vec![
Component::DefaultNamespace(MATHML.into()),
Component::Negation(
vec![
Selector::from_vec(
vec![Selector::from_vec(
vec![
Component::DefaultNamespace(MATHML.into()),
Component::LocalName(LocalName {
@ -3091,8 +3094,7 @@ pub mod tests {
],
specificity(0, 0, 1),
Default::default(),
),
]
),]
.into_boxed_slice()
),
],
@ -3196,15 +3198,12 @@ pub mod tests {
parse_ns(":not(*)", &parser),
Ok(SelectorList::from_vec(vec![Selector::from_vec(
vec![Component::Negation(
vec![
Selector::from_vec(
vec![
Component::ExplicitUniversalType
],
vec![Selector::from_vec(
vec![Component::ExplicitUniversalType],
specificity(0, 0, 0),
Default::default(),
)
].into_boxed_slice()
)]
.into_boxed_slice()
)],
specificity(0, 0, 0),
Default::default(),
@ -3214,16 +3213,14 @@ pub mod tests {
parse_ns(":not(|*)", &parser),
Ok(SelectorList::from_vec(vec![Selector::from_vec(
vec![Component::Negation(
vec![
Selector::from_vec(
vec![Selector::from_vec(
vec![
Component::ExplicitNoNamespace,
Component::ExplicitUniversalType,
],
specificity(0, 0, 0),
Default::default(),
)
]
)]
.into_boxed_slice(),
)],
specificity(0, 0, 0),
@ -3236,15 +3233,12 @@ pub mod tests {
parse_ns_expected(":not(*|*)", &parser, Some(":not(*)")),
Ok(SelectorList::from_vec(vec![Selector::from_vec(
vec![Component::Negation(
vec![
Selector::from_vec(
vec![
Component::ExplicitUniversalType
],
vec![Selector::from_vec(
vec![Component::ExplicitUniversalType],
specificity(0, 0, 0),
Default::default()
)
].into_boxed_slice()
)]
.into_boxed_slice()
)],
specificity(0, 0, 0),
Default::default(),

View file

@ -12,6 +12,7 @@ use crate::str::str_join;
use crate::str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS};
use crate::str::{read_numbers, split_commas, split_html_space_chars};
use crate::values::specified::Length;
use crate::values::AtomString;
use crate::{Atom, LocalName, Namespace, Prefix};
use app_units::Au;
use cssparser::{self, Color, RGBA};
@ -354,7 +355,7 @@ impl AttrValue {
}
}
pub fn eval_selector(&self, selector: &AttrSelectorOperation<&String>) -> bool {
pub fn eval_selector(&self, selector: &AttrSelectorOperation<&AtomString>) -> bool {
// FIXME(SimonSapin) this can be more efficient by matching on `(self, selector)` variants
// and doing Atom comparisons instead of string comparisons where possible,
// with SelectorImpl::AttrValue changed to Atom.

View file

@ -16,7 +16,6 @@ use selectors::matching::{self, MatchingContext, MatchingMode};
use selectors::parser::{Combinator, Component, LocalName, SelectorImpl};
use selectors::{Element, NthIndexCache, SelectorList};
use smallvec::SmallVec;
use std::borrow::Borrow;
/// <https://dom.spec.whatwg.org/#dom-element-matches>
pub fn element_matches<E>(
@ -354,11 +353,14 @@ where
ref name,
ref lower_name,
} = *local_name;
if element.is_html_element_in_html_document() {
element.local_name() == lower_name.borrow()
let chosen_name = if element.is_html_element_in_html_document() {
lower_name
} else {
element.local_name() == name.borrow()
}
name
};
element.local_name() == &**chosen_name
}
/// Fast paths for querySelector with a single simple selector.

View file

@ -128,7 +128,7 @@ bitflags! {
/// https://html.spec.whatwg.org/multipage/#centered-alignment
const IN_MODAL_DIALOG_STATE = 1 << 53;
/// https://html.spec.whatwg.org/multipage/interaction.html#inert-subtrees
/// https://html.spec.whatwg.org/multipage/#inert-subtrees
const IN_MOZINERT_STATE = 1 << 54;
/// State for the topmost dialog element in top layer
const IN_TOPMOST_MODAL_DIALOG_STATE = 1 << 55;

View file

@ -307,7 +307,7 @@ fn eval_prefers_reduced_motion(device: &Device, query_value: Option<PrefersReduc
/// Possible values for prefers-contrast media query.
/// https://drafts.csswg.org/mediaqueries-5/#prefers-contrast
#[derive(Clone, Copy, Debug, FromPrimitive, PartialEq, Parse, ToCss)]
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, PartialEq, ToCss)]
#[repr(u8)]
pub enum PrefersContrast {
/// More contrast is preferred. Corresponds to an accessibility theme
@ -331,7 +331,7 @@ fn eval_prefers_contrast(device: &Device, query_value: Option<PrefersContrast>)
/// Possible values for the forced-colors media query.
/// https://drafts.csswg.org/mediaqueries-5/#forced-colors
#[derive(Clone, Copy, Debug, FromPrimitive, PartialEq, Parse, ToCss)]
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, PartialEq, ToCss)]
#[repr(u8)]
pub enum ForcedColors {
/// Page colors are not being forced.

View file

@ -147,6 +147,13 @@ impl PartialEq for WeakAtom {
}
}
impl PartialEq<Atom> for WeakAtom {
#[inline]
fn eq(&self, other: &Atom) -> bool {
self == &**other
}
}
unsafe impl Send for Atom {}
unsafe impl Sync for Atom {}
unsafe impl Sync for WeakAtom {}

View file

@ -47,7 +47,7 @@ impl PrecomputedHash for Namespace {
}
/// A Gecko WeakNamespace is a wrapped WeakAtom.
#[derive(Hash, Deref)]
#[derive(Deref, Hash)]
pub struct WeakNamespace(WeakAtom);
impl Deref for Namespace {

View file

@ -66,7 +66,7 @@ impl Invalidation {
/// Whether we should invalidate just the element, or the whole subtree within
/// it.
#[derive(Copy, Clone, Debug, Eq, MallocSizeOf, Ord, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Ord, PartialEq, PartialOrd)]
enum InvalidationKind {
None = 0,
Element,

View file

@ -138,15 +138,19 @@ pub type LocalName = crate::values::AtomIdent;
#[cfg(feature = "gecko")]
pub use crate::gecko_string_cache::Namespace;
#[cfg(feature = "servo")]
pub use html5ever::LocalName;
#[cfg(feature = "servo")]
pub use html5ever::Namespace;
#[cfg(feature = "servo")]
pub use html5ever::Prefix;
#[cfg(feature = "servo")]
pub use servo_atoms::Atom;
#[cfg(feature = "servo")]
#[allow(missing_docs)]
pub type LocalName = crate::values::GenericAtomIdent<html5ever::LocalNameStaticSet>;
#[cfg(feature = "servo")]
#[allow(missing_docs)]
pub type Namespace = crate::values::GenericAtomIdent<html5ever::NamespaceStaticSet>;
#[cfg(feature = "servo")]
#[allow(missing_docs)]
pub type Prefix = crate::values::GenericAtomIdent<html5ever::PrefixStaticSet>;
pub use style_traits::arc_slice::ArcSlice;
pub use style_traits::owned_slice::OwnedSlice;
pub use style_traits::owned_str::OwnedStr;

View file

@ -134,6 +134,23 @@ macro_rules! profiler_label {
($label_type:ident) => {};
}
#[cfg(feature = "servo")]
macro_rules! local_name {
($s:tt) => {
$crate::values::GenericAtomIdent(html5ever::local_name!($s))
};
}
#[cfg(feature = "servo")]
macro_rules! ns {
() => {
$crate::values::GenericAtomIdent(html5ever::ns!())
};
($s:tt) => {
$crate::values::GenericAtomIdent(html5ever::ns!($s))
};
}
#[cfg(feature = "gecko")]
macro_rules! local_name {
($s:tt) => {

View file

@ -111,7 +111,7 @@ def main():
p.name: {"pref": getattr(p, pref_attr)}
for prop in properties_list
if prop.enabled_in_content()
for p in [prop] + prop.alias
for p in [prop] + prop.aliases
}
for kind, properties_list in [
("longhands", properties.longhands),

View file

@ -948,7 +948,8 @@
input.parse_entirely(|input| parse_value(context, input)).map(|longhands| {
% for sub_property in shorthand.sub_properties:
% if sub_property.may_be_disabled_in(shorthand, engine):
if NonCustomPropertyId::from(LonghandId::${sub_property.camel_case}).allowed_in_ignoring_rule_type(context) {
if NonCustomPropertyId::from(LonghandId::${sub_property.camel_case})
.allowed_in_ignoring_rule_type(context) {
% endif
declarations.push(PropertyDeclaration::${sub_property.camel_case}(
longhands.${sub_property.ident}
@ -984,7 +985,10 @@
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
let parse_one = |c: &ParserContext, input: &mut Parser<'i, 't>| -> Result<crate::properties::longhands::${to_rust_ident(first_property)}::SpecifiedValue, ParseError<'i>> {
let parse_one = |c: &ParserContext, input: &mut Parser<'i, 't>| -> Result<
crate::properties::longhands::${to_rust_ident(first_property)}::SpecifiedValue,
ParseError<'i>
> {
${parser_function}(c, input)
};
@ -1028,7 +1032,10 @@
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
let rect = Rect::parse_with(context, input, |c, i| -> Result<crate::properties::longhands::${to_rust_ident(sub_property_pattern % "top")}::SpecifiedValue, ParseError<'i>> {
let rect = Rect::parse_with(context, input, |c, i| -> Result<
crate::properties::longhands::${to_rust_ident(sub_property_pattern % "top")}::SpecifiedValue,
ParseError<'i>
> {
% if allow_quirks != "No":
${parser_function}_quirky(c, i, specified::AllowQuirks::${allow_quirks})
% else:

View file

@ -37,7 +37,7 @@ ${helpers.single_keyword(
gecko_enum_prefix="StyleInert",
animation_value_type="discrete",
enabled_in="ua",
spec="Nonstandard (https://html.spec.whatwg.org/multipage/interaction.html#inert-subtrees)",
spec="Nonstandard (https://html.spec.whatwg.org/multipage/#inert-subtrees)",
)}
${helpers.single_keyword(

View file

@ -60,6 +60,7 @@ ${helpers.predefined_type(
initial_specified_value="specified::Image::None",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image",
boxed=engine == "servo-2013",
servo_restyle_damage="rebuild_and_reflow",
)}

View file

@ -54,7 +54,8 @@ pub use self::cascade::*;
<%!
from collections import defaultdict
from data import Method, PropertyRestrictions, Keyword, to_rust_ident, to_camel_case, RULE_VALUES, SYSTEM_FONT_LONGHANDS
from data import Method, PropertyRestrictions, Keyword, to_rust_ident, \
to_camel_case, RULE_VALUES, SYSTEM_FONT_LONGHANDS
import os.path
%>
@ -1199,7 +1200,10 @@ impl LonghandId {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<PropertyDeclaration, ParseError<'i>> {
type ParsePropertyFn = for<'i, 't> fn(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<PropertyDeclaration, ParseError<'i>>;
type ParsePropertyFn = for<'i, 't> fn(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<PropertyDeclaration, ParseError<'i>>;
static PARSE_PROPERTY: [ParsePropertyFn; ${len(data.longhands)}] = [
% for property in data.longhands:
longhands::${property.ident}::parse_declared,

View file

@ -4,6 +4,7 @@
//! Servo's media-query device and expression representation.
use crate::context::QuirksMode;
use crate::custom_properties::CssEnvironment;
use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements};
use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription};
@ -33,6 +34,9 @@ pub struct Device {
viewport_size: Size2D<f32, CSSPixel>,
/// The current device pixel ratio, from CSS pixels to device pixels.
device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>,
/// The current quirks mode.
#[ignore_malloc_size_of = "Pure stack type"]
quirks_mode: QuirksMode,
/// The font size of the root element
/// This is set when computing the style of the root
@ -60,6 +64,7 @@ impl Device {
/// Trivially construct a new `Device`.
pub fn new(
media_type: MediaType,
quirks_mode: QuirksMode,
viewport_size: Size2D<f32, CSSPixel>,
device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>,
) -> Device {
@ -67,6 +72,7 @@ impl Device {
media_type,
viewport_size,
device_pixel_ratio,
quirks_mode,
// FIXME(bz): Seems dubious?
root_font_size: AtomicU32::new(FONT_MEDIUM_PX.to_bits()),
used_root_font_size: AtomicBool::new(false),
@ -101,6 +107,11 @@ impl Device {
.store(size.px().to_bits(), Ordering::Relaxed)
}
/// Get the quirks mode of the current device.
pub fn quirks_mode(&self) -> QuirksMode {
self.quirks_mode
}
/// Sets the body text color for the "inherit color from body" quirk.
///
/// <https://quirks.spec.whatwg.org/#the-tables-inherit-color-from-body-quirk>

View file

@ -15,6 +15,7 @@ use crate::properties::longhands::display::computed_value::T as Display;
use crate::properties::{ComputedValues, PropertyFlags};
use crate::selector_parser::AttrValue as SelectorAttrValue;
use crate::selector_parser::{PseudoElementCascadeType, SelectorParser};
use crate::values::{AtomIdent, AtomString};
use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix};
use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss};
use fxhash::FxHashMap;
@ -66,10 +67,6 @@ pub enum PseudoElement {
/// The count of all pseudo-elements.
pub const PSEUDO_COUNT: usize = PseudoElement::ServoInlineAbsolute as usize + 1;
impl ::selectors::parser::PseudoElement for PseudoElement {
type Impl = SelectorImpl;
}
impl ToCss for PseudoElement {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
@ -96,6 +93,10 @@ impl ToCss for PseudoElement {
}
}
impl ::selectors::parser::PseudoElement for PseudoElement {
type Impl = SelectorImpl;
}
/// The number of eager pseudo-elements. Keep this in sync with cascade_type.
pub const EAGER_PSEUDO_COUNT: usize = 3;
@ -344,7 +345,6 @@ impl ToCss for NonTSPseudoClass {
Fullscreen => ":fullscreen",
Hover => ":hover",
Indeterminate => ":indeterminate",
MozInert => ":-moz-inert",
Link => ":link",
PlaceholderShown => ":placeholder-shown",
ReadWrite => ":read-write",
@ -402,15 +402,13 @@ impl ::selectors::SelectorImpl for SelectorImpl {
type NonTSPseudoClass = NonTSPseudoClass;
type ExtraMatchingData = InvalidationMatchingData;
type AttrValue = String;
type Identifier = Atom;
type ClassName = Atom;
type PartName = Atom;
type AttrValue = AtomString;
type Identifier = AtomIdent;
type LocalName = LocalName;
type NamespacePrefix = Prefix;
type NamespaceUrl = Namespace;
type BorrowedLocalName = LocalName;
type BorrowedNamespaceUrl = Namespace;
type BorrowedLocalName = html5ever::LocalName;
type BorrowedNamespaceUrl = html5ever::Namespace;
}
impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
@ -434,7 +432,6 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
"fullscreen" => Fullscreen,
"hover" => Hover,
"indeterminate" => Indeterminate,
"-moz-inert" => MozInert,
"link" => Link,
"placeholder-shown" => PlaceholderShown,
"read-write" => ReadWrite,
@ -697,15 +694,15 @@ impl ElementSnapshot for ServoElementSnapshot {
.map(|v| v.as_atom())
}
fn is_part(&self, _name: &Atom) -> bool {
fn is_part(&self, _name: &AtomIdent) -> bool {
false
}
fn imported_part(&self, _: &Atom) -> Option<Atom> {
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
None
}
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
self.get_attr(&ns!(), &local_name!("class"))
.map_or(false, |v| {
v.as_tokens()
@ -716,11 +713,11 @@ impl ElementSnapshot for ServoElementSnapshot {
fn each_class<F>(&self, mut callback: F)
where
F: FnMut(&Atom),
F: FnMut(&AtomIdent),
{
if let Some(v) = self.get_attr(&ns!(), &local_name!("class")) {
for class in v.as_tokens() {
callback(class);
callback(AtomIdent::cast(class));
}
}
}
@ -728,7 +725,7 @@ impl ElementSnapshot for ServoElementSnapshot {
fn lang_attr(&self) -> Option<SelectorAttrValue> {
self.get_attr(&ns!(xml), &local_name!("lang"))
.or_else(|| self.get_attr(&ns!(), &local_name!("lang")))
.map(|v| String::from(v as &str))
.map(|v| SelectorAttrValue::from(v as &str))
}
}
@ -738,7 +735,7 @@ impl ServoElementSnapshot {
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>,
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self

View file

@ -107,11 +107,17 @@ impl CssUrl {
///
/// This is only for shape images and masks in Gecko, thus unimplemented for
/// now so somebody notices when trying to do so.
pub fn parse_with_cors_anonymous<'i, 't>(
_context: &ParserContext,
_input: &mut Parser<'i, 't>,
pub fn parse_with_cors_mode<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
cors_mode: CorsMode,
) -> Result<Self, ParseError<'i>> {
unimplemented!("Need to record somewhere that the request needs to be CORS-enabled")
let url = input.expect_url()?;
Ok(Self::parse_from_string(
url.as_ref().to_owned(),
context,
cors_mode,
))
}
}
@ -120,12 +126,7 @@ impl Parse for CssUrl {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let url = input.expect_url()?;
Ok(Self::parse_from_string(
url.as_ref().to_owned(),
context,
CorsMode::None,
))
Self::parse_with_cors_mode(context, input, CorsMode::None)
}
}

View file

@ -179,3 +179,11 @@ pub type CssStringWriter = ::nsstring::nsACString;
/// needs to allocate a temporary string.
#[cfg(feature = "gecko")]
pub type CssString = ::nsstring::nsCString;
/// String. The comments for the Gecko types explain the need for this abstraction.
#[cfg(feature = "servo")]
pub type CssStringWriter = String;
/// String. The comments for the Gecko types explain the need for this abstraction.
#[cfg(feature = "servo")]
pub type CssString = String;

View file

@ -9,7 +9,6 @@ use crate::computed_value_flags::ComputedValueFlags;
use crate::dom::TElement;
use crate::properties::longhands::display::computed_value::T as Display;
use crate::properties::longhands::float::computed_value::T as Float;
use crate::properties::longhands::overflow_x::computed_value::T as Overflow;
use crate::properties::longhands::position::computed_value::T as Position;
use crate::properties::{self, ComputedValues, StyleBuilder};
@ -153,7 +152,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
}
/// https://html.spec.whatwg.org/multipage/interaction.html#inert-subtrees
/// https://html.spec.whatwg.org/multipage/#inert-subtrees
///
/// If -moz-inert is applied then add:
/// -moz-user-focus: none;
@ -168,6 +167,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
///
/// NOTE: If this or the pointer-events tweak is removed, then
/// minimal-xul.css and the scrollbar style caching need to be tweaked.
#[cfg(feature = "gecko")]
fn adjust_for_inert(&mut self) {
use crate::values::specified::ui::CursorKind;
use crate::values::specified::ui::UserSelect;
@ -529,6 +529,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// parent, but we need to make sure it's still scrollable.
#[cfg(feature = "gecko")]
fn adjust_for_text_control_editing_root(&mut self) {
use crate::properties::longhands::overflow_x::computed_value::T as Overflow;
use crate::selector_parser::PseudoElement;
if self.style.pseudo != Some(&PseudoElement::MozTextControlEditingRoot) {

View file

@ -510,10 +510,11 @@ trivial_to_computed_value!(u16);
trivial_to_computed_value!(u32);
trivial_to_computed_value!(usize);
trivial_to_computed_value!(Atom);
trivial_to_computed_value!(crate::values::AtomIdent);
#[cfg(feature = "servo")]
trivial_to_computed_value!(html5ever::Namespace);
trivial_to_computed_value!(crate::Namespace);
#[cfg(feature = "servo")]
trivial_to_computed_value!(html5ever::Prefix);
trivial_to_computed_value!(crate::Prefix);
trivial_to_computed_value!(String);
trivial_to_computed_value!(Box<str>);
trivial_to_computed_value!(crate::OwnedStr);

View file

@ -117,7 +117,7 @@ pub use self::GenericCrossFadeElement as CrossFadeElement;
pub use self::GenericCrossFadeImage as CrossFadeImage;
/// https://drafts.csswg.org/css-images-4/#image-set-notation
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem, ToCss)]
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, ToShmem)]
#[css(comma, function = "image-set")]
#[repr(C)]
pub struct GenericImageSet<Image, Resolution> {

View file

@ -68,7 +68,7 @@ pub fn serialize_atom_identifier<Static, W>(
dest: &mut W,
) -> fmt::Result
where
Static: ::string_cache::StaticAtomSet,
Static: string_cache::StaticAtomSet,
W: Write,
{
serialize_identifier(&ident, dest)
@ -90,7 +90,7 @@ pub fn serialize_atom_name<Static, W>(
dest: &mut W,
) -> fmt::Result
where
Static: ::string_cache::StaticAtomSet,
Static: string_cache::StaticAtomSet,
W: Write,
{
serialize_name(&ident, dest)
@ -114,14 +114,28 @@ where
)]
pub struct AtomString(pub Atom);
#[cfg(feature = "servo")]
impl AsRef<str> for AtomString {
fn as_ref(&self) -> &str {
&*self.0
}
}
impl cssparser::ToCss for AtomString {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
W: Write,
{
#[cfg(feature = "servo")]
{
cssparser::CssStringWriter::new(dest).write_str(self.as_ref())
}
#[cfg(feature = "gecko")]
{
self.0
.with_str(|s| cssparser::CssStringWriter::new(dest).write_str(s))
}
}
}
impl PrecomputedHash for AtomString {
@ -138,24 +152,138 @@ impl<'a> From<&'a str> for AtomString {
}
}
/// A generic CSS `<ident>` stored as an `Atom`.
#[cfg(feature = "servo")]
#[repr(transparent)]
#[derive(Deref)]
pub struct GenericAtomIdent<Set>(pub string_cache::Atom<Set>)
where
Set: string_cache::StaticAtomSet;
/// A generic CSS `<ident>` stored as an `Atom`, for the default atom set.
#[cfg(feature = "servo")]
pub type AtomIdent = GenericAtomIdent<servo_atoms::AtomStaticSet>;
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> style_traits::SpecifiedValueInfo for GenericAtomIdent<Set> {}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> Default for GenericAtomIdent<Set> {
fn default() -> Self {
Self(string_cache::Atom::default())
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> std::fmt::Debug for GenericAtomIdent<Set> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.0.fmt(f)
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> std::hash::Hash for GenericAtomIdent<Set> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state)
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> Eq for GenericAtomIdent<Set> {}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> PartialEq for GenericAtomIdent<Set> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> Clone for GenericAtomIdent<Set> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> to_shmem::ToShmem for GenericAtomIdent<Set> {
fn to_shmem(&self, builder: &mut to_shmem::SharedMemoryBuilder) -> to_shmem::Result<Self> {
use std::mem::ManuallyDrop;
let atom = self.0.to_shmem(builder)?;
Ok(ManuallyDrop::new(Self(ManuallyDrop::into_inner(atom))))
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> malloc_size_of::MallocSizeOf for GenericAtomIdent<Set> {
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
self.0.size_of(ops)
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> cssparser::ToCss for GenericAtomIdent<Set> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
W: Write,
{
serialize_atom_identifier(&self.0, dest)
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> PrecomputedHash for GenericAtomIdent<Set> {
#[inline]
fn precomputed_hash(&self) -> u32 {
self.0.precomputed_hash()
}
}
#[cfg(feature = "servo")]
impl<'a, Set: string_cache::StaticAtomSet> From<&'a str> for GenericAtomIdent<Set> {
#[inline]
fn from(string: &str) -> Self {
Self(string_cache::Atom::from(string))
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> std::borrow::Borrow<string_cache::Atom<Set>>
for GenericAtomIdent<Set>
{
#[inline]
fn borrow(&self) -> &string_cache::Atom<Set> {
&self.0
}
}
#[cfg(feature = "servo")]
impl<Set: string_cache::StaticAtomSet> GenericAtomIdent<Set> {
/// Constructs a new GenericAtomIdent.
#[inline]
pub fn new(atom: string_cache::Atom<Set>) -> Self {
Self(atom)
}
/// Cast an atom ref to an AtomIdent ref.
#[inline]
pub fn cast<'a>(atom: &'a string_cache::Atom<Set>) -> &'a Self {
let ptr = atom as *const _ as *const Self;
// safety: repr(transparent)
unsafe { &*ptr }
}
}
/// A CSS `<ident>` stored as an `Atom`.
#[cfg(feature = "gecko")]
#[repr(transparent)]
#[derive(
Clone,
Debug,
Default,
Deref,
Eq,
Hash,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
Clone, Debug, Default, Deref, Eq, Hash, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToShmem,
)]
pub struct AtomIdent(pub Atom);
#[cfg(feature = "gecko")]
impl cssparser::ToCss for AtomIdent {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
@ -165,6 +293,7 @@ impl cssparser::ToCss for AtomIdent {
}
}
#[cfg(feature = "gecko")]
impl PrecomputedHash for AtomIdent {
#[inline]
fn precomputed_hash(&self) -> u32 {
@ -172,6 +301,7 @@ impl PrecomputedHash for AtomIdent {
}
}
#[cfg(feature = "gecko")]
impl<'a> From<&'a str> for AtomIdent {
#[inline]
fn from(string: &str) -> Self {
@ -179,9 +309,15 @@ impl<'a> From<&'a str> for AtomIdent {
}
}
#[cfg(feature = "gecko")]
impl AtomIdent {
/// Constructs a new AtomIdent.
#[inline]
pub fn new(atom: Atom) -> Self {
Self(atom)
}
/// Like `Atom::with` but for `AtomIdent`.
#[cfg(feature = "gecko")]
pub unsafe fn with<F, R>(ptr: *const crate::gecko_bindings::structs::nsAtom, callback: F) -> R
where
F: FnOnce(&Self) -> R,

View file

@ -74,14 +74,15 @@ trivial_to_resolved_value!(Box<str>);
trivial_to_resolved_value!(crate::OwnedStr);
trivial_to_resolved_value!(cssparser::RGBA);
trivial_to_resolved_value!(crate::Atom);
trivial_to_resolved_value!(crate::values::AtomIdent);
trivial_to_resolved_value!(app_units::Au);
trivial_to_resolved_value!(computed::url::ComputedUrl);
#[cfg(feature = "gecko")]
trivial_to_resolved_value!(computed::url::ComputedImageUrl);
#[cfg(feature = "servo")]
trivial_to_resolved_value!(html5ever::Namespace);
trivial_to_resolved_value!(crate::Namespace);
#[cfg(feature = "servo")]
trivial_to_resolved_value!(html5ever::Prefix);
trivial_to_resolved_value!(crate::Prefix);
trivial_to_resolved_value!(computed::LengthPercentage);
trivial_to_resolved_value!(style_traits::values::specified::AllowedNumericType);

View file

@ -1144,15 +1144,6 @@ impl Parse for PaintWorklet {
}
impl MozImageRect {
#[cfg(not(feature = "gecko"))]
fn parse<'i, 't>(
_context: &ParserContext,
input: &mut Parser<'i, 't>,
_cors_mode: CorsMode,
) -> Result<Self, ParseError<'i>> {
Err(input.new_error_for_next_token())
}
#[cfg(feature = "gecko")]
fn parse<'i, 't>(
context: &ParserContext,

View file

@ -12,7 +12,7 @@ use cssparser::{Parser, Token};
use style_traits::{ParseError, StyleParseErrorKind};
/// A specified resolution.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToShmem, SpecifiedValueInfo)]
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
pub enum Resolution {
/// Dots per inch.
#[css(dimension)]

View file

@ -4,8 +4,6 @@
//! Specified types for CSS values related to tables.
use crate::parser::ParserContext;
/// Specified values for the `caption-side` property.
///
/// Note that despite having "physical" names, these are actually interpreted
@ -15,7 +13,7 @@ use crate::parser::ParserContext;
///
/// https://drafts.csswg.org/css-tables/#propdef-caption-side
#[cfg(feature = "gecko")]
fn caption_side_non_standard_enabled(_context: &ParserContext) -> bool {
fn caption_side_non_standard_enabled(_: &crate::parser::ParserContext) -> bool {
static_prefs::pref!("layout.css.caption-side-non-standard.enabled")
}

View file

@ -16,7 +16,7 @@ gecko = []
[dependencies]
app_units = "0.7"
bitflags = "1.0"
cssparser = "0.27"
cssparser = "0.28"
euclid = "0.20"
lazy_static = "1"
malloc_size_of = { path = "../malloc_size_of" }

View file

@ -118,6 +118,16 @@ where
}
}
impl ToCss for () {
#[inline]
fn to_css<W>(&self, _: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
Ok(())
}
}
/// A writer tailored for serialising CSS.
///
/// Coupled with SequenceWriter, this allows callers to transparently handle

View file

@ -14,7 +14,7 @@ servo = ["cssparser/serde", "string_cache"]
gecko = []
[dependencies]
cssparser = "0.27"
cssparser = "0.28"
servo_arc = { path = "../servo_arc" }
smallbitvec = "2.1.1"
smallvec = "1.0"

View file

@ -103,6 +103,10 @@ impl ServoUrl {
scheme == "about" || scheme == "blob" || scheme == "data"
}
pub fn chrome_rules_enabled(&self) -> bool {
self.is_chrome()
}
pub fn is_chrome(&self) -> bool {
self.scheme() == "chrome"
}

View file

@ -11,7 +11,7 @@ doctest = false
[dependencies]
app_units = "0.7"
cssparser = "0.27"
cssparser = "0.28"
euclid = "0.20"
html5ever = "0.25"
rayon = "1"

View file

@ -5,6 +5,7 @@
use cssparser::{Parser, ParserInput};
use euclid::{Scale, Size2D};
use servo_arc::Arc;
use style::context::QuirksMode;
use style::custom_properties::{
CustomPropertiesBuilder, CustomPropertiesMap, Name, SpecifiedValue,
};
@ -30,6 +31,7 @@ fn cascade(
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
Size2D::new(800., 600.),
Scale::new(1.0),
);

View file

@ -12,7 +12,8 @@ fn parse_selector<'i, 't>(
input: &mut Parser<'i, 't>,
) -> Result<SelectorList<SelectorImpl>, ParseError<'i>> {
let mut ns = Namespaces::default();
ns.prefixes.insert("svg".into(), ns!(svg));
ns.prefixes
.insert("svg".into(), style::Namespace::new(ns!(svg)));
let parser = SelectorParser {
stylesheet_origin: Origin::UserAgent,
namespaces: &ns,

View file

@ -214,6 +214,7 @@ fn test_insert() {
fn mock_stylist() -> Stylist {
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
Size2D::new(0f32, 0f32),
Scale::new(1.0),
);

View file

@ -113,6 +113,7 @@ macro_rules! viewport_length {
fn empty_viewport_rule() {
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
Size2D::new(800., 600.),
Scale::new(1.0),
);
@ -140,6 +141,7 @@ macro_rules! assert_decl_eq {
fn simple_viewport_rules() {
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
Size2D::new(800., 600.),
Scale::new(1.0),
);
@ -308,6 +310,7 @@ fn simple_meta_viewport_contents() {
fn cascading_within_viewport_rule() {
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
Size2D::new(800., 600.),
Scale::new(1.0),
);
@ -448,6 +451,7 @@ fn multiple_stylesheets_cascading() {
set_pref!(layout.viewport.enabled, true);
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
Size2D::new(800., 600.),
Scale::new(1.0),
);
@ -539,7 +543,12 @@ fn constrain_viewport() {
}
let initial_viewport = Size2D::new(800., 600.);
let device = Device::new(MediaType::screen(), initial_viewport, Scale::new(1.0));
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
initial_viewport,
Scale::new(1.0),
);
let mut input = ParserInput::new("");
assert_eq!(
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),
@ -597,7 +606,12 @@ fn constrain_viewport() {
);
let initial_viewport = Size2D::new(200., 150.);
let device = Device::new(MediaType::screen(), initial_viewport, Scale::new(1.0));
let device = Device::new(
MediaType::screen(),
QuirksMode::NoQuirks,
initial_viewport,
Scale::new(1.0),
);
let mut input = ParserInput::new("width: 320px auto");
assert_eq!(
ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks),