+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.
/*
- * 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
extern "C" {
struct _WebKitWebHistoryItemPrivate {
- WTF::RefPtr<WebCore::HistoryItem> historyItem;
+ WebCore::HistoryItem* historyItem;
WebCore::CString title;
WebCore::CString alternateTitle;
}
/* 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);
}
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;
}
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;
}
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)
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;
}