mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Miscellaneous build / tidy fixes.
This commit is contained in:
parent
5158f65810
commit
31e8e418ea
66 changed files with 566 additions and 294 deletions
|
@ -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" }
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue