summaryrefslogtreecommitdiffstats
path: root/WebCore/history
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch)
treed49911209b132da58d838efa852daf28d516df21 /WebCore/history
parent87eb0cb35bad8784770ebc807e6c982432e47107 (diff)
downloadexternal_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2
Initial Contribution
Diffstat (limited to 'WebCore/history')
-rw-r--r--WebCore/history/BackForwardList.cpp40
-rw-r--r--WebCore/history/BackForwardList.h6
-rw-r--r--WebCore/history/CachedPage.cpp3
-rw-r--r--WebCore/history/HistoryItem.cpp96
-rw-r--r--WebCore/history/HistoryItem.h36
5 files changed, 160 insertions, 21 deletions
diff --git a/WebCore/history/BackForwardList.cpp b/WebCore/history/BackForwardList.cpp
index f912239..3bd7a06 100644
--- a/WebCore/history/BackForwardList.cpp
+++ b/WebCore/history/BackForwardList.cpp
@@ -29,6 +29,12 @@
#include "HistoryItem.h"
#include "Logging.h"
#include "PageCache.h"
+#ifdef ANDROID_HISTORY_CLIENT
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
+#include "Page.h"
+#endif
using namespace std;
@@ -76,25 +82,45 @@ void BackForwardList::addItem(PassRefPtr<HistoryItem> prpItem)
m_entryHash.remove(item);
pageCache()->remove(item.get());
m_current--;
+#ifdef ANDROID_HISTORY_CLIENT
+ m_page->mainFrame()->loader()->client()->dispatchDidRemoveHistoryItem(item.get(), 0);
+#endif
}
m_entries.append(prpItem);
m_entryHash.add(m_entries.last());
m_current++;
+#ifdef ANDROID_HISTORY_CLIENT
+ m_page->mainFrame()->loader()->client()->dispatchDidAddHistoryItem(currentItem());
+#endif
}
void BackForwardList::goBack()
{
ASSERT(m_current > 0);
+#ifdef ANDROID_HISTORY_CLIENT
+ if (m_current > 0) {
+ m_current--;
+ m_page->mainFrame()->loader()->client()->dispatchDidChangeHistoryIndex(this);
+ }
+#else
if (m_current > 0)
m_current--;
+#endif
}
void BackForwardList::goForward()
{
ASSERT(m_current < m_entries.size() - 1);
+#ifdef ANDROID_HISTORY_CLIENT
+ if (m_current < m_entries.size() - 1) {
+ m_current++;
+ m_page->mainFrame()->loader()->client()->dispatchDidChangeHistoryIndex(this);
+ }
+#else
if (m_current < m_entries.size() - 1)
m_current++;
+#endif
}
void BackForwardList::goToItem(HistoryItem* item)
@@ -106,8 +132,15 @@ void BackForwardList::goToItem(HistoryItem* item)
for (; index < m_entries.size(); ++index)
if (m_entries[index] == item)
break;
+#ifdef ANDROID_HISTORY_CLIENT
+ if (index < m_entries.size()) {
+ m_current = index;
+ m_page->mainFrame()->loader()->client()->dispatchDidChangeHistoryIndex(this);
+ }
+#else
if (index < m_entries.size())
m_current = index;
+#endif
}
HistoryItem* BackForwardList::backItem()
@@ -173,8 +206,15 @@ void BackForwardList::setCapacity(int size)
if (!size)
m_current = NoCurrentItemIndex;
+#ifdef ANDROID_HISTORY_CLIENT
+ else if (m_current > m_entries.size() - 1) {
+ m_current = m_entries.size() - 1;
+ m_page->mainFrame()->loader()->client()->dispatchDidChangeHistoryIndex(this);
+ }
+#else
else if (m_current > m_entries.size() - 1)
m_current = m_entries.size() - 1;
+#endif
m_capacity = size;
}
diff --git a/WebCore/history/BackForwardList.h b/WebCore/history/BackForwardList.h
index 048778b..61a0ada 100644
--- a/WebCore/history/BackForwardList.h
+++ b/WebCore/history/BackForwardList.h
@@ -27,7 +27,7 @@
#define BackForwardList_h
#include <wtf/RefCounted.h>
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
@@ -41,7 +41,7 @@ typedef HashSet<RefPtr<HistoryItem> > HistoryItemHashSet;
class BackForwardList : public RefCounted<BackForwardList> {
public:
- static PassRefPtr<BackForwardList> create(Page* page) { return adoptRef(new BackForwardList(page)); }
+ BackForwardList(Page*);
~BackForwardList();
Page* page() { return m_page; }
@@ -74,8 +74,6 @@ public:
HistoryItemVector& entries();
private:
- BackForwardList(Page*);
-
Page* m_page;
HistoryItemVector m_entries;
HistoryItemHashSet m_entryHash;
diff --git a/WebCore/history/CachedPage.cpp b/WebCore/history/CachedPage.cpp
index e28ab50..008f2d6 100644
--- a/WebCore/history/CachedPage.cpp
+++ b/WebCore/history/CachedPage.cpp
@@ -77,8 +77,7 @@ PassRefPtr<CachedPage> CachedPage::create(Page* page)
}
CachedPage::CachedPage(Page* page)
- : RefCounted<CachedPage>(0)
- , m_timeStamp(0)
+ : m_timeStamp(0)
, m_document(page->mainFrame()->document())
, m_view(page->mainFrame()->view())
, m_mousePressNode(page->mainFrame()->eventHandler()->mousePressNode())
diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp
index 05ee6ec..ffc5744 100644
--- a/WebCore/history/HistoryItem.cpp
+++ b/WebCore/history/HistoryItem.cpp
@@ -34,16 +34,18 @@
#include "Logging.h"
#include "PageCache.h"
#include "ResourceRequest.h"
-#include <stdio.h>
namespace WebCore {
+#ifdef ANDROID_HISTORY_CLIENT
+void (*notifyHistoryItemChanged)(HistoryItem*);
+#else
static void defaultNotifyHistoryItemChanged() {}
void (*notifyHistoryItemChanged)() = defaultNotifyHistoryItemChanged;
+#endif
HistoryItem::HistoryItem()
- : RefCounted<HistoryItem>(0)
- , m_lastVisitedTime(0)
+ : m_lastVisitedTime(0)
, m_isInPageCache(false)
, m_isTargetItem(false)
, m_visitCount(0)
@@ -51,8 +53,7 @@ HistoryItem::HistoryItem()
}
HistoryItem::HistoryItem(const String& urlString, const String& title, double time)
- : RefCounted<HistoryItem>(0)
- , m_urlString(urlString)
+ : m_urlString(urlString)
, m_originalURLString(urlString)
, m_title(title)
, m_lastVisitedTime(time)
@@ -64,8 +65,7 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, double ti
}
HistoryItem::HistoryItem(const String& urlString, const String& title, const String& alternateTitle, double time)
- : RefCounted<HistoryItem>(0)
- , m_urlString(urlString)
+ : m_urlString(urlString)
, m_originalURLString(urlString)
, m_title(title)
, m_displayTitle(alternateTitle)
@@ -78,8 +78,7 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, const Str
}
HistoryItem::HistoryItem(const KURL& url, const String& title)
- : RefCounted<HistoryItem>(0)
- , m_urlString(url.string())
+ : m_urlString(url.string())
, m_originalURLString(url.string())
, m_title(title)
, m_lastVisitedTime(0)
@@ -91,8 +90,7 @@ HistoryItem::HistoryItem(const KURL& url, const String& title)
}
HistoryItem::HistoryItem(const KURL& url, const String& target, const String& parent, const String& title)
- : RefCounted<HistoryItem>(0)
- , m_urlString(url.string())
+ : m_urlString(url.string())
, m_originalURLString(url.string())
, m_target(target)
, m_parent(parent)
@@ -112,7 +110,7 @@ HistoryItem::~HistoryItem()
}
HistoryItem::HistoryItem(const HistoryItem& item)
- : RefCounted<HistoryItem>(0)
+ : RefCounted<HistoryItem>()
, m_urlString(item.m_urlString)
, m_originalURLString(item.m_originalURLString)
, m_target(item.m_target)
@@ -126,10 +124,18 @@ HistoryItem::HistoryItem(const HistoryItem& item)
, m_visitCount(item.m_visitCount)
, m_formContentType(item.m_formContentType)
, m_formReferrer(item.m_formReferrer)
+#ifdef ANDROID_FIX
+ , m_originalFormContentType(item.m_originalFormContentType)
+ , m_originalFormReferrer(item.m_originalFormReferrer)
+#endif
, m_rssFeedReferrer(item.m_rssFeedReferrer)
{
if (item.m_formData)
m_formData = item.m_formData->copy();
+#ifdef ANDROID_FIX
+ if (item.m_originalFormData)
+ m_originalFormData = item.m_originalFormData->copy();
+#endif
unsigned size = item.m_subItems.size();
m_subItems.reserveCapacity(size);
@@ -177,12 +183,12 @@ double HistoryItem::lastVisitedTime() const
KURL HistoryItem::url() const
{
- return KURL(m_urlString);
+ return KURL(m_urlString.deprecatedString());
}
KURL HistoryItem::originalURL() const
{
- return KURL(m_originalURLString);
+ return KURL(m_originalURLString.deprecatedString());
}
const String& HistoryItem::target() const
@@ -198,7 +204,9 @@ const String& HistoryItem::parent() const
void HistoryItem::setAlternateTitle(const String& alternateTitle)
{
m_displayTitle = alternateTitle;
+#ifndef ANDROID_HISTORY_CLIENT
notifyHistoryItemChanged();
+#endif
}
void HistoryItem::setURLString(const String& urlString)
@@ -209,7 +217,11 @@ void HistoryItem::setURLString(const String& urlString)
iconDatabase()->retainIconForPageURL(m_urlString);
}
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#else
notifyHistoryItemChanged();
+#endif
}
void HistoryItem::setURL(const KURL& url)
@@ -222,19 +234,31 @@ void HistoryItem::setURL(const KURL& url)
void HistoryItem::setOriginalURLString(const String& urlString)
{
m_originalURLString = urlString;
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#else
notifyHistoryItemChanged();
+#endif
}
void HistoryItem::setTitle(const String& title)
{
m_title = title;
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#else
notifyHistoryItemChanged();
+#endif
}
void HistoryItem::setTarget(const String& target)
{
m_target = target;
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#else
notifyHistoryItemChanged();
+#endif
}
void HistoryItem::setParent(const String& parent)
@@ -279,6 +303,9 @@ void HistoryItem::clearScrollPoint()
void HistoryItem::setDocumentState(const Vector<String>& state)
{
m_documentState = state;
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#endif
}
const Vector<String>& HistoryItem::documentState() const
@@ -289,6 +316,9 @@ const Vector<String>& HistoryItem::documentState() const
void HistoryItem::clearDocumentState()
{
m_documentState.clear();
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#endif
}
bool HistoryItem::isTargetItem() const
@@ -299,11 +329,17 @@ bool HistoryItem::isTargetItem() const
void HistoryItem::setIsTargetItem(bool flag)
{
m_isTargetItem = flag;
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#endif
}
void HistoryItem::addChildItem(PassRefPtr<HistoryItem> child)
{
m_subItems.append(child);
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#endif
}
HistoryItem* HistoryItem::childItemWithName(const String& name) const
@@ -384,6 +420,9 @@ void HistoryItem::setFormInfoFromRequest(const ResourceRequest& request)
m_formContentType = String();
m_formReferrer = String();
}
+#ifdef ANDROID_HISTORY_CLIENT
+ notifyHistoryItemChanged(this);
+#endif
}
FormData* HistoryItem::formData()
@@ -391,6 +430,35 @@ FormData* HistoryItem::formData()
return m_formData.get();
}
+#ifdef ANDROID_FIX
+const FormData* HistoryItem::formData() const
+{
+ return m_formData.get();
+}
+
+FormData* HistoryItem::originalFormData() const
+{
+ return m_originalFormData.get();
+}
+
+String HistoryItem::originalFormContentType() const
+{
+ return m_originalFormContentType;
+}
+
+String HistoryItem::originalFormReferrer() const
+{
+ return m_originalFormReferrer;
+}
+
+void HistoryItem::setOriginalFormInfo(PassRefPtr<FormData> formdata, const String& contentType, const String& referrer)
+{
+ m_originalFormData = formdata;
+ m_originalFormContentType = contentType;
+ m_originalFormReferrer = referrer;
+}
+#endif
+
bool HistoryItem::isCurrentDocument(Document* doc) const
{
// FIXME: We should find a better way to check if this is the current document.
diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h
index c0650a4..5920635 100644
--- a/WebCore/history/HistoryItem.h
+++ b/WebCore/history/HistoryItem.h
@@ -29,6 +29,7 @@
#include "CachedPage.h"
#include "FormData.h"
#include "IntPoint.h"
+#include "KURL.h"
#include "PlatformString.h"
#include <wtf/RefCounted.h>
#include "StringHash.h"
@@ -42,6 +43,10 @@
typedef struct objc_object* id;
#endif
+#ifdef ANDROID_HISTORY_CLIENT
+#include "WebHistory.h"
+#endif
+
namespace WebCore {
class Document;
@@ -52,7 +57,11 @@ class ResourceRequest;
class HistoryItem;
typedef Vector<RefPtr<HistoryItem> > HistoryItemVector;
+#ifdef ANDROID_HISTORY_CLIENT
+extern void (*notifyHistoryItemChanged)(HistoryItem*);
+#else
extern void (*notifyHistoryItemChanged)();
+#endif
class HistoryItem : public RefCounted<HistoryItem> {
friend class PageCache;
@@ -89,6 +98,15 @@ public:
bool isTargetItem() const;
FormData* formData();
+#ifdef ANDROID_FIX
+ const FormData* formData() const;
+
+ FormData* originalFormData() const;
+ String originalFormContentType() const;
+ String originalFormReferrer() const;
+
+ void setOriginalFormInfo(PassRefPtr<FormData>, const String&, const String&);
+#endif
String formContentType() const;
String formReferrer() const;
String rssFeedReferrer() const;
@@ -144,6 +162,11 @@ public:
int showTree() const;
int showTreeWithIndent(unsigned indentLevel) const;
#endif
+
+#ifdef ANDROID_HISTORY_CLIENT
+ void setBridge(android::WebHistoryItem* bridge) { m_bridge = bridge; }
+ android::WebHistoryItem* bridge() const { return m_bridge.get(); }
+#endif
private:
HistoryItem(const HistoryItem&);
@@ -170,7 +193,14 @@ private:
RefPtr<FormData> m_formData;
String m_formContentType;
String m_formReferrer;
-
+
+#ifdef ANDROID_FIX
+ // info used to repost form data for the original request
+ RefPtr<FormData> m_originalFormData;
+ String m_originalFormContentType;
+ String m_originalFormReferrer;
+#endif
+
// info used to support RSS feeds
String m_rssFeedReferrer;
@@ -183,6 +213,10 @@ private:
RetainPtr<id> m_viewState;
OwnPtr<HashMap<String, RetainPtr<id> > > m_transientProperties;
#endif
+
+#ifdef ANDROID_HISTORY_CLIENT
+ RefPtr<android::WebHistoryItem> m_bridge;
+#endif
}; //class HistoryItem
} //namespace WebCore