mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Auto merge of #14653 - upsuper:bug1321176, r=Manishearth
stylo: Fix assertion for unresolvable url <!-- Please describe your changes on the following line: --> This is the Servo part of [bug 1321176](https://bugzilla.mozilla.org/show_bug.cgi?id=1321176), which has been reviewed by @emilio, @Manishearth, and @heycam. r? @Manishearth --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14653) <!-- Reviewable:end -->
This commit is contained in:
commit
ae2b74e1c9
5 changed files with 25 additions and 12 deletions
|
@ -397,7 +397,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
|
PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
|
||||||
background_image::SpecifiedValue(vec![
|
background_image::SpecifiedValue(vec![
|
||||||
background_image::single_value::SpecifiedValue(Some(
|
background_image::single_value::SpecifiedValue(Some(
|
||||||
specified::Image::for_cascade(Some(url.into()), specified::url::UrlExtraData { })
|
specified::Image::for_cascade(url.into(), specified::url::UrlExtraData { })
|
||||||
))
|
))
|
||||||
])))));
|
])))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,9 @@ impl nsStyleImage {
|
||||||
self.set_gradient(gradient)
|
self.set_gradient(gradient)
|
||||||
},
|
},
|
||||||
Image::Url(ref url) if with_url => {
|
Image::Url(ref url) if with_url => {
|
||||||
let (ptr, len) = url.as_slice_components();
|
let (ptr, len) = match url.as_slice_components() {
|
||||||
|
Ok(value) | Err(value) => value
|
||||||
|
};
|
||||||
let extra_data = url.extra_data();
|
let extra_data = url.extra_data();
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_SetUrlImageValue(self,
|
Gecko_SetUrlImageValue(self,
|
||||||
|
|
|
@ -1152,7 +1152,10 @@ fn static_assert() {
|
||||||
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 extra_data = url.extra_data();
|
||||||
let (ptr, len) = url.as_slice_components();
|
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,
|
||||||
ptr,
|
ptr,
|
||||||
|
@ -1737,7 +1740,9 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Either::First(ref url) => {
|
Either::First(ref url) => {
|
||||||
let (ptr, len) = url.as_slice_components();
|
let (ptr, len) = match url.as_slice_components() {
|
||||||
|
Ok(value) | Err(value) => value
|
||||||
|
};
|
||||||
let extra_data = url.extra_data();
|
let extra_data = url.extra_data();
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_SetListStyleImage(&mut self.gecko,
|
Gecko_SetListStyleImage(&mut self.gecko,
|
||||||
|
@ -2433,7 +2438,9 @@ clip-path
|
||||||
for i in 0..v.images.len() {
|
for i in 0..v.images.len() {
|
||||||
let image = &v.images[i];
|
let image = &v.images[i];
|
||||||
let extra_data = image.url.extra_data();
|
let extra_data = image.url.extra_data();
|
||||||
let (ptr, len) = image.url.as_slice_components();
|
let (ptr, len) = match image.url.as_slice_components() {
|
||||||
|
Ok(value) | Err(value) => value,
|
||||||
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_SetCursorImage(&mut self.gecko.mCursorImages[i],
|
Gecko_SetCursorImage(&mut self.gecko.mCursorImages[i],
|
||||||
ptr, len as u32,
|
ptr, len as u32,
|
||||||
|
|
|
@ -45,7 +45,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.
|
||||||
pub fn for_cascade(url: Option<ServoUrl>, extra_data: UrlExtraData) -> Self {
|
pub fn for_cascade(url: ServoUrl, extra_data: UrlExtraData) -> Self {
|
||||||
Image::Url(SpecifiedUrl::for_cascade(url, extra_data))
|
Image::Url(SpecifiedUrl::for_cascade(url, extra_data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ use parser::ParserContextExtraData;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use std::ptr;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use values::NoViewportPercentage;
|
use values::NoViewportPercentage;
|
||||||
|
@ -121,19 +120,24 @@ impl SpecifiedUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Little helper for Gecko's ffi.
|
/// Little helper for Gecko's ffi.
|
||||||
pub fn as_slice_components(&self) -> (*const u8, usize) {
|
#[cfg(feature = "gecko")]
|
||||||
|
pub fn as_slice_components(&self) -> Result<(*const u8, usize), (*const u8, usize)> {
|
||||||
match self.resolved {
|
match self.resolved {
|
||||||
Some(ref url) => (url.as_str().as_ptr(), url.as_str().len()),
|
Some(ref url) => Ok((url.as_str().as_ptr(), url.as_str().len())),
|
||||||
None => (ptr::null(), 0),
|
None => {
|
||||||
|
let url = self.original.as_ref()
|
||||||
|
.expect("We should always have either the original or the resolved value");
|
||||||
|
Err((url.as_str().as_ptr(), url.as_str().len()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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: Option<ServoUrl>, extra_data: UrlExtraData) -> Self {
|
pub fn for_cascade(url: ServoUrl, extra_data: UrlExtraData) -> Self {
|
||||||
SpecifiedUrl {
|
SpecifiedUrl {
|
||||||
original: None,
|
original: None,
|
||||||
resolved: url,
|
resolved: Some(url),
|
||||||
extra_data: extra_data,
|
extra_data: extra_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue