2009-03-01 Jan Michael Alonzo <jmalonzo@webkit.org>
authorjmalonzo@webkit.org <jmalonzo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Mar 2009 19:21:34 +0000 (19:21 +0000)
committerjmalonzo@webkit.org <jmalonzo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Mar 2009 19:21:34 +0000 (19:21 +0000)
        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: https://svn.webkit.org/repository/webkit/trunk@41339 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/gtk/ChangeLog
WebKit/gtk/webkit/webkitprivate.h
WebKit/gtk/webkit/webkitwebbackforwardlist.cpp
WebKit/gtk/webkit/webkitwebhistoryitem.cpp

index 2a4f119719f50e1160dfc5f9903dbb20c7553a86..e6890b5e6381bef456e8f28dd2e56610fec3aebf 100644 (file)
@@ -1,3 +1,28 @@
+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.
index 114da07e0f3cf72ebf0cb55ee1bd3562615b6183..3fdd4119bb269745c98cba171faa5229ecf364b1 100644 (file)
@@ -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*);
index cbeb70d9c1c7b921b734bf7a18b0bca7f11e99e2..a772bacecfb5eed74f0cf4836a1acad406e9719a 100644 (file)
@@ -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));
     }
 
index 8cdaa906431daac76429c3b8166982db30938979..2b0394c10f1fa542150bd6d8600454efab9a6e82 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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;
 }