Simplify code around building ComputedImageUrl

RESOLVED FIXED in Firefox 62

Status

()

enhancement
RESOLVED FIXED
Last year
Last year

People

(Reporter: xidorn, Assigned: xidorn)

Tracking

Trunk
mozilla62
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox62 fixed)

Details

Attachments

(4 attachments)

See bug 1461288 comment 5, there are something inefficient, and something can be removed.
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 5

Last year
mozreview-review
Comment on attachment 8976035 [details]
Bug 1461858 part 1 - Make creating CssUrl infallible.

https://reviewboard.mozilla.org/r/244230/#review250210
Attachment #8976035 - Flags: review?(emilio) → review+

Comment 6

Last year
mozreview-review
Comment on attachment 8976036 [details]
Bug 1461858 part 2 - Make from_image_request infallible.

https://reviewboard.mozilla.org/r/244232/#review250212
Attachment #8976036 - Flags: review?(emilio) → review+

Comment 7

Last year
mozreview-review
Comment on attachment 8976037 [details]
Bug 1461858 part 3 - Have from_image_request reuse ImageValue from image request directly.

https://reviewboard.mozilla.org/r/244234/#review250214

::: layout/style/ServoBindings.cpp:1675
(Diff revision 1)
>  
> -const mozilla::css::URLValueData*
> -Gecko_GetURLValue(const nsStyleImage* aImage)
> +const nsStyleImageRequest*
> +Gecko_GetImageRequest(const nsStyleImage* aImage)
>  {
> -  MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Image);
> -  return aImage->GetURLValue();
> +  MOZ_ASSERT(aImage);
> +  return aImage->GetImageRequest();

We should probably rename GetImageRequest() to ImageRequest(), since it can't return null really.
Attachment #8976037 - Flags: review?(emilio) → review+

Comment 8

Last year
mozreview-review
Comment on attachment 8976038 [details]
Bug 1461858 part 4 - Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl.

https://reviewboard.mozilla.org/r/244236/#review250216

Thanks for cleaning this up! :)

::: servo/components/style/gecko/conversions.rs:682
(Diff revision 1)
>      impl<'a> From<&'a StyleShapeSource> for ClippingShape {
>          fn from(other: &'a StyleShapeSource) -> Self {
>              match other.mType {
>                  StyleShapeSourceType::URL => unsafe {
>                      let shape_image = &*other.mShapeImage.mPtr;
> -                    let other_url = &(**shape_image.__bindgen_anon_1.mURLValue.as_ref());
> +                    let other_url = RefPtr::from_ptr_ref(shape_image.__bindgen_anon_1.mURLValue.as_ref());

Huh, naming of from_ptr_ref is really confusing...

Anyhow this looks fine.
Attachment #8976038 - Flags: review?(emilio) → review+

Comment 9

Last year
mozreview-review-reply
Comment on attachment 8976038 [details]
Bug 1461858 part 4 - Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl.

https://reviewboard.mozilla.org/r/244236/#review250216

> Huh, naming of from_ptr_ref is really confusing...
> 
> Anyhow this looks fine.

Perhaps you can use just RefPtr::new(), instead of from_ptr_ref + clone? It'd be slightly easier to read imo.
Assignee

Comment 10

Last year
mozreview-review-reply
Comment on attachment 8976037 [details]
Bug 1461858 part 3 - Have from_image_request reuse ImageValue from image request directly.

https://reviewboard.mozilla.org/r/244234/#review250214

> We should probably rename GetImageRequest() to ImageRequest(), since it can't return null really.

Let's do it in a followup bug. It seems to me that nsStyleImageRequest also has some method can be renamed.

Comment 11

Last year
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7358416f54f4
part 1 - Make creating CssUrl infallible. r=emilio
https://hg.mozilla.org/integration/autoland/rev/c728ab64fa12
part 2 - Make from_image_request infallible. r=emilio
https://hg.mozilla.org/integration/autoland/rev/ae886b67a96f
part 3 - Have from_image_request reuse ImageValue from image request directly. r=emilio
https://hg.mozilla.org/integration/autoland/rev/2e6a54985ec6
part 4 - Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl. r=emilio
Assignee

Updated

Last year
Blocks: 1461940
Assignee

Comment 12

Last year
mozreview-review-reply
Comment on attachment 8976038 [details]
Bug 1461858 part 4 - Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl.

https://reviewboard.mozilla.org/r/244236/#review250216

> Perhaps you can use just RefPtr::new(), instead of from_ptr_ref + clone? It'd be slightly easier to read imo.

Oh... I missed this issue. So yeah, I agree. It is written this way because I initially have from_url_value accept `&RefPtr<URLValue>`, then I realized that `to_safe()` actually clones, thus I change that function to take ownership instead, and at that point, I just add clone everywhere... but yeah, using `::new` should be better. I'll push a followup.

Comment 13

Last year
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/235b702765bb
followup - Use RefPtr::new instead of RefPtr::from_ptr_ref + clone.
You need to log in before you can comment on or make changes to this bug.