Closed Bug 1461858 Opened 7 years ago Closed 7 years ago

Simplify code around building ComputedImageUrl

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: xidorn, Assigned: xidorn)

References

Details

Attachments

(4 files)

See bug 1461288 comment 5, there are something inefficient, and something can be removed.
Attachment #8976035 - Flags: review?(emilio) → review+
Attachment #8976036 - Flags: review?(emilio) → 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 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 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.
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.
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
Blocks: 1461940
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.
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.

Attachment

General

Created:
Updated:
Size: