Commit 7f1b0e79 authored by jmalonzo@webkit.org's avatar jmalonzo@webkit.org
Browse files

2009-03-01 Jan Michael Alonzo <jmalonzo@webkit.org>

        Reviewed by Holger Freyther.

        [Gtk] get the HTTP layout tests going
        https://bugs.webkit.org/show_bug.cgi?id=24259

        Create a WebKitWebHistoryItem for each WebCore::HistoryItem when
        necessary.
        Add necessary API additions for us to be able to dump a WebKitWebHistoryItem

        * webkit/webkitprivate.h:
        * webkit/webkitwebbackforwardlist.cpp:
        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_forward_list_with_limit):
        (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_back_list_with_limit):
        * webkit/webkitwebhistoryitem.cpp:
        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_core_item):
        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new):
        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_data):
        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_target):
        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_is_target_item):
        (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_children):
        (WebKit::core):
        (WebKit::kit):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41339 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8a089a4e
2009-03-01 Jan Michael Alonzo <jmalonzo@webkit.org>
Reviewed by Holger Freyther.
[Gtk] get the HTTP layout tests going
https://bugs.webkit.org/show_bug.cgi?id=24259
Create a WebKitWebHistoryItem for each WebCore::HistoryItem when
necessary.
Add necessary API additions for us to be able to dump a WebKitWebHistoryItem
* webkit/webkitprivate.h:
* webkit/webkitwebbackforwardlist.cpp:
(_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_forward_list_with_limit):
(_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_back_list_with_limit):
* webkit/webkitwebhistoryitem.cpp:
(_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_core_item):
(_WebKitWebHistoryItemPrivate::webkit_web_history_item_new):
(_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_data):
(_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_target):
(_WebKitWebHistoryItemPrivate::webkit_web_history_item_is_target_item):
(_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_children):
(WebKit::core):
(WebKit::kit):
2009-03-01 Christian Dywan <christian@twotoasts.de>
Reviewed by Holger Freyther.
......
......@@ -57,7 +57,7 @@ namespace WebKit {
WebKitWebView* kit(WebCore::Page*);
WebCore::HistoryItem* core(WebKitWebHistoryItem*);
WebKitWebHistoryItem* kit(WebCore::HistoryItem*);
WebKitWebHistoryItem* kit(PassRefPtr<WebCore::HistoryItem>);
WebCore::BackForwardList* core(WebKitWebBackForwardList*);
......@@ -124,8 +124,19 @@ extern "C" {
void
webkit_web_frame_core_frame_gone(WebKitWebFrame*);
// WebKitWebHistoryItem private
WebKitWebHistoryItem*
webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*);
webkit_web_history_item_new_with_core_item(PassRefPtr<WebCore::HistoryItem> historyItem);
WEBKIT_API G_CONST_RETURN gchar*
webkit_web_history_item_get_target(WebKitWebHistoryItem*);
WEBKIT_API gboolean
webkit_web_history_item_is_target_item(WebKitWebHistoryItem*);
WEBKIT_API GList*
webkit_web_history_item_get_children(WebKitWebHistoryItem*);
// end WebKitWebHistoryItem private
void
webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebKit::InspectorClient*);
......
......@@ -189,7 +189,7 @@ GList* webkit_web_back_forward_list_get_forward_list_with_limit(WebKitWebBackFor
backForwardList->forwardListWithLimit(limit, items);
for (unsigned i = 0; i < items.size(); i++) {
WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new_with_core_item(items[i].get());
WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new_with_core_item(items[i]);
forwardItems = g_list_prepend(forwardItems, g_object_ref(webHistoryItem));
}
......@@ -219,7 +219,7 @@ GList* webkit_web_back_forward_list_get_back_list_with_limit(WebKitWebBackForwar
backForwardList->backListWithLimit(limit, items);
for (unsigned i = 0; i < items.size(); i++) {
WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new_with_core_item(items[i].get());
WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new_with_core_item(items[i]);
backItems = g_list_prepend(backItems, g_object_ref(webHistoryItem));
}
......
/*
* Copyright (C) 2008 Jan Michael C. Alonzo
* Copyright (C) 2008, 2009 Jan Michael C. Alonzo
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -53,7 +53,7 @@ using namespace WebKit;
extern "C" {
struct _WebKitWebHistoryItemPrivate {
WTF::RefPtr<WebCore::HistoryItem> historyItem;
WebCore::HistoryItem* historyItem;
WebCore::CString title;
WebCore::CString alternateTitle;
......@@ -270,21 +270,9 @@ static void webkit_web_history_item_get_property(GObject* object, guint prop_id,
}
/* Helper function to create a new WebHistoryItem instance when needed */
WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::HistoryItem* item)
WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(PassRefPtr<WebCore::HistoryItem> historyItem)
{
WebKitWebHistoryItem* webHistoryItem = kit(item);
if (webHistoryItem)
g_object_ref(webHistoryItem);
else {
webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
priv->historyItem = item;
webkit_history_item_add(webHistoryItem, priv->historyItem.get());
}
return webHistoryItem;
return kit(historyItem);
}
......@@ -300,8 +288,9 @@ WebKitWebHistoryItem* webkit_web_history_item_new()
WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
priv->historyItem = WebCore::HistoryItem::create();
webkit_history_item_add(webHistoryItem, priv->historyItem.get());
RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create();
priv->historyItem = item.release().releaseRef();
webkit_history_item_add(webHistoryItem, priv->historyItem);
return webHistoryItem;
}
......@@ -323,8 +312,9 @@ WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, co
WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
priv->historyItem = WebCore::HistoryItem::create(historyUri, historyTitle, 0);
webkit_history_item_add(webHistoryItem, priv->historyItem.get());
RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(historyUri, historyTitle, 0);
priv->historyItem = item.release().releaseRef();
webkit_history_item_add(webHistoryItem, priv->historyItem);
return webHistoryItem;
}
......@@ -452,6 +442,51 @@ gdouble webkit_web_history_item_get_last_visited_time(WebKitWebHistoryItem* webH
return item->lastVisitedTime();
}
/* private methods */
G_CONST_RETURN gchar* webkit_web_history_item_get_target(WebKitWebHistoryItem* webHistoryItem)
{
g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
WebCore::HistoryItem* item = core(webHistoryItem);
g_return_val_if_fail(item != NULL, NULL);
WebCore::CString t = item->target().utf8();
return g_strdup(t.data());
}
gboolean webkit_web_history_item_is_target_item(WebKitWebHistoryItem* webHistoryItem)
{
g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
WebCore::HistoryItem* item = core(webHistoryItem);
g_return_val_if_fail(item != NULL, NULL);
return item->isTargetItem();
}
GList* webkit_web_history_item_get_children(WebKitWebHistoryItem* webHistoryItem)
{
g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
WebCore::HistoryItem* item = core(webHistoryItem);
g_return_val_if_fail(item != NULL, NULL);
const WebCore::HistoryItemVector& children = item->children();
if (!children.size())
return NULL;
unsigned size = children.size();
GList* kids = NULL;
for (unsigned i = 0; i < size; ++i)
kids = g_list_prepend(kids, kit(children[i].get()));
return g_list_reverse(kids);
}
} /* end extern "C" */
WebCore::HistoryItem* WebKit::core(WebKitWebHistoryItem* webHistoryItem)
......@@ -459,19 +494,29 @@ WebCore::HistoryItem* WebKit::core(WebKitWebHistoryItem* webHistoryItem)
g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
WTF::RefPtr<WebCore::HistoryItem> historyItem = priv->historyItem;
return historyItem ? historyItem.get() : 0;
return priv->historyItem ? priv->historyItem : 0;
}
WebKitWebHistoryItem* WebKit::kit(WebCore::HistoryItem* historyItem)
WebKitWebHistoryItem* WebKit::kit(PassRefPtr<WebCore::HistoryItem> historyItem)
{
g_return_val_if_fail(historyItem != NULL, NULL);
RefPtr<WebCore::HistoryItem> item = historyItem;
WebKitWebHistoryItem* webHistoryItem;
GHashTable* table = webkit_history_items();
webHistoryItem = (WebKitWebHistoryItem*) g_hash_table_lookup(table, historyItem);
webHistoryItem = (WebKitWebHistoryItem*) g_hash_table_lookup(table, item.get());
if (!webHistoryItem) {
webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
priv->historyItem = item.release().releaseRef();
webkit_history_item_add(webHistoryItem, priv->historyItem);
}
return webHistoryItem;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment