mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Create URLExtraData for holding base uri, referrer, and principal.
This commit is contained in:
parent
a31271b07f
commit
0a97a0df0c
9 changed files with 35 additions and 82 deletions
|
@ -367,7 +367,6 @@ mod bindings {
|
|||
"nsCursorImage",
|
||||
"nsFont",
|
||||
"nsIAtom",
|
||||
"nsIURI",
|
||||
"nsMainThreadPtrHandle",
|
||||
"nsMainThreadPtrHolder",
|
||||
"nsMargin",
|
||||
|
@ -604,10 +603,8 @@ mod bindings {
|
|||
"RawGeckoPresContext",
|
||||
"RawGeckoPresContextOwned",
|
||||
"RawGeckoStyleAnimationList",
|
||||
"GeckoParserExtraData",
|
||||
"RawGeckoURLExtraData",
|
||||
"RefPtr",
|
||||
"ThreadSafeURIHolder",
|
||||
"ThreadSafePrincipalHolder",
|
||||
"CSSPseudoClassType",
|
||||
"TraversalRootBehavior",
|
||||
"FontFamilyList",
|
||||
|
@ -630,7 +627,6 @@ mod bindings {
|
|||
"nsCursorImage",
|
||||
"nsFont",
|
||||
"nsIAtom",
|
||||
"nsIURI",
|
||||
"nsMediaFeature",
|
||||
"nsRestyleHint",
|
||||
"nsStyleBackground",
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
//! Common handling for the specified value CSS url() values.
|
||||
|
||||
use cssparser::CssStringWriter;
|
||||
use gecko_bindings::structs::ServoBundledURI;
|
||||
use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
|
||||
use gecko_bindings::sugar::refptr::RefPtr;
|
||||
use parser::ParserContext;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::{self, Write};
|
||||
|
@ -22,12 +22,8 @@ pub struct SpecifiedUrl {
|
|||
/// really large.
|
||||
serialization: Arc<String>,
|
||||
|
||||
/// The base URI.
|
||||
pub base: GeckoArcURI,
|
||||
/// The referrer.
|
||||
pub referrer: GeckoArcURI,
|
||||
/// The principal that originated this URI.
|
||||
pub principal: GeckoArcPrincipal,
|
||||
/// The URL extra data.
|
||||
pub extra_data: RefPtr<URLExtraData>,
|
||||
}
|
||||
|
||||
impl SpecifiedUrl {
|
||||
|
@ -39,7 +35,7 @@ impl SpecifiedUrl {
|
|||
context: &ParserContext)
|
||||
-> Result<Self, ()> {
|
||||
let extra = &context.extra_data;
|
||||
if extra.base.is_none() || extra.referrer.is_none() || extra.principal.is_none() {
|
||||
if extra.data.is_none() {
|
||||
// FIXME(heycam) should ensure we always have a principal, etc.,
|
||||
// when parsing style attributes and re-parsing due to CSS
|
||||
// Variables.
|
||||
|
@ -49,9 +45,7 @@ impl SpecifiedUrl {
|
|||
|
||||
Ok(SpecifiedUrl {
|
||||
serialization: Arc::new(url.into_owned()),
|
||||
base: extra.base.as_ref().unwrap().clone(),
|
||||
referrer: extra.referrer.as_ref().unwrap().clone(),
|
||||
principal: extra.principal.as_ref().unwrap().clone(),
|
||||
extra_data: extra.data.as_ref().unwrap().clone(),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -88,9 +82,7 @@ impl SpecifiedUrl {
|
|||
ServoBundledURI {
|
||||
mURLString: ptr,
|
||||
mURLStringLength: len as u32,
|
||||
mBaseURI: self.base.get(),
|
||||
mReferrer: self.referrer.get(),
|
||||
mPrincipal: self.principal.get(),
|
||||
mExtraData: self.extra_data.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,12 +261,9 @@ macro_rules! impl_threadsafe_refcount {
|
|||
);
|
||||
}
|
||||
|
||||
impl_threadsafe_refcount!(::gecko_bindings::structs::ThreadSafePrincipalHolder,
|
||||
Gecko_AddRefPrincipalArbitraryThread,
|
||||
Gecko_ReleasePrincipalArbitraryThread);
|
||||
impl_threadsafe_refcount!(::gecko_bindings::structs::ThreadSafeURIHolder,
|
||||
Gecko_AddRefURIArbitraryThread,
|
||||
Gecko_ReleaseURIArbitraryThread);
|
||||
impl_threadsafe_refcount!(::gecko_bindings::structs::RawGeckoURLExtraData,
|
||||
Gecko_AddRefURLExtraDataArbitraryThread,
|
||||
Gecko_ReleaseURLExtraDataArbitraryThread);
|
||||
impl_threadsafe_refcount!(::gecko_bindings::structs::nsStyleQuoteValues,
|
||||
Gecko_AddRefQuoteValuesArbitraryThread,
|
||||
Gecko_ReleaseQuoteValuesArbitraryThread);
|
||||
|
@ -276,10 +273,3 @@ impl_threadsafe_refcount!(::gecko_bindings::structs::nsCSSValueSharedList,
|
|||
impl_threadsafe_refcount!(::gecko_bindings::structs::mozilla::css::URLValue,
|
||||
Gecko_AddRefCSSURLValueArbitraryThread,
|
||||
Gecko_ReleaseCSSURLValueArbitraryThread);
|
||||
/// A Gecko `ThreadSafePrincipalHolder` wrapped in a safe refcounted pointer, to
|
||||
/// use during stylesheet parsing and style computation.
|
||||
pub type GeckoArcPrincipal = RefPtr<::gecko_bindings::structs::ThreadSafePrincipalHolder>;
|
||||
|
||||
/// A Gecko `ThreadSafeURIHolder` wrapped in a safe refcounted pointer, to use
|
||||
/// during stylesheet parsing and style computation.
|
||||
pub type GeckoArcURI = RefPtr<::gecko_bindings::structs::ThreadSafeURIHolder>;
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
use cssparser::{Parser, SourcePosition, UnicodeRange};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use gecko_bindings::structs::URLExtraData;
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_bindings::sugar::refptr::RefPtr;
|
||||
use servo_url::ServoUrl;
|
||||
use style_traits::OneOrMoreCommaSeparated;
|
||||
use stylesheets::Origin;
|
||||
|
@ -21,12 +23,8 @@ pub struct ParserContextExtraData;
|
|||
/// Extra data that the style backend may need to parse stylesheets.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub struct ParserContextExtraData {
|
||||
/// The base URI.
|
||||
pub base: Option<GeckoArcURI>,
|
||||
/// The referrer URI.
|
||||
pub referrer: Option<GeckoArcURI>,
|
||||
/// The principal that loaded this stylesheet.
|
||||
pub principal: Option<GeckoArcPrincipal>,
|
||||
/// The URL extra data.
|
||||
pub data: Option<RefPtr<URLExtraData>>,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
|
@ -39,7 +37,7 @@ impl Default for ParserContextExtraData {
|
|||
#[cfg(feature = "gecko")]
|
||||
impl Default for ParserContextExtraData {
|
||||
fn default() -> Self {
|
||||
ParserContextExtraData { base: None, referrer: None, principal: None }
|
||||
ParserContextExtraData { data: None }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,15 +46,10 @@ impl ParserContextExtraData {
|
|||
/// Construct from a GeckoParserExtraData
|
||||
///
|
||||
/// GeckoParserExtraData must live longer than this call
|
||||
pub unsafe fn new(data: *const ::gecko_bindings::structs::GeckoParserExtraData) -> Self {
|
||||
// the to_safe calls are safe since we trust that we have references to
|
||||
// real Gecko refptrs. The dereferencing of data is safe because this function
|
||||
// is expected to be called with a `data` living longer than this function.
|
||||
unsafe { ParserContextExtraData {
|
||||
base: Some((*data).mBaseURI.to_safe()),
|
||||
referrer: Some((*data).mReferrer.to_safe()),
|
||||
principal: Some((*data).mPrincipal.to_safe()),
|
||||
}}
|
||||
pub unsafe fn new(data: *mut URLExtraData) -> Self {
|
||||
ParserContextExtraData {
|
||||
data: Some(RefPtr::new(data)),
|
||||
}
|
||||
}
|
||||
}
|
||||
/// The data that the parser needs from outside in order to parse a stylesheet.
|
||||
|
|
|
@ -2158,8 +2158,7 @@ ${helpers.predefined_type("-moz-binding", "UrlOrNone", "Either::Second(None_)",
|
|||
animatable="False",
|
||||
gecko_ffi_name="mBinding",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-binding)",
|
||||
disable_when_testing="True",
|
||||
boxed=True)}
|
||||
disable_when_testing="True")}
|
||||
|
||||
${helpers.single_keyword("-moz-orient",
|
||||
"inline block horizontal vertical",
|
||||
|
|
|
@ -121,19 +121,16 @@ ${helpers.single_keyword("clip-rule", "nonzero evenodd",
|
|||
|
||||
${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)",
|
||||
products="gecko",
|
||||
boxed = product == "gecko",
|
||||
animatable="False",
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
||||
|
||||
${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)",
|
||||
products="gecko",
|
||||
boxed = product == "gecko",
|
||||
animatable="False",
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
||||
|
||||
${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
||||
products="gecko",
|
||||
boxed = product == "gecko",
|
||||
animatable="False",
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ ${helpers.single_keyword("list-style-type", """
|
|||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")}
|
||||
|
||||
${helpers.predefined_type("list-style-image", "UrlOrNone", "Either::Second(None_)",
|
||||
boxed = product == "gecko",
|
||||
initial_specified_value="Either::Second(None_)", animatable=False,
|
||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image")}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue