diff options
author | Ben Murdoch <benm@google.com> | 2009-12-04 11:44:00 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-12-04 11:50:30 +0000 |
commit | ccb5bca64507e67ae70f8190df403cbeff7ab97b (patch) | |
tree | a2fca86b6ac838a748c8bb446ca6d274e2ab9c28 | |
parent | a0759a90223201ad97d6131b7754e98f3f7a56e4 (diff) | |
parent | 130cd407abaa055e69b8dfb143b3a7779dbabefc (diff) | |
download | external_webkit-ccb5bca64507e67ae70f8190df403cbeff7ab97b.zip external_webkit-ccb5bca64507e67ae70f8190df403cbeff7ab97b.tar.gz external_webkit-ccb5bca64507e67ae70f8190df403cbeff7ab97b.tar.bz2 |
resolved conflicts for merge of 130cd407 to master
Change-Id: I472802c99be3510e346350f66a386643caba6410
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | WebCore/Android.mk | 2 | ||||
-rw-r--r-- | WebCore/config.h | 1 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 24 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h | 8 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreJniOnLoad.cpp | 1 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.cpp | 89 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.h | 35 |
8 files changed, 53 insertions, 108 deletions
@@ -176,6 +176,7 @@ LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ $(LOCAL_PATH)/WebCore/dom \ $(LOCAL_PATH)/WebCore/editing \ $(LOCAL_PATH)/WebCore/history \ + $(LOCAL_PATH)/WebCore/history/android \ $(LOCAL_PATH)/WebCore/html \ $(LOCAL_PATH)/WebCore/html/canvas \ $(LOCAL_PATH)/WebCore/inspector \ diff --git a/WebCore/Android.mk b/WebCore/Android.mk index 6d3c4b0..468e566 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -235,6 +235,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ history/HistoryItem.cpp \ history/PageCache.cpp \ \ + history/android/HistoryItemAndroid.cpp \ + \ html/CollectionCache.cpp \ html/File.cpp \ html/FileList.cpp \ diff --git a/WebCore/config.h b/WebCore/config.h index 598acc4..02958bc 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -141,7 +141,6 @@ // Converts ListBoxes to dropdown popup lists. #define ANDROID_LISTBOX_USES_MENU_LIST -#define ANDROID_HISTORY_CLIENT #define ANDROID_MULTIPLE_WINDOWS #define ANDROID_CSS_TAP_HIGHLIGHT_COLOR diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 6338e26..ea1f327 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -737,12 +737,11 @@ void FrameLoaderClientAndroid::frameLoadCompleted() { } void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT ASSERT(m_frame); ASSERT(item); // We should have added a bridge when the child item was added to its // parent. - WebHistoryItem* bridge = item->bridge(); + AndroidWebHistoryBridge* bridge = item->bridge(); ASSERT(bridge); // store the current scale (only) for the top frame if (!m_frame->tree()->parent()) { @@ -752,41 +751,38 @@ void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { } WebCore::notifyHistoryItemChanged(item); -#endif } void FrameLoaderClientAndroid::restoreViewState() { -#ifdef ANDROID_HISTORY_CLIENT WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); HistoryItem* item = m_frame->loader()->history()->currentItem(); + AndroidWebHistoryBridge* bridge = item->bridge(); // restore the scale (only) for the top frame if (!m_frame->tree()->parent()) { - int scale = item->bridge()->scale(); + int scale = bridge->scale(); webViewCore->restoreScale(scale); - int screenWidthScale = item->bridge()->screenWidthScale(); + int screenWidthScale = bridge->screenWidthScale(); if (screenWidthScale != scale) webViewCore->restoreScreenWidthScale(screenWidthScale); } -#endif } -#ifdef ANDROID_HISTORY_CLIENT -void FrameLoaderClientAndroid::dispatchDidAddHistoryItem(HistoryItem* item) const { +void FrameLoaderClientAndroid::dispatchDidAddBackForwardItem(HistoryItem* item) const { ASSERT(m_frame); m_webFrame->addHistoryItem(item); } -void FrameLoaderClientAndroid::dispatchDidRemoveHistoryItem(HistoryItem* item, int index) const { +void FrameLoaderClientAndroid::dispatchDidRemoveBackForwardItem(HistoryItem* item) const { ASSERT(m_frame); - m_webFrame->removeHistoryItem(index); + m_webFrame->removeHistoryItem(0); } -void FrameLoaderClientAndroid::dispatchDidChangeHistoryIndex( - BackForwardList* list) const { +void FrameLoaderClientAndroid::dispatchDidChangeBackForwardIndex() const { ASSERT(m_frame); + BackForwardList* list = m_frame->page()->backForwardList(); + ASSERT(list); m_webFrame->updateHistoryIndex(list->backListCount()); } -#endif void FrameLoaderClientAndroid::provisionalLoadStarted() { ASSERT(m_frame); diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h index ec522d2..86551f3 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h @@ -130,11 +130,9 @@ namespace android { virtual void didDisplayInsecureContent(); virtual void didRunInsecureContent(SecurityOrigin*); -#ifdef ANDROID_HISTORY_CLIENT - virtual void dispatchDidAddHistoryItem(HistoryItem*) const; - virtual void dispatchDidRemoveHistoryItem(HistoryItem*, int) const; - virtual void dispatchDidChangeHistoryIndex(BackForwardList*) const; -#endif + virtual void dispatchDidAddBackForwardItem(HistoryItem*) const; + virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const; + virtual void dispatchDidChangeBackForwardIndex() const; virtual ResourceError cancelledError(const ResourceRequest&); virtual ResourceError blockedError(const ResourceRequest&); diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp index 2450b78..b7c2fed 100644 --- a/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -56,6 +56,7 @@ #include "TextEncoding.h" #include "WebCoreViewBridge.h" #include "WebFrameView.h" +#include "WebHistory.h" #include "WebViewCore.h" #include "SkBitmap.h" diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index 3eecaa9..edca19a 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -90,7 +90,7 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame) list->removeItem(entries[i].get()); // Add the current item back to the list. if (current) { - current->setBridge(NULL); + current->setBridge(0); // addItem will update the children to match the newly created bridge list->addItem(current); @@ -174,10 +174,9 @@ static void WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray d // Inflate the history tree into one HistoryItem or null if the inflation // failed. RefPtr<WebCore::HistoryItem> newItem = WebCore::HistoryItem::create(); -#ifdef ANDROID_HISTORY_CLIENT RefPtr<WebHistoryItem> bridge = new WebHistoryItem(env, obj, newItem.get()); newItem->setBridge(bridge.get()); -#endif + // Inflate the item recursively. If it fails, that is ok. We'll have an // incomplete HistoryItem but that is better than crashing due to a null // item. @@ -187,28 +186,19 @@ static void WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray d const char* ptr = reinterpret_cast<const char*>(bytes); read_item_recursive(newItem.get(), &ptr, (int)size); env->ReleaseByteArrayElements(data, const_cast<jbyte*>(bytes), JNI_ABORT); -#ifdef ANDROID_HISTORY_CLIENT bridge->setActive(); -#endif // Add the new item to the back/forward list. WebCore::Frame* pFrame = (WebCore::Frame*)frame; pFrame->page()->backForwardList()->addItem(newItem); -#ifdef ANDROID_HISTORY_CLIENT // Update the item. bridge->updateHistoryItem(newItem.get()); -#endif } // 6 empty strings + no document state + children count = 8 unsigned values -// 1 char for isTargetItem -// ANDROID_HISTORY_CLIENT adds 1 int for scale. -#ifdef ANDROID_HISTORY_CLIENT +// 1 char for isTargetItem and 1 char is for scale. #define HISTORY_MIN_SIZE ((int)(sizeof(unsigned) * 9 + sizeof(char))) -#else -#define HISTORY_MIN_SIZE ((int)(sizeof(unsigned) * 8 + sizeof(char))) -#endif jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::HistoryItem* item) { @@ -220,9 +210,7 @@ jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::Histo // Write the top-level history item and then write all the children // recursively. -#ifdef ANDROID_HISTORY_CLIENT LOG_ASSERT(item->bridge(), "Why don't we have a bridge object here?"); -#endif write_item(v, item); write_children_recursive(v, item); @@ -238,32 +226,31 @@ jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::Histo WebHistoryItem::WebHistoryItem(JNIEnv* env, jobject obj, WebCore::HistoryItem* item) { - mObject = env->NewWeakGlobalRef(obj); - mScale = 100; - mActive = false; - mParent = NULL; - mHistoryItem = item; + m_object = env->NewWeakGlobalRef(obj); + m_parent = 0; + m_scale = 100; + m_active = false; + m_historyItem = item; } WebHistoryItem::~WebHistoryItem() { - if (mObject) { + if (m_object) { JNIEnv* env = JSC::Bindings::getJNIEnv(); if (!env) return; - env->DeleteWeakGlobalRef(mObject); + env->DeleteWeakGlobalRef(m_object); } } void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT // Do not want to update during inflation. - if (!mActive) + if (!m_active) return; WebHistoryItem* webItem = this; // Now we need to update the top-most WebHistoryItem based on the top-most // HistoryItem. - if (mParent) { - webItem = mParent.get(); + if (m_parent) { + webItem = m_parent.get(); if (webItem->hasOneRef()) { // if the parent only has one ref, it is from this WebHistoryItem. // This means that the matching WebCore::HistoryItem has been freed. @@ -280,7 +267,7 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { return; // Don't do anything if the item has been gc'd already - AutoJObject realItem = getRealObject(env, webItem->mObject); + AutoJObject realItem = getRealObject(env, webItem->m_object); if (!realItem.get()) return; @@ -325,21 +312,17 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { if (favicon) env->DeleteLocalRef(favicon); env->DeleteLocalRef(array); -#endif } static void historyItemChanged(WebCore::HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT - LOG_ASSERT(item, - "historyItemChanged called with a null item"); + LOG_ASSERT(item, "historyItemChanged called with a null item"); + if (item->bridge()) item->bridge()->updateHistoryItem(item); -#endif } void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT LOG_ASSERT(item, "newItem must take a valid HistoryItem!"); // Item already added. Should only happen when we are inflating the list. if (item->bridge() || !list.get()) @@ -364,7 +347,6 @@ void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item) // Delete our local reference. env->DeleteLocalRef(newItem); -#endif } void WebHistory::RemoveItem(const AutoJObject& list, int index) @@ -434,14 +416,12 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item) // Target write_string(v, item->target()); -#ifdef ANDROID_HISTORY_CLIENT - WebHistoryItem* bridge = item->bridge(); + AndroidWebHistoryBridge* bridge = item->bridge(); LOG_ASSERT(bridge, "We should have a bridge here!"); // Screen scale int scale = bridge->scale(); LOGV("Writing scale %d", scale); v.append((char*)&scale, sizeof(int)); -#endif // Document state const WTF::Vector<WebCore::String>& docState = item->documentState(); @@ -469,23 +449,23 @@ static void write_children_recursive(WTF::Vector<char>& v, WebCore::HistoryItem* WebCore::HistoryItemVector::const_iterator end = children.end(); for (WebCore::HistoryItemVector::const_iterator i = children.begin(); i != end; ++i) { WebCore::HistoryItem* item = (*i).get(); -#ifdef ANDROID_HISTORY_CLIENT LOG_ASSERT(parent->bridge(), "The parent item should have a bridge object!"); if (!item->bridge()) { - WebHistoryItem* bridge = new WebHistoryItem(parent->bridge()); + WebHistoryItem* bridge = new WebHistoryItem(static_cast<WebHistoryItem*>(parent->bridge())); item->setBridge(bridge); bridge->setActive(); } else { // The only time this item's parent may not be the same as the // parent's bridge is during history close. In that case, the // parent must not have a parent bridge. - LOG_ASSERT(parent->bridge()->parent() == NULL || - item->bridge()->parent() == parent->bridge(), + WebHistoryItem* bridge = static_cast<WebHistoryItem*>(item->bridge()); + WebHistoryItem* parentBridge = static_cast<WebHistoryItem*>(parent->bridge()); + LOG_ASSERT(parentBridge->parent() == 0 || + bridge->parent() == parentBridge, "Somehow this item has an incorrect parent"); - item->bridge()->setParent(parent->bridge()); + bridge->setParent(parentBridge); } -#endif write_item(v, item); write_children_recursive(v, item); } @@ -615,8 +595,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, if (end - data < sizeofUnsigned) return false; -#ifdef ANDROID_HISTORY_CLIENT - WebHistoryItem* bridge = newItem->bridge(); + AndroidWebHistoryBridge* bridge = newItem->bridge(); LOG_ASSERT(bridge, "There should be a bridge object during inflate"); // Read the screen scale memcpy(&l, data, sizeofUnsigned); @@ -625,7 +604,6 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, data += sizeofUnsigned; if (end - data < sizeofUnsigned) return false; -#endif // Read the document state memcpy(&l, data, sizeofUnsigned); @@ -685,18 +663,14 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, // No need to check the length each time because read_item_recursive // will return null if there isn't enough data left to parse. WTF::PassRefPtr<WebCore::HistoryItem> child = WebCore::HistoryItem::create(); -#ifdef ANDROID_HISTORY_CLIENT // Set a bridge that will not call into java. - child->setBridge(new WebHistoryItem(bridge)); -#endif + child->setBridge(new WebHistoryItem(static_cast<WebHistoryItem*>(bridge))); // Read the child item. if (!read_item_recursive(child.get(), pData, end - data)) { child.clear(); return false; } -#ifdef ANDROID_HISTORY_CLIENT child->bridge()->setActive(); -#endif newItem->addChildItem(child); } } @@ -717,9 +691,7 @@ static void unit_test() const char* test1 = new char[0]; WTF::RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(); WebCore::HistoryItem* testItem = item.get(); -#ifdef ANDROID_HISTORY_CLIENT - testItem->setBridge(new WebHistoryItem(NULL)); -#endif + testItem->setBridge(new WebHistoryItem(0)); LOG_ASSERT(!read_item_recursive(testItem, &test1, 0), "0 length array should fail!"); delete[] test1; const char* test2 = new char[2]; @@ -762,9 +734,7 @@ static void unit_test() ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length target should fail!"); -#ifdef ANDROID_HISTORY_CLIENT offset += 4; // Scale -#endif // Document state offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); @@ -783,12 +753,7 @@ static void unit_test() ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 kids should fail!"); - -#ifdef ANDROID_HISTORY_CLIENT offset = 36; -#else - offset = 28; -#endif // Test document state delete[] test3; test3 = new char[HISTORY_MIN_SIZE + sizeof(unsigned)]; @@ -826,10 +791,8 @@ static JNINativeMethod gWebHistoryItemMethods[] = { int register_webhistory(JNIEnv* env) { -#ifdef ANDROID_HISTORY_CLIENT // Get notified of all changes to history items. WebCore::notifyHistoryItemChanged = historyItemChanged; -#endif #ifdef UNIT_TEST unit_test(); #endif diff --git a/WebKit/android/jni/WebHistory.h b/WebKit/android/jni/WebHistory.h index b384000..83e1867 100644 --- a/WebKit/android/jni/WebHistory.h +++ b/WebKit/android/jni/WebHistory.h @@ -26,14 +26,12 @@ #ifndef ANDROID_WEBKIT_WEBHISTORY_H #define ANDROID_WEBKIT_WEBHISTORY_H +#include "AndroidWebHistoryBridge.h" + #include <jni.h> #include <wtf/RefCounted.h> #include <wtf/Vector.h> -namespace WebCore { - class HistoryItem; -} - namespace android { class AutoJObject; @@ -49,33 +47,20 @@ public: // there are two scale factors saved with each history item. mScale reflects the // viewport scale factor, default to 100 means 100%. mScreenWidthScale records // the scale factor for the screen width used to wrap the text paragraph. -class WebHistoryItem : public WTF::RefCounted<WebHistoryItem> { +class WebHistoryItem : public WebCore::AndroidWebHistoryBridge { public: WebHistoryItem(WebHistoryItem* parent) - : mParent(parent) - , mObject(NULL) - , mScale(100) - , mScreenWidthScale(100) - , mActive(false) - , mHistoryItem(NULL) {} + : WebCore::AndroidWebHistoryBridge() + , m_parent(parent) + , m_object(NULL) { } WebHistoryItem(JNIEnv*, jobject, WebCore::HistoryItem*); ~WebHistoryItem(); void updateHistoryItem(WebCore::HistoryItem* item); - void setScale(int s) { mScale = s; } - void setScreenWidthScale(int s) { mScreenWidthScale = s; } - void setActive() { mActive = true; } - void setParent(WebHistoryItem* parent) { mParent = parent; } - WebHistoryItem* parent() { return mParent.get(); } - int scale() { return mScale; } - int screenWidthScale() { return mScreenWidthScale; } - WebCore::HistoryItem* historyItem() { return mHistoryItem; } + void setParent(WebHistoryItem* parent) { m_parent = parent; } + WebHistoryItem* parent() const { return m_parent.get(); } private: - RefPtr<WebHistoryItem> mParent; - jweak mObject; - int mScale; - int mScreenWidthScale; - bool mActive; - WebCore::HistoryItem* mHistoryItem; + RefPtr<WebHistoryItem> m_parent; + jweak m_object; }; }; |