Diff
Modified: trunk/Source/WebCore/ChangeLog (160668 => 160669)
--- trunk/Source/WebCore/ChangeLog 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/ChangeLog 2013-12-16 23:54:09 UTC (rev 160669)
@@ -1,5 +1,43 @@
2013-12-16 Daniel Bates <[email protected]>
+ [iOS] Upstream WebCore/history changes
+ https://bugs.webkit.org/show_bug.cgi?id=125769
+
+ Reviewed by Darin Adler.
+
+ * history/BackForwardClient.h:
+ * history/BackForwardList.cpp:
+ (WebCore::BackForwardList::current): Added; guard by PLATFORM(IOS). Also added FIXME comment.
+ (WebCore::BackForwardList::setCurrent): Added; guard by PLATFORM(IOS). Also added FIXME comment.
+ (WebCore::BackForwardList::clearAllPageCaches): Added; guarded by PLATFORM(IOS).
+ * history/BackForwardList.h:
+ * history/CachedFrame.cpp:
+ (WebCore::CachedFrameBase::restore): Added iOS-specific code.
+ (WebCore::CachedFrame::CachedFrame): Ditto.
+ * history/CachedPage.cpp:
+ (WebCore::CachedPage::restore): Ditto.
+ * history/HistoryItem.cpp:
+ (WebCore::HistoryItem::HistoryItem): Ditto.
+ * history/HistoryItem.h:
+ (WebCore::HistoryItem::scale): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::scaleIsInitial): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::setScale): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::viewportArguments): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::setViewportArguments): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::bookmarkID): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::setBookmarkID): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::sharedLinkUniqueIdentifier): Added; guarded by PLATFORM(IOS).
+ (WebCore::HistoryItem::setSharedLinkUniqueIdentifier): Added; guarded by PLATFORM(IOS).
+ * history/PageCache.cpp:
+ (WebCore::logCanCacheFrameDecision): Added iOS-specific code.
+ (WebCore::logCanCachePageDecision): Ditto.
+ (WebCore::PageCache::canCachePageContainingThisFrame): Ditto.
+ (WebCore::PageCache::canCache): Ditto.
+ (WebCore::PageCache::pruneToCapacityNow): Added.
+ * history/PageCache.h:
+
+2013-12-16 Daniel Bates <[email protected]>
+
[iOS] Upstream WebCore/svg changes
https://bugs.webkit.org/show_bug.cgi?id=125784
Modified: trunk/Source/WebCore/history/BackForwardClient.h (160668 => 160669)
--- trunk/Source/WebCore/history/BackForwardClient.h 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/BackForwardClient.h 2013-12-16 23:54:09 UTC (rev 160669)
@@ -53,6 +53,15 @@
virtual void close() = 0;
+#if PLATFORM(IOS)
+ // FIXME: These methods seem to violate the encapsulation of this class.
+ virtual unsigned current() = 0;
+ virtual void setCurrent(unsigned newCurrent) = 0;
+
+ // FIXME: Consider renaming this method once we upstream the iOS changes to WebView.mm.
+ virtual bool clearAllPageCaches() = 0;
+#endif
+
// FIXME: Delete these once all callers are using BackForwardController
// instead of calling this directly.
HistoryItem* backItem() { return itemAtIndex(-1); }
Modified: trunk/Source/WebCore/history/BackForwardList.cpp (160668 => 160669)
--- trunk/Source/WebCore/history/BackForwardList.cpp 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/BackForwardList.cpp 2013-12-16 23:54:09 UTC (rev 160669)
@@ -228,6 +228,32 @@
return m_entries;
}
+#if PLATFORM(IOS)
+unsigned BackForwardList::current()
+{
+ return m_current;
+}
+
+void BackForwardList::setCurrent(unsigned newCurrent)
+{
+ m_current = newCurrent;
+}
+
+bool BackForwardList::clearAllPageCaches()
+{
+ bool didRemoveAtLeastOneItem = false;
+ unsigned length = m_entries.size();
+ for (unsigned i = 0; i < length; ++i) {
+ HistoryItem* item = m_entries[i].get();
+ if (item->isInPageCache()) {
+ didRemoveAtLeastOneItem = true;
+ pageCache()->remove(item);
+ }
+ }
+ return didRemoveAtLeastOneItem;
+}
+#endif
+
void BackForwardList::close()
{
int size = m_entries.size();
Modified: trunk/Source/WebCore/history/BackForwardList.h (160668 => 160669)
--- trunk/Source/WebCore/history/BackForwardList.h 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/BackForwardList.h 2013-12-16 23:54:09 UTC (rev 160669)
@@ -73,6 +73,13 @@
void removeItem(HistoryItem*);
HistoryItemVector& entries();
+#if PLATFORM(IOS)
+ virtual unsigned current() OVERRIDE;
+ virtual void setCurrent(unsigned newCurrent) OVERRIDE;
+
+ virtual bool clearAllPageCaches() OVERRIDE;
+#endif
+
private:
explicit BackForwardList(Page*);
Modified: trunk/Source/WebCore/history/CachedFrame.cpp (160668 => 160669)
--- trunk/Source/WebCore/history/CachedFrame.cpp 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/CachedFrame.cpp 2013-12-16 23:54:09 UTC (rev 160669)
@@ -131,6 +131,18 @@
m_childFrames[i]->open();
}
+#if PLATFORM(IOS)
+ if (m_isMainFrame) {
+ frame.loader().client().didRestoreFrameHierarchyForCachedFrame();
+
+ if (DOMWindow* domWindow = m_document->domWindow()) {
+ // FIXME: Add SCROLL_LISTENER to the list of event types on Document, and use m_document->hasListenerType(). See <rdar://problem/9615482>.
+ if (domWindow->scrollEventListenerCount() && frame.page())
+ frame.page()->chrome().client().setNeedsScrollNotifications(&frame, true);
+ }
+ }
+#endif
+
// FIXME: update Page Visibility state here.
// https://bugs.webkit.org/show_bug.cgi?id=116770
m_document->enqueuePageshowEvent(PageshowEventPersisted);
@@ -138,7 +150,7 @@
HistoryItem* historyItem = frame.loader().history().currentItem();
m_document->enqueuePopstateEvent(historyItem && historyItem->stateObject() ? historyItem->stateObject() : SerializedScriptValue::nullValue());
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
if (m_document->hasTouchEventHandlers())
m_document->page()->chrome().client().needTouchEvents(true);
#endif
@@ -209,6 +221,14 @@
LOG(PageCache, "Finished creating CachedFrame for child frame with url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get());
#endif
+#if PLATFORM(IOS)
+ if (m_isMainFrame) {
+ if (DOMWindow* domWindow = m_document->domWindow()) {
+ if (domWindow->scrollEventListenerCount() && frame.page())
+ frame.page()->chrome().client().setNeedsScrollNotifications(&frame, false);
+ }
+ }
+#endif
}
void CachedFrame::open()
Modified: trunk/Source/WebCore/history/CachedPage.cpp (160668 => 160669)
--- trunk/Source/WebCore/history/CachedPage.cpp 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/CachedPage.cpp 2013-12-16 23:54:09 UTC (rev 160669)
@@ -39,6 +39,10 @@
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/StdLibExtras.h>
+#if PLATFORM(IOS)
+#include "FrameSelection.h"
+#endif
+
using namespace JSC;
namespace WebCore {
@@ -85,8 +89,17 @@
// Restore the focus appearance for the focused element.
// FIXME: Right now we don't support pages w/ frames in the b/f cache. This may need to be tweaked when we add support for that.
Document* focusedDocument = page.focusController().focusedOrMainFrame().document();
- if (Element* element = focusedDocument->focusedElement())
+ if (Element* element = focusedDocument->focusedElement()) {
+#if PLATFORM(IOS)
+ // We don't want focused nodes changing scroll position when restoring from the cache
+ // as it can cause ugly jumps before we manage to restore the cached position.
+ page.mainFrame().selection().suppressScrolling();
+#endif
element->updateFocusAppearance(true);
+#if PLATFORM(IOS)
+ page.mainFrame().selection().restoreScrolling();
+#endif
+ }
if (m_needStyleRecalcForVisitedLinks) {
for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext())
Modified: trunk/Source/WebCore/history/HistoryItem.cpp (160668 => 160669)
--- trunk/Source/WebCore/history/HistoryItem.cpp 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/HistoryItem.cpp 2013-12-16 23:54:09 UTC (rev 160669)
@@ -70,6 +70,11 @@
, m_documentSequenceNumber(generateSequenceNumber())
, m_next(0)
, m_prev(0)
+#if PLATFORM(IOS)
+ , m_scale(0)
+ , m_scaleIsInitial(false)
+ , m_bookmarkID(0)
+#endif
{
}
@@ -87,6 +92,11 @@
, m_documentSequenceNumber(generateSequenceNumber())
, m_next(0)
, m_prev(0)
+#if PLATFORM(IOS)
+ , m_scale(0)
+ , m_scaleIsInitial(false)
+ , m_bookmarkID(0)
+#endif
{
iconDatabase().retainIconForPageURL(m_urlString);
}
@@ -106,6 +116,11 @@
, m_documentSequenceNumber(generateSequenceNumber())
, m_next(0)
, m_prev(0)
+#if PLATFORM(IOS)
+ , m_scale(0)
+ , m_scaleIsInitial(false)
+ , m_bookmarkID(0)
+#endif
{
iconDatabase().retainIconForPageURL(m_urlString);
}
@@ -126,6 +141,11 @@
, m_documentSequenceNumber(generateSequenceNumber())
, m_next(0)
, m_prev(0)
+#if PLATFORM(IOS)
+ , m_scale(0)
+ , m_scaleIsInitial(false)
+ , m_bookmarkID(0)
+#endif
{
iconDatabase().retainIconForPageURL(m_urlString);
}
@@ -157,6 +177,12 @@
, m_itemSequenceNumber(item.m_itemSequenceNumber)
, m_documentSequenceNumber(item.m_documentSequenceNumber)
, m_formContentType(item.m_formContentType)
+#if PLATFORM(IOS)
+ , m_scale(item.m_scale)
+ , m_scaleIsInitial(item.m_scaleIsInitial)
+ , m_bookmarkID(item.m_bookmarkID)
+ , m_sharedLinkUniqueIdentifier(item.m_sharedLinkUniqueIdentifier)
+#endif
{
if (item.m_formData)
m_formData = item.m_formData->copy();
Modified: trunk/Source/WebCore/history/HistoryItem.h (160668 => 160669)
--- trunk/Source/WebCore/history/HistoryItem.h 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/HistoryItem.h 2013-12-16 23:54:09 UTC (rev 160669)
@@ -34,6 +34,10 @@
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
+#if PLATFORM(IOS)
+#include "ViewportArguments.h"
+#endif
+
#if PLATFORM(MAC)
#import <wtf/RetainPtr.h>
typedef struct objc_object* id;
@@ -206,6 +210,24 @@
const Vector<int>& dailyVisitCounts() const { return m_dailyVisitCounts; }
const Vector<int>& weeklyVisitCounts() const { return m_weeklyVisitCounts; }
+#if PLATFORM(IOS)
+ float scale() const { return m_scale; }
+ bool scaleIsInitial() const { return m_scaleIsInitial; }
+ void setScale(float newScale, bool isInitial)
+ {
+ m_scale = newScale;
+ m_scaleIsInitial = isInitial;
+ }
+
+ const ViewportArguments& viewportArguments() const { return m_viewportArguments; }
+ void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
+
+ uint32_t bookmarkID() const { return m_bookmarkID; }
+ void setBookmarkID(uint32_t bookmarkID) { m_bookmarkID = bookmarkID; }
+ String sharedLinkUniqueIdentifier() const { return m_sharedLinkUniqueIdentifier; }
+ void setSharedLinkUniqueIdentifier(const String& sharedLinkUniqueidentifier) { m_sharedLinkUniqueIdentifier = sharedLinkUniqueidentifier; }
+#endif
+
private:
HistoryItem();
HistoryItem(const String& urlString, const String& title, double lastVisited);
@@ -272,7 +294,16 @@
HistoryItem* m_next;
HistoryItem* m_prev;
OwnPtr<CachedPage> m_cachedPage;
-
+
+#if PLATFORM(IOS)
+ float m_scale;
+ bool m_scaleIsInitial;
+ ViewportArguments m_viewportArguments;
+
+ uint32_t m_bookmarkID;
+ String m_sharedLinkUniqueIdentifier;
+#endif
+
#if PLATFORM(MAC)
RetainPtr<id> m_viewState;
OwnPtr<HashMap<String, RetainPtr<id>>> m_transientProperties;
Modified: trunk/Source/WebCore/history/PageCache.cpp (160668 => 160669)
--- trunk/Source/WebCore/history/PageCache.cpp 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/PageCache.cpp 2013-12-16 23:54:09 UTC (rev 160669)
@@ -57,6 +57,10 @@
#include "DeviceProximityController.h"
#endif
+#if PLATFORM(IOS)
+#include "MemoryPressureHandler.h"
+#endif
+
namespace WebCore {
#if !defined(NDEBUG)
@@ -103,7 +107,14 @@
unsigned rejectReasons = 0;
if (!frame->loader().documentLoader()->mainDocumentError().isNull()) {
PCLOG(" -Main document has an error");
+#if !PLATFORM(IOS)
rejectReasons |= 1 << MainDocumentError;
+#else
+ if (frame->loader().documentLoader()->mainDocumentError().isCancellation() && frame->loader().documentLoader()->subresourceLoadersArePageCacheAcceptable())
+ PCLOG(" -But, it was a cancellation and all loaders during the cancel were loading images.");
+ else
+ rejectReasons |= 1 << MainDocumentError;
+#endif
}
if (frame->loader().documentLoader()->substituteData().isValid() && frame->loader().documentLoader()->substituteData().failingURL().isEmpty()) {
PCLOG(" -Frame is an error page");
@@ -121,7 +132,12 @@
}
if (frame->document()->domWindow() && frame->document()->domWindow()->hasEventListeners(eventNames().unloadEvent)) {
PCLOG(" -Frame has an unload event listener");
+#if !PLATFORM(IOS)
rejectReasons |= 1 << HasUnloadListener;
+#else
+ // iOS allows pages with unload event listeners to enter the page cache.
+ PCLOG(" -BUT iOS allows these pages to be cached.");
+#endif
}
#if ENABLE(SQL_DATABASE)
if (DatabaseManager::manager().hasOpenDatabases(frame->document())) {
@@ -223,7 +239,7 @@
PCLOG(" -Page settings says b/f cache disabled");
rejectReasons |= 1 << DisabledPageCache;
}
-#if ENABLE(DEVICE_ORIENTATION)
+#if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS)
if (DeviceMotionController::isActiveAt(page)) {
PCLOG(" -Page is using DeviceMotion");
rejectReasons |= 1 << UsesDeviceMotion;
@@ -312,12 +328,18 @@
Document* document = frame->document();
return documentLoader
+#if !PLATFORM(IOS)
&& documentLoader->mainDocumentError().isNull()
+#else
+ && (documentLoader->mainDocumentError().isNull() || (documentLoader->mainDocumentError().isCancellation() && documentLoader->subresourceLoadersArePageCacheAcceptable()))
+#endif
// Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs).
&& !(documentLoader->substituteData().isValid() && !documentLoader->substituteData().failingURL().isEmpty())
&& (!frameLoader.subframeLoader().containsPlugins() || frame->page()->settings().pageCacheSupportsPlugins())
&& (!document->url().protocolIs("https") || (!documentLoader->response().cacheControlContainsNoCache() && !documentLoader->response().cacheControlContainsNoStore()))
+#if !PLATFORM(IOS)
&& (!document->domWindow() || !document->domWindow()->hasEventListeners(eventNames().unloadEvent))
+#endif
#if ENABLE(SQL_DATABASE)
&& !DatabaseManager::manager().hasOpenDatabases(document)
#endif
@@ -343,7 +365,12 @@
#if !defined(NDEBUG)
logCanCachePageDecision(page);
#endif
-
+
+#if PLATFORM(IOS)
+ if (memoryPressureHandler().hasReceivedMemoryPressure())
+ return false;
+#endif
+
// Cache the page, if possible.
// Don't write to the cache if in the middle of a redirect, since we will want to
// store the final page we end up on.
@@ -355,7 +382,7 @@
&& canCachePageContainingThisFrame(&page->mainFrame())
&& page->backForward().isActive()
&& page->settings().usesPageCache()
-#if ENABLE(DEVICE_ORIENTATION)
+#if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS)
&& !DeviceMotionController::isActiveAt(page)
&& !DeviceOrientationController::isActiveAt(page)
#endif
@@ -368,6 +395,13 @@
|| loadType == FrameLoadTypeIndexedBackForward);
}
+void PageCache::pruneToCapacityNow(int capacity)
+{
+ int savedCapacity = m_capacity;
+ setCapacity(capacity);
+ setCapacity(savedCapacity);
+}
+
void PageCache::setCapacity(int capacity)
{
ASSERT(capacity >= 0);
Modified: trunk/Source/WebCore/history/PageCache.h (160668 => 160669)
--- trunk/Source/WebCore/history/PageCache.h 2013-12-16 23:25:31 UTC (rev 160668)
+++ trunk/Source/WebCore/history/PageCache.h 2013-12-16 23:54:09 UTC (rev 160669)
@@ -61,6 +61,9 @@
// Will mark all cached pages associated with the given page as needing style recalc.
void markPagesForFullStyleRecalc(Page*);
+ // Used when memory is low to prune some cached pages.
+ void pruneToCapacityNow(int capacity);
+
#if ENABLE(VIDEO_TRACK)
void markPagesForCaptionPreferencesChanged();
#endif