[webkit-reviews] review granted: [Bug 39102] [GTK] eventSender.contextClick() should return the contents of the context menu : [Attachment 67534] proposed patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Sep 15 07:50:40 PDT 2010
Eric Carlson <eric.carlson at apple.com> has granted Philippe Normand
<pnormand at igalia.com>'s request for review:
Bug 39102: [GTK] eventSender.contextClick() should return the contents of the
context menu
https://bugs.webkit.org/show_bug.cgi?id=39102
Attachment 67534: proposed patch
https://bugs.webkit.org/attachment.cgi?id=67534&action=review
------- Additional Comments from Eric Carlson <eric.carlson at apple.com>
> + JSValueRef valueRef = JSObjectMakeArray(context, 0, NULL, NULL);
> + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
> + GtkMenu* gtkMenu = webkit_web_view_get_context_menu(view);
> + if (gtkMenu) {
> + GList* items = gtk_container_get_children(GTK_CONTAINER(gtkMenu));
> + JSValueRef arrayValues[g_list_length(items)];
> + int index = 0;
> + for (GList* item = g_list_first(items); item; item =
g_list_next(item)) {
> + const gchar* label;
> + if (GTK_IS_SEPARATOR_MENU_ITEM(item->data))
> + label = g_strdup("<separator>");
> + else
> + label =
g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(item->data)));
> +
> + arrayValues[index] = JSValueMakeString(context,
JSStringCreateWithUTF8CString(label));
> + index++;
> + }
> + if (index)
> + valueRef = JSObjectMakeArray(context, index - 1, arrayValues,
NULL);
Aren't you leaking the label string allocated for arrayValues?
I am definitely not a GTK expert so you might want to get another opinion, but
this looks correct to me.
More information about the webkit-reviews
mailing list