mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
stylo: Add ServoBundledURI abstraction for use when setting css::URLValues
MozReview-Commit-ID: 4QKKzJ1DVYP
This commit is contained in:
parent
47ebeaa95c
commit
e965b4e345
6 changed files with 63 additions and 29 deletions
|
@ -383,6 +383,7 @@ mod bindings {
|
||||||
"PropertyValuePair",
|
"PropertyValuePair",
|
||||||
"Runnable",
|
"Runnable",
|
||||||
"ServoAttrSnapshot",
|
"ServoAttrSnapshot",
|
||||||
|
"ServoBundledURI",
|
||||||
"ServoElementSnapshot",
|
"ServoElementSnapshot",
|
||||||
"SheetParsingMode",
|
"SheetParsingMode",
|
||||||
"StaticRefPtr",
|
"StaticRefPtr",
|
||||||
|
@ -523,6 +524,7 @@ mod bindings {
|
||||||
"FontFamilyList",
|
"FontFamilyList",
|
||||||
"FontFamilyType",
|
"FontFamilyType",
|
||||||
"Keyframe",
|
"Keyframe",
|
||||||
|
"ServoBundledURI",
|
||||||
"ServoElementSnapshot",
|
"ServoElementSnapshot",
|
||||||
"SheetParsingMode",
|
"SheetParsingMode",
|
||||||
"StyleBasicShape",
|
"StyleBasicShape",
|
||||||
|
|
|
@ -20,6 +20,7 @@ use gecko_bindings::structs::TraversalRootBehavior;
|
||||||
use gecko_bindings::structs::FontFamilyList;
|
use gecko_bindings::structs::FontFamilyList;
|
||||||
use gecko_bindings::structs::FontFamilyType;
|
use gecko_bindings::structs::FontFamilyType;
|
||||||
use gecko_bindings::structs::Keyframe;
|
use gecko_bindings::structs::Keyframe;
|
||||||
|
use gecko_bindings::structs::ServoBundledURI;
|
||||||
use gecko_bindings::structs::ServoElementSnapshot;
|
use gecko_bindings::structs::ServoElementSnapshot;
|
||||||
use gecko_bindings::structs::SheetParsingMode;
|
use gecko_bindings::structs::SheetParsingMode;
|
||||||
use gecko_bindings::structs::StyleBasicShape;
|
use gecko_bindings::structs::StyleBasicShape;
|
||||||
|
@ -590,11 +591,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_SetListStyleImage(style_struct: *mut nsStyleList,
|
pub fn Gecko_SetListStyleImage(style_struct: *mut nsStyleList,
|
||||||
string_bytes: *const u8,
|
uri: ServoBundledURI);
|
||||||
string_length: u32,
|
|
||||||
base_uri: *mut ThreadSafeURIHolder,
|
|
||||||
referrer: *mut ThreadSafeURIHolder,
|
|
||||||
principal: *mut ThreadSafePrincipalHolder);
|
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyListStyleImageFrom(dest: *mut nsStyleList,
|
pub fn Gecko_CopyListStyleImageFrom(dest: *mut nsStyleList,
|
||||||
|
@ -617,10 +614,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_SetMozBinding(style_struct: *mut nsStyleDisplay,
|
pub fn Gecko_SetMozBinding(style_struct: *mut nsStyleDisplay,
|
||||||
string_bytes: *const u8, string_length: u32,
|
bundled_uri: ServoBundledURI);
|
||||||
base_uri: *mut ThreadSafeURIHolder,
|
|
||||||
referrer: *mut ThreadSafeURIHolder,
|
|
||||||
principal: *mut ThreadSafePrincipalHolder);
|
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_CopyMozBindingFrom(des: *mut nsStyleDisplay,
|
pub fn Gecko_CopyMozBindingFrom(des: *mut nsStyleDisplay,
|
||||||
|
|
|
@ -25363,6 +25363,23 @@ pub mod root {
|
||||||
pub type ThreadSafePrincipalHolder =
|
pub type ThreadSafePrincipalHolder =
|
||||||
root::nsMainThreadPtrHolder<root::nsIPrincipal>;
|
root::nsMainThreadPtrHolder<root::nsIPrincipal>;
|
||||||
pub type ThreadSafeURIHolder = root::nsMainThreadPtrHolder<root::nsIURI>;
|
pub type ThreadSafeURIHolder = root::nsMainThreadPtrHolder<root::nsIURI>;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Debug, Copy)]
|
||||||
|
pub struct ServoBundledURI {
|
||||||
|
pub mURLString: *const u8,
|
||||||
|
pub mURLStringLength: u32,
|
||||||
|
pub mBaseURI: *mut root::ThreadSafeURIHolder,
|
||||||
|
pub mReferrer: *mut root::ThreadSafeURIHolder,
|
||||||
|
pub mPrincipal: *mut root::ThreadSafePrincipalHolder,
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn bindgen_test_layout_ServoBundledURI() {
|
||||||
|
assert_eq!(::std::mem::size_of::<ServoBundledURI>() , 40usize);
|
||||||
|
assert_eq!(::std::mem::align_of::<ServoBundledURI>() , 8usize);
|
||||||
|
}
|
||||||
|
impl Clone for ServoBundledURI {
|
||||||
|
fn clone(&self) -> Self { *self }
|
||||||
|
}
|
||||||
pub type nsMediaFeatureValueGetter =
|
pub type nsMediaFeatureValueGetter =
|
||||||
::std::option::Option<unsafe extern "C" fn(aPresContext:
|
::std::option::Option<unsafe extern "C" fn(aPresContext:
|
||||||
*mut root::nsPresContext,
|
*mut root::nsPresContext,
|
||||||
|
|
|
@ -24719,6 +24719,23 @@ pub mod root {
|
||||||
pub type ThreadSafePrincipalHolder =
|
pub type ThreadSafePrincipalHolder =
|
||||||
root::nsMainThreadPtrHolder<root::nsIPrincipal>;
|
root::nsMainThreadPtrHolder<root::nsIPrincipal>;
|
||||||
pub type ThreadSafeURIHolder = root::nsMainThreadPtrHolder<root::nsIURI>;
|
pub type ThreadSafeURIHolder = root::nsMainThreadPtrHolder<root::nsIURI>;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Debug, Copy)]
|
||||||
|
pub struct ServoBundledURI {
|
||||||
|
pub mURLString: *const u8,
|
||||||
|
pub mURLStringLength: u32,
|
||||||
|
pub mBaseURI: *mut root::ThreadSafeURIHolder,
|
||||||
|
pub mReferrer: *mut root::ThreadSafeURIHolder,
|
||||||
|
pub mPrincipal: *mut root::ThreadSafePrincipalHolder,
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn bindgen_test_layout_ServoBundledURI() {
|
||||||
|
assert_eq!(::std::mem::size_of::<ServoBundledURI>() , 40usize);
|
||||||
|
assert_eq!(::std::mem::align_of::<ServoBundledURI>() , 8usize);
|
||||||
|
}
|
||||||
|
impl Clone for ServoBundledURI {
|
||||||
|
fn clone(&self) -> Self { *self }
|
||||||
|
}
|
||||||
pub type nsMediaFeatureValueGetter =
|
pub type nsMediaFeatureValueGetter =
|
||||||
::std::option::Option<unsafe extern "C" fn(aPresContext:
|
::std::option::Option<unsafe extern "C" fn(aPresContext:
|
||||||
*mut root::nsPresContext,
|
*mut root::nsPresContext,
|
||||||
|
|
|
@ -1322,18 +1322,9 @@ fn static_assert() {
|
||||||
match v {
|
match v {
|
||||||
Either::Second(_none) => debug_assert!(self.gecko.mBinding.mRawPtr.is_null()),
|
Either::Second(_none) => debug_assert!(self.gecko.mBinding.mRawPtr.is_null()),
|
||||||
Either::First(ref url) => {
|
Either::First(ref url) => {
|
||||||
let extra_data = url.extra_data();
|
|
||||||
let (ptr, len) = match url.as_slice_components() {
|
|
||||||
Ok(value) => value,
|
|
||||||
Err(_) => (ptr::null(), 0),
|
|
||||||
};
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_SetMozBinding(&mut self.gecko,
|
Gecko_SetMozBinding(&mut self.gecko, url.for_ffi());
|
||||||
ptr,
|
|
||||||
len as u32,
|
|
||||||
extra_data.base.get(),
|
|
||||||
extra_data.referrer.get(),
|
|
||||||
extra_data.principal.get());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2066,17 +2057,9 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Either::First(ref url) => {
|
Either::First(ref url) => {
|
||||||
let (ptr, len) = match url.as_slice_components() {
|
|
||||||
Ok(value) | Err(value) => value
|
|
||||||
};
|
|
||||||
let extra_data = url.extra_data();
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_SetListStyleImage(&mut self.gecko,
|
Gecko_SetListStyleImage(&mut self.gecko,
|
||||||
ptr,
|
url.for_ffi());
|
||||||
len as u32,
|
|
||||||
extra_data.base.get(),
|
|
||||||
extra_data.referrer.get(),
|
|
||||||
extra_data.principal.get());
|
|
||||||
}
|
}
|
||||||
// We don't need to record this struct as uncacheable, like when setting
|
// We don't need to record this struct as uncacheable, like when setting
|
||||||
// background-image to a url() value, since only properties in reset structs
|
// background-image to a url() value, since only properties in reset structs
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
use cssparser::{CssStringWriter, Parser};
|
use cssparser::{CssStringWriter, Parser};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
use gecko_bindings::structs::ServoBundledURI;
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||||
use parser::{Parse, ParserContext};
|
use parser::{Parse, ParserContext};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -167,6 +169,25 @@ impl SpecifiedUrl {
|
||||||
extra_data: UrlExtraData {}
|
extra_data: UrlExtraData {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a bundled URI suitable for sending to Gecko
|
||||||
|
/// to be constructed into a css::URLValue
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub fn for_ffi(&self) -> ServoBundledURI {
|
||||||
|
use std::ptr;
|
||||||
|
let extra_data = self.extra_data();
|
||||||
|
let (ptr, len) = match self.as_slice_components() {
|
||||||
|
Ok(value) => value,
|
||||||
|
Err(_) => (ptr::null(), 0),
|
||||||
|
};
|
||||||
|
ServoBundledURI {
|
||||||
|
mURLString: ptr,
|
||||||
|
mURLStringLength: len as u32,
|
||||||
|
mBaseURI: extra_data.base.get(),
|
||||||
|
mReferrer: extra_data.referrer.get(),
|
||||||
|
mPrincipal: extra_data.principal.get(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for SpecifiedUrl {
|
impl PartialEq for SpecifiedUrl {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue