diff --git a/servo/components/style/gecko/url.rs b/servo/components/style/gecko/url.rs index f8d0f4ec72e66e58159fbf1c1afb159b6c13285b..3a53f639afeebfece0f8c3f601de903c50ffa008 100644 --- a/servo/components/style/gecko/url.rs +++ b/servo/components/style/gecko/url.rs @@ -260,12 +260,8 @@ pub struct SpecifiedImageUrl(pub SpecifiedUrl); impl SpecifiedImageUrl { /// Parse a URL from a string value that is a valid CSS token for a URL. - pub fn parse_from_string(url: String, context: &ParserContext) -> Self { - SpecifiedImageUrl(SpecifiedUrl::parse_from_string( - url, - context, - CorsMode::None, - )) + pub fn parse_from_string(url: String, context: &ParserContext, cors_mode: CorsMode) -> Self { + SpecifiedImageUrl(SpecifiedUrl::parse_from_string(url, context, cors_mode)) } /// Provides an alternate method for parsing that associates the URL diff --git a/servo/components/style/servo/url.rs b/servo/components/style/servo/url.rs index fd7726289be37d29dd5b5e7600c80f029221e132..8e011796e79acef4f5006f64b2bac269effbb88d 100644 --- a/servo/components/style/servo/url.rs +++ b/servo/components/style/servo/url.rs @@ -5,14 +5,12 @@ //! Common handling for the specified value CSS url() values. use crate::parser::{Parse, ParserContext}; +use crate::stylesheets::CorsMode; +use crate::values::computed::{Context, ToComputedValue}; use cssparser::Parser; +use servo_arc::Arc; use servo_url::ServoUrl; use std::fmt::{self, Write}; -// Note: We use std::sync::Arc rather than servo_arc::Arc here because the -// nonzero optimization is important in keeping the size of SpecifiedUrl below -// the threshold. -use crate::values::computed::{Context, ToComputedValue}; -use servo_arc::Arc; use style_traits::{CssWriter, ParseError, ToCss}; /// A CSS url() value for servo. @@ -44,7 +42,9 @@ pub struct CssUrl { impl CssUrl { /// Try to parse a URL from a string value that is a valid CSS token for a /// URL. - pub fn parse_from_string(url: String, context: &ParserContext) -> Self { + /// + /// FIXME(emilio): Should honor CorsMode. + pub fn parse_from_string(url: String, context: &ParserContext, _: CorsMode) -> Self { let serialization = Arc::new(url); let resolved = context.url_data.join(&serialization).ok(); CssUrl { @@ -121,7 +121,11 @@ impl Parse for CssUrl { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let url = input.expect_url()?; - Ok(Self::parse_from_string(url.as_ref().to_owned(), context)) + Ok(Self::parse_from_string( + url.as_ref().to_owned(), + context, + CorsMode::None, + )) } } diff --git a/servo/components/style/shared_lock.rs b/servo/components/style/shared_lock.rs index a29d97a98141b2a8c9b2f1c7a0d40b518c470c9a..d46370952d392ddd97679f5314aaeb1528dce1f2 100644 --- a/servo/components/style/shared_lock.rs +++ b/servo/components/style/shared_lock.rs @@ -71,6 +71,14 @@ impl SharedRwLock { } } + /// Create a new global shared lock (servo). + #[cfg(feature = "servo")] + pub fn new_leaked() -> Self { + SharedRwLock { + arc: Arc::new_leaked(RwLock::new(())), + } + } + /// Create a new global shared lock (gecko). #[cfg(feature = "gecko")] pub fn new_leaked() -> Self { diff --git a/servo/components/style/values/specified/image.rs b/servo/components/style/values/specified/image.rs index ad2ecb180869b07c6b65475239039384b0961a6c..ca7f687bfeaefae86b394489b0912e45748efe0c 100644 --- a/servo/components/style/values/specified/image.rs +++ b/servo/components/style/values/specified/image.rs @@ -11,6 +11,7 @@ use crate::custom_properties::SpecifiedValue; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs; use crate::parser::{Parse, ParserContext}; +use crate::stylesheets::CorsMode; #[cfg(feature = "gecko")] use crate::values::computed::{Context, Position as ComputedPosition, ToComputedValue}; use crate::values::generics::image::PaintWorklet; @@ -1032,7 +1033,11 @@ impl Parse for MozImageRect { input.try(|i| i.expect_function_matching("-moz-image-rect"))?; input.parse_nested_block(|i| { let string = i.expect_url_or_string()?; - let url = SpecifiedImageUrl::parse_from_string(string.as_ref().to_owned(), context); + let url = SpecifiedImageUrl::parse_from_string( + string.as_ref().to_owned(), + context, + CorsMode::None, + ); i.expect_comma()?; let top = NumberOrPercentage::parse_non_negative(context, i)?; i.expect_comma()?; diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 3dbd7c8b8f1dfcf2f6b4c288b5ea1bd08795bef9..3d811f650a77e7b7736e0b23080f9198b0fe06b8 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -4924,6 +4924,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage( ) { use style::properties::longhands::background_image::SpecifiedValue as BackgroundImage; use style::properties::PropertyDeclaration; + use style::stylesheets::CorsMode; use style::values::generics::image::Image; use style::values::specified::url::SpecifiedImageUrl; use style::values::Either; @@ -4939,7 +4940,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage( None, None, ); - let url = SpecifiedImageUrl::parse_from_string(string.into(), &context); + let url = SpecifiedImageUrl::parse_from_string(string.into(), &context, CorsMode::None); let decl = PropertyDeclaration::BackgroundImage(BackgroundImage(vec![Either::Second( Image::Url(url), )].into()));