RESOLVED FIXED 106440
[EFL][WK2] Add ewk_view_page_contents_get() API
https://bugs.webkit.org/show_bug.cgi?id=106440
Summary [EFL][WK2] Add ewk_view_page_contents_get() API
KwangYong Choi
Reported 2013-01-09 03:36:14 PST
Add ewk_view_mhtml_data_get() API for getting mhtml data of current page.
Attachments
Patch (4.61 KB, patch)
2013-01-09 03:56 PST, KwangYong Choi
no flags
Patch (5.18 KB, patch)
2013-01-09 20:54 PST, KwangYong Choi
no flags
Patch (5.17 KB, patch)
2013-01-09 20:57 PST, KwangYong Choi
no flags
Patch (5.00 KB, patch)
2013-01-09 23:02 PST, KwangYong Choi
webkit.review.bot: commit-queue-
Patch (5.00 KB, patch)
2013-01-10 01:31 PST, KwangYong Choi
no flags
Patch (5.00 KB, patch)
2013-01-10 18:14 PST, KwangYong Choi
no flags
Patch (4.97 KB, patch)
2013-01-10 18:16 PST, KwangYong Choi
no flags
Patch (6.58 KB, patch)
2013-01-10 23:30 PST, KwangYong Choi
no flags
Patch (6.58 KB, patch)
2013-01-10 23:53 PST, KwangYong Choi
no flags
Patch (6.50 KB, patch)
2013-01-11 00:19 PST, KwangYong Choi
no flags
KwangYong Choi
Comment 1 2013-01-09 03:56:58 PST
WebKit Review Bot
Comment 2 2013-01-09 03:59:37 PST
Attachment 181892 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit2/ChangeLog', u'Source/WebKit..." exit_code: 1 Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:954: When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mikhail Pozdnyakov
Comment 3 2013-01-09 04:51:23 PST
Comment on attachment 181892 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=181892&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:941 > + Ewk_View_MHTML_Data_Cb MHTMLDataCallback = reinterpret_cast<Ewk_View_MHTML_Data_Cb>(context); why reinterpret_cast? static_cast should work here as far as I remember. > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:943 > + MHTMLDataCallback(webData.get()->size(), webData.get()->bytes()); you don't need '.get()' invoking > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:958 > + return false; UNUSED_PARAM ? > Source/WebKit2/UIProcess/API/efl/ewk_view.h:323 > +typedef void (*Ewk_View_MHTML_Data_Cb)(unsigned size, const unsigned char *bytes); why not 'const char*'?
Chris Dumez
Comment 4 2013-01-09 05:06:18 PST
Comment on attachment 181892 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=181892&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:938 > +static void ewk_view_mhtml_data_callback(WKDataRef wkData, WKErrorRef, void* context) I think we should use camel case here since this is coding style for non-exposed functions. > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:943 > + MHTMLDataCallback(webData.get()->size(), webData.get()->bytes()); webData->size(), webData->bytes() (i.e. .get() is useless) >> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:954 >> + ewk_view_mhtml_data_callback), false); > > When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] Please fix style. Also, it would be nice to have an inline comment to indicate what 'false' stands for. e.g. false /* useBinaryEncoding */ > Source/WebKit2/UIProcess/API/efl/ewk_view.h:323 > +typedef void (*Ewk_View_MHTML_Data_Cb)(unsigned size, const unsigned char *bytes); Shouldn't we reverse the arguments? It feels better to me to get the array first and then its size second. Also, why "const unsigned char *" instead of "const char *"? Technically, you are returning a string, not binary bytes. "bytes" may be a bit confusing here. > Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp:926 > + ASSERT_EQ(size, strlen(reinterpret_cast<const char*>(bytes))); Question: why do we pass the size to the callback if the array is null terminated? Usually it is one or the other. > Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp:928 > + MHTMLDataObtained = true; No validation of the data besides its length?
KwangYong Choi
Comment 5 2013-01-09 20:09:47 PST
Comment on attachment 181892 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=181892&action=review >> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:938 >> +static void ewk_view_mhtml_data_callback(WKDataRef wkData, WKErrorRef, void* context) > > I think we should use camel case here since this is coding style for non-exposed functions. OK. I will use camel case here. >> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:941 >> + Ewk_View_MHTML_Data_Cb MHTMLDataCallback = reinterpret_cast<Ewk_View_MHTML_Data_Cb>(context); > > why reinterpret_cast? static_cast should work here as far as I remember. static_cast is not work. >>> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:943 >>> + MHTMLDataCallback(webData.get()->size(), webData.get()->bytes()); >> >> you don't need '.get()' invoking > > webData->size(), webData->bytes() (i.e. .get() is useless) OK. >>> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:954 >>> + ewk_view_mhtml_data_callback), false); >> >> When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] > > Please fix style. Also, it would be nice to have an inline comment to indicate what 'false' stands for. e.g. false /* useBinaryEncoding */ OK I will fix. >> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:958 >> + return false; > > UNUSED_PARAM ? OK. I will add UNUSED_PARAM. >>> Source/WebKit2/UIProcess/API/efl/ewk_view.h:323 >>> +typedef void (*Ewk_View_MHTML_Data_Cb)(unsigned size, const unsigned char *bytes); >> >> why not 'const char*'? > > Shouldn't we reverse the arguments? It feels better to me to get the array first and then its size second. > > Also, why "const unsigned char *" instead of "const char *"? Technically, you are returning a string, not binary bytes. "bytes" may be a bit confusing here. OK. I will reverse the arguments. It's my work sequence. I just worked size first. And also change const unsigned char *bytes to const char *data. >> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp:926 >> + ASSERT_EQ(size, strlen(reinterpret_cast<const char*>(bytes))); > > Question: why do we pass the size to the callback if the array is null terminated? Usually it is one or the other. Actually, the buffer is always null terminated string. Shall I remove the size argument? >> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp:928 >> + MHTMLDataObtained = true; > > No validation of the data besides its length? OK. I will add the data comparison routine.
KwangYong Choi
Comment 6 2013-01-09 20:54:24 PST
KwangYong Choi
Comment 7 2013-01-09 20:57:28 PST
Chris Dumez
Comment 8 2013-01-09 21:59:36 PST
Comment on attachment 182057 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182057&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.h:323 > +typedef void (*Ewk_View_MHTML_Data_Cb)(const char *data, unsigned length); I would remove the length argument since data is a NULL-terminated string.
KwangYong Choi
Comment 9 2013-01-09 23:02:43 PST
Created attachment 182070 [details] Patch Removed length argument in callback function.
Benjamin Poulain
Comment 10 2013-01-09 23:06:50 PST
(In reply to comment #8) > (From update of attachment 182057 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=182057&action=review > > > Source/WebKit2/UIProcess/API/efl/ewk_view.h:323 > > +typedef void (*Ewk_View_MHTML_Data_Cb)(const char *data, unsigned length); > > I would remove the length argument since data is a NULL-terminated string. This depends a lot on the platform, on some architecture you really don't want to read memory if you can avoid it (some ARMv7 implementations for example). On Intel, the caches are so huge, that probably does not matter. (I don't mind either way for this patch)
WebKit Review Bot
Comment 11 2013-01-10 00:13:06 PST
Comment on attachment 182070 [details] Patch Attachment 182070 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/15762841 New failing tests: inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html
KwangYong Choi
Comment 12 2013-01-10 01:31:46 PST
Created attachment 182086 [details] Patch Upload same patch again.
Gyuyoung Kim
Comment 13 2013-01-10 18:04:47 PST
Comment on attachment 182086 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182086&action=review = > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:954 > + ewkViewMHTMLDataCallback), false /* useBinaryEncoding */); I don't know you should mention /* useBinaryEncoding */ comment. We can know what mean *false* if we see getContentsAsMHTMLData(). > Source/WebKit2/UIProcess/API/efl/ewk_view.h:318 > + * Creates a type name for the callback function used to get the mhtml data. s/mhtml/MHTML/g > Source/WebKit2/UIProcess/API/efl/ewk_view.h:320 > + * @param data string buffer of the mhtml data ditto. > Source/WebKit2/UIProcess/API/efl/ewk_view.h:859 > + * @param o view object to get mhtml data ditto. > Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp:921 > +static bool MHTMLDataObtained = false; Generally, verb is placed first. For example, obtainedMHTMLData.
KwangYong Choi
Comment 14 2013-01-10 18:12:03 PST
Comment on attachment 182086 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182086&action=review >> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:954 >> + ewkViewMHTMLDataCallback), false /* useBinaryEncoding */); > > I don't know you should mention /* useBinaryEncoding */ comment. We can know what mean *false* if we see getContentsAsMHTMLData(). OK. I will remove. >> Source/WebKit2/UIProcess/API/efl/ewk_view.h:318 >> + * Creates a type name for the callback function used to get the mhtml data. > > s/mhtml/MHTML/g OK >> Source/WebKit2/UIProcess/API/efl/ewk_view.h:320 >> + * @param data string buffer of the mhtml data > > ditto. OK >> Source/WebKit2/UIProcess/API/efl/ewk_view.h:859 >> + * @param o view object to get mhtml data > > ditto. OK >> Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp:921 >> +static bool MHTMLDataObtained = false; > > Generally, verb is placed first. For example, obtainedMHTMLData. OK. I will use obtainedMHTMLData.
KwangYong Choi
Comment 15 2013-01-10 18:14:08 PST
KwangYong Choi
Comment 16 2013-01-10 18:16:40 PST
Gyuyoung Kim
Comment 17 2013-01-10 19:43:33 PST
Comment on attachment 182234 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182234&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.h:864 > +EAPI Eina_Bool ewk_view_mhtml_data_get(const Evas_Object *o, Ewk_View_MHTML_Data_Cb callback); As you know, GTK port added *WebKitSaveMode* enum to support webpage saving functionality. I also think we need to support various data formats to save a webpage in future. I don't like to add new API to support new format. How about adding saving mode as GTK port ?
KwangYong Choi
Comment 18 2013-01-10 21:04:52 PST
Comment on attachment 182234 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182234&action=review >> Source/WebKit2/UIProcess/API/efl/ewk_view.h:864 >> +EAPI Eina_Bool ewk_view_mhtml_data_get(const Evas_Object *o, Ewk_View_MHTML_Data_Cb callback); > > As you know, GTK port added *WebKitSaveMode* enum to support webpage saving functionality. I also think we need to support various data formats to save a webpage in future. I don't like to add new API to support new format. How about adding saving mode as GTK port ? OK. I will implement mode feature.
KwangYong Choi
Comment 19 2013-01-10 23:30:55 PST
Created attachment 182271 [details] Patch Renamed the API name as ewk_view_page_contents_get(). And it can set the contents type for the callback data. It supports only MHTML for now.
Gyuyoung Kim
Comment 20 2013-01-10 23:46:22 PST
Comment on attachment 182271 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182271&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:155 > +struct Ewk_Page_Contents_Context { Please use _Ewk_Page_Contents_Context
KwangYong Choi
Comment 21 2013-01-10 23:53:25 PST
Created attachment 182274 [details] Patch struct Ewk_Page_Contents_Context -> struct _Ewk_Page_Contents_Context
Mikhail Pozdnyakov
Comment 22 2013-01-11 00:03:06 PST
(In reply to comment #20) > (From update of attachment 182271 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=182271&action=review > > > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:155 > > +struct Ewk_Page_Contents_Context { > > Please use _Ewk_Page_Contents_Context I guess we do not use '_' prefixes in other places. Why is it needed? (Sorry if I missed something)
Mikhail Pozdnyakov
Comment 23 2013-01-11 00:05:11 PST
Comment on attachment 182274 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182274&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:950 > + if (!context) it's invoked internally, how 'context' can be NULL? ASSERTION or EINA check at least is needed. > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:968 > + Ewk_Page_Contents_Context* context = static_cast<Ewk_Page_Contents_Context*>(calloc(1, sizeof(Ewk_Page_Contents_Context))); why not 'new/delete' ?
Gyuyoung Kim
Comment 24 2013-01-11 00:07:28 PST
(In reply to comment #22) > (In reply to comment #20) > > (From update of attachment 182271 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=182271&action=review > > > > > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:155 > > > +struct Ewk_Page_Contents_Context { > > > > Please use _Ewk_Page_Contents_Context > > I guess we do not use '_' prefixes in other places. Why is it needed? (Sorry if I missed something) That is my mistake. I saw old version which is used by my private debugging. Sorry for my noise.
KwangYong Choi
Comment 25 2013-01-11 00:19:31 PST
Created attachment 182277 [details] Patch Modified to use EINA_SAFETY_ON_NULL_RETURN(context); Modified to use new/delete.
Mikhail Pozdnyakov
Comment 26 2013-01-11 00:24:28 PST
Comment on attachment 182277 [details] Patch looks OK
WebKit Review Bot
Comment 27 2013-01-11 02:33:06 PST
Comment on attachment 182277 [details] Patch Clearing flags on attachment: 182277 Committed r139422: <http://trac.webkit.org/changeset/139422>
WebKit Review Bot
Comment 28 2013-01-11 02:33:13 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.