Bug 97547 - Code inside FrameLoaderClient::canShowMIMEType() implementations can be shared among different WK ports
Summary: Code inside FrameLoaderClient::canShowMIMEType() implementations can be share...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mikhail Pozdnyakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-25 03:25 PDT by Mikhail Pozdnyakov
Modified: 2012-09-28 11:16 PDT (History)
10 users (show)

See Also:


Attachments
patch (14.23 KB, patch)
2012-09-25 05:46 PDT, Mikhail Pozdnyakov
buildbot: commit-queue-
Details | Formatted Diff | Diff
patch v2 (15.35 KB, patch)
2012-09-25 06:01 PDT, Mikhail Pozdnyakov
no flags Details | Formatted Diff | Diff
patch v3 (do not put flags) (14.88 KB, patch)
2012-09-27 01:57 PDT, Mikhail Pozdnyakov
buildbot: commit-queue-
Details | Formatted Diff | Diff
patch v4 (15.11 KB, patch)
2012-09-27 02:12 PDT, Mikhail Pozdnyakov
no flags Details | Formatted Diff | Diff
patch v5 (15.14 KB, patch)
2012-09-27 05:34 PDT, Mikhail Pozdnyakov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Pozdnyakov 2012-09-25 03:25:45 PDT
Currently the code inside FrameLoaderClient::canShowMIMEType() implementations is pretty much similar among
different WK ports:
EFL, Qt, GTK, WinCe have following snippet inside FrameLoaderClient canShowMIMEType() function:
MIMETypeRegistry::isSupportedImageMIMEType(type)
            || MIMETypeRegistry::isSupportedNonImageMIMEType(type)
            || MIMETypeRegistry::isSupportedMediaMIMEType(type)

WK2 has similar logic inside WebKit::WebPageProxy::canShowMIMEType()
    if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
        return true;

    if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
        return true;

    if (mimeType.startsWith("text/", false))
        return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType);

Think it would be wise to have a new function inside MIMETypeRegistry, that would encapsulate this logic.
Comment 1 Mikhail Pozdnyakov 2012-09-25 05:46:48 PDT
Created attachment 165593 [details]
patch
Comment 2 Build Bot 2012-09-25 05:52:08 PDT
Comment on attachment 165593 [details]
patch

Attachment 165593 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14030057
Comment 3 Mikhail Pozdnyakov 2012-09-25 06:01:40 PDT
Created attachment 165594 [details]
patch v2

Rebased. Build on MAC should be fixed.
Comment 4 Kenneth Rohde Christiansen 2012-09-25 06:08:51 PDT
Comment on attachment 165594 [details]
patch v2

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

> Source/WebCore/platform/MIMETypeRegistry.cpp:582
>  
> +bool MIMETypeRegistry::isVisuallyRepresentableMIMEType(const String& mimeType)

Isnt that like a really weird name. What if it contains only javascript?
Comment 5 Mikhail Pozdnyakov 2012-09-25 06:11:20 PDT
(In reply to comment #4)
> (From update of attachment 165594 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=165594&action=review
> 
> > Source/WebCore/platform/MIMETypeRegistry.cpp:582
> >  
> > +bool MIMETypeRegistry::isVisuallyRepresentableMIMEType(const String& mimeType)
> 
> Isnt that like a really weird name. What if it contains only javascript?

right. I need to find a better one..
Comment 6 Mikhail Pozdnyakov 2012-09-26 00:22:17 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > (From update of attachment 165594 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=165594&action=review
> > 
> > > Source/WebCore/platform/MIMETypeRegistry.cpp:582
> > >  
> > > +bool MIMETypeRegistry::isVisuallyRepresentableMIMEType(const String& mimeType)
> > 
> > Isnt that like a really weird name. What if it contains only javascript?
> 
> right. I need to find a better one..

How about 'isMIMETypeHandledByWebPage' ?
Comment 7 Benjamin Poulain 2012-09-26 11:25:38 PDT
Comment on attachment 165594 [details]
patch v2

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

> Source/WebCore/WebCore.exp.in:422
>  __ZN7WebCore16MIMETypeRegistry27getUnsupportedTextMIMETypesEv
>  __ZN7WebCore16MIMETypeRegistry27isSupportedNonImageMIMETypeERKN3WTF6StringE
>  __ZN7WebCore16MIMETypeRegistry29getSupportedNonImageMIMETypesEv
> +__ZN7WebCore16MIMETypeRegistry31isVisuallyRepresentableMIMETypeERKN3WTF6StringE

Are all the other exports still needed?
Comment 8 Mikhail Pozdnyakov 2012-09-27 01:53:00 PDT
(In reply to comment #7)
> (From update of attachment 165594 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=165594&action=review
> 
> > Source/WebCore/WebCore.exp.in:422
> >  __ZN7WebCore16MIMETypeRegistry27getUnsupportedTextMIMETypesEv
> >  __ZN7WebCore16MIMETypeRegistry27isSupportedNonImageMIMETypeERKN3WTF6StringE
> >  __ZN7WebCore16MIMETypeRegistry29getSupportedNonImageMIMETypesEv
> > +__ZN7WebCore16MIMETypeRegistry31isVisuallyRepresentableMIMETypeERKN3WTF6StringE
> 
> Are all the other exports still needed?

Looks MIMETypeRegistry::getUnsupportedTextMIMETypes does not need to be exported anymore.
Comment 9 Mikhail Pozdnyakov 2012-09-27 01:57:00 PDT
Created attachment 165953 [details]
patch v3 (do not put flags)

Having an IRC discussion with Kenneth came to conclusion that the already used "canShowMIMEType" looks like the most appropriate name for the new function. 
Do not require any flags as need to get mangled name for the new function from MAC bot first :)
Comment 10 Simon Hausmann 2012-09-27 02:01:37 PDT
Comment on attachment 165953 [details]
patch v3 (do not put flags)

Yay for removal of duplicated code!
Comment 11 Build Bot 2012-09-27 02:02:20 PDT
Comment on attachment 165953 [details]
patch v3 (do not put flags)

Attachment 165953 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14037732
Comment 12 Mikhail Pozdnyakov 2012-09-27 02:12:53 PDT
Created attachment 165955 [details]
patch v4

Now should build on MAC. Thanks, bot.
Comment 13 Mikhail Pozdnyakov 2012-09-27 05:34:22 PDT
Created attachment 165980 [details]
patch v5

Rebased.
Comment 14 Mikhail Pozdnyakov 2012-09-27 08:59:31 PDT
Could please anyone review?
Comment 15 Adam Barth 2012-09-28 11:03:14 PDT
Comment on attachment 165980 [details]
patch v5

Looks great.
Comment 16 WebKit Review Bot 2012-09-28 11:16:20 PDT
Comment on attachment 165980 [details]
patch v5

Clearing flags on attachment: 165980

Committed r129924: <http://trac.webkit.org/changeset/129924>
Comment 17 WebKit Review Bot 2012-09-28 11:16:25 PDT
All reviewed patches have been landed.  Closing bug.