mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Remove dependency on servo_url (#31358)
In order for stylo to be a separate crate, it needs to depend on less things from Servo. This change makes it so that stylo no longer depends on servo_url.
This commit is contained in:
parent
29e1dfe1e4
commit
9a6973d629
42 changed files with 236 additions and 144 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -3107,6 +3107,7 @@ dependencies = [
|
||||||
"style",
|
"style",
|
||||||
"style_traits",
|
"style_traits",
|
||||||
"time 0.1.45",
|
"time 0.1.45",
|
||||||
|
"url",
|
||||||
"webrender_api",
|
"webrender_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3143,6 +3144,7 @@ dependencies = [
|
||||||
"servo_url",
|
"servo_url",
|
||||||
"style",
|
"style",
|
||||||
"style_traits",
|
"style_traits",
|
||||||
|
"url",
|
||||||
"webrender_api",
|
"webrender_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5374,6 +5376,7 @@ dependencies = [
|
||||||
"malloc_size_of",
|
"malloc_size_of",
|
||||||
"malloc_size_of_derive",
|
"malloc_size_of_derive",
|
||||||
"serde",
|
"serde",
|
||||||
|
"servo_arc",
|
||||||
"servo_rand",
|
"servo_rand",
|
||||||
"to_shmem",
|
"to_shmem",
|
||||||
"url",
|
"url",
|
||||||
|
@ -5707,7 +5710,6 @@ dependencies = [
|
||||||
"servo_arc",
|
"servo_arc",
|
||||||
"servo_atoms",
|
"servo_atoms",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
"servo_url",
|
|
||||||
"smallbitvec",
|
"smallbitvec",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
|
@ -5723,6 +5725,7 @@ dependencies = [
|
||||||
"uluru",
|
"uluru",
|
||||||
"unicode-bidi",
|
"unicode-bidi",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
|
"url",
|
||||||
"void",
|
"void",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
@ -5753,9 +5756,9 @@ dependencies = [
|
||||||
"servo_arc",
|
"servo_arc",
|
||||||
"servo_atoms",
|
"servo_atoms",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
"servo_url",
|
|
||||||
"style",
|
"style",
|
||||||
"style_traits",
|
"style_traits",
|
||||||
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5773,10 +5776,10 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"servo_arc",
|
"servo_arc",
|
||||||
"servo_atoms",
|
"servo_atoms",
|
||||||
"servo_url",
|
|
||||||
"size_of_test",
|
"size_of_test",
|
||||||
"to_shmem",
|
"to_shmem",
|
||||||
"to_shmem_derive",
|
"to_shmem_derive",
|
||||||
|
"url",
|
||||||
"webrender_api",
|
"webrender_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ impl FontCache {
|
||||||
|
|
||||||
// FIXME:
|
// FIXME:
|
||||||
// This shouldn't use NoReferrer, but the current documents url
|
// This shouldn't use NoReferrer, but the current documents url
|
||||||
let request = RequestBuilder::new(url.clone(), Referrer::NoReferrer)
|
let request = RequestBuilder::new(url.clone().into(), Referrer::NoReferrer)
|
||||||
.destination(Destination::Font);
|
.destination(Destination::Font);
|
||||||
|
|
||||||
let channel_to_self = self.channel_to_self.clone();
|
let channel_to_self = self.channel_to_self.clone();
|
||||||
|
@ -334,7 +334,7 @@ impl FontCache {
|
||||||
};
|
};
|
||||||
let command = Command::AddDownloadedWebFont(
|
let command = Command::AddDownloadedWebFont(
|
||||||
family_name.clone(),
|
family_name.clone(),
|
||||||
url.clone(),
|
url.clone().into(),
|
||||||
bytes,
|
bytes,
|
||||||
sender.clone(),
|
sender.clone(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -160,7 +160,6 @@ impl FontTemplateData {
|
||||||
.to_string(),
|
.to_string(),
|
||||||
)
|
)
|
||||||
.expect("Couldn't parse Core Text font URL!")
|
.expect("Couldn't parse Core Text font URL!")
|
||||||
.as_url()
|
|
||||||
.to_file_path()
|
.to_file_path()
|
||||||
.expect("Core Text font didn't name a path!");
|
.expect("Core Text font didn't name a path!");
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
|
|
|
@ -1512,7 +1512,7 @@ where
|
||||||
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
|
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
|
||||||
Image::Url(ref url_value) => {
|
Image::Url(ref url_value) => {
|
||||||
let image_info = Box::new(ImageFragmentInfo::new(
|
let image_info = Box::new(ImageFragmentInfo::new(
|
||||||
url_value.url().cloned(),
|
url_value.url().cloned().map(Into::into),
|
||||||
None,
|
None,
|
||||||
node,
|
node,
|
||||||
self.layout_context,
|
self.layout_context,
|
||||||
|
|
|
@ -734,7 +734,7 @@ impl Fragment {
|
||||||
if let Some(url) = image_url.url() {
|
if let Some(url) = image_url.url() {
|
||||||
let webrender_image = state.layout_context.get_webrender_image_for_url(
|
let webrender_image = state.layout_context.get_webrender_image_for_url(
|
||||||
self.node,
|
self.node,
|
||||||
url.clone(),
|
url.clone().into(),
|
||||||
UsePlaceholder::No,
|
UsePlaceholder::No,
|
||||||
);
|
);
|
||||||
if let Some(webrender_image) = webrender_image {
|
if let Some(webrender_image) = webrender_image {
|
||||||
|
@ -1205,7 +1205,7 @@ impl Fragment {
|
||||||
let url = image_url.url()?;
|
let url = image_url.url()?;
|
||||||
let image = state.layout_context.get_webrender_image_for_url(
|
let image = state.layout_context.get_webrender_image_for_url(
|
||||||
self.node,
|
self.node,
|
||||||
url.clone(),
|
url.clone().into(),
|
||||||
UsePlaceholder::No,
|
UsePlaceholder::No,
|
||||||
)?;
|
)?;
|
||||||
width = image.width;
|
width = image.width;
|
||||||
|
|
|
@ -37,7 +37,7 @@ use style::properties::{
|
||||||
};
|
};
|
||||||
use style::selector_parser::PseudoElement;
|
use style::selector_parser::PseudoElement;
|
||||||
use style::shared_lock::SharedRwLock;
|
use style::shared_lock::SharedRwLock;
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||||
use style_traits::{CSSPixel, ParsingMode, ToCss};
|
use style_traits::{CSSPixel, ParsingMode, ToCss};
|
||||||
use webrender_api::ExternalScrollId;
|
use webrender_api::ExternalScrollId;
|
||||||
|
|
||||||
|
@ -798,7 +798,7 @@ fn create_font_declaration(
|
||||||
property.clone(),
|
property.clone(),
|
||||||
value,
|
value,
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
url_data,
|
&UrlExtraData(url_data.get_arc()),
|
||||||
None,
|
None,
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
|
|
@ -608,7 +608,7 @@ impl<'a> BuilderForBoxFragment<'a> {
|
||||||
};
|
};
|
||||||
let (width, height, key) = match builder.context.get_webrender_image_for_url(
|
let (width, height, key) = match builder.context.get_webrender_image_for_url(
|
||||||
node,
|
node,
|
||||||
image_url,
|
image_url.into(),
|
||||||
UsePlaceholder::No,
|
UsePlaceholder::No,
|
||||||
) {
|
) {
|
||||||
Some(WebRenderImageInfo {
|
Some(WebRenderImageInfo {
|
||||||
|
|
|
@ -177,7 +177,7 @@ impl ReplacedContent {
|
||||||
if let ComputedUrl::Valid(image_url) = image_url {
|
if let ComputedUrl::Valid(image_url) = image_url {
|
||||||
let (image, width, height) = match context.get_or_request_image_or_meta(
|
let (image, width, height) = match context.get_or_request_image_or_meta(
|
||||||
element.opaque(),
|
element.opaque(),
|
||||||
image_url.clone(),
|
image_url.clone().into(),
|
||||||
UsePlaceholder::No,
|
UsePlaceholder::No,
|
||||||
) {
|
) {
|
||||||
Some(ImageOrMetadataAvailable::ImageAvailable { image, .. }) => {
|
Some(ImageOrMetadataAvailable::ImageAvailable { image, .. }) => {
|
||||||
|
|
|
@ -44,4 +44,5 @@ servo_url = { path = "../url" }
|
||||||
style = { path = "../style" }
|
style = { path = "../style" }
|
||||||
style_traits = { workspace = true }
|
style_traits = { workspace = true }
|
||||||
time = { workspace = true }
|
time = { workspace = true }
|
||||||
|
url = { workspace = true }
|
||||||
webrender_api = { workspace = true }
|
webrender_api = { workspace = true }
|
||||||
|
|
|
@ -100,13 +100,15 @@ use style::selector_parser::{PseudoElement, SnapshotMap};
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
||||||
use style::stylesheets::{
|
use style::stylesheets::{
|
||||||
DocumentStyleSheet, Origin, Stylesheet, StylesheetInDocument, UserAgentStylesheets,
|
DocumentStyleSheet, Origin, Stylesheet, StylesheetInDocument, UrlExtraData,
|
||||||
|
UserAgentStylesheets,
|
||||||
};
|
};
|
||||||
use style::stylist::Stylist;
|
use style::stylist::Stylist;
|
||||||
use style::thread_state::{self, ThreadState};
|
use style::thread_state::{self, ThreadState};
|
||||||
use style::traversal::DomTraversal;
|
use style::traversal::DomTraversal;
|
||||||
use style::traversal_flags::TraversalFlags;
|
use style::traversal_flags::TraversalFlags;
|
||||||
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
|
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
|
||||||
|
use url::Url;
|
||||||
use webrender_api::{units, ColorF, HitTestFlags};
|
use webrender_api::{units, ColorF, HitTestFlags};
|
||||||
|
|
||||||
/// Information needed by the layout thread.
|
/// Information needed by the layout thread.
|
||||||
|
@ -1795,9 +1797,12 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
||||||
filename: &str,
|
filename: &str,
|
||||||
content: &[u8],
|
content: &[u8],
|
||||||
) -> Result<DocumentStyleSheet, &'static str> {
|
) -> Result<DocumentStyleSheet, &'static str> {
|
||||||
|
let url = Url::parse(&format!("chrome://resources/{:?}", filename))
|
||||||
|
.ok()
|
||||||
|
.unwrap();
|
||||||
Ok(DocumentStyleSheet(ServoArc::new(Stylesheet::from_bytes(
|
Ok(DocumentStyleSheet(ServoArc::new(Stylesheet::from_bytes(
|
||||||
content,
|
content,
|
||||||
ServoUrl::parse(&format!("chrome://resources/{:?}", filename)).unwrap(),
|
url.into(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
|
@ -1835,7 +1840,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
||||||
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
|
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
|
||||||
Stylesheet::from_bytes(
|
Stylesheet::from_bytes(
|
||||||
&contents,
|
&contents,
|
||||||
url.clone(),
|
UrlExtraData(url.get_arc()),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Origin::User,
|
Origin::User,
|
||||||
|
|
|
@ -40,4 +40,5 @@ servo_config = { path = "../config" }
|
||||||
servo_url = { path = "../url" }
|
servo_url = { path = "../url" }
|
||||||
style = { path = "../style" }
|
style = { path = "../style" }
|
||||||
style_traits = { workspace = true }
|
style_traits = { workspace = true }
|
||||||
|
url = { workspace = true }
|
||||||
webrender_api = { workspace = true }
|
webrender_api = { workspace = true }
|
||||||
|
|
|
@ -84,13 +84,15 @@ use style::properties::PropertyId;
|
||||||
use style::selector_parser::SnapshotMap;
|
use style::selector_parser::SnapshotMap;
|
||||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
||||||
use style::stylesheets::{
|
use style::stylesheets::{
|
||||||
DocumentStyleSheet, Origin, Stylesheet, StylesheetInDocument, UserAgentStylesheets,
|
DocumentStyleSheet, Origin, Stylesheet, StylesheetInDocument, UrlExtraData,
|
||||||
|
UserAgentStylesheets,
|
||||||
};
|
};
|
||||||
use style::stylist::Stylist;
|
use style::stylist::Stylist;
|
||||||
use style::thread_state::{self, ThreadState};
|
use style::thread_state::{self, ThreadState};
|
||||||
use style::traversal::DomTraversal;
|
use style::traversal::DomTraversal;
|
||||||
use style::traversal_flags::TraversalFlags;
|
use style::traversal_flags::TraversalFlags;
|
||||||
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
|
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
|
||||||
|
use url::Url;
|
||||||
use webrender_api::{units, HitTestFlags};
|
use webrender_api::{units, HitTestFlags};
|
||||||
|
|
||||||
/// Information needed by the layout thread.
|
/// Information needed by the layout thread.
|
||||||
|
@ -1387,9 +1389,12 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
||||||
filename: &str,
|
filename: &str,
|
||||||
content: &[u8],
|
content: &[u8],
|
||||||
) -> Result<DocumentStyleSheet, &'static str> {
|
) -> Result<DocumentStyleSheet, &'static str> {
|
||||||
|
let url = Url::parse(&format!("chrome://resources/{:?}", filename))
|
||||||
|
.ok()
|
||||||
|
.unwrap();
|
||||||
Ok(DocumentStyleSheet(ServoArc::new(Stylesheet::from_bytes(
|
Ok(DocumentStyleSheet(ServoArc::new(Stylesheet::from_bytes(
|
||||||
content,
|
content,
|
||||||
ServoUrl::parse(&format!("chrome://resources/{:?}", filename)).unwrap(),
|
url.into(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
|
@ -1427,7 +1432,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
||||||
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
|
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
|
||||||
Stylesheet::from_bytes(
|
Stylesheet::from_bytes(
|
||||||
&contents,
|
&contents,
|
||||||
url.clone(),
|
UrlExtraData(url.get_arc()),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Origin::User,
|
Origin::User,
|
||||||
|
|
|
@ -32,6 +32,7 @@ use style::values::computed::font::FontStyle;
|
||||||
use style::values::specified::color::Color;
|
use style::values::specified::color::Color;
|
||||||
use style_traits::values::ToCss;
|
use style_traits::values::ToCss;
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{
|
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{
|
||||||
|
@ -1681,7 +1682,7 @@ impl CanvasState {
|
||||||
pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<RGBA, ()> {
|
pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<RGBA, ()> {
|
||||||
let mut input = ParserInput::new(string);
|
let mut input = ParserInput::new(string);
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let url = ServoUrl::parse("about:blank").unwrap();
|
let url = Url::parse("about:blank").unwrap().into();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use dom_struct::dom_struct;
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::supports_rule::{parse_condition_or_declaration, Declaration};
|
use style::stylesheets::supports_rule::{parse_condition_or_declaration, Declaration};
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::Window_Binding::WindowMethods;
|
use crate::dom::bindings::codegen::Bindings::WindowBinding::Window_Binding::WindowMethods;
|
||||||
|
@ -39,10 +39,10 @@ impl CSS {
|
||||||
decl.push_str(": ");
|
decl.push_str(": ");
|
||||||
decl.push_str(&value);
|
decl.push_str(&value);
|
||||||
let decl = Declaration(decl);
|
let decl = Declaration(decl);
|
||||||
let url = win.Document().url();
|
let url_data = UrlExtraData(win.Document().url().get_arc());
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Style),
|
Some(CssRuleType::Style),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
QuirksMode::NoQuirks,
|
QuirksMode::NoQuirks,
|
||||||
|
@ -62,10 +62,10 @@ impl CSS {
|
||||||
Err(..) => return false,
|
Err(..) => return false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let url = win.Document().url();
|
let url_data = UrlExtraData(win.Document().url().get_arc());
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Style),
|
Some(CssRuleType::Style),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
QuirksMode::NoQuirks,
|
QuirksMode::NoQuirks,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use style::properties::{
|
||||||
};
|
};
|
||||||
use style::selector_parser::PseudoElement;
|
use style::selector_parser::PseudoElement;
|
||||||
use style::shared_lock::Locked;
|
use style::shared_lock::Locked;
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
||||||
|
@ -160,12 +160,15 @@ impl CSSStyleOwner {
|
||||||
fn base_url(&self) -> ServoUrl {
|
fn base_url(&self) -> ServoUrl {
|
||||||
match *self {
|
match *self {
|
||||||
CSSStyleOwner::Element(ref el) => window_from_node(&**el).Document().base_url(),
|
CSSStyleOwner::Element(ref el) => window_from_node(&**el).Document().base_url(),
|
||||||
CSSStyleOwner::CSSRule(ref rule, _) => (*rule
|
CSSStyleOwner::CSSRule(ref rule, _) => ServoUrl::from(
|
||||||
.parent_stylesheet()
|
rule.parent_stylesheet()
|
||||||
.style_stylesheet()
|
.style_stylesheet()
|
||||||
.contents
|
.contents
|
||||||
.url_data
|
.url_data
|
||||||
.read())
|
.read()
|
||||||
|
.0
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.clone(),
|
.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +310,7 @@ impl CSSStyleDeclaration {
|
||||||
id,
|
id,
|
||||||
&value,
|
&value,
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&self.owner.base_url(),
|
&UrlExtraData(self.owner.base_url().get_arc()),
|
||||||
window.css_error_reporter(),
|
window.css_error_reporter(),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
@ -458,7 +461,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
// Step 3
|
// Step 3
|
||||||
*pdb = parse_style_attribute(
|
*pdb = parse_style_attribute(
|
||||||
&value,
|
&value,
|
||||||
&self.owner.base_url(),
|
&UrlExtraData(self.owner.base_url().get_arc()),
|
||||||
window.css_error_reporter(),
|
window.css_error_reporter(),
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
CssRuleType::Style,
|
CssRuleType::Style,
|
||||||
|
|
|
@ -13,6 +13,7 @@ use js::jsapi::JSObject;
|
||||||
use js::rust::{CustomAutoRooterGuard, HandleObject};
|
use js::rust::{CustomAutoRooterGuard, HandleObject};
|
||||||
use js::typedarray::{Float32Array, Float64Array};
|
use js::typedarray::{Float32Array, Float64Array};
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
|
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
|
||||||
|
@ -830,10 +831,10 @@ pub fn transform_to_matrix(value: String) -> Fallible<(bool, Transform3D<f64>)>
|
||||||
|
|
||||||
let mut input = ParserInput::new(&value);
|
let mut input = ParserInput::new(&value);
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let url = ::servo_url::ServoUrl::parse("about:blank").unwrap();
|
let url_data = Url::parse("about:blank").unwrap().into();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
::style::stylesheets::Origin::Author,
|
::style::stylesheets::Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(::style::stylesheets::CssRuleType::Style),
|
Some(::style::stylesheets::CssRuleType::Style),
|
||||||
::style_traits::ParsingMode::DEFAULT,
|
::style_traits::ParsingMode::DEFAULT,
|
||||||
::style::context::QuirksMode::NoQuirks,
|
::style::context::QuirksMode::NoQuirks,
|
||||||
|
|
|
@ -53,7 +53,7 @@ use style::selector_parser::{
|
||||||
};
|
};
|
||||||
use style::shared_lock::{Locked, SharedRwLock};
|
use style::shared_lock::{Locked, SharedRwLock};
|
||||||
use style::stylesheets::layer_rule::LayerOrder;
|
use style::stylesheets::layer_rule::LayerOrder;
|
||||||
use style::stylesheets::CssRuleType;
|
use style::stylesheets::{CssRuleType, UrlExtraData};
|
||||||
use style::values::generics::NonNegative;
|
use style::values::generics::NonNegative;
|
||||||
use style::values::{computed, specified, AtomIdent, AtomString, CSSFloat};
|
use style::values::{computed, specified, AtomIdent, AtomString, CSSFloat};
|
||||||
use style::{dom_apis, thread_state, CaseSensitivityExt};
|
use style::{dom_apis, thread_state, CaseSensitivityExt};
|
||||||
|
@ -724,7 +724,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::BackgroundImage(background_image::SpecifiedValue(
|
PropertyDeclaration::BackgroundImage(background_image::SpecifiedValue(
|
||||||
vec![specified::Image::for_cascade(url.into())].into(),
|
vec![specified::Image::for_cascade(url.get_arc())].into(),
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -2752,7 +2752,10 @@ impl ElementMethods for Element {
|
||||||
fn Matches(&self, selectors: DOMString) -> Fallible<bool> {
|
fn Matches(&self, selectors: DOMString) -> Fallible<bool> {
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
let url = doc.url();
|
let url = doc.url();
|
||||||
let selectors = match SelectorParser::parse_author_origin_no_namespace(&selectors, &url) {
|
let selectors = match SelectorParser::parse_author_origin_no_namespace(
|
||||||
|
&selectors,
|
||||||
|
&UrlExtraData(url.get_arc()),
|
||||||
|
) {
|
||||||
Err(_) => return Err(Error::Syntax),
|
Err(_) => return Err(Error::Syntax),
|
||||||
Ok(selectors) => selectors,
|
Ok(selectors) => selectors,
|
||||||
};
|
};
|
||||||
|
@ -2772,7 +2775,10 @@ impl ElementMethods for Element {
|
||||||
fn Closest(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
fn Closest(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
let url = doc.url();
|
let url = doc.url();
|
||||||
let selectors = match SelectorParser::parse_author_origin_no_namespace(&selectors, &url) {
|
let selectors = match SelectorParser::parse_author_origin_no_namespace(
|
||||||
|
&selectors,
|
||||||
|
&UrlExtraData(url.get_arc()),
|
||||||
|
) {
|
||||||
Err(_) => return Err(Error::Syntax),
|
Err(_) => return Err(Error::Syntax),
|
||||||
Ok(selectors) => selectors,
|
Ok(selectors) => selectors,
|
||||||
};
|
};
|
||||||
|
@ -2926,7 +2932,7 @@ impl VirtualMethods for Element {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
Arc::new(doc.style_shared_lock().wrap(parse_style_attribute(
|
Arc::new(doc.style_shared_lock().wrap(parse_style_attribute(
|
||||||
&attr.value(),
|
&attr.value(),
|
||||||
&doc.base_url(),
|
&UrlExtraData(doc.base_url().get_arc()),
|
||||||
win.css_error_reporter(),
|
win.css_error_reporter(),
|
||||||
doc.quirks_mode(),
|
doc.quirks_mode(),
|
||||||
CssRuleType::Style,
|
CssRuleType::Style,
|
||||||
|
|
|
@ -87,8 +87,10 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-body-background
|
// https://html.spec.whatwg.org/multipage/#dom-body-background
|
||||||
fn SetBackground(&self, input: DOMString) {
|
fn SetBackground(&self, input: DOMString) {
|
||||||
let value =
|
let value = AttrValue::from_resolved_url(
|
||||||
AttrValue::from_resolved_url(&document_from_node(self).base_url(), input.into());
|
&document_from_node(self).base_url().get_arc(),
|
||||||
|
input.into(),
|
||||||
|
);
|
||||||
self.upcast::<Element>()
|
self.upcast::<Element>()
|
||||||
.set_attribute(&local_name!("background"), value);
|
.set_attribute(&local_name!("background"), value);
|
||||||
}
|
}
|
||||||
|
@ -123,6 +125,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
||||||
.get_attr_for_layout(&ns!(), &local_name!("background"))
|
.get_attr_for_layout(&ns!(), &local_name!("background"))
|
||||||
.and_then(AttrValue::as_resolved_url)
|
.and_then(AttrValue::as_resolved_url)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
.map(Into::into)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,9 +167,10 @@ impl VirtualMethods for HTMLBodyElement {
|
||||||
local_name!("bgcolor") | local_name!("text") => {
|
local_name!("bgcolor") | local_name!("text") => {
|
||||||
AttrValue::from_legacy_color(value.into())
|
AttrValue::from_legacy_color(value.into())
|
||||||
},
|
},
|
||||||
local_name!("background") => {
|
local_name!("background") => AttrValue::from_resolved_url(
|
||||||
AttrValue::from_resolved_url(&document_from_node(self).base_url(), value.into())
|
&document_from_node(self).base_url().get_arc(),
|
||||||
},
|
value.into(),
|
||||||
|
),
|
||||||
_ => self
|
_ => self
|
||||||
.super_type()
|
.super_type()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -40,11 +40,12 @@ use style::context::QuirksMode;
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::str::is_ascii_digit;
|
use style::str::is_ascii_digit;
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||||
use style::values::specified::length::{Length, NoCalcLength};
|
use style::values::specified::length::{Length, NoCalcLength};
|
||||||
use style::values::specified::source_size_list::SourceSizeList;
|
use style::values::specified::source_size_list::SourceSizeList;
|
||||||
use style::values::specified::AbsoluteLength;
|
use style::values::specified::AbsoluteLength;
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
use crate::document_loader::{LoadBlocker, LoadType};
|
use crate::document_loader::{LoadBlocker, LoadType};
|
||||||
use crate::dom::activation::Activatable;
|
use crate::dom::activation::Activatable;
|
||||||
|
@ -678,7 +679,7 @@ impl HTMLImageElement {
|
||||||
fn matches_environment(&self, media_query: String) -> bool {
|
fn matches_environment(&self, media_query: String) -> bool {
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
let quirks_mode = document.quirks_mode();
|
let quirks_mode = document.quirks_mode();
|
||||||
let document_url = &document.url();
|
let document_url_data = UrlExtraData(document.url().get_arc());
|
||||||
// FIXME(emilio): This should do the same that we do for other media
|
// FIXME(emilio): This should do the same that we do for other media
|
||||||
// lists regarding the rule type and such, though it doesn't really
|
// lists regarding the rule type and such, though it doesn't really
|
||||||
// matter right now...
|
// matter right now...
|
||||||
|
@ -686,7 +687,7 @@ impl HTMLImageElement {
|
||||||
// Also, ParsingMode::all() is wrong, and should be DEFAULT.
|
// Also, ParsingMode::all() is wrong, and should be DEFAULT.
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
document_url,
|
&document_url_data,
|
||||||
Some(CssRuleType::Style),
|
Some(CssRuleType::Style),
|
||||||
ParsingMode::all(),
|
ParsingMode::all(),
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
@ -1434,10 +1435,10 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
||||||
pub fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList {
|
pub fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList {
|
||||||
let mut input = ParserInput::new(&value);
|
let mut input = ParserInput::new(&value);
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let url = ServoUrl::parse("about:blank").unwrap();
|
let url_data = Url::parse("about:blank").unwrap().into();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Style),
|
Some(CssRuleType::Style),
|
||||||
// FIXME(emilio): why ::empty() instead of ::DEFAULT? Also, what do
|
// FIXME(emilio): why ::empty() instead of ::DEFAULT? Also, what do
|
||||||
// browsers do regarding quirks-mode in a media list?
|
// browsers do regarding quirks-mode in a media list?
|
||||||
|
|
|
@ -18,7 +18,7 @@ use style::attr::AttrValue;
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::parser::ParserContext as CssParserContext;
|
use style::parser::ParserContext as CssParserContext;
|
||||||
use style::str::HTML_SPACE_CHARACTERS;
|
use style::str::HTML_SPACE_CHARACTERS;
|
||||||
use style::stylesheets::{CssRuleType, Origin, Stylesheet};
|
use style::stylesheets::{CssRuleType, Origin, Stylesheet, UrlExtraData};
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
|
|
||||||
use crate::dom::attr::Attr;
|
use crate::dom::attr::Attr;
|
||||||
|
@ -310,14 +310,14 @@ impl HTMLLinkElement {
|
||||||
|
|
||||||
let mut input = ParserInput::new(&mq_str);
|
let mut input = ParserInput::new(&mq_str);
|
||||||
let mut css_parser = CssParser::new(&mut input);
|
let mut css_parser = CssParser::new(&mut input);
|
||||||
let doc_url = document.url();
|
let document_url_data = &UrlExtraData(document.url().get_arc());
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
// FIXME(emilio): This looks somewhat fishy, since we use the context
|
// FIXME(emilio): This looks somewhat fishy, since we use the context
|
||||||
// only to parse the media query list, CssRuleType::Media doesn't make
|
// only to parse the media query list, CssRuleType::Media doesn't make
|
||||||
// much sense.
|
// much sense.
|
||||||
let context = CssParserContext::new(
|
let context = CssParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&doc_url,
|
&document_url_data,
|
||||||
Some(CssRuleType::Media),
|
Some(CssRuleType::Media),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
document.quirks_mode(),
|
document.quirks_mode(),
|
||||||
|
|
|
@ -1117,7 +1117,7 @@ impl HTMLScriptElement {
|
||||||
if let Some(record) = record {
|
if let Some(record) = record {
|
||||||
rooted!(in(*GlobalScope::get_cx()) let mut rval = UndefinedValue());
|
rooted!(in(*GlobalScope::get_cx()) let mut rval = UndefinedValue());
|
||||||
let evaluated =
|
let evaluated =
|
||||||
module_tree.execute_module(global, record, rval.handle_mut().into());
|
module_tree.execute_module(&global, record, rval.handle_mut().into());
|
||||||
|
|
||||||
if let Err(exception) = evaluated {
|
if let Err(exception) = evaluated {
|
||||||
module_tree.set_rethrow_error(exception);
|
module_tree.set_rethrow_error(exception);
|
||||||
|
|
|
@ -12,7 +12,7 @@ use net_traits::ReferrerPolicy;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::parser::ParserContext as CssParserContext;
|
use style::parser::ParserContext as CssParserContext;
|
||||||
use style::stylesheets::{AllowImportRules, CssRuleType, Origin, Stylesheet};
|
use style::stylesheets::{AllowImportRules, CssRuleType, Origin, Stylesheet, UrlExtraData};
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
|
@ -100,11 +100,11 @@ impl HTMLStyleElement {
|
||||||
let data = node
|
let data = node
|
||||||
.GetTextContent()
|
.GetTextContent()
|
||||||
.expect("Element.textContent must be a string");
|
.expect("Element.textContent must be a string");
|
||||||
let url = window.get_url();
|
let url_data = UrlExtraData(window.get_url().get_arc());
|
||||||
let css_error_reporter = window.css_error_reporter();
|
let css_error_reporter = window.css_error_reporter();
|
||||||
let context = CssParserContext::new(
|
let context = CssParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Media),
|
Some(CssRuleType::Media),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
doc.quirks_mode(),
|
doc.quirks_mode(),
|
||||||
|
@ -119,7 +119,7 @@ impl HTMLStyleElement {
|
||||||
let loader = StylesheetLoader::for_element(self.upcast());
|
let loader = StylesheetLoader::for_element(self.upcast());
|
||||||
let sheet = Stylesheet::from_str(
|
let sheet = Stylesheet::from_str(
|
||||||
&data,
|
&data,
|
||||||
window.get_url(),
|
UrlExtraData(window.get_url().get_arc()),
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
mq,
|
mq,
|
||||||
shared_lock,
|
shared_lock,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use servo_arc::Arc;
|
||||||
use style::media_queries::{MediaList as StyleMediaList, MediaQuery};
|
use style::media_queries::{MediaList as StyleMediaList, MediaQuery};
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::shared_lock::{Locked, SharedRwLock};
|
use style::shared_lock::{Locked, SharedRwLock};
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||||
use style_traits::{ParsingMode, ToCss};
|
use style_traits::{ParsingMode, ToCss};
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods;
|
use crate::dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods;
|
||||||
|
@ -80,11 +80,11 @@ impl MediaListMethods for MediaList {
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
let url = window.get_url();
|
let url_data = UrlExtraData(window.get_url().get_arc());
|
||||||
let quirks_mode = window.Document().quirks_mode();
|
let quirks_mode = window.Document().quirks_mode();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Media),
|
Some(CssRuleType::Media),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
@ -123,11 +123,11 @@ impl MediaListMethods for MediaList {
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let win = global.as_window();
|
let win = global.as_window();
|
||||||
let url = win.get_url();
|
let url_data = UrlExtraData(win.get_url().get_arc());
|
||||||
let quirks_mode = win.Document().quirks_mode();
|
let quirks_mode = win.Document().quirks_mode();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Media),
|
Some(CssRuleType::Media),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
@ -162,11 +162,11 @@ impl MediaListMethods for MediaList {
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let win = global.as_window();
|
let win = global.as_window();
|
||||||
let url = win.get_url();
|
let url_data = UrlExtraData(win.get_url().get_arc());
|
||||||
let quirks_mode = win.Document().quirks_mode();
|
let quirks_mode = win.Document().quirks_mode();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Media),
|
Some(CssRuleType::Media),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
|
|
@ -41,7 +41,7 @@ use style::context::QuirksMode;
|
||||||
use style::dom::OpaqueNode;
|
use style::dom::OpaqueNode;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::selector_parser::{SelectorImpl, SelectorParser};
|
use style::selector_parser::{SelectorImpl, SelectorParser};
|
||||||
use style::stylesheets::Stylesheet;
|
use style::stylesheets::{Stylesheet, UrlExtraData};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::document_loader::DocumentLoader;
|
use crate::document_loader::DocumentLoader;
|
||||||
|
@ -961,7 +961,10 @@ impl Node {
|
||||||
pub fn query_selector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
pub fn query_selector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let doc = self.owner_doc();
|
let doc = self.owner_doc();
|
||||||
match SelectorParser::parse_author_origin_no_namespace(&selectors, &doc.url()) {
|
match SelectorParser::parse_author_origin_no_namespace(
|
||||||
|
&selectors,
|
||||||
|
&UrlExtraData(doc.url().get_arc()),
|
||||||
|
) {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Err(_) => Err(Error::Syntax),
|
Err(_) => Err(Error::Syntax),
|
||||||
// Step 3.
|
// Step 3.
|
||||||
|
@ -989,7 +992,10 @@ impl Node {
|
||||||
pub fn query_selector_iter(&self, selectors: DOMString) -> Fallible<QuerySelectorIterator> {
|
pub fn query_selector_iter(&self, selectors: DOMString) -> Fallible<QuerySelectorIterator> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let url = self.owner_doc().url();
|
let url = self.owner_doc().url();
|
||||||
match SelectorParser::parse_author_origin_no_namespace(&selectors, &url) {
|
match SelectorParser::parse_author_origin_no_namespace(
|
||||||
|
&selectors,
|
||||||
|
&UrlExtraData(url.get_arc()),
|
||||||
|
) {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Err(_) => Err(Error::Syntax),
|
Err(_) => Err(Error::Syntax),
|
||||||
// Step 3.
|
// Step 3.
|
||||||
|
|
|
@ -73,7 +73,7 @@ use style::properties::style_structs::Font;
|
||||||
use style::properties::{PropertyId, ShorthandId};
|
use style::properties::{PropertyId, ShorthandId};
|
||||||
use style::selector_parser::PseudoElement;
|
use style::selector_parser::PseudoElement;
|
||||||
use style::str::HTML_SPACE_CHARACTERS;
|
use style::str::HTML_SPACE_CHARACTERS;
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||||
use style_traits::{CSSPixel, DevicePixel, ParsingMode};
|
use style_traits::{CSSPixel, DevicePixel, ParsingMode};
|
||||||
use url::Position;
|
use url::Position;
|
||||||
use webrender_api::units::{DeviceIntPoint, DeviceIntSize, LayoutPixel};
|
use webrender_api::units::{DeviceIntPoint, DeviceIntSize, LayoutPixel};
|
||||||
|
@ -1328,11 +1328,11 @@ impl WindowMethods for Window {
|
||||||
fn MatchMedia(&self, query: DOMString) -> DomRoot<MediaQueryList> {
|
fn MatchMedia(&self, query: DOMString) -> DomRoot<MediaQueryList> {
|
||||||
let mut input = ParserInput::new(&query);
|
let mut input = ParserInput::new(&query);
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let url = self.get_url();
|
let url_data = UrlExtraData(self.get_url().get_arc());
|
||||||
let quirks_mode = self.Document().quirks_mode();
|
let quirks_mode = self.Document().quirks_mode();
|
||||||
let context = CssParserContext::new(
|
let context = CssParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Media),
|
Some(CssRuleType::Media),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
|
@ -2826,11 +2826,16 @@ pub struct CSSErrorReporter {
|
||||||
unsafe_no_jsmanaged_fields!(CSSErrorReporter);
|
unsafe_no_jsmanaged_fields!(CSSErrorReporter);
|
||||||
|
|
||||||
impl ParseErrorReporter for CSSErrorReporter {
|
impl ParseErrorReporter for CSSErrorReporter {
|
||||||
fn report_error(&self, url: &ServoUrl, location: SourceLocation, error: ContextualParseError) {
|
fn report_error(
|
||||||
|
&self,
|
||||||
|
url: &UrlExtraData,
|
||||||
|
location: SourceLocation,
|
||||||
|
error: ContextualParseError,
|
||||||
|
) {
|
||||||
if log_enabled!(log::Level::Info) {
|
if log_enabled!(log::Level::Info) {
|
||||||
info!(
|
info!(
|
||||||
"Url:\t{}\n{}:{} {}",
|
"Url:\t{}\n{}:{} {}",
|
||||||
url.as_str(),
|
url.0.as_str(),
|
||||||
location.line,
|
location.line,
|
||||||
location.column,
|
location.column,
|
||||||
error
|
error
|
||||||
|
@ -2844,7 +2849,7 @@ impl ParseErrorReporter for CSSErrorReporter {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.send(ConstellationControlMsg::ReportCSSError(
|
.send(ConstellationControlMsg::ReportCSSError(
|
||||||
self.pipelineid,
|
self.pipelineid,
|
||||||
url.to_string(),
|
url.0.to_string(),
|
||||||
location.line,
|
location.line,
|
||||||
location.column,
|
location.column,
|
||||||
error.to_string(),
|
error.to_string(),
|
||||||
|
|
|
@ -25,7 +25,7 @@ use style::shared_lock::{Locked, SharedRwLock};
|
||||||
use style::stylesheets::import_rule::{ImportLayer, ImportSheet, ImportSupportsCondition};
|
use style::stylesheets::import_rule::{ImportLayer, ImportSheet, ImportSupportsCondition};
|
||||||
use style::stylesheets::{
|
use style::stylesheets::{
|
||||||
CssRules, ImportRule, Origin, Stylesheet, StylesheetContents,
|
CssRules, ImportRule, Origin, Stylesheet, StylesheetContents,
|
||||||
StylesheetLoader as StyleStylesheetLoader,
|
StylesheetLoader as StyleStylesheetLoader, UrlExtraData,
|
||||||
};
|
};
|
||||||
use style::values::CssUrl;
|
use style::values::CssUrl;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ impl FetchResponseListener for StylesheetContext {
|
||||||
let shared_lock = document.style_shared_lock().clone();
|
let shared_lock = document.style_shared_lock().clone();
|
||||||
let sheet = Arc::new(Stylesheet::from_bytes(
|
let sheet = Arc::new(Stylesheet::from_bytes(
|
||||||
&data,
|
&data,
|
||||||
final_url,
|
UrlExtraData(final_url.get_arc()),
|
||||||
protocol_encoding_label,
|
protocol_encoding_label,
|
||||||
Some(environment_encoding),
|
Some(environment_encoding),
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
|
@ -183,7 +183,7 @@ impl FetchResponseListener for StylesheetContext {
|
||||||
&data,
|
&data,
|
||||||
protocol_encoding_label,
|
protocol_encoding_label,
|
||||||
Some(environment_encoding),
|
Some(environment_encoding),
|
||||||
final_url,
|
UrlExtraData(final_url.get_arc()),
|
||||||
Some(&loader),
|
Some(&loader),
|
||||||
win.css_error_reporter(),
|
win.css_error_reporter(),
|
||||||
);
|
);
|
||||||
|
@ -404,7 +404,7 @@ impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> {
|
||||||
// TODO (mrnayak) : Whether we should use the original loader's CORS
|
// TODO (mrnayak) : Whether we should use the original loader's CORS
|
||||||
// setting? Fix this when spec has more details.
|
// setting? Fix this when spec has more details.
|
||||||
let source = StylesheetContextSource::Import(sheet.clone());
|
let source = StylesheetContextSource::Import(sheet.clone());
|
||||||
self.load(source, url, None, "".to_owned());
|
self.load(source, url.into(), None, "".to_owned());
|
||||||
|
|
||||||
Arc::new(lock.wrap(import))
|
Arc::new(lock.wrap(import))
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ servo = [
|
||||||
"cssparser/serde",
|
"cssparser/serde",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"malloc_size_of/servo",
|
"malloc_size_of/servo",
|
||||||
"servo_url",
|
|
||||||
"string_cache",
|
"string_cache",
|
||||||
"to_shmem/servo",
|
"to_shmem/servo",
|
||||||
"servo_arc/servo",
|
"servo_arc/servo",
|
||||||
|
"url",
|
||||||
]
|
]
|
||||||
gecko_debug = []
|
gecko_debug = []
|
||||||
gecko_refcount_logging = []
|
gecko_refcount_logging = []
|
||||||
|
@ -69,7 +69,6 @@ serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
servo_arc = { path = "../servo_arc" }
|
servo_arc = { path = "../servo_arc" }
|
||||||
servo_atoms = { path = "../atoms", optional = true }
|
servo_atoms = { path = "../atoms", optional = true }
|
||||||
servo_config = { path = "../config", optional = true }
|
servo_config = { path = "../config", optional = true }
|
||||||
servo_url = { path = "../url", optional = true }
|
|
||||||
smallbitvec = "2.3.0"
|
smallbitvec = "2.3.0"
|
||||||
smallvec = "1.0"
|
smallvec = "1.0"
|
||||||
static_assertions = "1.1"
|
static_assertions = "1.1"
|
||||||
|
@ -81,6 +80,7 @@ time = "0.1"
|
||||||
thin-vec = { workspace = true }
|
thin-vec = { workspace = true }
|
||||||
to_shmem = { path = "../to_shmem" }
|
to_shmem = { path = "../to_shmem" }
|
||||||
to_shmem_derive = { path = "../to_shmem_derive" }
|
to_shmem_derive = { path = "../to_shmem_derive" }
|
||||||
|
url = { workspace = true, optional = true, features = ["serde"] }
|
||||||
uluru = "3.0"
|
uluru = "3.0"
|
||||||
unicode-bidi = "0.3"
|
unicode-bidi = "0.3"
|
||||||
unicode-segmentation = "1.0"
|
unicode-segmentation = "1.0"
|
||||||
|
|
|
@ -20,7 +20,6 @@ use euclid::num::Zero;
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
use selectors::attr::AttrSelectorOperation;
|
use selectors::attr::AttrSelectorOperation;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
// Duplicated from script::dom::values.
|
// Duplicated from script::dom::values.
|
||||||
|
@ -51,7 +50,10 @@ pub enum AttrValue {
|
||||||
///
|
///
|
||||||
/// The URL is resolved at setting-time, so this kind of attribute value is
|
/// The URL is resolved at setting-time, so this kind of attribute value is
|
||||||
/// not actually suitable for most URL-reflecting IDL attributes.
|
/// not actually suitable for most URL-reflecting IDL attributes.
|
||||||
ResolvedUrl(String, Option<ServoUrl>),
|
ResolvedUrl(
|
||||||
|
String,
|
||||||
|
#[ignore_malloc_size_of = "Arc"] Option<Arc<url::Url>>
|
||||||
|
),
|
||||||
|
|
||||||
/// Note that this variant is only used transitively as a fast path to set
|
/// Note that this variant is only used transitively as a fast path to set
|
||||||
/// the property declaration block relevant to the style of an element when
|
/// the property declaration block relevant to the style of an element when
|
||||||
|
@ -243,8 +245,8 @@ impl AttrValue {
|
||||||
AttrValue::Atom(value)
|
AttrValue::Atom(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_resolved_url(base: &ServoUrl, url: String) -> AttrValue {
|
pub fn from_resolved_url(base: &Arc<::url::Url>, url: String) -> AttrValue {
|
||||||
let joined = base.join(&url).ok();
|
let joined = base.join(&url).ok().map(Arc::new);
|
||||||
AttrValue::ResolvedUrl(url, joined)
|
AttrValue::ResolvedUrl(url, joined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +318,7 @@ impl AttrValue {
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// Panics if the `AttrValue` is not a `ResolvedUrl`
|
/// Panics if the `AttrValue` is not a `ResolvedUrl`
|
||||||
pub fn as_resolved_url(&self) -> Option<&ServoUrl> {
|
pub fn as_resolved_url(&self) -> Option<&Arc<::url::Url>> {
|
||||||
match *self {
|
match *self {
|
||||||
AttrValue::ResolvedUrl(_, ref url) => url.as_ref(),
|
AttrValue::ResolvedUrl(_, ref url) => url.as_ref(),
|
||||||
_ => panic!("Url not found"),
|
_ => panic!("Url not found"),
|
||||||
|
|
|
@ -9,9 +9,10 @@ use crate::stylesheets::CorsMode;
|
||||||
use crate::values::computed::{Context, ToComputedValue};
|
use crate::values::computed::{Context, ToComputedValue};
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ParseError, ToCss};
|
use style_traits::{CssWriter, ParseError, ToCss};
|
||||||
|
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
/// A CSS url() value for servo.
|
/// A CSS url() value for servo.
|
||||||
///
|
///
|
||||||
|
@ -24,7 +25,7 @@ use style_traits::{CssWriter, ParseError, ToCss};
|
||||||
///
|
///
|
||||||
/// TODO(emilio): This should be shrunk by making CssUrl a wrapper type of an
|
/// TODO(emilio): This should be shrunk by making CssUrl a wrapper type of an
|
||||||
/// arc, and keep the serialization in that Arc. See gecko/url.rs for example.
|
/// arc, and keep the serialization in that Arc. See gecko/url.rs for example.
|
||||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, SpecifiedValueInfo, ToShmem)]
|
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, SpecifiedValueInfo)]
|
||||||
pub struct CssUrl {
|
pub struct CssUrl {
|
||||||
/// The original URI. This might be optional since we may insert computed
|
/// The original URI. This might be optional since we may insert computed
|
||||||
/// values of images into the cascade directly, and we don't bother to
|
/// values of images into the cascade directly, and we don't bother to
|
||||||
|
@ -36,7 +37,14 @@ pub struct CssUrl {
|
||||||
original: Option<Arc<String>>,
|
original: Option<Arc<String>>,
|
||||||
|
|
||||||
/// The resolved value for the url, if valid.
|
/// The resolved value for the url, if valid.
|
||||||
resolved: Option<ServoUrl>,
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
|
resolved: Option<Arc<Url>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToShmem for CssUrl {
|
||||||
|
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> to_shmem::Result<Self> {
|
||||||
|
unimplemented!("If servo wants to share stylesheets across processes, ToShmem for Url must be implemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CssUrl {
|
impl CssUrl {
|
||||||
|
@ -46,7 +54,7 @@ impl CssUrl {
|
||||||
/// FIXME(emilio): Should honor CorsMode.
|
/// FIXME(emilio): Should honor CorsMode.
|
||||||
pub fn parse_from_string(url: String, context: &ParserContext, _: CorsMode) -> Self {
|
pub fn parse_from_string(url: String, context: &ParserContext, _: CorsMode) -> Self {
|
||||||
let serialization = Arc::new(url);
|
let serialization = Arc::new(url);
|
||||||
let resolved = context.url_data.join(&serialization).ok();
|
let resolved = context.url_data.0.join(&serialization).ok().map(Arc::new);
|
||||||
CssUrl {
|
CssUrl {
|
||||||
original: Some(serialization),
|
original: Some(serialization),
|
||||||
resolved: resolved,
|
resolved: resolved,
|
||||||
|
@ -71,7 +79,7 @@ impl CssUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the resolved url if it was valid.
|
/// Returns the resolved url if it was valid.
|
||||||
pub fn url(&self) -> Option<&ServoUrl> {
|
pub fn url(&self) -> Option<&Arc<Url>> {
|
||||||
self.resolved.as_ref()
|
self.resolved.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +95,7 @@ impl CssUrl {
|
||||||
|
|
||||||
/// Creates an already specified url value from an already resolved URL
|
/// Creates an already specified url value from an already resolved URL
|
||||||
/// for insertion in the cascade.
|
/// for insertion in the cascade.
|
||||||
pub fn for_cascade(url: ServoUrl) -> Self {
|
pub fn for_cascade(url: Arc<::url::Url>) -> Self {
|
||||||
CssUrl {
|
CssUrl {
|
||||||
original: None,
|
original: None,
|
||||||
resolved: Some(url),
|
resolved: Some(url),
|
||||||
|
@ -98,7 +106,7 @@ impl CssUrl {
|
||||||
pub fn new_for_testing(url: &str) -> Self {
|
pub fn new_for_testing(url: &str) -> Self {
|
||||||
CssUrl {
|
CssUrl {
|
||||||
original: Some(Arc::new(url.into())),
|
original: Some(Arc::new(url.into())),
|
||||||
resolved: ServoUrl::parse(url).ok(),
|
resolved: ::url::Url::parse(url).ok().map(Arc::new),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,12 +213,12 @@ pub enum ComputedUrl {
|
||||||
/// The `url()` was invalid or it wasn't specified by the user.
|
/// The `url()` was invalid or it wasn't specified by the user.
|
||||||
Invalid(#[ignore_malloc_size_of = "Arc"] Arc<String>),
|
Invalid(#[ignore_malloc_size_of = "Arc"] Arc<String>),
|
||||||
/// The resolved `url()` relative to the stylesheet URL.
|
/// The resolved `url()` relative to the stylesheet URL.
|
||||||
Valid(ServoUrl),
|
Valid(#[ignore_malloc_size_of = "Arc"] Arc<Url>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputedUrl {
|
impl ComputedUrl {
|
||||||
/// Returns the resolved url if it was valid.
|
/// Returns the resolved url if it was valid.
|
||||||
pub fn url(&self) -> Option<&ServoUrl> {
|
pub fn url(&self) -> Option<&Arc<Url>> {
|
||||||
match *self {
|
match *self {
|
||||||
ComputedUrl::Valid(ref url) => Some(url),
|
ComputedUrl::Valid(ref url) => Some(url),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -43,7 +43,6 @@ use std::fmt;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use std::mem::{self, ManuallyDrop};
|
use std::mem::{self, ManuallyDrop};
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
use to_shmem::{self, SharedMemoryBuilder, ToShmem};
|
use to_shmem::{self, SharedMemoryBuilder, ToShmem};
|
||||||
|
|
||||||
pub use self::container_rule::ContainerRule;
|
pub use self::container_rule::ContainerRule;
|
||||||
|
@ -102,8 +101,36 @@ pub enum CorsMode {
|
||||||
pub struct UrlExtraData(usize);
|
pub struct UrlExtraData(usize);
|
||||||
|
|
||||||
/// Extra data that the backend may need to resolve url values.
|
/// Extra data that the backend may need to resolve url values.
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct UrlExtraData(pub Arc<::url::Url>);
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
impl UrlExtraData {
|
||||||
|
/// True if this URL scheme is chrome.
|
||||||
|
pub fn chrome_rules_enabled(&self) -> bool {
|
||||||
|
self.0.scheme() == "chrome"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the interior Url as a string.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.0.as_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
impl From<::url::Url> for UrlExtraData {
|
||||||
|
fn from(url: ::url::Url) -> Self {
|
||||||
|
Self(Arc::new(url))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
pub type UrlExtraData = ::servo_url::ServoUrl;
|
impl ToShmem for UrlExtraData {
|
||||||
|
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> to_shmem::Result<Self> {
|
||||||
|
unimplemented!("If servo wants to share stylesheets across processes, ToShmem for Url must be implemented");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl Clone for UrlExtraData {
|
impl Clone for UrlExtraData {
|
||||||
|
|
|
@ -27,8 +27,6 @@ use crate::values::specified::{Number, NumberOrPercentage, Percentage};
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use cssparser::{Delimiter, Parser, Token};
|
use cssparser::{Delimiter, Parser, Token};
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError};
|
use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError};
|
||||||
|
@ -260,7 +258,7 @@ impl Image {
|
||||||
/// Creates an already specified image value from an already resolved URL
|
/// Creates an already specified image value from an already resolved URL
|
||||||
/// for insertion in the cascade.
|
/// for insertion in the cascade.
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub fn for_cascade(url: ServoUrl) -> Self {
|
pub fn for_cascade(url: ::servo_arc::Arc<::url::Url>) -> Self {
|
||||||
use crate::values::CssUrl;
|
use crate::values::CssUrl;
|
||||||
generic::Image::Url(CssUrl::for_cascade(url))
|
generic::Image::Url(CssUrl::for_cascade(url))
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ name = "style_traits"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
servo = ["servo_atoms", "cssparser/serde", "webrender_api", "servo_url", "euclid/serde"]
|
servo = ["servo_atoms", "cssparser/serde", "webrender_api", "url", "euclid/serde"]
|
||||||
gecko = []
|
gecko = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -26,8 +26,8 @@ selectors = { path = "../selectors", features = ["shmem"] }
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
servo_arc = { path = "../servo_arc" }
|
servo_arc = { path = "../servo_arc" }
|
||||||
servo_atoms = { path = "../atoms", optional = true }
|
servo_atoms = { path = "../atoms", optional = true }
|
||||||
servo_url = { path = "../url", optional = true }
|
|
||||||
size_of_test = { path = "../size_of_test" }
|
size_of_test = { path = "../size_of_test" }
|
||||||
to_shmem = { path = "../to_shmem" }
|
to_shmem = { path = "../to_shmem" }
|
||||||
to_shmem_derive = { path = "../to_shmem_derive" }
|
to_shmem_derive = { path = "../to_shmem_derive" }
|
||||||
|
url = { workspace = true, optional = true }
|
||||||
webrender_api = { workspace = true, optional = true }
|
webrender_api = { workspace = true, optional = true }
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl SpecifiedValueInfo for crate::owned_str::OwnedStr {}
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
impl SpecifiedValueInfo for ::servo_atoms::Atom {}
|
impl SpecifiedValueInfo for ::servo_atoms::Atom {}
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
impl SpecifiedValueInfo for ::servo_url::ServoUrl {}
|
impl SpecifiedValueInfo for ::url::Url {}
|
||||||
|
|
||||||
impl<T: SpecifiedValueInfo + ?Sized> SpecifiedValueInfo for Box<T> {
|
impl<T: SpecifiedValueInfo + ?Sized> SpecifiedValueInfo for Box<T> {
|
||||||
const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES;
|
const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES;
|
||||||
|
|
|
@ -14,6 +14,7 @@ path = "lib.rs"
|
||||||
malloc_size_of = { path = "../malloc_size_of", features = ["servo"] }
|
malloc_size_of = { path = "../malloc_size_of", features = ["servo"] }
|
||||||
malloc_size_of_derive = { workspace = true }
|
malloc_size_of_derive = { workspace = true }
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
|
servo_arc = { path = "../servo_arc" }
|
||||||
servo_rand = { path = "../rand" }
|
servo_rand = { path = "../rand" }
|
||||||
to_shmem = { path = "../to_shmem" }
|
to_shmem = { path = "../to_shmem" }
|
||||||
url = { workspace = true, features = ["serde"] }
|
url = { workspace = true, features = ["serde"] }
|
||||||
|
|
|
@ -14,10 +14,10 @@ use std::hash::Hasher;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo};
|
use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use servo_arc::Arc;
|
||||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||||
pub use url::Host;
|
pub use url::Host;
|
||||||
use url::{Position, Url};
|
use url::{Position, Url};
|
||||||
|
@ -46,11 +46,15 @@ impl ServoUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_string(self) -> String {
|
pub fn into_string(self) -> String {
|
||||||
String::from(Arc::try_unwrap(self.0).unwrap_or_else(|s| (*s).clone()))
|
String::from(self.into_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_url(self) -> Url {
|
pub fn into_url(self) -> Url {
|
||||||
Arc::try_unwrap(self.0).unwrap_or_else(|s| (*s).clone())
|
self.as_url().clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_arc(&self) -> Arc<Url> {
|
||||||
|
self.0.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_url(&self) -> &Url {
|
pub fn as_url(&self) -> &Url {
|
||||||
|
@ -96,14 +100,6 @@ impl ServoUrl {
|
||||||
scheme == "about" || scheme == "blob" || scheme == "data"
|
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
self.0.as_str()
|
self.0.as_str()
|
||||||
}
|
}
|
||||||
|
@ -298,3 +294,9 @@ impl From<Url> for ServoUrl {
|
||||||
ServoUrl::from_url(url)
|
ServoUrl::from_url(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Arc<Url>> for ServoUrl {
|
||||||
|
fn from(url: Arc<Url>) -> Self {
|
||||||
|
ServoUrl(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@ selectors = {path = "../../../components/selectors", features = ["shmem"] }
|
||||||
servo_arc = {path = "../../../components/servo_arc"}
|
servo_arc = {path = "../../../components/servo_arc"}
|
||||||
servo_atoms = {path = "../../../components/atoms"}
|
servo_atoms = {path = "../../../components/atoms"}
|
||||||
servo_config = {path = "../../../components/config"}
|
servo_config = {path = "../../../components/config"}
|
||||||
servo_url = {path = "../../../components/url"}
|
|
||||||
style = {path = "../../../components/style", features = ["servo"]}
|
style = {path = "../../../components/style", features = ["servo"]}
|
||||||
style_traits = {path = "../../../components/style_traits"}
|
style_traits = {path = "../../../components/style_traits"}
|
||||||
|
url = { workspace = true }
|
||||||
|
|
|
@ -15,10 +15,10 @@ extern crate selectors;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate servo_arc;
|
extern crate servo_arc;
|
||||||
extern crate servo_atoms;
|
extern crate servo_atoms;
|
||||||
extern crate servo_url;
|
|
||||||
extern crate style;
|
extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
extern crate url;
|
||||||
|
|
||||||
mod animated_properties;
|
mod animated_properties;
|
||||||
mod attr;
|
mod attr;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use style::context::QuirksMode;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style_traits::{ParseError, ParsingMode};
|
use style_traits::{ParseError, ParsingMode};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
fn parse<T, F>(f: F, s: &'static str) -> Result<T, ParseError<'static>>
|
fn parse<T, F>(f: F, s: &'static str) -> Result<T, ParseError<'static>>
|
||||||
where
|
where
|
||||||
|
@ -22,10 +23,10 @@ fn parse_input<'i: 't, 't, T, F>(f: F, input: &'t mut ParserInput<'i>) -> Result
|
||||||
where
|
where
|
||||||
F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>,
|
F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>,
|
||||||
{
|
{
|
||||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
let url_data = Url::parse("http://localhost").unwrap().into();
|
||||||
let context = ParserContext::new(
|
let context = ParserContext::new(
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
&url,
|
&url_data,
|
||||||
Some(CssRuleType::Style),
|
Some(CssRuleType::Style),
|
||||||
ParsingMode::DEFAULT,
|
ParsingMode::DEFAULT,
|
||||||
QuirksMode::NoQuirks,
|
QuirksMode::NoQuirks,
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
use cssparser::{Parser, ParserInput, ToCss};
|
use cssparser::{Parser, ParserInput, ToCss};
|
||||||
use selectors::parser::SelectorList;
|
use selectors::parser::SelectorList;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use style::selector_parser::{SelectorImpl, SelectorParser};
|
use style::selector_parser::{SelectorImpl, SelectorParser};
|
||||||
use style::stylesheets::{Namespaces, Origin};
|
use style::stylesheets::{Namespaces, Origin};
|
||||||
use style_traits::ParseError;
|
use style_traits::ParseError;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
fn parse_selector<'i, 't>(
|
fn parse_selector<'i, 't>(
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
|
@ -15,11 +15,11 @@ fn parse_selector<'i, 't>(
|
||||||
let mut ns = Namespaces::default();
|
let mut ns = Namespaces::default();
|
||||||
ns.prefixes
|
ns.prefixes
|
||||||
.insert("svg".into(), style::Namespace::new(ns!(svg)));
|
.insert("svg".into(), style::Namespace::new(ns!(svg)));
|
||||||
let dummy_url = ServoUrl::parse("about:blank").unwrap();
|
let dummy_url_data = Url::parse("about:blank").unwrap().into();
|
||||||
let parser = SelectorParser {
|
let parser = SelectorParser {
|
||||||
stylesheet_origin: Origin::UserAgent,
|
stylesheet_origin: Origin::UserAgent,
|
||||||
namespaces: &ns,
|
namespaces: &ns,
|
||||||
url_data: &dummy_url,
|
url_data: &dummy_url_data,
|
||||||
for_supports_rule: false,
|
for_supports_rule: false,
|
||||||
};
|
};
|
||||||
SelectorList::parse(&parser, input)
|
SelectorList::parse(&parser, input)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use cssparser::SourceLocation;
|
use cssparser::SourceLocation;
|
||||||
use rayon;
|
use rayon;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use style::applicable_declarations::CascadePriority;
|
use style::applicable_declarations::CascadePriority;
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||||
|
@ -14,13 +13,19 @@ use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDecl
|
||||||
use style::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
|
use style::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
|
||||||
use style::shared_lock::{SharedRwLock, StylesheetGuards};
|
use style::shared_lock::{SharedRwLock, StylesheetGuards};
|
||||||
use style::stylesheets::layer_rule::LayerOrder;
|
use style::stylesheets::layer_rule::LayerOrder;
|
||||||
use style::stylesheets::{AllowImportRules, CssRule, Origin, Stylesheet};
|
use style::stylesheets::{AllowImportRules, CssRule, Origin, Stylesheet, UrlExtraData};
|
||||||
use style::thread_state::{self, ThreadState};
|
use style::thread_state::{self, ThreadState};
|
||||||
use test::{self, Bencher};
|
use test::{self, Bencher};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
struct ErrorringErrorReporter;
|
struct ErrorringErrorReporter;
|
||||||
impl ParseErrorReporter for ErrorringErrorReporter {
|
impl ParseErrorReporter for ErrorringErrorReporter {
|
||||||
fn report_error(&self, url: &ServoUrl, location: SourceLocation, error: ContextualParseError) {
|
fn report_error(
|
||||||
|
&self,
|
||||||
|
url: &UrlExtraData,
|
||||||
|
location: SourceLocation,
|
||||||
|
error: ContextualParseError,
|
||||||
|
) {
|
||||||
panic!(
|
panic!(
|
||||||
"CSS error: {}\t\n{}:{} {}",
|
"CSS error: {}\t\n{}:{} {}",
|
||||||
url.as_str(),
|
url.as_str(),
|
||||||
|
@ -59,9 +64,10 @@ impl<'a> Drop for AutoGCRuleTree<'a> {
|
||||||
fn parse_rules(lock: &SharedRwLock, css: &str) -> Vec<(StyleSource, CascadeLevel)> {
|
fn parse_rules(lock: &SharedRwLock, css: &str) -> Vec<(StyleSource, CascadeLevel)> {
|
||||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||||
|
|
||||||
|
let url_data = Url::parse("http://localhost").unwrap().into();
|
||||||
let s = Stylesheet::from_str(
|
let s = Stylesheet::from_str(
|
||||||
css,
|
css,
|
||||||
ServoUrl::parse("http://localhost").unwrap(),
|
url_data,
|
||||||
Origin::Author,
|
Origin::Author,
|
||||||
media,
|
media,
|
||||||
lock.clone(),
|
lock.clone(),
|
||||||
|
|
|
@ -6,16 +6,16 @@ use std::cell::RefCell;
|
||||||
|
|
||||||
use cssparser::SourceLocation;
|
use cssparser::SourceLocation;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::shared_lock::SharedRwLock;
|
use style::shared_lock::SharedRwLock;
|
||||||
use style::stylesheets::{AllowImportRules, Origin, Stylesheet};
|
use style::stylesheets::{AllowImportRules, Origin, Stylesheet, UrlExtraData};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct CSSError {
|
struct CSSError {
|
||||||
pub url: ServoUrl,
|
pub url: Arc<Url>,
|
||||||
pub line: u32,
|
pub line: u32,
|
||||||
pub column: u32,
|
pub column: u32,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
@ -60,9 +60,14 @@ impl TestingErrorReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParseErrorReporter for TestingErrorReporter {
|
impl ParseErrorReporter for TestingErrorReporter {
|
||||||
fn report_error(&self, url: &ServoUrl, location: SourceLocation, error: ContextualParseError) {
|
fn report_error(
|
||||||
|
&self,
|
||||||
|
url: &UrlExtraData,
|
||||||
|
location: SourceLocation,
|
||||||
|
error: ContextualParseError,
|
||||||
|
) {
|
||||||
self.errors.borrow_mut().push(CSSError {
|
self.errors.borrow_mut().push(CSSError {
|
||||||
url: url.clone(),
|
url: url.0.clone(),
|
||||||
line: location.line,
|
line: location.line,
|
||||||
column: location.column,
|
column: location.column,
|
||||||
message: error.to_string(),
|
message: error.to_string(),
|
||||||
|
@ -88,14 +93,14 @@ fn test_report_error_stylesheet() {
|
||||||
@supports (color: green) and invalid and (margin: 0) {}
|
@supports (color: green) and invalid and (margin: 0) {}
|
||||||
@keyframes foo { from invalid {} to { margin: 0 invalid 0; } }
|
@keyframes foo { from invalid {} to { margin: 0 invalid 0; } }
|
||||||
";
|
";
|
||||||
let url = ServoUrl::parse("about::test").unwrap();
|
let url = Url::parse("about::test").unwrap();
|
||||||
let error_reporter = TestingErrorReporter::new();
|
let error_reporter = TestingErrorReporter::new();
|
||||||
|
|
||||||
let lock = SharedRwLock::new();
|
let lock = SharedRwLock::new();
|
||||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||||
Stylesheet::from_str(
|
Stylesheet::from_str(
|
||||||
css,
|
css,
|
||||||
url.clone(),
|
url.clone().into(),
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
media,
|
media,
|
||||||
lock,
|
lock,
|
||||||
|
@ -134,7 +139,7 @@ fn test_report_error_stylesheet() {
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert_eq!(error_reporter.errors.borrow()[0].url, url);
|
assert_eq!(*error_reporter.errors.borrow()[0].url, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -146,14 +151,14 @@ fn test_no_report_unrecognized_vendor_properties() {
|
||||||
-moz-background-color: red;
|
-moz-background-color: red;
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
let url = ServoUrl::parse("about::test").unwrap();
|
let url = Url::parse("about::test").unwrap();
|
||||||
let error_reporter = TestingErrorReporter::new();
|
let error_reporter = TestingErrorReporter::new();
|
||||||
|
|
||||||
let lock = SharedRwLock::new();
|
let lock = SharedRwLock::new();
|
||||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||||
Stylesheet::from_str(
|
Stylesheet::from_str(
|
||||||
css,
|
css,
|
||||||
url,
|
url.into(),
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
media,
|
media,
|
||||||
lock,
|
lock,
|
||||||
|
@ -182,12 +187,12 @@ fn test_source_map_url() {
|
||||||
];
|
];
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
let url = ServoUrl::parse("about::test").unwrap();
|
let url = Url::parse("about::test").unwrap();
|
||||||
let lock = SharedRwLock::new();
|
let lock = SharedRwLock::new();
|
||||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||||
let stylesheet = Stylesheet::from_str(
|
let stylesheet = Stylesheet::from_str(
|
||||||
test.0,
|
test.0,
|
||||||
url.clone(),
|
url.into(),
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
media,
|
media,
|
||||||
lock,
|
lock,
|
||||||
|
@ -210,12 +215,12 @@ fn test_source_url() {
|
||||||
];
|
];
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
let url = ServoUrl::parse("about::test").unwrap();
|
let url = Url::parse("about::test").unwrap();
|
||||||
let lock = SharedRwLock::new();
|
let lock = SharedRwLock::new();
|
||||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||||
let stylesheet = Stylesheet::from_str(
|
let stylesheet = Stylesheet::from_str(
|
||||||
test.0,
|
test.0,
|
||||||
url.clone(),
|
url.into(),
|
||||||
Origin::UserAgent,
|
Origin::UserAgent,
|
||||||
media,
|
media,
|
||||||
lock,
|
lock,
|
||||||
|
|
|
@ -7,7 +7,6 @@ use euclid::{Scale, Size2D};
|
||||||
use selectors::parser::{AncestorHashes, Selector};
|
use selectors::parser::{AncestorHashes, Selector};
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use servo_url::ServoUrl;
|
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
use style::media_queries::{Device, MediaType};
|
use style::media_queries::{Device, MediaType};
|
||||||
use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
||||||
|
@ -19,11 +18,12 @@ use style::stylist::{
|
||||||
needs_revalidation_for_testing, ContainerConditionId, LayerId, Rule, Stylist,
|
needs_revalidation_for_testing, ContainerConditionId, LayerId, Rule, Stylist,
|
||||||
};
|
};
|
||||||
use style::thread_state::{self, ThreadState};
|
use style::thread_state::{self, ThreadState};
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
/// Helper method to get some Rules from selector strings.
|
/// Helper method to get some Rules from selector strings.
|
||||||
/// Each sublist of the result contains the Rules for one StyleRule.
|
/// Each sublist of the result contains the Rules for one StyleRule.
|
||||||
fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
||||||
let dummy_url = &ServoUrl::parse("about:blank").unwrap();
|
let dummy_url_data = Url::parse("about:blank").unwrap().into();
|
||||||
let shared_lock = SharedRwLock::new();
|
let shared_lock = SharedRwLock::new();
|
||||||
(
|
(
|
||||||
css_selectors
|
css_selectors
|
||||||
|
@ -31,7 +31,8 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, selectors)| {
|
.map(|(i, selectors)| {
|
||||||
let selectors =
|
let selectors =
|
||||||
SelectorParser::parse_author_origin_no_namespace(selectors, dummy_url).unwrap();
|
SelectorParser::parse_author_origin_no_namespace(selectors, &dummy_url_data)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let locked = Arc::new(shared_lock.wrap(StyleRule {
|
let locked = Arc::new(shared_lock.wrap(StyleRule {
|
||||||
selectors: selectors,
|
selectors: selectors,
|
||||||
|
@ -66,11 +67,11 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_selectors(selectors: &[&str]) -> Vec<Selector<SelectorImpl>> {
|
fn parse_selectors(selectors: &[&str]) -> Vec<Selector<SelectorImpl>> {
|
||||||
let dummy_url = &ServoUrl::parse("about:blank").unwrap();
|
let dummy_url_data = Url::parse("about:blank").unwrap().into();
|
||||||
selectors
|
selectors
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
SelectorParser::parse_author_origin_no_namespace(x, dummy_url)
|
SelectorParser::parse_author_origin_no_namespace(x, &dummy_url_data)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.0
|
.0
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue