| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 bool HistoryItem::hasChildren() const | 483 bool HistoryItem::hasChildren() const |
| 484 { | 484 { |
| 485 return !m_children.isEmpty(); | 485 return !m_children.isEmpty(); |
| 486 } | 486 } |
| 487 | 487 |
| 488 void HistoryItem::clearChildren() | 488 void HistoryItem::clearChildren() |
| 489 { | 489 { |
| 490 m_children.clear(); | 490 m_children.clear(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 // We do same-document navigation if going to a different item and if either of
the following is true: |
| 494 // - The other item corresponds to the same document (for history entries create
d via pushState or fragment changes). |
| 495 // - The other item corresponds to the same set of documents, including frames (
for history entries created via regular navigation) |
| 496 bool HistoryItem::shouldDoSameDocumentNavigationTo(HistoryItem* otherItem) const |
| 497 { |
| 498 if (this == otherItem) |
| 499 return false; |
| 500 |
| 501 if (stateObject() || otherItem->stateObject()) |
| 502 return documentSequenceNumber() == otherItem->documentSequenceNumber(); |
| 503 |
| 504 if ((url().hasFragmentIdentifier() || otherItem->url().hasFragmentIdentifier
()) && equalIgnoringFragmentIdentifier(url(), otherItem->url())) |
| 505 return documentSequenceNumber() == otherItem->documentSequenceNumber();
|
| 506 |
| 507 return hasSameDocumentTree(otherItem); |
| 508 } |
| 509 |
| 493 // Does a recursive check that this item and its descendants have the same | 510 // Does a recursive check that this item and its descendants have the same |
| 494 // document sequence numbers as the other item. | 511 // document sequence numbers as the other item. |
| 495 bool HistoryItem::hasSameDocuments(HistoryItem* otherItem) | 512 bool HistoryItem::hasSameDocumentTree(HistoryItem* otherItem) const |
| 496 { | 513 { |
| 497 if (documentSequenceNumber() != otherItem->documentSequenceNumber()) | 514 if (documentSequenceNumber() != otherItem->documentSequenceNumber()) |
| 498 return false; | 515 return false; |
| 499 | 516 |
| 500 if (children().size() != otherItem->children().size()) | 517 if (children().size() != otherItem->children().size()) |
| 501 return false; | 518 return false; |
| 502 | 519 |
| 503 for (size_t i = 0; i < children().size(); i++) { | 520 for (size_t i = 0; i < children().size(); i++) { |
| 504 HistoryItem* child = children()[i].get(); | 521 HistoryItem* child = children()[i].get(); |
| 505 HistoryItem* otherChild = otherItem->childItemWithDocumentSequenceNumber
(child->documentSequenceNumber()); | 522 HistoryItem* otherChild = otherItem->childItemWithDocumentSequenceNumber
(child->documentSequenceNumber()); |
| 506 if (!otherChild || !child->hasSameDocuments(otherChild)) | 523 if (!otherChild || !child->hasSameDocumentTree(otherChild)) |
| 507 return false; | 524 return false; |
| 508 } | 525 } |
| 509 | 526 |
| 510 return true; | 527 return true; |
| 511 } | 528 } |
| 512 | 529 |
| 513 // Does a non-recursive check that this item and its immediate children have the | 530 // Does a non-recursive check that this item and its immediate children have the |
| 514 // same frames as the other item. | 531 // same frames as the other item. |
| 515 bool HistoryItem::hasSameFrames(HistoryItem* otherItem) | 532 bool HistoryItem::hasSameFrames(HistoryItem* otherItem) const |
| 516 { | 533 { |
| 517 if (target() != otherItem->target()) | 534 if (target() != otherItem->target()) |
| 518 return false; | 535 return false; |
| 519 | 536 |
| 520 if (children().size() != otherItem->children().size()) | 537 if (children().size() != otherItem->children().size()) |
| 521 return false; | 538 return false; |
| 522 | 539 |
| 523 for (size_t i = 0; i < children().size(); i++) { | 540 for (size_t i = 0; i < children().size(); i++) { |
| 524 if (!otherItem->childItemWithTarget(children()[i]->target())) | 541 if (!otherItem->childItemWithTarget(children()[i]->target())) |
| 525 return false; | 542 return false; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 } // namespace WebCore | 647 } // namespace WebCore |
| 631 | 648 |
| 632 #ifndef NDEBUG | 649 #ifndef NDEBUG |
| 633 | 650 |
| 634 int showTree(const WebCore::HistoryItem* item) | 651 int showTree(const WebCore::HistoryItem* item) |
| 635 { | 652 { |
| 636 return item->showTree(); | 653 return item->showTree(); |
| 637 } | 654 } |
| 638 | 655 |
| 639 #endif | 656 #endif |
| OLD | NEW |