[webkit-dev] The mysterious IconDatabase

Brady Eidson beidson at apple.com
Tue Sep 18 09:46:07 PDT 2007


Hi Patrick,

Could you give a little more context?  Are you using ToT WebKit?

On Sep 18, 2007, at 9:27 AM, Patrick Hanna wrote:

> Load www.google.com, FrameLoaderClient::dispatchDidReceiveIcon is  
> called. IconDatabase::iconForPageURL returns an icon, this is perfect.

Right

> Load www.google.com/search?hl=en&q=some_query&btnG=Google+Search,  
> dispatchDidReceiveIcon is *not* called.

In current ToT WebKit, it should be called for every single page  
load.  Specifically as of revision 25557 (http://trac.webkit.org/projects/webkit/changeset/25557 
)

> If I call iconForPageURL *before* the load is finished, I won't get  
> an icon unless I have already visited the site. If I call it after  
> the load has finished, this could potentially show the wrong icon  
> until the load has finished.

This is expected - until you visit a site, the icon database doesn't  
know what icon belongs to the site.  You might think it quite obvious  
that "www.google.com/search?hl=en&q=some_query&btnG=Google+Search"  
should use the google site icon, but "www.google.com/search?hl=en&q=some_query&btnG=Google+Search 
" might manually link to "www.foobar.com/favicon.ico" in it's <head>  
element - we simply don't know until the sight has loaded once.

Therefore, until you do actually load the site, iconForPageURL("www.google.com/search?hl=en&q=some_query&btnG=Google+Search 
") should return the default icon.

> Here is the behavior that I want:
> Load www.google.com, show the default icon until the google favicon  
> is loaded and dispatchDidReceiveIcon is called. Load www.google.com/search?hl=whatever 
> , show the google favicon unless dispatchDidReceiveIcon is called.  
> Load www.someothersite.com, show the default icon until  
> dispatchDidReceiveIcon is called. How can I accomplish this behavior  
> when the IconDatabase doesn't know about pageUrls->iconUrls until  
> *after* the load has completed?

To accomplish this behavior you'll have to do a little work.

As I said above, it is impossible to know for sure which icon belongs  
to a site until you've visited that site once.  But I think it's quite  
reasonable if an API client wants to make assumptions by itself and  
ask for a different icon.

Maybe what you're going for here is to have your API client run it's  
own logic that says "Okay, I don't know the icon for http://www.google.com/search?hl=en&q=some_query&btnG=Google+Search 
, but I do know the icon for http://www.google.com/, so I'll show that  
icon instead until I know the http://www.google.com/search?hl=en&q=some_query&btnG=Google+Search 
  icon for sure"

And the tools *are* in place to accomplish that now.

Hope this helps,

 Brady
Safari/WebKit Engineer

> Thanks,
> Patrick
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-dev




More information about the webkit-dev mailing list