summaryrefslogtreecommitdiffstats
path: root/WebCore/history
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/history')
-rw-r--r--WebCore/history/HistoryItem.cpp26
-rw-r--r--WebCore/history/HistoryItem.h6
-rw-r--r--WebCore/history/PageCache.cpp25
3 files changed, 47 insertions, 10 deletions
diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp
index 8a84e2e..34b54a1 100644
--- a/WebCore/history/HistoryItem.cpp
+++ b/WebCore/history/HistoryItem.cpp
@@ -32,8 +32,9 @@
#include "PageCache.h"
#include "ResourceRequest.h"
#include <stdio.h>
-#include <wtf/text/CString.h>
#include <wtf/CurrentTime.h>
+#include <wtf/MathExtras.h>
+#include <wtf/text/CString.h>
namespace WebCore {
@@ -490,9 +491,26 @@ void HistoryItem::clearChildren()
m_children.clear();
}
+// We do same-document navigation if going to a different item and if either of the following is true:
+// - The other item corresponds to the same document (for history entries created via pushState or fragment changes).
+// - The other item corresponds to the same set of documents, including frames (for history entries created via regular navigation)
+bool HistoryItem::shouldDoSameDocumentNavigationTo(HistoryItem* otherItem) const
+{
+ if (this == otherItem)
+ return false;
+
+ if (stateObject() || otherItem->stateObject())
+ return documentSequenceNumber() == otherItem->documentSequenceNumber();
+
+ if ((url().hasFragmentIdentifier() || otherItem->url().hasFragmentIdentifier()) && equalIgnoringFragmentIdentifier(url(), otherItem->url()))
+ return documentSequenceNumber() == otherItem->documentSequenceNumber();
+
+ return hasSameDocumentTree(otherItem);
+}
+
// Does a recursive check that this item and its descendants have the same
// document sequence numbers as the other item.
-bool HistoryItem::hasSameDocuments(HistoryItem* otherItem)
+bool HistoryItem::hasSameDocumentTree(HistoryItem* otherItem) const
{
if (documentSequenceNumber() != otherItem->documentSequenceNumber())
return false;
@@ -503,7 +521,7 @@ bool HistoryItem::hasSameDocuments(HistoryItem* otherItem)
for (size_t i = 0; i < children().size(); i++) {
HistoryItem* child = children()[i].get();
HistoryItem* otherChild = otherItem->childItemWithDocumentSequenceNumber(child->documentSequenceNumber());
- if (!otherChild || !child->hasSameDocuments(otherChild))
+ if (!otherChild || !child->hasSameDocumentTree(otherChild))
return false;
}
@@ -512,7 +530,7 @@ bool HistoryItem::hasSameDocuments(HistoryItem* otherItem)
// Does a non-recursive check that this item and its immediate children have the
// same frames as the other item.
-bool HistoryItem::hasSameFrames(HistoryItem* otherItem)
+bool HistoryItem::hasSameFrames(HistoryItem* otherItem) const
{
if (target() != otherItem->target())
return false;
diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h
index b11a92e..ef9ac23 100644
--- a/WebCore/history/HistoryItem.h
+++ b/WebCore/history/HistoryItem.h
@@ -161,8 +161,8 @@ public:
bool hasChildren() const;
void clearChildren();
- bool hasSameDocuments(HistoryItem* otherItem);
- bool hasSameFrames(HistoryItem* otherItem);
+ bool shouldDoSameDocumentNavigationTo(HistoryItem* otherItem) const;
+ bool hasSameFrames(HistoryItem* otherItem) const;
// This should not be called directly for HistoryItems that are already included
// in GlobalHistory. The WebKit api for this is to use -[WebHistory setLastVisitedTimeInterval:forItem:] instead.
@@ -218,6 +218,8 @@ private:
void padDailyCountsForNewVisit(double time);
void collapseDailyVisitsToWeekly();
void recordVisitAtTime(double, VisitCountBehavior = IncreaseVisitCount);
+
+ bool hasSameDocumentTree(HistoryItem* otherItem) const;
HistoryItem* findTargetItem();
diff --git a/WebCore/history/PageCache.cpp b/WebCore/history/PageCache.cpp
index a5b29ce..fedc1e3 100644
--- a/WebCore/history/PageCache.cpp
+++ b/WebCore/history/PageCache.cpp
@@ -31,6 +31,8 @@
#include "Cache.h"
#include "CachedPage.h"
#include "DOMWindow.h"
+#include "DeviceMotionController.h"
+#include "DeviceOrientationController.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "Frame.h"
@@ -45,6 +47,7 @@
#include "SystemTime.h"
#include <wtf/CurrentTime.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringConcatenate.h>
using namespace std;
@@ -74,7 +77,7 @@ static void pageCacheLog(const String& prefix, const String& message)
LOG(PageCache, "%s%s", prefix.utf8().data(), message.utf8().data());
}
-#define PCLOG(...) pageCacheLog(pageCacheLogPrefix(indentLevel), String::format(__VA_ARGS__))
+#define PCLOG(...) pageCacheLog(pageCacheLogPrefix(indentLevel), makeString(__VA_ARGS__))
static bool logCanCacheFrameDecision(Frame* frame, int indentLevel)
{
@@ -88,9 +91,9 @@ static bool logCanCacheFrameDecision(Frame* frame, int indentLevel)
PCLOG("+---");
KURL newURL = frame->loader()->provisionalDocumentLoader() ? frame->loader()->provisionalDocumentLoader()->url() : KURL();
if (!newURL.isEmpty())
- PCLOG(" Determining if frame can be cached navigating from (%s) to (%s):", currentURL.string().utf8().data(), newURL.string().utf8().data());
+ PCLOG(" Determining if frame can be cached navigating from (", currentURL.string(), ") to (", newURL.string(), "):");
else
- PCLOG(" Determining if subframe with URL (%s) can be cached:", currentURL.string().utf8().data());
+ PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:");
bool cannotCache = false;
@@ -201,6 +204,16 @@ static void logCanCachePageDecision(Page* page)
PCLOG(" -Page settings says b/f cache disabled");
cannotCache = true;
}
+#if ENABLE(DEVICE_ORIENTATION)
+ if (page->deviceMotionController() && page->deviceMotionController()->isActive()) {
+ PCLOG(" -Page is using DeviceMotion");
+ cannotCache = true;
+ }
+ if (page->deviceOrientationController() && page->deviceOrientationController()->isActive()) {
+ PCLOG(" -Page is using DeviceOrientation");
+ cannotCache = true;
+ }
+#endif
if (loadType == FrameLoadTypeReload) {
PCLOG(" -Load type is: Reload");
cannotCache = true;
@@ -297,7 +310,11 @@ bool PageCache::canCache(Page* page)
&& page->backForwardList()->enabled()
&& page->backForwardList()->capacity() > 0
&& page->settings()->usesPageCache()
- && loadType != FrameLoadTypeReload
+#if ENABLE(DEVICE_ORIENTATION)
+ && !(page->deviceMotionController() && page->deviceMotionController()->isActive())
+ && !(page->deviceOrientationController() && page->deviceOrientationController()->isActive())
+#endif
+ && loadType != FrameLoadTypeReload
&& loadType != FrameLoadTypeReloadFromOrigin
&& loadType != FrameLoadTypeSame;
}