Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Unified Diff: Source/core/history/HistoryItem.cpp

Issue 28983004: Split the frame tree logic out of HistoryItem (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/history/HistoryItem.h ('k') | Source/core/loader/FrameLoader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/history/HistoryItem.cpp
diff --git a/Source/core/history/HistoryItem.cpp b/Source/core/history/HistoryItem.cpp
index 4c488047d17b2e15fda9c8e817df355d7b2ef196..93b9dc8954dbdb9fc5753f29bc30ce7c25da3c1d 100644
--- a/Source/core/history/HistoryItem.cpp
+++ b/Source/core/history/HistoryItem.cpp
@@ -66,6 +66,7 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
, m_target(item.m_target)
, m_scrollPoint(item.m_scrollPoint)
, m_pageScaleFactor(item.m_pageScaleFactor)
+ , m_documentState(item.m_documentState)
, m_itemSequenceNumber(item.m_itemSequenceNumber)
, m_documentSequenceNumber(item.m_documentSequenceNumber)
, m_targetFrameID(item.m_targetFrameID)
@@ -208,42 +209,9 @@ void HistoryItem::setStateObject(PassRefPtr<SerializedScriptValue> object)
void HistoryItem::addChildItem(PassRefPtr<HistoryItem> child)
{
- ASSERT(!childItemWithTarget(child->target()));
m_children.append(child);
}
-void HistoryItem::setChildItem(PassRefPtr<HistoryItem> child)
-{
- unsigned size = m_children.size();
- for (unsigned i = 0; i < size; ++i) {
- if (m_children[i]->target() == child->target()) {
- m_children[i] = child;
- return;
- }
- }
- m_children.append(child);
-}
-
-HistoryItem* HistoryItem::childItemWithTarget(const String& target) const
-{
- unsigned size = m_children.size();
- for (unsigned i = 0; i < size; ++i) {
- if (m_children[i]->target() == target)
- return m_children[i].get();
- }
- return 0;
-}
-
-HistoryItem* HistoryItem::childItemWithDocumentSequenceNumber(long long number) const
-{
- unsigned size = m_children.size();
- for (unsigned i = 0; i < size; ++i) {
- if (m_children[i]->documentSequenceNumber() == number)
- return m_children[i].get();
- }
- return 0;
-}
-
const HistoryItemVector& HistoryItem::children() const
{
return m_children;
@@ -254,61 +222,6 @@ 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::hasSameDocumentTree(HistoryItem* otherItem) const
-{
- if (documentSequenceNumber() != otherItem->documentSequenceNumber())
- return false;
-
- if (children().size() != otherItem->children().size())
- return false;
-
- for (size_t i = 0; i < children().size(); i++) {
- HistoryItem* child = children()[i].get();
- HistoryItem* otherChild = otherItem->childItemWithDocumentSequenceNumber(child->documentSequenceNumber());
- if (!otherChild || !child->hasSameDocumentTree(otherChild))
- return false;
- }
-
- return true;
-}
-
-// 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) const
-{
- if (target() != otherItem->target())
- return false;
-
- if (children().size() != otherItem->children().size())
- return false;
-
- for (size_t i = 0; i < children().size(); i++) {
- if (!otherItem->childItemWithTarget(children()[i]->target()))
- return false;
- }
-
- return true;
-}
-
String HistoryItem::formContentType() const
{
return m_formContentType;
@@ -350,37 +263,5 @@ bool HistoryItem::isCurrentDocument(Document* doc) const
return equalIgnoringFragmentIdentifier(url(), doc->url());
}
-#ifndef NDEBUG
-
-int HistoryItem::showTree() const
-{
- return showTreeWithIndent(0);
-}
-
-int HistoryItem::showTreeWithIndent(unsigned indentLevel) const
-{
- Vector<char> prefix;
- for (unsigned i = 0; i < indentLevel; ++i)
- prefix.append(" ", 2);
- prefix.append("\0", 1);
-
- fprintf(stderr, "%s+-%s (%p)\n", prefix.data(), m_urlString.utf8().data(), this);
-
- int totalSubItems = 0;
- for (unsigned i = 0; i < m_children.size(); ++i)
- totalSubItems += m_children[i]->showTreeWithIndent(indentLevel + 1);
- return totalSubItems + 1;
-}
-
-#endif
-
} // namespace WebCore
-#ifndef NDEBUG
-
-int showTree(const WebCore::HistoryItem* item)
-{
- return item->showTree();
-}
-
-#endif
« no previous file with comments | « Source/core/history/HistoryItem.h ('k') | Source/core/loader/FrameLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698