Bug 62931

Summary: Separate concerns of loading file icons and choosing files.
Product: WebKit Reporter: Dimitri Glazkov (Google) <dglazkov>
Component: New BugsAssignee: Dimitri Glazkov (Google) <dglazkov>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, darin, dglazkov, tkent, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 62069    
Attachments:
Description Flags
WIP: Cook on bots.
none
Fix Win build.
none
Energize.
darin: review+
Patch for landing. webkit.review.bot: commit-queue-

Description Dimitri Glazkov (Google) 2011-06-18 10:45:03 PDT
Separate concerns of loading file icons from choosing files.
Comment 1 Dimitri Glazkov (Google) 2011-06-18 10:45:24 PDT
Created attachment 97702 [details]
WIP: Cook on bots.
Comment 2 Dimitri Glazkov (Google) 2011-06-18 14:19:10 PDT
Created attachment 97706 [details]
Fix Win build.
Comment 3 Dimitri Glazkov (Google) 2011-06-18 16:24:14 PDT
Created attachment 97708 [details]
Energize.
Comment 4 Dimitri Glazkov (Google) 2011-06-18 16:27:28 PDT
This patch also resolves nicely the conundrum from bug 36723, which was fixed by introducing "am I a real boy yet?" boolean. It's brittle, and I am happy to report we no longer need this workaround.
Comment 5 Darin Adler 2011-06-18 17:36:43 PDT
Comment on attachment 97708 [details]
Energize.

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

Seems like a nice improvement.

> Source/WebCore/page/ChromeClient.h:230
> -        virtual void chooseIconForFiles(const Vector<String>&, FileChooser*) = 0;
> +        virtual void loadIconForFiles(const Vector<String>&, PassRefPtr<FileIconLoader>) = 0;

I think that FileIconLoader should be a raw pointer, not a PassRefPtr. The caller is giving an icon loader for use, not handing off ownership. Even if the recipient might choose to take a reference to it.

> Source/WebCore/rendering/RenderFileUploadControl.cpp:82
> +    if (Chrome* chromePointer = chrome())
> +        chromePointer->loadIconForFiles(filenames, m_iconLoader);

Our style for this is normally:

    if (Chrome* chrome = this->chrome())

That way you can use the word “chrome” and not have to say “chromePointer”.

> Source/WebCore/rendering/RenderFileUploadControl.h:70
> +    // FileIconLoaderClient methods.
> +    void updateRendering(PassRefPtr<Icon>);

I know the other comment uses the word “methods”, but that is not a C++ term. The C++ term is virtual member functions or just virtual functions.

These should be explicitly marked virtual too. Again, FileChooserClient functions above are not done that way, but that’s a mistake.

At some point we need to add a feature to clang so we can use something explicitly for overriding, like virtual but a compile error or warning if you are not overriding something inherited from a base class. In other compilers we’d just use “virtual”. I wonder if someone has already designed that and whether the clang folks would be open to it or not.

> Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm:791
> -void WebChromeClient::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser)
> +void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, PassRefPtr<FileIconLoader> iconLoader)
>  {
> -    chooser->iconLoaded(Icon::createIconForFiles(filenames));
> +    iconLoader->notifyFinished(Icon::createIconForFiles(filenames));
>  }

I’d just use the name loader here instead of iconLoader; in this local scope the extra word doesn’t add clarity, so brevity is better.
Comment 6 Dimitri Glazkov (Google) 2011-06-18 17:48:53 PDT
Comment on attachment 97708 [details]
Energize.

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

Thanks for your review! I will address the feedback and land.

>> Source/WebCore/page/ChromeClient.h:230
>> +        virtual void loadIconForFiles(const Vector<String>&, PassRefPtr<FileIconLoader>) = 0;
> 
> I think that FileIconLoader should be a raw pointer, not a PassRefPtr. The caller is giving an icon loader for use, not handing off ownership. Even if the recipient might choose to take a reference to it.

I could've sworn you've given me a nearly opposite feedback once... Here it is: https://bugs.webkit.org/show_bug.cgi?id=46015#c15
Comment 7 Darin Adler 2011-06-18 17:53:33 PDT
(In reply to comment #6)
> I could've sworn you've given me a nearly opposite feedback once... Here it is: https://bugs.webkit.org/show_bug.cgi?id=46015#c15

I’m not sure whether I was wrong that time or wrong this time. I just wrote a message to webkit-dev about this subject.
Comment 8 Dimitri Glazkov (Google) 2011-06-18 17:54:26 PDT
(In reply to comment #7)
> (In reply to comment #6)
> > I could've sworn you've given me a nearly opposite feedback once... Here it is: https://bugs.webkit.org/show_bug.cgi?id=46015#c15
> 
> I’m not sure whether I was wrong that time or wrong this time. I just wrote a message to webkit-dev about this subject.

It's the ghost of the past battling the ghost of the future!!! :P
Comment 9 Dimitri Glazkov (Google) 2011-06-19 08:55:52 PDT
Created attachment 97725 [details]
Patch for landing.
Comment 10 WebKit Review Bot 2011-06-19 09:01:58 PDT
Comment on attachment 97725 [details]
Patch for landing.

Attachment 97725 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/8914144
Comment 11 WebKit Review Bot 2011-06-19 09:23:18 PDT
Comment on attachment 97725 [details]
Patch for landing.

Attachment 97725 [details] did not pass cr-mac-ews (chromium):
Output: http://queues.webkit.org/results/8909160
Comment 12 Dimitri Glazkov (Google) 2011-06-19 10:00:37 PDT
Committed r89216: <http://trac.webkit.org/changeset/89216>