style: Make from_image_request infallible.

All callsites already assert, so moving the assertion into the method
should be fine. It is not expected to handle a null image value anyway.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: J8CA8m22eSv
This commit is contained in:
Xidorn Quan 2018-05-16 13:39:58 +10:00 committed by Emilio Cobos Álvarez
parent dc2aadd43a
commit 45a37503af
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 5 additions and 12 deletions

View file

@ -317,13 +317,10 @@ impl ComputedImageUrl {
}
/// Convert from nsStyleImageReques to ComputedImageUrl.
pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Result<Self, ()> {
if image_request.mImageValue.mRawPtr.is_null() {
return Err(());
}
let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap();
pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Self {
let image_value = image_request.mImageValue.mRawPtr
.as_ref().expect("mImageValue is null");
let url_value_data = &image_value._base;
Ok(Self::from_url_value_data(url_value_data))
Self::from_url_value_data(url_value_data)
}
}