| Differences between
and this patch
- a/Source/WebKit2/ChangeLog +91 lines
Lines 1-5 a/Source/WebKit2/ChangeLog_sec1
1
2011-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
1
2011-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
2
2
3
        [GTK] Initial implementation of back forward list for WebKit2 GTK+ API
4
        https://bugs.webkit.org/show_bug.cgi?id=69343
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * GNUmakefile.am: Add new files to compilation.
9
        * UIProcess/API/gtk/WebKitBackForwardList.cpp: Added.
10
        (webkitBackForwardListFinalize):
11
        (webkit_back_forward_list_init):
12
        (webkit_back_forward_list_class_init):
13
        (webkitBackForwardListGetOrCreateItem): Helper function that
14
        creates a new WebKitBackForwardListItem for the given
15
        WebBackForwardListItem or returns it from the cache if it's
16
        already cached.
17
        (webkitBackForwardListCreateList): Helper function to convert a
18
        WKArray of WebBackForwardListItems into a GList of
19
        WebKitBackForwardListItems.
20
        (webkitBackForwardListCreate): Create a new WebKitBackForwardList.
21
        (webkitBackForwardListChanged): Emits changed signal when the back
22
        forward list changes.
23
        (webkit_back_forward_list_get_current_item):
24
        (webkit_back_forward_list_get_back_item):
25
        (webkit_back_forward_list_get_forward_item):
26
        (webkit_back_forward_list_get_nth_item):
27
        (webkit_back_forward_list_get_length):
28
        (webkit_back_forward_list_get_back_list):
29
        (webkit_back_forward_list_get_back_list_with_limit):
30
        (webkit_back_forward_list_get_forward_list):
31
        (webkit_back_forward_list_get_forward_list_with_limit):
32
        * UIProcess/API/gtk/WebKitBackForwardList.h: Added.
33
        * UIProcess/API/gtk/WebKitBackForwardListItem.cpp: Added.
34
        (webkitBackForwardListItemFinalize):
35
        (webkit_back_forward_list_item_init):
36
        (webkit_back_forward_list_item_class_init):
37
        (historyItemsMap): Global cache for WebKitBackForwardListItems.
38
        (webkitBackForwardListItemFinalized):
39
        (webkitBackForwardListItemGetOrCreate): Helper function that
40
        creates a new WebKitBackForwardListItem for the given
41
        WebBackForwardListItem or returns it from the global cache if it's
42
        already cached.
43
        (webkit_back_forward_list_item_get_uri):
44
        (webkit_back_forward_list_item_get_title):
45
        (webkit_back_forward_list_item_get_original_uri):
46
        * UIProcess/API/gtk/WebKitBackForwardListItem.h: Added.
47
        * UIProcess/API/gtk/WebKitBackForwardListPrivate.h:
48
        * UIProcess/API/gtk/WebKitWebLoaderClient.cpp:
49
        (didChangeBackForwardList): Call webkitBackForwardListChanged() to
50
        notify that the list has changed.
51
        (webkitWebLoaderClientAttachLoaderClientToPage): Add
52
        implementation for didChangeBackForwardList.
53
        * UIProcess/API/gtk/WebKitWebView.cpp:
54
        (webkitWebViewSetLoaderClient): Internal function to set the
55
        loader client.
56
        (webkitWebViewConstructed): Create the back forward list for the
57
        view.
58
        (webkit_web_view_set_loader_client): Use
59
        webkitWebViewSetLoaderClient().
60
        (webkit_web_view_get_back_forward_list): Return the back forward
61
        list.
62
        * UIProcess/API/gtk/WebKitWebView.h:
63
        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
64
        (webkitWebViewBaseCreateWebPage): Return the newly created
65
        WebPageProxy to avoid having to call webkitWebViewBaseGetPage()
66
        after creating it.
67
        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
68
        * UIProcess/API/gtk/tests/GNUmakefile.am: Add new test.
69
        * UIProcess/API/gtk/tests/TestBackForwardList.cpp: Added.
70
        (serverCallback):
71
        (testBackForwardListNavigation):
72
        (testBackForwardListLimitAndCache):
73
        (beforeAll):
74
        (afterAll):
75
        * UIProcess/API/gtk/tests/TestMain.h:
76
        (Test::~Test): Checks there are no objects leaked.
77
        (Test::objectFinalized): Callback called when a GObject is
78
        deleted, used to remove the watched object the list.
79
        (Test::watchObject): Add an object to the list of watched objects
80
        and add a weak pointer to remove it from the list when the object
81
        is finalized. If there aren't objects leaked, the list should be
82
        empty when the test finishes.
83
        * UIProcess/API/gtk/tests/WebViewTest.cpp:
84
        (WebViewTest::WebViewTest): Watch the web view to make sure it's
85
        not leaked.
86
        * UIProcess/API/gtk/tests/WebViewTest.h: Make WebViewTest inherit
87
        from Test.
88
        * UIProcess/API/gtk/webkit2.h: Include WebKitBackForwardList.h and
89
        WebKitBackForwardListItem.h.
90
        * UIProcess/API/gtk/webkit2marshal.list:
91
92
2011-10-20  Carlos Garcia Campos  <cgarcia@igalia.com>
93
3
        [GTK] Remove WebKitWebLoaderClientPrivate
94
        [GTK] Remove WebKitWebLoaderClientPrivate
4
        https://bugs.webkit.org/show_bug.cgi?id=70488
95
        https://bugs.webkit.org/show_bug.cgi?id=70488
5
96
- a/Source/WebKit2/GNUmakefile.am +7 lines
Lines 71-76 libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_HEA a/Source/WebKit2/GNUmakefile.am_sec1
71
71
72
libwebkit2gtkincludedir = $(libwebkitgtkincludedir)/webkit2
72
libwebkit2gtkincludedir = $(libwebkitgtkincludedir)/webkit2
73
webkit2gtk_headers = \
73
webkit2gtk_headers = \
74
	$(WebKit2)/UIProcess/API/gtk/WebKitBackForwardList.h \
75
	$(WebKit2)/UIProcess/API/gtk/WebKitBackForwardListItem.h \
74
	$(WebKit2)/UIProcess/API/gtk/WebKitDefines.h \
76
	$(WebKit2)/UIProcess/API/gtk/WebKitDefines.h \
75
	$(WebKit2)/UIProcess/API/gtk/WebKitError.h \
77
	$(WebKit2)/UIProcess/API/gtk/WebKitError.h \
76
	$(WebKit2)/UIProcess/API/gtk/WebKitWebContext.h \
78
	$(WebKit2)/UIProcess/API/gtk/WebKitWebContext.h \
Lines 474-479 libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU a/Source/WebKit2/GNUmakefile.am_sec2
474
	Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h \
476
	Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h \
475
	Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h \
477
	Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h \
476
	Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp \
478
	Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp \
479
	Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h \
480
	Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp \
481
	Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h \
482
	Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp \
483
	Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h \
477
	Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h \
484
	Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h \
478
	Source/WebKit2/UIProcess/API/gtk/WebKitError.h \
485
	Source/WebKit2/UIProcess/API/gtk/WebKitError.h \
479
	Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp \
486
	Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp \
- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp +307 lines
Line 0 a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Igalia S.L.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#include "config.h"
21
#include "WebKitBackForwardList.h"
22
23
#include "WebKitBackForwardListPrivate.h"
24
#include "WebKitMarshal.h"
25
#include <WebKit2/WKBackForwardList.h>
26
#include <wtf/gobject/GRefPtr.h>
27
28
/**
29
 * SECTION: WebKitBackForwardList
30
 * @Short_description: List of visited pages
31
 * @Title: WebKitBackForwardList
32
 * @See_also: #WebKitWebView, #WebKitBackForwardListItem
33
 *
34
 * WebKitBackForwardList maintains a list of visited pages used to
35
 * used to navigate to recent pages. Items are inserted in the list
36
 * in the order they are visited.
37
 *
38
 * WebKitBackForwardList also maintains the notion of the current item
39
 * (which is always at index 0), the preceding item (which is at index -1),
40
 * and the following item (which is at index 1).
41
 * Methods webkit_web_view_go_back() and webkit_web_view_go_forward() move
42
 * the current item backward or forward by one. Method
43
 * webkit_web_view_go_to_back_forward_list_item() sets the current item to the
44
 * specified item. All other methods returning #WebKitBackForwardListItem<!-- -->s
45
 * do not change the value of the current item, they just return the requested
46
 * item or items.
47
 */
48
49
enum {
50
    CHANGED,
51
52
    LAST_SIGNAL
53
};
54
55
typedef HashMap<WKBackForwardListItemRef, GRefPtr<WebKitBackForwardListItem> > BackForwardListItemsMap;
56
57
struct _WebKitBackForwardListPrivate {
58
    WKBackForwardListRef wkList;
59
    BackForwardListItemsMap itemsMap;
60
};
61
62
static guint signals[LAST_SIGNAL] = { 0, };
63
64
G_DEFINE_TYPE(WebKitBackForwardList, webkit_back_forward_list, G_TYPE_OBJECT)
65
66
static void webkitBackForwardListFinalize(GObject* object)
67
{
68
    WEBKIT_BACK_FORWARD_LIST(object)->priv->~WebKitBackForwardListPrivate();
69
    G_OBJECT_CLASS(webkit_back_forward_list_parent_class)->finalize(object);
70
}
71
72
static void webkit_back_forward_list_init(WebKitBackForwardList* list)
73
{
74
    WebKitBackForwardListPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(list, WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListPrivate);
75
    list->priv = priv;
76
    new (priv) WebKitBackForwardListPrivate();
77
}
78
79
static void webkit_back_forward_list_class_init(WebKitBackForwardListClass* listClass)
80
{
81
    GObjectClass* gObjectClass = G_OBJECT_CLASS(listClass);
82
83
    gObjectClass->finalize = webkitBackForwardListFinalize;
84
85
    /**
86
     * WebKitBackForwardList::changed:
87
     * @back_forward_list: the #WebKitBackForwardList on which the signal was emitted
88
     * @item_added: (allow-none): the #WebKitBackForwardListItem added or %NULL
89
     * @items_removed: a #GList of #WebKitBackForwardListItem<!-- -->s
90
     *
91
     * This signal is emitted when @back_forward_list changes. This happens
92
     * when the current item is updated, a new item is added or one or more
93
     * items are removed. Note that both @item_added and @items_removed can
94
     * %NULL when only the current item is updated. Items are only removed
95
     * when the list is cleared or the maximum items limit is reached.
96
     */
97
    signals[CHANGED] =
98
        g_signal_new("changed",
99
                     G_TYPE_FROM_CLASS(listClass),
100
                     G_SIGNAL_RUN_LAST,
101
                     0, 0, 0,
102
                     webkit_marshal_VOID__OBJECT_POINTER,
103
                     G_TYPE_NONE, 2,
104
                     WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM,
105
                     G_TYPE_POINTER);
106
107
    g_type_class_add_private(listClass, sizeof(WebKitBackForwardListPrivate));
108
}
109
110
static WebKitBackForwardListItem* webkitBackForwardListGetOrCreateItem(WebKitBackForwardList* list, WKBackForwardListItemRef wkListItem)
111
{
112
    if (!wkListItem)
113
        return 0;
114
115
    WebKitBackForwardListPrivate* priv = list->priv;
116
    GRefPtr<WebKitBackForwardListItem> listItem = priv->itemsMap.get(wkListItem);
117
    if (listItem)
118
        return listItem.get();
119
120
    listItem = webkitBackForwardListItemGetOrCreate(wkListItem);
121
    priv->itemsMap.set(wkListItem, listItem);
122
123
    return listItem.get();
124
}
125
126
static GList* webkitBackForwardListCreateList(WKArrayRef wkList)
127
{
128
    if (!wkList)
129
        return 0;
130
131
    GList* list = 0;
132
    for (size_t i = 0; i < WKArrayGetSize(wkList); ++i) {
133
        WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkList, i));
134
        WebKitBackForwardListItem* item = webkitBackForwardListItemGetOrCreate(wkItem);
135
        if (!item)
136
            continue;
137
138
        list = g_list_prepend(list, item);
139
    }
140
141
    return list;
142
}
143
144
WebKitBackForwardList* webkitBackForwardListCreate(WKBackForwardListRef wkList)
145
{
146
    WebKitBackForwardList* list = WEBKIT_BACK_FORWARD_LIST(g_object_new(WEBKIT_TYPE_BACK_FORWARD_LIST, NULL));
147
    list->priv->wkList = wkList;
148
149
    return list;
150
}
151
152
void webkitBackForwardListChanged(WebKitBackForwardList* backForwardList, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems)
153
{
154
    WebKitBackForwardListItem* addedItem = webkitBackForwardListGetOrCreateItem(backForwardList, wkAddedItem);
155
    GList* removedItems = 0;
156
157
    size_t removedItemsSize = wkRemovedItems ? WKArrayGetSize(wkRemovedItems) : 0;
158
    WebKitBackForwardListPrivate* priv = backForwardList->priv;
159
    for (size_t i = 0; i < removedItemsSize; ++i) {
160
        WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkRemovedItems, i));
161
        removedItems = g_list_prepend(removedItems, g_object_ref(G_OBJECT(priv->itemsMap.get(wkItem).get())));
162
        priv->itemsMap.remove(wkItem);
163
    }
164
165
    g_signal_emit(backForwardList, signals[CHANGED], 0, addedItem, removedItems, NULL);
166
    g_list_free_full(removedItems, static_cast<GDestroyNotify>(g_object_unref));
167
}
168
169
/**
170
 * webkit_back_forward_list_get_current_item:
171
 * @back_forward_list: a #WebKitBackForwardList
172
 *
173
 * Returns the current item in @back_forward_list.
174
 *
175
 * Return value: (transfer none): a #WebKitWebHistoryItem
176
 *    or %NULL if @back_forward_list is empty.
177
 */
178
WebKitBackForwardListItem* webkit_back_forward_list_get_current_item(WebKitBackForwardList* backForwardList)
179
{
180
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
181
182
    return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetCurrentItem(backForwardList->priv->wkList));
183
}
184
185
/**
186
 * webkit_back_forward_list_get_back_item:
187
 * @back_forward_list: a #WebKitBackForwardList
188
 *
189
 * Returns the item that precedes the current item.
190
 *
191
 * Returns: (transfer none): the #WebKitBackForwardListItem
192
 *    preceding the current item or %NULL.
193
 */
194
WebKitBackForwardListItem* webkit_back_forward_list_get_back_item(WebKitBackForwardList* backForwardList)
195
{
196
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
197
198
    return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetBackItem(backForwardList->priv->wkList));
199
}
200
201
/**
202
 * webkit_back_forward_list_get_forward_item:
203
 * @back_forward_list: a #WebKitBackForwardList
204
 *
205
 * Returns the item that succeeds the current item.
206
 *
207
 * Returns: (transfer none): the #WebKitBackForwardListItem
208
 *    following the current item or %NULL.
209
 */
210
WebKitBackForwardListItem* webkit_back_forward_list_get_forward_item(WebKitBackForwardList* backForwardList)
211
{
212
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
213
214
    return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetForwardItem(backForwardList->priv->wkList));
215
}
216
217
/**
218
 * webkit_back_forward_list_get_nth_item:
219
 * @back_forward_list: a #WebKitBackForwardList
220
 * @index: the index of the item
221
 *
222
 * Returns the item at a given index relative to the current item.
223
 *
224
 * Returns: (transfer none): the #WebKitBackForwardListItem
225
 *    located at the specified index relative to the current item.
226
 */
227
WebKitBackForwardListItem* webkit_back_forward_list_get_nth_item(WebKitBackForwardList* backForwardList, gint index)
228
{
229
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
230
231
    return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetItemAtIndex(backForwardList->priv->wkList, index));
232
}
233
234
/**
235
 * webkit_back_forward_list_get_length:
236
 * @back_forward_list: a #WebKitBackForwardList
237
 *
238
 * Returns: the length of @back_forward_list.
239
 */
240
guint webkit_back_forward_list_get_length(WebKitBackForwardList* backForwardList)
241
{
242
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
243
244
    WebKitBackForwardListPrivate* priv = backForwardList->priv;
245
    guint currentItem = webkit_back_forward_list_get_current_item(backForwardList) ? 1 : 0;
246
    return WKBackForwardListGetBackListCount(priv->wkList) + WKBackForwardListGetForwardListCount(priv->wkList) + currentItem;
247
}
248
249
/**
250
 * webkit_back_forward_list_get_back_list:
251
 * @back_forward_list: a #WebKitBackForwardList
252
 *
253
 * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
254
 *    items preceding the current item.
255
 */
256
GList* webkit_back_forward_list_get_back_list(WebKitBackForwardList* backForwardList)
257
{
258
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
259
260
    guint limit = WKBackForwardListGetBackListCount(backForwardList->priv->wkList);
261
    return webkitBackForwardListCreateList(WKBackForwardListCopyBackListWithLimit(backForwardList->priv->wkList, limit));
262
}
263
264
/**
265
 * webkit_back_forward_list_get_back_list_with_limit:
266
 * @back_forward_list: a #WebKitBackForwardList
267
 * @limit: the number of items to retrieve
268
 *
269
 * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
270
 *    items preceding the current item limited by @limit.
271
 */
272
GList* webkit_back_forward_list_get_back_list_with_limit(WebKitBackForwardList* backForwardList, guint limit)
273
{
274
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
275
276
    return webkitBackForwardListCreateList(WKBackForwardListCopyBackListWithLimit(backForwardList->priv->wkList, limit));
277
}
278
279
/**
280
 * webkit_back_forward_list_get_forward_list:
281
 * @back_forward_list: a #WebKitBackForwardList
282
 *
283
 * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
284
 *    items following the current item.
285
 */
286
GList* webkit_back_forward_list_get_forward_list(WebKitBackForwardList* backForwardList)
287
{
288
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
289
290
    guint limit = WKBackForwardListGetForwardListCount(backForwardList->priv->wkList);
291
    return webkitBackForwardListCreateList(WKBackForwardListCopyForwardListWithLimit(backForwardList->priv->wkList, limit));
292
}
293
294
/**
295
 * webkit_back_forward_list_get_forward_list_with_limit:
296
 * @back_forward_list: a #WebKitBackForwardList
297
 * @limit: the number of items to retrieve
298
 *
299
 * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
300
 *    items following the current item limited by @limit.
301
 */
302
GList* webkit_back_forward_list_get_forward_list_with_limit(WebKitBackForwardList* backForwardList, guint limit)
303
{
304
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
305
306
    return webkitBackForwardListCreateList(WKBackForwardListCopyForwardListWithLimit(backForwardList->priv->wkList, limit));
307
}
- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h +88 lines
Line 0 a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h_sec1
1
/*
2
 * Copyright (C) 2011 Igalia S.L.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
21
#error "Only <webkit2/webkit2.h> can be included directly."
22
#endif
23
24
#ifndef WebKitBackForwardList_h
25
#define WebKitBackForwardList_h
26
27
#include <glib-object.h>
28
#include <webkit2/WebKitBackForwardListItem.h>
29
#include <webkit2/WebKitDefines.h>
30
31
G_BEGIN_DECLS
32
33
#define WEBKIT_TYPE_BACK_FORWARD_LIST            (webkit_back_forward_list_get_type())
34
#define WEBKIT_BACK_FORWARD_LIST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardList))
35
#define WEBKIT_BACK_FORWARD_LIST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListClass))
36
#define WEBKIT_IS_BACK_FORWARD_LIST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BACK_FORWARD_LIST))
37
#define WEBKIT_IS_BACK_FORWARD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_BACK_FORWARD_LIST))
38
#define WEBKIT_BACK_FORWARD_LIST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListClass))
39
40
typedef struct _WebKitBackForwardList        WebKitBackForwardList;
41
typedef struct _WebKitBackForwardListClass   WebKitBackForwardListClass;
42
typedef struct _WebKitBackForwardListPrivate WebKitBackForwardListPrivate;
43
44
struct _WebKitBackForwardList {
45
    GObject parent;
46
47
    WebKitBackForwardListPrivate *priv;
48
};
49
50
struct _WebKitBackForwardListClass {
51
    GObjectClass parent_class;
52
};
53
54
WEBKIT_API GType
55
webkit_back_forward_list_get_type                    (void);
56
57
WEBKIT_API WebKitBackForwardListItem *
58
webkit_back_forward_list_get_current_item            (WebKitBackForwardList *back_forward_list);
59
60
WEBKIT_API WebKitBackForwardListItem *
61
webkit_back_forward_list_get_back_item               (WebKitBackForwardList *back_forward_list);
62
63
WEBKIT_API WebKitBackForwardListItem *
64
webkit_back_forward_list_get_forward_item            (WebKitBackForwardList *back_forward_list);
65
66
WEBKIT_API WebKitBackForwardListItem *
67
webkit_back_forward_list_get_nth_item                (WebKitBackForwardList *back_forward_list,
68
                                                      gint                   index);
69
WEBKIT_API guint
70
webkit_back_forward_list_get_length                  (WebKitBackForwardList *back_forward_list);
71
72
WEBKIT_API GList *
73
webkit_back_forward_list_get_back_list               (WebKitBackForwardList *back_forward_list);
74
75
WEBKIT_API GList *
76
webkit_back_forward_list_get_back_list_with_limit    (WebKitBackForwardList *back_forward_list,
77
                                                      guint                  limit);
78
79
WEBKIT_API GList *
80
webkit_back_forward_list_get_forward_list            (WebKitBackForwardList *back_forward_list);
81
82
WEBKIT_API GList *
83
webkit_back_forward_list_get_forward_list_with_limit (WebKitBackForwardList *back_forward_list,
84
                                                      guint                  limit);
85
86
G_END_DECLS
87
88
#endif
- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp +157 lines
Line 0 a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Igalia S.L.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#include "config.h"
21
#include "WebKitBackForwardListItem.h"
22
23
#include "WebKitBackForwardListPrivate.h"
24
#include <WebKit2/WKBackForwardListItem.h>
25
#include <WebKit2/WKRetainPtr.h>
26
#include <wtf/HashMap.h>
27
#include <wtf/gobject/GRefPtr.h>
28
#include <wtf/text/CString.h>
29
30
using namespace WebKit;
31
32
struct _WebKitBackForwardListItemPrivate {
33
    WKRetainPtr<WKBackForwardListItemRef> wkListItem;
34
    CString uri;
35
    CString title;
36
    CString originalURI;
37
};
38
39
G_DEFINE_TYPE(WebKitBackForwardListItem, webkit_back_forward_list_item, G_TYPE_INITIALLY_UNOWNED)
40
41
static void webkitBackForwardListItemFinalize(GObject* object)
42
{
43
    WEBKIT_BACK_FORWARD_LIST_ITEM(object)->priv->~WebKitBackForwardListItemPrivate();
44
    G_OBJECT_CLASS(webkit_back_forward_list_item_parent_class)->finalize(object);
45
}
46
47
static void webkit_back_forward_list_item_init(WebKitBackForwardListItem* listItem)
48
{
49
    WebKitBackForwardListItemPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(listItem, WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemPrivate);
50
    listItem->priv = priv;
51
    new (priv) WebKitBackForwardListItemPrivate();
52
}
53
54
static void webkit_back_forward_list_item_class_init(WebKitBackForwardListItemClass* listItemClass)
55
{
56
    GObjectClass* gObjectClass = G_OBJECT_CLASS(listItemClass);
57
58
    gObjectClass->finalize = webkitBackForwardListItemFinalize;
59
60
    g_type_class_add_private(listItemClass, sizeof(WebKitBackForwardListItemPrivate));
61
}
62
63
typedef HashMap<WKBackForwardListItemRef, WebKitBackForwardListItem* > HistoryItemsMap;
64
65
static HistoryItemsMap& historyItemsMap()
66
{
67
    DEFINE_STATIC_LOCAL(HistoryItemsMap, itemsMap, ());
68
    return itemsMap;
69
}
70
71
static void webkitBackForwardListItemFinalized(gpointer wkListItem, GObject* finalizedListItem)
72
{
73
    ASSERT(G_OBJECT(historyItemsMap().get(static_cast<WKBackForwardListItemRef>(wkListItem))) == finalizedListItem);
74
    historyItemsMap().remove(static_cast<WKBackForwardListItemRef>(wkListItem));
75
}
76
77
WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WKBackForwardListItemRef wkListItem)
78
{
79
    if (!wkListItem)
80
        return 0;
81
82
    WebKitBackForwardListItem* listItem = historyItemsMap().get(wkListItem);
83
    if (listItem)
84
        return listItem;
85
86
    listItem = WEBKIT_BACK_FORWARD_LIST_ITEM(g_object_new(WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, NULL));
87
    listItem->priv->wkListItem = wkListItem;
88
89
    g_object_weak_ref(G_OBJECT(listItem), webkitBackForwardListItemFinalized,
90
                      static_cast<gpointer>(const_cast<OpaqueWKBackForwardListItem*>(wkListItem)));
91
    historyItemsMap().set(wkListItem, listItem);
92
93
    return listItem;
94
}
95
96
/**
97
 * webkit_back_forward_list_item_get_uri:
98
 * @back_forward_list_item: a #WebKitBackForwardListItem
99
 *
100
 * This URI may differ from the original URI if the page was,
101
 * for example, redirected to a new location.
102
 * See also webkit_back_forward_list_item_get_original_uri().
103
 *
104
 * Returns: the URI of @back_forward_list_item.
105
 */
106
const gchar* webkit_back_forward_list_item_get_uri(WebKitBackForwardListItem* listItem)
107
{
108
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0);
109
110
    WebKitBackForwardListItemPrivate* priv = listItem->priv;
111
    WKRetainPtr<WKURLRef> wkURI(AdoptWK, WKBackForwardListItemCopyURL(priv->wkListItem.get()));
112
    if (toImpl(wkURI.get())->string().isEmpty())
113
        return 0;
114
115
    priv->uri = toImpl(wkURI.get())->string().utf8();
116
    return priv->uri.data();
117
}
118
119
/**
120
 * webkit_back_forward_list_item_get_title:
121
 * @back_forward_list_item: a #WebKitBackForwardListItem
122
 *
123
 * Returns: the page title of @back_forward_list_item.
124
 */
125
const gchar* webkit_back_forward_list_item_get_title(WebKitBackForwardListItem* listItem)
126
{
127
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0);
128
129
    WebKitBackForwardListItemPrivate* priv = listItem->priv;
130
    WKRetainPtr<WKStringRef> wkTitle(AdoptWK, WKBackForwardListItemCopyTitle(priv->wkListItem.get()));
131
    if (toImpl(wkTitle.get())->string().isEmpty())
132
        return 0;
133
134
    priv->title = toImpl(wkTitle.get())->string().utf8();
135
    return priv->title.data();
136
}
137
138
/**
139
 * webkit_back_forward_list_item_get_original_uri:
140
 * @back_forward_list_item: a #WebKitWebHistoryItem
141
 *
142
 * See also webkit_back_forward_list_item_get_uri().
143
 *
144
 * Returns: the original URI of @back_forward_list_item.
145
 */
146
const gchar* webkit_back_forward_list_item_get_original_uri(WebKitBackForwardListItem* listItem)
147
{
148
    g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0);
149
150
    WebKitBackForwardListItemPrivate* priv = listItem->priv;
151
    WKRetainPtr<WKURLRef> wkOriginalURI(AdoptWK, WKBackForwardListItemCopyOriginalURL(priv->wkListItem.get()));
152
    if (toImpl(wkOriginalURI.get())->string().isEmpty())
153
        return 0;
154
155
    priv->originalURI = toImpl(wkOriginalURI.get())->string().utf8();
156
    return priv->originalURI.data();
157
}
- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h +67 lines
Line 0 a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h_sec1
1
/*
2
 * Copyright (C) 2011 Igalia S.L.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
21
#error "Only <webkit2/webkit2.h> can be included directly."
22
#endif
23
24
#ifndef WebKitBackForwardListItem_h
25
#define WebKitBackForwardListItem_h
26
27
#include <glib-object.h>
28
#include <webkit2/WebKitDefines.h>
29
30
G_BEGIN_DECLS
31
32
#define WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM            (webkit_back_forward_list_item_get_type())
33
#define WEBKIT_BACK_FORWARD_LIST_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItem))
34
#define WEBKIT_BACK_FORWARD_LIST_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemClass))
35
#define WEBKIT_IS_BACK_FORWARD_LIST_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM))
36
#define WEBKIT_IS_BACK_FORWARD_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM))
37
#define WEBKIT_BACK_FORWARD_LIST_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemClass))
38
39
typedef struct _WebKitBackForwardListItem        WebKitBackForwardListItem;
40
typedef struct _WebKitBackForwardListItemClass   WebKitBackForwardListItemClass;
41
typedef struct _WebKitBackForwardListItemPrivate WebKitBackForwardListItemPrivate;
42
43
struct _WebKitBackForwardListItem {
44
    GInitiallyUnowned parent;
45
46
    WebKitBackForwardListItemPrivate *priv;
47
};
48
49
struct _WebKitBackForwardListItemClass {
50
    GInitiallyUnownedClass parent_class;
51
};
52
53
WEBKIT_API GType
54
webkit_back_forward_list_item_get_type         (void);
55
56
WEBKIT_API const gchar *
57
webkit_back_forward_list_item_get_uri          (WebKitBackForwardListItem* list_item);
58
59
WEBKIT_API const gchar *
60
webkit_back_forward_list_item_get_title        (WebKitBackForwardListItem* list_item);
61
62
WEBKIT_API const gchar *
63
webkit_back_forward_list_item_get_original_uri (WebKitBackForwardListItem* list_item);
64
65
G_END_DECLS
66
67
#endif
- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h +37 lines
Line 0 a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h_sec1
1
/*
2
 * Copyright (C) 2011 Igalia S.L.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef WebKitBackForwardListPrivate_h
27
#define WebKitBackForwardListPrivate_h
28
29
#include "WebBackForwardList.h"
30
#include "WebKitBackForwardList.h"
31
#include <WebKit2/WebKit2.h>
32
33
WebKitBackForwardList* webkitBackForwardListCreate(WKBackForwardListRef);
34
WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WKBackForwardListItemRef);
35
void webkitBackForwardListChanged(WebKitBackForwardList*, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems);
36
37
#endif // WebKitBackForwardListPrivate_h
- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp -1 / +8 lines
Lines 20-25 a/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp_sec1
20
#include "config.h"
20
#include "config.h"
21
#include "WebKitWebLoaderClient.h"
21
#include "WebKitWebLoaderClient.h"
22
22
23
#include "WebKitBackForwardListPrivate.h"
23
#include "WebKitError.h"
24
#include "WebKitError.h"
24
#include "WebKitMarshal.h"
25
#include "WebKitMarshal.h"
25
#include "WebKitPrivate.h"
26
#include "WebKitPrivate.h"
Lines 125-130 static void didChangeProgress(WKPageRef page, const void* clientInfo) a/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp_sec2
125
    webkitWebViewSetEstimatedLoadProgress(webView, WKPageGetEstimatedProgress(page));
126
    webkitWebViewSetEstimatedLoadProgress(webView, WKPageGetEstimatedProgress(page));
126
}
127
}
127
128
129
static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo)
130
{
131
    WebKitWebView* webView = WEBKIT_WEB_VIEW(toImpl(page)->viewWidget());
132
    webkitBackForwardListChanged(webkit_web_view_get_back_forward_list(webView), addedItem, removedItems);
133
}
134
128
void webkitWebLoaderClientAttachLoaderClientToPage(WebKitWebLoaderClient* loaderClient, WKPageRef wkPage)
135
void webkitWebLoaderClientAttachLoaderClientToPage(WebKitWebLoaderClient* loaderClient, WKPageRef wkPage)
129
{
136
{
130
    WKPageLoaderClient wkLoaderClient = {
137
    WKPageLoaderClient wkLoaderClient = {
Lines 152-158 void webkitWebLoaderClientAttachLoaderClientToPage(WebKitWebLoaderClient* loader a/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp_sec3
152
        0, // didBecomeUnresponsive
159
        0, // didBecomeUnresponsive
153
        0, // didBecomeResponsive
160
        0, // didBecomeResponsive
154
        0, // processDidCrash
161
        0, // processDidCrash
155
        0, // didChangeBackForwardList
162
        didChangeBackForwardList,
156
        0, // shouldGoToBackForwardListItem
163
        0, // shouldGoToBackForwardListItem
157
        0 // didFailToInitializePlugin
164
        0 // didFailToInitializePlugin
158
    };
165
    };
- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp -6 / +30 lines
Lines 20-25 a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp_sec1
20
#include "config.h"
20
#include "config.h"
21
#include "WebKitWebView.h"
21
#include "WebKitWebView.h"
22
22
23
#include "WebKitBackForwardListPrivate.h"
23
#include "WebKitWebContextPrivate.h"
24
#include "WebKitWebContextPrivate.h"
24
#include "WebKitWebLoaderClient.h"
25
#include "WebKitWebLoaderClient.h"
25
#include "WebKitWebLoaderClientPrivate.h"
26
#include "WebKitWebLoaderClientPrivate.h"
Lines 50-68 struct _WebKitWebViewPrivate { a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp_sec2
50
    double estimatedLoadProgress;
51
    double estimatedLoadProgress;
51
52
52
    GRefPtr<WebKitWebLoaderClient> loaderClient;
53
    GRefPtr<WebKitWebLoaderClient> loaderClient;
54
    GRefPtr<WebKitBackForwardList> backForwardList;
53
};
55
};
54
56
55
G_DEFINE_TYPE(WebKitWebView, webkit_web_view, WEBKIT_TYPE_WEB_VIEW_BASE)
57
G_DEFINE_TYPE(WebKitWebView, webkit_web_view, WEBKIT_TYPE_WEB_VIEW_BASE)
56
58
59
static void webkitWebViewSetLoaderClient(WebKitWebView* webView, WebKitWebLoaderClient* loaderClient, WKPageRef wkPage)
60
{
61
    webView->priv->loaderClient = loaderClient;
62
    webkitWebLoaderClientAttachLoaderClientToPage(loaderClient, wkPage);
63
}
64
57
static void webkitWebViewConstructed(GObject* object)
65
static void webkitWebViewConstructed(GObject* object)
58
{
66
{
59
    WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
67
    WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
60
    WebKitWebViewPrivate* priv = webView->priv;
68
    WebKitWebViewPrivate* priv = webView->priv;
61
69
    WebPageProxy* page = webkitWebViewBaseCreateWebPage(WEBKIT_WEB_VIEW_BASE(webView), webkitWebContextGetWKContext(priv->context), 0);
62
    webkitWebViewBaseCreateWebPage(WEBKIT_WEB_VIEW_BASE(webView), webkitWebContextGetWKContext(priv->context), 0);
63
70
64
    static GRefPtr<WebKitWebLoaderClient> defaultLoaderClient = adoptGRef(WEBKIT_WEB_LOADER_CLIENT(g_object_new(WEBKIT_TYPE_WEB_LOADER_CLIENT, NULL)));
71
    static GRefPtr<WebKitWebLoaderClient> defaultLoaderClient = adoptGRef(WEBKIT_WEB_LOADER_CLIENT(g_object_new(WEBKIT_TYPE_WEB_LOADER_CLIENT, NULL)));
65
    webkit_web_view_set_loader_client(webView, defaultLoaderClient.get());
72
    webkitWebViewSetLoaderClient(webView, defaultLoaderClient.get(), toAPI(page));
73
74
    priv->backForwardList = adoptGRef(webkitBackForwardListCreate(WKPageGetBackForwardList(toAPI(page))));
66
}
75
}
67
76
68
static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
77
static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
Lines 235-242 void webkit_web_view_set_loader_client(WebKitWebView* webView, WebKitWebLoaderCl a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp_sec3
235
        return;
244
        return;
236
245
237
    WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
246
    WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
238
    webkitWebLoaderClientAttachLoaderClientToPage(loaderClient, toAPI(page));
247
    webkitWebViewSetLoaderClient(webView, loaderClient, toAPI(page));
239
    priv->loaderClient = loaderClient;
240
}
248
}
241
249
242
/**
250
/**
Lines 416-422 void webkit_web_view_set_custom_charset(WebKitWebView* webView, const gchar* cha a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp_sec4
416
    WKPageSetCustomTextEncodingName(toAPI(page), wkEncodingName.get());
424
    WKPageSetCustomTextEncodingName(toAPI(page), wkEncodingName.get());
417
}
425
}
418
426
419
/*
427
/**
420
 * webkit_web_view_get_estimated_load_progress:
428
 * webkit_web_view_get_estimated_load_progress:
421
 * @web_view: a #WebKitWebView
429
 * @web_view: a #WebKitWebView
422
 *
430
 *
Lines 432-434 gdouble webkit_web_view_get_estimated_load_progress(WebKitWebView* webView) a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp_sec5
432
    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
440
    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
433
    return webView->priv->estimatedLoadProgress;
441
    return webView->priv->estimatedLoadProgress;
434
}
442
}
443
444
/**
445
 * webkit_web_view_get_back_forward_list:
446
 * @web_view: a #WebKitWebView
447
 *
448
 * Obtains the #WebKitBackForwardList associated with the given #WebKitWebView. The
449
 * #WebKitBackForwardList is owned by the #WebKitWebView.
450
 *
451
 * Returns: (transfer none): the #WebKitBackForwardList
452
 */
453
WebKitBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView)
454
{
455
    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
456
457
    return webView->priv->backForwardList.get();
458
}
- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h -2 / +6 lines
Lines 27-32 a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h_sec1
27
#ifndef WebKitWebView_h
27
#ifndef WebKitWebView_h
28
#define WebKitWebView_h
28
#define WebKitWebView_h
29
29
30
#include <webkit2/WebKitBackForwardList.h>
30
#include <webkit2/WebKitDefines.h>
31
#include <webkit2/WebKitDefines.h>
31
#include <webkit2/WebKitWebContext.h>
32
#include <webkit2/WebKitWebContext.h>
32
#include <webkit2/WebKitWebLoaderClient.h>
33
#include <webkit2/WebKitWebLoaderClient.h>
Lines 103-115 WEBKIT_API void a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h_sec2
103
webkit_web_view_go_back                     (WebKitWebView         *web_view);
104
webkit_web_view_go_back                     (WebKitWebView         *web_view);
104
105
105
WEBKIT_API gboolean
106
WEBKIT_API gboolean
106
webkit_web_view_can_go_back         (WebKitWebView         *web_view);
107
webkit_web_view_can_go_back                 (WebKitWebView         *web_view);
107
108
108
WEBKIT_API void
109
WEBKIT_API void
109
webkit_web_view_go_forward                  (WebKitWebView         *web_view);
110
webkit_web_view_go_forward                  (WebKitWebView         *web_view);
110
111
112
WEBKIT_API WebKitBackForwardList *
113
webkit_web_view_get_back_forward_list       (WebKitWebView         *web_view);
114
111
WEBKIT_API gboolean
115
WEBKIT_API gboolean
112
webkit_web_view_can_go_forward      (WebKitWebView         *web_view);
116
webkit_web_view_can_go_forward              (WebKitWebView         *web_view);
113
117
114
WEBKIT_API const gchar *
118
WEBKIT_API const gchar *
115
webkit_web_view_get_custom_charset          (WebKitWebView         *web_view);
119
webkit_web_view_get_custom_charset          (WebKitWebView         *web_view);
- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp -1 / +2 lines
Lines 433-444 WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase* webkitWebViewBase) a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp_sec1
433
    return webkitWebViewBase->priv->pageProxy.get();
433
    return webkitWebViewBase->priv->pageProxy.get();
434
}
434
}
435
435
436
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WKContextRef context, WKPageGroupRef pageGroup)
436
WebPageProxy* webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WKContextRef context, WKPageGroupRef pageGroup)
437
{
437
{
438
    WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
438
    WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
439
439
440
    priv->pageProxy = toImpl(context)->createWebPage(priv->pageClient.get(), toImpl(pageGroup));
440
    priv->pageProxy = toImpl(context)->createWebPage(priv->pageClient.get(), toImpl(pageGroup));
441
    priv->pageProxy->initializeWebPage();
441
    priv->pageProxy->initializeWebPage();
442
    return priv->pageProxy.get();
442
}
443
}
443
444
444
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip)
445
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip)
- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h -1 / +1 lines
Lines 42-48 GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*); a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h_sec1
42
42
43
WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
43
WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
44
44
45
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WKContextRef, WKPageGroupRef);
45
WebPageProxy* webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WKContextRef, WKPageGroupRef);
46
46
47
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
47
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
48
48
- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am -1 / +9 lines
Lines 2-8 TEST_PROGS += \ a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am_sec1
2
	Programs/WebKit2APITests/TestWebKitWebContext \
2
	Programs/WebKit2APITests/TestWebKitWebContext \
3
	Programs/WebKit2APITests/TestWebKitWebView \
3
	Programs/WebKit2APITests/TestWebKitWebView \
4
	Programs/WebKit2APITests/TestWebKitWebLoaderClient \
4
	Programs/WebKit2APITests/TestWebKitWebLoaderClient \
5
	Programs/WebKit2APITests/TestWebKitSettings
5
	Programs/WebKit2APITests/TestWebKitSettings \
6
	Programs/WebKit2APITests/TestBackForwardList
6
7
7
noinst_PROGRAMS += $(TEST_PROGS)
8
noinst_PROGRAMS += $(TEST_PROGS)
8
webkit2_tests_cppflags = \
9
webkit2_tests_cppflags = \
Lines 68-70 Programs_WebKit2APITests_TestWebKitSettings_SOURCES = \ a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am_sec2
68
Programs_WebKit2APITests_TestWebKitSettings_CPPFLAGS = $(webkit2_tests_cppflags)
69
Programs_WebKit2APITests_TestWebKitSettings_CPPFLAGS = $(webkit2_tests_cppflags)
69
Programs_WebKit2APITests_TestWebKitSettings_LDADD = $(webkit2_tests_ldadd)
70
Programs_WebKit2APITests_TestWebKitSettings_LDADD = $(webkit2_tests_ldadd)
70
Programs_WebKit2APITests_TestWebKitSettings_LDFLAGS = $(webkit2_tests_ldflags)
71
Programs_WebKit2APITests_TestWebKitSettings_LDFLAGS = $(webkit2_tests_ldflags)
72
73
Programs_WebKit2APITests_TestBackForwardList_SOURCES = \
74
        Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp
75
Programs_WebKit2APITests_TestBackForwardList_CPPFLAGS = $(webkit2_tests_cppflags)
76
Programs_WebKit2APITests_TestBackForwardList_LDADD = $(webkit2_tests_ldadd)
77
Programs_WebKit2APITests_TestBackForwardList_LDFLAGS = $(webkit2_tests_ldflags)
78
- a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp +269 lines
Line 0 a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Igalia S.L.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 */
19
20
#include "config.h"
21
22
#include "LoadTrackingTest.h"
23
#include "WebKitTestServer.h"
24
#include <gtk/gtk.h>
25
#include <libsoup/soup.h>
26
#include <string.h>
27
#include <webkit2/webkit2.h>
28
29
// Back forward list limit is 100 by default.
30
static const size_t wkBackForwardListLimit = 100;
31
32
static WebKitTestServer* kServer;
33
34
static void serverCallback(SoupServer* server, SoupMessage* msg, const char* path, GHashTable* query, SoupClientContext* context, gpointer data)
35
{
36
    if (msg->method != SOUP_METHOD_GET) {
37
        soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED);
38
        return;
39
    }
40
41
    soup_message_set_status(msg, SOUP_STATUS_OK);
42
43
    char* body = g_strdup_printf("<html><title>%s</title><body>%s</body></html>", path + 1, path + 1);
44
    soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, body, strlen(body));
45
46
    soup_message_body_complete(msg->response_body);
47
}
48
49
class BackForwardListTest: public LoadTrackingTest {
50
public:
51
    MAKE_GLIB_TEST_FIXTURE(BackForwardListTest);
52
53
    enum {
54
        Backward,
55
        Forward
56
    };
57
58
    enum {
59
        CurrentItem  = 1 << 0,
60
        AddedItem    = 1 << 1,
61
        RemovedItems = 1 << 2
62
    };
63
64
    static void checkItem(WebKitBackForwardListItem* item, const gchar* title, const gchar* uri, const gchar* originalURI)
65
    {
66
        g_assert(item);
67
        g_assert_cmpstr(webkit_back_forward_list_item_get_uri(item), ==, uri);
68
        g_assert_cmpstr(webkit_back_forward_list_item_get_title(item), == , title);
69
        g_assert_cmpstr(webkit_back_forward_list_item_get_original_uri(item), ==, originalURI);
70
    }
71
72
    static void checkItemIndex(WebKitBackForwardList* list)
73
    {
74
        g_assert(webkit_back_forward_list_get_nth_item(list, -1) == webkit_back_forward_list_get_back_item(list));
75
        g_assert(webkit_back_forward_list_get_nth_item(list, 0) == webkit_back_forward_list_get_current_item(list));
76
        g_assert(webkit_back_forward_list_get_nth_item(list, 1) == webkit_back_forward_list_get_forward_item(list));
77
    }
78
79
    static void checkList(WebKitBackForwardList* list, guint type, WebKitBackForwardListItem** items, guint nItems)
80
    {
81
        GList* listItems = type == BackForwardListTest::Backward ? webkit_back_forward_list_get_back_list(list) :
82
            webkit_back_forward_list_get_forward_list(list);
83
        g_assert(listItems);
84
85
        guint i = 0;
86
        for (GList* listItem = listItems; listItem; listItem = g_list_next(listItem), i++) {
87
            g_assert_cmpuint(i, <, nItems);
88
            g_assert(listItem->data == items[i]);
89
        }
90
        g_list_free(listItems);
91
    }
92
93
    static void backForwardListChanged(WebKitBackForwardList* list, WebKitBackForwardListItem* addedItem, GList* removedItems, BackForwardListTest* test)
94
    {
95
        test->m_hasChanged = true;
96
97
        if (test->m_changedFlags & BackForwardListTest::AddedItem) {
98
            g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(addedItem));
99
            test->watchObject(G_OBJECT(addedItem));
100
        } else
101
            g_assert(!addedItem);
102
103
        if (test->m_changedFlags & BackForwardListTest::RemovedItems) {
104
            g_assert(removedItems);
105
            for (GList* iter = removedItems; iter; iter = iter->next) {
106
                g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(iter->data));
107
                if (test->m_expectedRemovedItems)
108
                    g_assert(g_list_find(test->m_expectedRemovedItems, iter->data));
109
            }
110
111
        } else
112
            g_assert(!removedItems);
113
    }
114
115
    BackForwardListTest()
116
        : m_list(webkit_web_view_get_back_forward_list(m_webView))
117
        , m_changedFlags(0)
118
        , m_hasChanged(false)
119
        , m_expectedRemovedItems(0)
120
    {
121
        g_signal_connect(m_list, "changed", G_CALLBACK(backForwardListChanged), this);
122
        watchObject(G_OBJECT(m_list));
123
    }
124
125
    ~BackForwardListTest()
126
    {
127
        g_signal_handlers_disconnect_matched(m_list, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
128
    }
129
130
    void waitUntilLoadFinished()
131
    {
132
        m_hasChanged = false;
133
        LoadTrackingTest::waitUntilLoadFinished();
134
        g_assert(m_hasChanged);
135
    }
136
137
    void waitUntilLoadFinishedAndCheckRemovedItems(GList* removedItems)
138
    {
139
        m_expectedRemovedItems = removedItems;
140
        waitUntilLoadFinished();
141
        m_expectedRemovedItems = 0;
142
    }
143
144
    WebKitBackForwardList* m_list;
145
    gulong m_changedFlags;
146
    bool m_hasChanged;
147
    GList* m_expectedRemovedItems;
148
};
149
150
static void testBackForwardListNavigation(BackForwardListTest* test, gconstpointer)
151
{
152
    WebKitBackForwardListItem* items[1];
153
154
    g_assert(!webkit_web_view_can_go_back(test->m_webView));
155
    g_assert(!webkit_web_view_can_go_forward(test->m_webView));
156
157
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 0);
158
    g_assert(!webkit_back_forward_list_get_current_item(test->m_list));
159
    g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
160
    g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
161
    BackForwardListTest::checkItemIndex(test->m_list);
162
    g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
163
    g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
164
165
    CString uriPage1 = kServer->getURIForPath("/Page1");
166
    test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
167
    webkit_web_view_load_uri(test->m_webView, uriPage1.data());
168
    test->waitUntilLoadFinished();
169
170
    g_assert(!webkit_web_view_can_go_back(test->m_webView));
171
    g_assert(!webkit_web_view_can_go_forward(test->m_webView));
172
173
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 1);
174
    WebKitBackForwardListItem* itemPage1 = webkit_back_forward_list_get_current_item(test->m_list);
175
    BackForwardListTest::checkItem(itemPage1, "Page1", uriPage1.data(), uriPage1.data());
176
    g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
177
    g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
178
    BackForwardListTest::checkItemIndex(test->m_list);
179
    g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
180
    g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
181
182
    CString uriPage2 = kServer->getURIForPath("/Page2");
183
    test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
184
    webkit_web_view_load_uri(test->m_webView, uriPage2.data());
185
    test->waitUntilLoadFinished();
186
187
    g_assert(webkit_web_view_can_go_back(test->m_webView));
188
    g_assert(!webkit_web_view_can_go_forward(test->m_webView));
189
190
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
191
    WebKitBackForwardListItem* itemPage2 = webkit_back_forward_list_get_current_item(test->m_list);
192
    BackForwardListTest::checkItem(itemPage2, "Page2", uriPage2.data(), uriPage2.data());
193
    g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1);
194
    g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
195
    BackForwardListTest::checkItemIndex(test->m_list);
196
    items[0] = itemPage1;
197
    BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1);
198
    g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
199
200
    test->m_changedFlags = BackForwardListTest::CurrentItem;
201
    webkit_web_view_go_back(test->m_webView);
202
    test->waitUntilLoadFinished();
203
204
    g_assert(!webkit_web_view_can_go_back(test->m_webView));
205
    g_assert(webkit_web_view_can_go_forward(test->m_webView));
206
207
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
208
    g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list));
209
    BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page1", uriPage1.data(), uriPage1.data());
210
    g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
211
    g_assert(webkit_back_forward_list_get_forward_item(test->m_list) == itemPage2);
212
    BackForwardListTest::checkItemIndex(test->m_list);
213
    g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
214
    items[0] = itemPage2;
215
    BackForwardListTest::checkList(test->m_list, BackForwardListTest::Forward, items, 1);
216
217
    test->m_changedFlags = BackForwardListTest::CurrentItem;
218
    webkit_web_view_go_forward(test->m_webView);
219
    test->waitUntilLoadFinished();
220
221
    g_assert(webkit_web_view_can_go_back(test->m_webView));
222
    g_assert(!webkit_web_view_can_go_forward(test->m_webView));
223
224
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
225
    g_assert(itemPage2 == webkit_back_forward_list_get_current_item(test->m_list));
226
    BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page2", uriPage2.data(), uriPage2.data());
227
    g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1);
228
    g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
229
    BackForwardListTest::checkItemIndex(test->m_list);
230
    items[0] = itemPage1;
231
    BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1);
232
    g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
233
}
234
235
static void testBackForwardListLimitAndCache(BackForwardListTest* test, gconstpointer)
236
{
237
    for (size_t i = 0; i < wkBackForwardListLimit; i++) {
238
        GOwnPtr<char> path(g_strdup_printf("/Page%d", i));
239
        test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
240
        webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath(path.get()).data());
241
        test->waitUntilLoadFinished();
242
    }
243
244
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, wkBackForwardListLimit);
245
    WebKitBackForwardListItem* itemPageFirst = webkit_back_forward_list_get_nth_item(test->m_list, -(wkBackForwardListLimit - 1));
246
    GOwnPtr<GList> removedItems(g_list_prepend(0, itemPageFirst));
247
248
    GOwnPtr<char> path(g_strdup_printf("/Page%d", wkBackForwardListLimit));
249
    test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem | BackForwardListTest::RemovedItems;
250
    webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath(path.get()).data());
251
    test->waitUntilLoadFinishedAndCheckRemovedItems(removedItems.get());
252
253
    g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, wkBackForwardListLimit);
254
}
255
256
void beforeAll()
257
{
258
    kServer = new WebKitTestServer();
259
    kServer->run(serverCallback);
260
261
    BackForwardListTest::add("BackForwardList", "navigation", testBackForwardListNavigation);
262
    BackForwardListTest::add("BackForwardList", "list-limit-and-cache", testBackForwardListLimitAndCache);
263
}
264
265
void afterAll()
266
{
267
    delete kServer;
268
}
269
- a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h -1 / +20 lines
Lines 20-27 a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h_sec1
20
#ifndef TestMain_h
20
#ifndef TestMain_h
21
#define TestMain_h
21
#define TestMain_h
22
22
23
#include <glib.h>
23
#include <glib-object.h>
24
#include <JavaScriptCore/GOwnPtr.h>
24
#include <JavaScriptCore/GOwnPtr.h>
25
#include <JavaScriptCore/HashSet.h>
25
26
26
#define MAKE_GLIB_TEST_FIXTURE(ClassName) \
27
#define MAKE_GLIB_TEST_FIXTURE(ClassName) \
27
    static void setUp(ClassName* fixture, gconstpointer data) \
28
    static void setUp(ClassName* fixture, gconstpointer data) \
Lines 42-47 class Test a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h_sec2
42
{
43
{
43
public:
44
public:
44
    MAKE_GLIB_TEST_FIXTURE(Test);
45
    MAKE_GLIB_TEST_FIXTURE(Test);
46
47
    ~Test()
48
    {
49
        g_assert(m_watchedObjects.isEmpty());
50
    }
51
52
    static void objectFinalized(Test* test, GObject* finalizedObject)
53
    {
54
        test->m_watchedObjects.remove(finalizedObject);
55
    }
56
57
    void watchObject(GObject* object)
58
    {
59
        m_watchedObjects.add(object);
60
        g_object_weak_ref(object, reinterpret_cast<GWeakNotify>(objectFinalized), this);
61
    }
62
63
    HashSet<GObject*> m_watchedObjects;
45
};
64
};
46
65
47
#endif // TestMain_h
66
#endif // TestMain_h
- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp +1 lines
Lines 24-29 WebViewTest::WebViewTest() a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp_sec1
24
    : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new())))
24
    : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new())))
25
    , m_mainLoop(g_main_loop_new(0, TRUE))
25
    , m_mainLoop(g_main_loop_new(0, TRUE))
26
{
26
{
27
    watchObject(G_OBJECT(m_webView));
27
}
28
}
28
29
29
WebViewTest::~WebViewTest()
30
WebViewTest::~WebViewTest()
- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h -1 / +1 lines
Lines 23-29 a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h_sec1
23
#include "TestMain.h"
23
#include "TestMain.h"
24
#include <webkit2/webkit2.h>
24
#include <webkit2/webkit2.h>
25
25
26
class WebViewTest {
26
class WebViewTest: public Test {
27
public:
27
public:
28
    MAKE_GLIB_TEST_FIXTURE(WebViewTest);
28
    MAKE_GLIB_TEST_FIXTURE(WebViewTest);
29
    WebViewTest();
29
    WebViewTest();
- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h +2 lines
Lines 23-28 a/Source/WebKit2/UIProcess/API/gtk/webkit2.h_sec1
23
23
24
#define __WEBKIT2_H_INSIDE__
24
#define __WEBKIT2_H_INSIDE__
25
25
26
#include <webkit2/WebKitBackForwardList.h>
27
#include <webkit2/WebKitBackForwardListItem.h>
26
#include <webkit2/WebKitDefines.h>
28
#include <webkit2/WebKitDefines.h>
27
#include <webkit2/WebKitEnumTypes.h>
29
#include <webkit2/WebKitEnumTypes.h>
28
#include <webkit2/WebKitError.h>
30
#include <webkit2/WebKitError.h>
- a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list +1 lines
Lines 1-4 a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list_sec1
1
BOOLEAN:OBJECT,STRING,POINTER
1
BOOLEAN:OBJECT,STRING,POINTER
2
BOOLEAN:OBJECT
2
BOOLEAN:OBJECT
3
BOOLEAN:VOID
3
BOOLEAN:VOID
4
VOID:OBJECT,POINTER
4
5

Return to Bug 69343