[webkit-help] Loading and viewing a .webarchive file with webkit

Alexander Shulgin alexander.shulgin at yessoftware.com
Thu Jun 3 08:36:08 PDT 2010


On 03.06.2010 18:26, Frederic Gos wrote:
> Hi,
> I've built a simple test program that uses webkit to show html files.
> I've used the COM api from c++ under windows.
> I'm able to display html comming from the web via IWebUrlRequest with
> both a http: url and a file: url. this works great.
> I did have to copy the CFNEtwork.resources files for the file: url to
> work, etc.
> Now, I need to try to make it display a .webacrhive file. I've created
> that file with safari and can also load it again
> with safari and it displays it fine.
> In my program, when i make a file: url to the .webarchive file and use
> 'initWithUrl' like I did for a html file, the display is blank...
> I then researched a bit more and found that IWebFrame has this
> loadArchive method and thought uuuuuh ;) But alas,
> now I need to build a IWebArchive object (i think) and load the data
> from the .webarchive into that. I've looked at the code and
> seen that the only method which is implemented in the COM api is
> initFromNode (IDOMNode* etc).
> So now I need to build a DOMDocument and create a node in it and load
> the data into that? Is this correct? I presume this is done with
> libxml2.lib kind of code? Is this the right track or am i on a wild
> goose chase?
> Even better, maybe someone has a sample doing just that?
> I'm pretty sure it can be done since safari displays webarchive files
> fine. But maybe safari isn't using webkit through the COM api and goes
> directly
> to WebCore?
> Anyway, ' ll quit babbling for now and hope someone can help push me in
> the right directioin.

I think your best bet is implementing WebArchive::initWithData(IStream*) 
by looking at corresponding code in WebKit/mac/WebView/WebArchive.mm.

I'd use WebCore::LegacyWebArchive::create(SharedBuffer*) overload to 
accomplish the task, while copying the data from IStream* to newly 
allocated SharedBuffer instance beforehand.

--
Alex


More information about the webkit-help mailing list