Skip to content

Commit

Permalink
style: Make from_image_request infallible.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
upsuper authored and emilio committed May 20, 2018
1 parent dc2aadd commit 45a3750
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 4 additions & 7 deletions components/style/gecko/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
6 changes: 1 addition & 5 deletions components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4145,9 +4145,7 @@ fn static_assert() {

unsafe {
let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
UrlOrNone::Url(ComputedImageUrl::from_image_request(
gecko_image_request
).expect("mListStyleImage could not convert to ComputedImageUrl"))
UrlOrNone::Url(ComputedImageUrl::from_image_request(gecko_image_request))
}
}

Expand Down Expand Up @@ -5437,7 +5435,6 @@ clip-path
let url = unsafe {
let gecko_image_request = gecko_cursor_image.mImage.mRawPtr.as_ref().unwrap();
ComputedImageUrl::from_image_request(&gecko_image_request)
.expect("mCursorImages.mImage could not convert to ComputedImageUrl")
};

let hotspot =
Expand Down Expand Up @@ -5713,7 +5710,6 @@ clip-path
&**gecko_content.mContent.mImage.as_ref();
ContentItem::Url(
ComputedImageUrl::from_image_request(gecko_image_request)
.expect("mContent could not convert to ComputedImageUrl")
)
}
},
Expand Down

0 comments on commit 45a3750

Please sign in to comment.