aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2021-02-26 12:40:48 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2021-02-26 17:53:55 +0100
commit31e8e418ea888b3366128ba42a9c771780f97e87 (patch)
treef47d0f809e944341d1ea6a724153c2e7386ca2ba
parent5158f658104c1edbb87a94958c4ab424d3b854b4 (diff)
downloadservo-31e8e418ea888b3366128ba42a9c771780f97e87.tar.gz
servo-31e8e418ea888b3366128ba42a9c771780f97e87.zip
Miscellaneous build / tidy fixes.
-rw-r--r--Cargo.lock7
-rw-r--r--components/canvas/Cargo.toml2
-rw-r--r--components/canvas_traits/Cargo.toml2
-rw-r--r--components/derive_common/cg.rs13
-rw-r--r--components/layout/construct.rs14
-rw-r--r--components/layout/display_list/builder.rs3
-rw-r--r--components/layout/query.rs3
-rw-r--r--components/layout_2020/Cargo.toml2
-rw-r--r--components/layout_2020/display_list/mod.rs3
-rw-r--r--components/layout_2020/lists.rs11
-rw-r--r--components/layout_thread/dom_wrapper.rs43
-rw-r--r--components/layout_thread/lib.rs8
-rw-r--r--components/layout_thread_2020/dom_wrapper.rs41
-rw-r--r--components/layout_thread_2020/lib.rs8
-rw-r--r--components/malloc_size_of/Cargo.toml4
-rw-r--r--components/script/Cargo.toml2
-rw-r--r--components/script/dom/attr.rs31
-rw-r--r--components/script/dom/css.rs8
-rw-r--r--components/script/dom/cssmediarule.rs5
-rw-r--r--components/script/dom/cssnamespacerule.rs2
-rw-r--r--components/script/dom/cssstyledeclaration.rs4
-rw-r--r--components/script/dom/csssupportsrule.rs5
-rw-r--r--components/script/dom/document.rs12
-rw-r--r--components/script/dom/element.rs28
-rw-r--r--components/script/dom/htmllinkelement.rs5
-rw-r--r--components/script/dom/htmlstyleelement.rs3
-rw-r--r--components/script/dom/medialist.rs11
-rw-r--r--components/script/dom/window.rs5
-rw-r--r--components/selectors/Cargo.toml2
-rw-r--r--components/selectors/matching.rs7
-rw-r--r--components/selectors/parser.rs154
-rw-r--r--components/style/attr.rs3
-rw-r--r--components/style/dom_apis.rs12
-rw-r--r--components/style/element_state.rs2
-rw-r--r--components/style/gecko/media_features.rs4
-rw-r--r--components/style/gecko_string_cache/mod.rs7
-rw-r--r--components/style/gecko_string_cache/namespace.rs2
-rw-r--r--components/style/invalidation/stylesheets.rs2
-rw-r--r--components/style/lib.rs12
-rw-r--r--components/style/macros.rs17
-rw-r--r--components/style/properties/build.py2
-rw-r--r--components/style/properties/helpers.mako.rs13
-rw-r--r--components/style/properties/longhands/inherited_ui.mako.rs2
-rw-r--r--components/style/properties/longhands/list.mako.rs1
-rw-r--r--components/style/properties/properties.mako.rs8
-rw-r--r--components/style/servo/media_queries.rs11
-rw-r--r--components/style/servo/selector_parser.rs35
-rw-r--r--components/style/servo/url.rs21
-rw-r--r--components/style/str.rs8
-rw-r--r--components/style/style_adjuster.rs5
-rw-r--r--components/style/values/computed/mod.rs5
-rw-r--r--components/style/values/generics/image.rs2
-rw-r--r--components/style/values/mod.rs170
-rw-r--r--components/style/values/resolved/mod.rs5
-rw-r--r--components/style/values/specified/image.rs9
-rw-r--r--components/style/values/specified/resolution.rs2
-rw-r--r--components/style/values/specified/table.rs4
-rw-r--r--components/style_traits/Cargo.toml2
-rw-r--r--components/style_traits/values.rs10
-rw-r--r--components/to_shmem/Cargo.toml2
-rw-r--r--components/url/lib.rs4
-rw-r--r--tests/unit/style/Cargo.toml2
-rw-r--r--tests/unit/style/custom_properties.rs2
-rw-r--r--tests/unit/style/parsing/selectors.rs3
-rw-r--r--tests/unit/style/stylist.rs1
-rw-r--r--tests/unit/style/viewport.rs18
66 files changed, 564 insertions, 292 deletions
diff --git a/Cargo.lock b/Cargo.lock
index baaf758cb72..029cf147954 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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",
]
diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml
index f5e9dbcd47a..74545af1b93 100644
--- a/components/canvas/Cargo.toml
+++ b/components/canvas/Cargo.toml
@@ -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"
diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml
index 8414349939c..d6d8290378e 100644
--- a/components/canvas_traits/Cargo.toml
+++ b/components/canvas_traits/Cargo.toml
@@ -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"
diff --git a/components/derive_common/cg.rs b/components/derive_common/cg.rs
index 8abfd871496..ab4b8e52760 100644
--- a/components/derive_common/cg.rs
+++ b/components/derive_common/cg.rs
@@ -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),
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 7078e063978..c17d52dd155 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -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(),
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index d268f8428d3..8f087e1c6c2 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -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 {}
diff --git a/components/layout/query.rs b/components/layout/query.rs
index 56b1fc7d0f8..a02a5c935c2 100644
--- a/components/layout/query.rs
+++ b/components/layout/query.rs
@@ -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(()) => {
diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml
index 75a948fa56d..24e3ead663b 100644
--- a/components/layout_2020/Cargo.toml
+++ b/components/layout_2020/Cargo.toml
@@ -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"
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index 4fc0c390d0d..3f77e4ae362 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -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")
+ },
}
}
}
diff --git a/components/layout_2020/lists.rs b/components/layout_2020/lists.rs
index c8fa7eabee3..99074747599 100644
--- a/components/layout_2020/lists.rs
+++ b/components/layout_2020/lists.rs
@@ -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(
diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs
index f0d25ff8c49..cfbc207431a 100644
--- a/components/layout_thread/dom_wrapper.rs
+++ b/components/layout_thread/dom_wrapper.rs
@@ -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
}
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 74deb9fb907..ba2a1f27f68 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -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
diff --git a/components/layout_thread_2020/dom_wrapper.rs b/components/layout_thread_2020/dom_wrapper.rs
index d3c355c2fe7..e37bbd38274 100644
--- a/components/layout_thread_2020/dom_wrapper.rs
+++ b/components/layout_thread_2020/dom_wrapper.rs
@@ -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
}
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs
index 41ceddc5d44..6b32a44a5b4 100644
--- a/components/layout_thread_2020/lib.rs
+++ b/components/layout_thread_2020/lib.rs
@@ -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
diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml
index 3f6d6e80ed9..f3b40bfa0d6 100644
--- a/components/malloc_size_of/Cargo.toml
+++ b/components/malloc_size_of/Cargo.toml
@@ -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 }
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index 68ac6638907..a09ccf8f257 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -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" }
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index e2e8b79f9af..9c4b221f6f3 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -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 }
}
}
diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs
index 138ffb6b9da..8c9600549c5 100644
--- a/components/script/dom/css.rs
+++ b/components/script/dom/css.rs
@@ -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,
diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs
index 2f54b0a0839..ca2bdd4d447 100644
--- a/components/script/dom/cssmediarule.rs
+++ b/components/script/dom/cssmediarule.rs
@@ -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,
diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs
index f3ff8df36d9..3a15c7d5ffd 100644
--- a/components/script/dom/cssnamespacerule.rs
+++ b/components/script/dom/cssnamespacerule.rs
@@ -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()
}
}
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 3c0d63ce92f..41101afd625 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -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,
);
});
diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs
index c462faf7eba..8a028e9efb2 100644
--- a/components/script/dom/csssupportsrule.rs
+++ b/components/script/dom/csssupportsrule.rs
@@ -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,
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index eccc14f67ed..8ae80be66a1 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -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
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index d3813b34001..e69fd558f5c 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -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 {
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index d240b913a9e..30a45471203 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -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,
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index 4e81837fc35..83d35fc78c8 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -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,
diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs
index de0f61d0c00..772c508fc04 100644
--- a/components/script/dom/medialist.rs
+++ b/components/script/dom/medialist.rs
@@ -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,
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 71ceb293664..7e36c8086fb 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -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,
diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml
index 0716da63752..f8e2b7ac538 100644
--- a/components/selectors/Cargo.toml
+++ b/components/selectors/Cargo.toml
@@ -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"
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs
index 244572b53bd..1d116063240 100644
--- a/components/selectors/matching.rs
+++ b/components/selectors/matching.rs
@@ -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)
}
diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs
index 70f66419250..a5fa010d50c 100644
--- a/components/selectors/parser.rs
+++ b/components/selectors/parser.rs
@@ -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| {
- selector
- .iter_raw_match_order()
- .all(|c| c.maybe_allowed_after_pseudo_element())
- })
- },
+ 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| {
- selector
- .iter_raw_match_order()
- .all(|c| c.matches_for_stateless_pseudo_element())
- })
- },
+ 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![Component::Class(DummyAtom::from("cl"))],
- specificity(0, 1, 0),
- Default::default(),
- )
- ].into_boxed_slice()
+ vec![Selector::from_vec(
+ vec![Component::Class(DummyAtom::from("cl"))],
+ specificity(0, 1, 0),
+ Default::default(),
+ )]
+ .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![
- Component::DefaultNamespace(MATHML.into()),
- Component::ExplicitUniversalType,
- ],
- specificity(0, 0, 0),
- Default::default(),
- )
- ]
+ vec![Selector::from_vec(
+ vec![
+ Component::DefaultNamespace(MATHML.into()),
+ Component::ExplicitUniversalType,
+ ],
+ specificity(0, 0, 0),
+ Default::default(),
+ )]
.into_boxed_slice(),
),
],
@@ -3080,19 +3084,17 @@ pub mod tests {
vec![
Component::DefaultNamespace(MATHML.into()),
Component::Negation(
- vec![
- Selector::from_vec(
- vec![
- Component::DefaultNamespace(MATHML.into()),
- Component::LocalName(LocalName {
- name: DummyAtom::from("e"),
- lower_name: DummyAtom::from("e"),
- }),
- ],
- specificity(0, 0, 1),
- Default::default(),
- ),
- ]
+ vec![Selector::from_vec(
+ vec![
+ Component::DefaultNamespace(MATHML.into()),
+ Component::LocalName(LocalName {
+ name: DummyAtom::from("e"),
+ lower_name: DummyAtom::from("e"),
+ }),
+ ],
+ 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
- ],
- specificity(0, 0, 0),
- Default::default(),
- )
- ].into_boxed_slice()
+ vec![Selector::from_vec(
+ vec![Component::ExplicitUniversalType],
+ specificity(0, 0, 0),
+ Default::default(),
+ )]
+ .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![
- Component::ExplicitNoNamespace,
- Component::ExplicitUniversalType,
- ],
- specificity(0, 0, 0),
- Default::default(),
- )
- ]
+ 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
- ],
- specificity(0, 0, 0),
- Default::default()
- )
- ].into_boxed_slice()
+ vec![Selector::from_vec(
+ vec![Component::ExplicitUniversalType],
+ specificity(0, 0, 0),
+ Default::default()
+ )]
+ .into_boxed_slice()
)],
specificity(0, 0, 0),
Default::default(),
diff --git a/components/style/attr.rs b/components/style/attr.rs
index 92ab7700fb8..05833fa08d8 100644
--- a/components/style/attr.rs
+++ b/components/style/attr.rs
@@ -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.
diff --git a/components/style/dom_apis.rs b/components/style/dom_apis.rs
index a6c50805cbb..6d19801cfc5 100644
--- a/components/style/dom_apis.rs
+++ b/components/style/dom_apis.rs
@@ -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.
diff --git a/components/style/element_state.rs b/components/style/element_state.rs
index e05ff8778e7..0852b4574fa 100644
--- a/components/style/element_state.rs
+++ b/components/style/element_state.rs
@@ -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;
diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs
index 37d667896cc..bfc78b84b15 100644
--- a/components/style/gecko/media_features.rs
+++ b/components/style/gecko/media_features.rs
@@ -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.
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs
index a6cf017877d..cb040390cfe 100644
--- a/components/style/gecko_string_cache/mod.rs
+++ b/components/style/gecko_string_cache/mod.rs
@@ -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 {}
diff --git a/components/style/gecko_string_cache/namespace.rs b/components/style/gecko_string_cache/namespace.rs
index 1acf04c93ff..d9745b9e21f 100644
--- a/components/style/gecko_string_cache/namespace.rs
+++ b/components/style/gecko_string_cache/namespace.rs
@@ -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 {
diff --git a/components/style/invalidation/stylesheets.rs b/components/style/invalidation/stylesheets.rs
index 9854387ccad..edecc3fc243 100644
--- a/components/style/invalidation/stylesheets.rs
+++ b/components/style/invalidation/stylesheets.rs
@@ -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,
diff --git a/components/style/lib.rs b/components/style/lib.rs
index f1d36b2722c..a9853e4c823 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -139,13 +139,17 @@ pub type LocalName = crate::values::AtomIdent;
pub use crate::gecko_string_cache::Namespace;
#[cfg(feature = "servo")]
-pub use html5ever::LocalName;
+pub use servo_atoms::Atom;
+
#[cfg(feature = "servo")]
-pub use html5ever::Namespace;
+#[allow(missing_docs)]
+pub type LocalName = crate::values::GenericAtomIdent<html5ever::LocalNameStaticSet>;
#[cfg(feature = "servo")]
-pub use html5ever::Prefix;
+#[allow(missing_docs)]
+pub type Namespace = crate::values::GenericAtomIdent<html5ever::NamespaceStaticSet>;
#[cfg(feature = "servo")]
-pub use servo_atoms::Atom;
+#[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;
diff --git a/components/style/macros.rs b/components/style/macros.rs
index e60be8efc5f..f5937d8b469 100644
--- a/components/style/macros.rs
+++ b/components/style/macros.rs
@@ -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) => {
diff --git a/components/style/properties/build.py b/components/style/properties/build.py
index e74c9b9795f..97ad10408ea 100644
--- a/components/style/properties/build.py
+++ b/components/style/properties/build.py
@@ -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),
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index caa941df1ff..30eaac343ac 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -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:
diff --git a/components/style/properties/longhands/inherited_ui.mako.rs b/components/style/properties/longhands/inherited_ui.mako.rs
index cb48acaa1fe..233ef365329 100644
--- a/components/style/properties/longhands/inherited_ui.mako.rs
+++ b/components/style/properties/longhands/inherited_ui.mako.rs
@@ -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(
diff --git a/components/style/properties/longhands/list.mako.rs b/components/style/properties/longhands/list.mako.rs
index b9a11a574f5..99d848d9db6 100644
--- a/components/style/properties/longhands/list.mako.rs
+++ b/components/style/properties/longhands/list.mako.rs
@@ -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",
)}
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index a3430526458..fc8ef438041 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -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,
diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs
index 039bcf95e29..17949c723d0 100644
--- a/components/style/servo/media_queries.rs
+++ b/components/style/servo/media_queries.rs
@@ -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>
diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs
index 82722571c85..ce61c172553 100644
--- a/components/style/servo/selector_parser.rs
+++ b/components/style/servo/selector_parser.rs
@@ -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
diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs
index 8e011796e79..f4ae4e25edf 100644
--- a/components/style/servo/url.rs
+++ b/components/style/servo/url.rs
@@ -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)
}
}
diff --git a/components/style/str.rs b/components/style/str.rs
index 9badcdf413c..c610b5241a7 100644
--- a/components/style/str.rs
+++ b/components/style/str.rs
@@ -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;
diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs
index 13599c6630a..158be6d5dfb 100644
--- a/components/style/style_adjuster.rs
+++ b/components/style/style_adjuster.rs
@@ -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) {
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index a07c51fe210..1b242547307 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -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);
diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs
index bb875b9f32e..d49a8a2b4de 100644
--- a/components/style/values/generics/image.rs
+++ b/components/style/values/generics/image.rs
@@ -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> {
diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs
index 9587b52648d..79ec424ab3a 100644
--- a/components/style/values/mod.rs
+++ b/components/style/values/mod.rs
@@ -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,13 +114,27 @@ 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,
{
- self.0
- .with_str(|s| cssparser::CssStringWriter::new(dest).write_str(s))
+ #[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))
+ }
}
}
@@ -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,
diff --git a/components/style/values/resolved/mod.rs b/components/style/values/resolved/mod.rs
index 45cc5cbd8cf..4ec84c2ae14 100644
--- a/components/style/values/resolved/mod.rs
+++ b/components/style/values/resolved/mod.rs
@@ -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);
diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs
index 51bacdf2ce5..3f150e74d1d 100644
--- a/components/style/values/specified/image.rs
+++ b/components/style/values/specified/image.rs
@@ -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,
diff --git a/components/style/values/specified/resolution.rs b/components/style/values/specified/resolution.rs
index e8674cffaaa..5ed642f9818 100644
--- a/components/style/values/specified/resolution.rs
+++ b/components/style/values/specified/resolution.rs
@@ -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)]
diff --git a/components/style/values/specified/table.rs b/components/style/values/specified/table.rs
index 79136b12ca1..81f3414e8f6 100644
--- a/components/style/values/specified/table.rs
+++ b/components/style/values/specified/table.rs
@@ -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")
}
diff --git a/components/style_traits/Cargo.toml b/components/style_traits/Cargo.toml
index 50e93ab25e6..02bee7d899c 100644
--- a/components/style_traits/Cargo.toml
+++ b/components/style_traits/Cargo.toml
@@ -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" }
diff --git a/components/style_traits/values.rs b/components/style_traits/values.rs
index df33c949fb6..05ba0b5f2a5 100644
--- a/components/style_traits/values.rs
+++ b/components/style_traits/values.rs
@@ -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
diff --git a/components/to_shmem/Cargo.toml b/components/to_shmem/Cargo.toml
index 76be7671da3..6027d2670e6 100644
--- a/components/to_shmem/Cargo.toml
+++ b/components/to_shmem/Cargo.toml
@@ -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"
diff --git a/components/url/lib.rs b/components/url/lib.rs
index d59d79e519a..944d02f29f7 100644
--- a/components/url/lib.rs
+++ b/components/url/lib.rs
@@ -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"
}
diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml
index 2764c9d0408..51056e378f4 100644
--- a/tests/unit/style/Cargo.toml
+++ b/tests/unit/style/Cargo.toml
@@ -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"
diff --git a/tests/unit/style/custom_properties.rs b/tests/unit/style/custom_properties.rs
index 5bb0a800812..1e4ab0a7282 100644
--- a/tests/unit/style/custom_properties.rs
+++ b/tests/unit/style/custom_properties.rs
@@ -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),
);
diff --git a/tests/unit/style/parsing/selectors.rs b/tests/unit/style/parsing/selectors.rs
index 1ce7498caad..7aa77200732 100644
--- a/tests/unit/style/parsing/selectors.rs
+++ b/tests/unit/style/parsing/selectors.rs
@@ -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,
diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs
index 8836436c8be..31b7869a258 100644
--- a/tests/unit/style/stylist.rs
+++ b/tests/unit/style/stylist.rs
@@ -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),
);
diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs
index 445ec4bf8fd..c12939f8f34 100644
--- a/tests/unit/style/viewport.rs
+++ b/tests/unit/style/viewport.rs
@@ -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),