mirror of
https://github.com/servo/servo.git
synced 2025-07-30 18:50:36 +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(
|
||||
background_image::SpecifiedValue(vec![
|
||||
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)
|
||||
},
|
||||
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();
|
||||
unsafe {
|
||||
Gecko_SetUrlImageValue(self,
|
||||
|
|
|
@ -1152,7 +1152,10 @@ fn static_assert() {
|
|||
Either::Second(_none) => debug_assert!(self.gecko.mBinding.mRawPtr.is_null()),
|
||||
Either::First(ref url) => {
|
||||
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 {
|
||||
Gecko_SetMozBinding(&mut self.gecko,
|
||||
ptr,
|
||||
|
@ -1737,7 +1740,9 @@ fn static_assert() {
|
|||
}
|
||||
}
|
||||
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();
|
||||
unsafe {
|
||||
Gecko_SetListStyleImage(&mut self.gecko,
|
||||
|
@ -2433,7 +2438,9 @@ clip-path
|
|||
for i in 0..v.images.len() {
|
||||
let image = &v.images[i];
|
||||
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 {
|
||||
Gecko_SetCursorImage(&mut self.gecko.mCursorImages[i],
|
||||
ptr, len as u32,
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Image {
|
|||
|
||||
/// Creates an already specified image value from an already resolved URL
|
||||
/// 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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ use parser::ParserContextExtraData;
|
|||
use servo_url::ServoUrl;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::{self, Write};
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use style_traits::ToCss;
|
||||
use values::NoViewportPercentage;
|
||||
|
@ -121,19 +120,24 @@ impl SpecifiedUrl {
|
|||
}
|
||||
|
||||
/// 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 {
|
||||
Some(ref url) => (url.as_str().as_ptr(), url.as_str().len()),
|
||||
None => (ptr::null(), 0),
|
||||
Some(ref url) => Ok((url.as_str().as_ptr(), url.as_str().len())),
|
||||
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
|
||||
/// 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 {
|
||||
original: None,
|
||||
resolved: url,
|
||||
resolved: Some(url),
|
||||
extra_data: extra_data,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue