Bug 184356 - Tighten ImageSource to have BitmapImage pointer instead of Image
Summary: Tighten ImageSource to have BitmapImage pointer instead of Image
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-04-06 04:52 PDT by Antti Koivisto
Modified: 2018-04-06 09:29 PDT (History)
10 users (show)

See Also:


Attachments
patch (8.13 KB, patch)
2018-04-06 05:36 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (9.61 KB, patch)
2018-04-06 06:18 PDT, Antti Koivisto
sabouhallawa: review+
Details | Formatted Diff | Diff
patch (12.40 KB, patch)
2018-04-06 08:35 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2018-04-06 04:52:05 PDT
ImageSource is an implementation detail of BitmapImage, not a generic type.
Comment 1 Antti Koivisto 2018-04-06 05:36:33 PDT
Created attachment 337356 [details]
patch
Comment 2 Radar WebKit Bug Importer 2018-04-06 05:37:11 PDT
<rdar://problem/39236223>
Comment 3 Antti Koivisto 2018-04-06 06:18:30 PDT
Created attachment 337360 [details]
patch
Comment 4 Said Abou-Hallawa 2018-04-06 07:26:21 PDT
Comment on attachment 337360 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=337360&action=review

> Source/WebCore/loader/ImageLoader.cpp:422
> -    if (!image->isBitmapImage()) {
> +    if (!is<BitmapImage>(image)) {

There are places of the code which use isBitmapImage() and others use is<BitmapImage>(). I do not know the rule here and I don't know which way is more preferable. But I think we should be consistent and use one way or the other all over the code.

> Source/WebCore/platform/graphics/BitmapImage.h:142
> +    void decode(WTF::Function<void()>&&);

I think we can remove WTF:: here.

> Source/WebCore/platform/graphics/Image.h:-142
> -    virtual void decode(WTF::Function<void()>&&) { }
> -    virtual void imageFrameAvailableAtIndex(size_t) { }
> -

Shouldn't we do the same thing for the other methods which are related to multi-frame images only?

    virtual NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; }
    virtual ImageOrientation orientationForCurrentFrame() const { return ImageOrientation(); }
    virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }
Comment 5 Antti Koivisto 2018-04-06 07:43:10 PDT
> There are places of the code which use isBitmapImage() and others use
> is<BitmapImage>(). I do not know the rule here and I don't know which way is
> more preferable. But I think we should be consistent and use one way or the
> other all over the code.

I think it is good to always use is<> when paired with downcast<>. The safety of the code is then immediately obvious.
Comment 6 Antti Koivisto 2018-04-06 08:05:34 PDT
> Shouldn't we do the same thing for the other methods which are related to
> multi-frame images only?
> 
>     virtual NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext*
> = nullptr) { return nullptr; }
>     virtual ImageOrientation orientationForCurrentFrame() const { return
> ImageOrientation(); }
>     virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }


nativeImageForCurrentFrame has SVGImage implementation too. Did the rest.
Comment 7 Antti Koivisto 2018-04-06 08:35:43 PDT
Created attachment 337365 [details]
patch
Comment 8 WebKit Commit Bot 2018-04-06 09:29:57 PDT
Comment on attachment 337365 [details]
patch

Clearing flags on attachment: 337365

Committed r230334: <https://trac.webkit.org/changeset/230334>
Comment 9 WebKit Commit Bot 2018-04-06 09:29:59 PDT
All reviewed patches have been landed.  Closing bug.