Bug 134735

Summary: [GTK] Implement webkit_web_view_load_bytes() in WebKit2
Product: WebKit Reporter: Gergely Polonkai <gergely>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Enhancement CC: berto, bunhere, cdumez, cgarcia, commit-queue, gustavo, gyuyoung.kim, mrobinson, sergio
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch svillar: review+

Description Gergely Polonkai 2014-07-08 11:35:05 PDT
It would be nice to have the old webkit_web_view_load_string() function in the WebKit2 API, or provide a way to simulate it.
Comment 1 Carlos Garcia Campos 2014-07-10 04:22:06 PDT
load_string() like in webkit1 limits the API to null terminated array of characters, so in this case I would use webkit_web_view_load_bytes() that receives a GBytes. That way we can take a reference and create an API::Data object without duplicating the memory.
Comment 2 Gergely Polonkai 2014-07-10 04:40:46 PDT
How about (for 1.x compatibility reasons) implementing both? _load_string() may internally convert the null-terminated strings into GBytes and call _load_bytes() maybe. I don’t know how hard it would be, even navigating the sources is hard for me as a webkit newbie…
Comment 3 Carlos Garcia Campos 2014-07-10 05:19:20 PDT
Created attachment 234704 [details]
Patch
Comment 4 WebKit Commit Bot 2014-07-10 05:20:38 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 5 Carlos Garcia Campos 2014-07-10 05:22:30 PDT
(In reply to comment #2)
> How about (for 1.x compatibility reasons) implementing both? _load_string() may internally convert the null-terminated strings into GBytes and call _load_bytes() maybe. I don’t know how hard it would be, even navigating the sources is hard for me as a webkit newbie…

I think load_string is a confusing name in any case, so in case of adding a new (convenient) API to load a const char, it would be load_data that receives const char + data length. But I think it's very easy for users to simply create a GBytes.
Comment 6 Gustavo Noronha (kov) 2014-07-10 05:45:24 PDT
I agree, wonder how that impacts bindings though, does anyone know if it can be made idiomatic for js and python?
Comment 7 Gustavo Noronha (kov) 2014-07-10 05:50:08 PDT
Comment on attachment 234704 [details]
Patch

The API looks good to me, fwiw.
Comment 8 Sergio Villar Senin 2014-07-29 04:03:07 PDT
Comment on attachment 234704 [details]
Patch

The API looks fine to me too.
Comment 9 Carlos Garcia Campos 2014-07-29 04:36:18 PDT
Committed r171740: <http://trac.webkit.org/changeset/171740>
Comment 10 Tim Horton 2014-07-29 08:21:07 PDT
Comment on attachment 234704 [details]
Patch

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

> Source/WebKit2/ChangeLog:9
> +        random data in the web view using the given MIME-Type, encoding

Hopefully the data isn't random. Arbitrary?
Comment 11 Carlos Garcia Campos 2014-07-29 08:29:53 PDT
(In reply to comment #10)
> (From update of attachment 234704 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=234704&action=review
> 
> > Source/WebKit2/ChangeLog:9
> > +        random data in the web view using the given MIME-Type, encoding
> 
> Hopefully the data isn't random. Arbitrary?

Oops, yes, you are right, bad english translation in my head.