OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
9 * | 9 * |
10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 return true; | 494 return true; |
495 } | 495 } |
496 | 496 |
497 void FrameLoader::didExplicitOpen() | 497 void FrameLoader::didExplicitOpen() |
498 { | 498 { |
499 m_isComplete = false; | 499 m_isComplete = false; |
500 m_didCallImplicitClose = false; | 500 m_didCallImplicitClose = false; |
501 | 501 |
502 // Calling document.open counts as committing the first real document load. | 502 // Calling document.open counts as committing the first real document load. |
503 if (!m_stateMachine.committedFirstRealDocumentLoad()) | 503 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
504 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmpty
DocumentPostCommit); | 504 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); |
505 | 505 |
506 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results | 506 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results |
507 // from a subsequent window.document.open / window.document.write call. | 507 // from a subsequent window.document.open / window.document.write call. |
508 // Canceling redirection here works for all cases because document.open | 508 // Canceling redirection here works for all cases because document.open |
509 // implicitly precedes document.write. | 509 // implicitly precedes document.write. |
510 m_frame->navigationScheduler()->cancel(); | 510 m_frame->navigationScheduler()->cancel(); |
511 } | 511 } |
512 | 512 |
513 | 513 |
514 void FrameLoader::cancelAndClear() | 514 void FrameLoader::cancelAndClear() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if (clearScriptObjects) | 557 if (clearScriptObjects) |
558 m_frame->script()->clearScriptObjects(); | 558 m_frame->script()->clearScriptObjects(); |
559 | 559 |
560 m_frame->script()->enableEval(); | 560 m_frame->script()->enableEval(); |
561 | 561 |
562 m_frame->navigationScheduler()->clear(); | 562 m_frame->navigationScheduler()->clear(); |
563 | 563 |
564 m_checkTimer.stop(); | 564 m_checkTimer.stop(); |
565 m_shouldCallCheckCompleted = false; | 565 m_shouldCallCheckCompleted = false; |
566 m_shouldCallCheckLoadComplete = false; | 566 m_shouldCallCheckLoadComplete = false; |
567 | |
568 if (m_stateMachine.isDisplayingInitialEmptyDocument() && m_stateMachine.comm
ittedFirstRealDocumentLoad()) | |
569 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); | |
570 } | 567 } |
571 | 568 |
572 void FrameLoader::receivedFirstData() | 569 void FrameLoader::receivedFirstData() |
573 { | 570 { |
574 dispatchDidCommitLoad(); | 571 dispatchDidCommitLoad(); |
575 dispatchDidClearWindowObjectsInAllWorlds(); | 572 dispatchDidClearWindowObjectsInAllWorlds(); |
576 | 573 |
577 if (m_documentLoader) { | 574 if (m_documentLoader) { |
578 StringWithDirection ptitle = m_documentLoader->title(); | 575 StringWithDirection ptitle = m_documentLoader->title(); |
579 // If we have a title let the WebView know about it. | 576 // If we have a title let the WebView know about it. |
(...skipping 23 matching lines...) Expand all Loading... |
603 m_outgoingReferrer = url.strippedForUseAsReferrer(); | 600 m_outgoingReferrer = url.strippedForUseAsReferrer(); |
604 } | 601 } |
605 | 602 |
606 void FrameLoader::didBeginDocument(bool dispatch) | 603 void FrameLoader::didBeginDocument(bool dispatch) |
607 { | 604 { |
608 m_needsClear = true; | 605 m_needsClear = true; |
609 m_isComplete = false; | 606 m_isComplete = false; |
610 m_didCallImplicitClose = false; | 607 m_didCallImplicitClose = false; |
611 m_frame->document()->setReadyState(Document::Loading); | 608 m_frame->document()->setReadyState(Document::Loading); |
612 | 609 |
613 if (m_pendingStateObject) { | 610 if (history()->currentItem()) |
614 m_frame->document()->statePopped(m_pendingStateObject.get()); | 611 m_frame->document()->statePopped(history()->currentItem()->stateObject()
); |
615 m_pendingStateObject.clear(); | |
616 } | |
617 | 612 |
618 if (dispatch) | 613 if (dispatch) |
619 dispatchDidClearWindowObjectsInAllWorlds(); | 614 dispatchDidClearWindowObjectsInAllWorlds(); |
620 | 615 |
621 updateFirstPartyForCookies(); | 616 updateFirstPartyForCookies(); |
622 m_frame->document()->initContentSecurityPolicy(); | 617 m_frame->document()->initContentSecurityPolicy(); |
623 | 618 |
624 Settings* settings = m_frame->document()->settings(); | 619 Settings* settings = m_frame->document()->settings(); |
625 if (settings) { | 620 if (settings) { |
626 m_frame->document()->cachedResourceLoader()->setImagesEnabled(settings->
areImagesEnabled()); | 621 m_frame->document()->cachedResourceLoader()->setImagesEnabled(settings->
areImagesEnabled()); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 void FrameLoader::handleFallbackContent() | 906 void FrameLoader::handleFallbackContent() |
912 { | 907 { |
913 HTMLFrameOwnerElement* owner = m_frame->ownerElement(); | 908 HTMLFrameOwnerElement* owner = m_frame->ownerElement(); |
914 if (!owner || !owner->hasTagName(objectTag)) | 909 if (!owner || !owner->hasTagName(objectTag)) |
915 return; | 910 return; |
916 static_cast<HTMLObjectElement*>(owner)->renderFallbackContent(); | 911 static_cast<HTMLObjectElement*>(owner)->renderFallbackContent(); |
917 } | 912 } |
918 | 913 |
919 void FrameLoader::provisionalLoadStarted() | 914 void FrameLoader::provisionalLoadStarted() |
920 { | 915 { |
921 if (m_stateMachine.firstLayoutDone()) | |
922 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); | |
923 m_frame->navigationScheduler()->cancel(); | 916 m_frame->navigationScheduler()->cancel(); |
924 m_quickRedirectComing = false; | 917 m_quickRedirectComing = false; |
925 } | 918 } |
926 | 919 |
927 void FrameLoader::resetMultipleFormSubmissionProtection() | 920 void FrameLoader::resetMultipleFormSubmissionProtection() |
928 { | 921 { |
929 m_submittedFormURL = KURL(); | 922 m_submittedFormURL = KURL(); |
930 } | 923 } |
931 | 924 |
932 void FrameLoader::updateFirstPartyForCookies() | 925 void FrameLoader::updateFirstPartyForCookies() |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 // history navigation we need to manufacture one, and update | 1033 // history navigation we need to manufacture one, and update |
1041 // the state machine of this frame to impersonate having | 1034 // the state machine of this frame to impersonate having |
1042 // loaded it. | 1035 // loaded it. |
1043 RefPtr<HistoryItem> currentItem = history()->currentItem(); | 1036 RefPtr<HistoryItem> currentItem = history()->currentItem(); |
1044 if (!currentItem) { | 1037 if (!currentItem) { |
1045 currentItem = HistoryItem::create(); | 1038 currentItem = HistoryItem::create(); |
1046 history()->setCurrentItem(currentItem.get()); | 1039 history()->setCurrentItem(currentItem.get()); |
1047 frame()->page()->backForward()->setCurrentItem(currentItem.get()); | 1040 frame()->page()->backForward()->setCurrentItem(currentItem.get()); |
1048 | 1041 |
1049 ASSERT(stateMachine()->isDisplayingInitialEmptyDocument()); | 1042 ASSERT(stateMachine()->isDisplayingInitialEmptyDocument()); |
1050 stateMachine()->advanceTo(FrameLoaderStateMachine::DisplayingInitialEmpt
yDocumentPostCommit); | |
1051 stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoa
d); | 1043 stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoa
d); |
1052 } | 1044 } |
1053 } | 1045 } |
1054 | 1046 |
1055 void FrameLoader::prepareForLoadStart() | 1047 void FrameLoader::prepareForLoadStart() |
1056 { | 1048 { |
1057 m_progressTracker->progressStarted(); | 1049 m_progressTracker->progressStarted(); |
1058 m_client->dispatchDidStartProvisionalLoad(); | 1050 m_client->dispatchDidStartProvisionalLoad(); |
1059 | 1051 |
1060 // Notify accessibility. | 1052 // Notify accessibility. |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 ASSERT(m_state == FrameStateProvisional); | 1548 ASSERT(m_state == FrameStateProvisional); |
1557 | 1549 |
1558 if (m_state != FrameStateProvisional) | 1550 if (m_state != FrameStateProvisional) |
1559 return; | 1551 return; |
1560 | 1552 |
1561 if (FrameView* view = m_frame->view()) { | 1553 if (FrameView* view = m_frame->view()) { |
1562 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) | 1554 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) |
1563 scrollAnimator->cancelAnimations(); | 1555 scrollAnimator->cancelAnimations(); |
1564 } | 1556 } |
1565 | 1557 |
1566 history()->updateForCommit(); | |
1567 | |
1568 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary | 1558 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary |
1569 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, | 1559 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, |
1570 // or the two will stomp each other. | 1560 // or the two will stomp each other. |
1571 DocumentLoader* pdl = m_provisionalDocumentLoader.get(); | 1561 DocumentLoader* pdl = m_provisionalDocumentLoader.get(); |
1572 if (m_documentLoader) | 1562 if (m_documentLoader) |
1573 closeURL(); | 1563 closeURL(); |
1574 if (pdl != m_provisionalDocumentLoader) | 1564 if (pdl != m_provisionalDocumentLoader) |
1575 return; | 1565 return; |
1576 | 1566 |
1577 // Nothing else can interupt this commit - set the Provisional->Committed tr
ansition in stone | 1567 // Nothing else can interupt this commit - set the Provisional->Committed tr
ansition in stone |
1578 if (m_documentLoader) | 1568 if (m_documentLoader) |
1579 m_documentLoader->stopLoadingSubresources(); | 1569 m_documentLoader->stopLoadingSubresources(); |
1580 | 1570 |
1581 setDocumentLoader(m_provisionalDocumentLoader.get()); | 1571 setDocumentLoader(m_provisionalDocumentLoader.get()); |
1582 setProvisionalDocumentLoader(0); | 1572 setProvisionalDocumentLoader(0); |
1583 | 1573 |
1584 if (pdl != m_documentLoader) { | 1574 if (pdl != m_documentLoader) { |
1585 ASSERT(m_state == FrameStateComplete); | 1575 ASSERT(m_state == FrameStateComplete); |
1586 return; | 1576 return; |
1587 } | 1577 } |
1588 | 1578 |
1589 setState(FrameStateCommittedPage); | 1579 setState(FrameStateCommittedPage); |
1590 | 1580 |
1591 if (isLoadingMainFrame()) | 1581 if (isLoadingMainFrame()) |
1592 m_frame->page()->chrome()->client()->needTouchEvents(false); | 1582 m_frame->page()->chrome()->client()->needTouchEvents(false); |
1593 | 1583 |
1594 // Handle adding the URL to the back/forward list. | 1584 history()->updateForCommit(); |
1595 DocumentLoader* dl = m_documentLoader.get(); | 1585 m_client->transitionToCommittedForNewPage(); |
1596 | |
1597 switch (m_loadType) { | |
1598 case FrameLoadTypeForward: | |
1599 case FrameLoadTypeBack: | |
1600 case FrameLoadTypeIndexedBackForward: | |
1601 if (m_frame->page()) { | |
1602 // If the first load within a frame is a navigation within a bac
k/forward list that was attached | |
1603 // without any of the items being loaded then we need to update
the history in a similar manner as | |
1604 // for a standard load with the exception of updating the back/f
orward list (<rdar://problem/8091103>). | |
1605 if (!m_stateMachine.committedFirstRealDocumentLoad() && isLoadin
gMainFrame()) | |
1606 history()->updateForStandardLoad(HistoryController::UpdateAl
lExceptBackForwardList); | |
1607 | |
1608 history()->updateForBackForwardNavigation(); | |
1609 | |
1610 if (history()->currentItem()) | |
1611 m_pendingStateObject = history()->currentItem()->stateObject
(); | |
1612 | |
1613 // Create a document view for this document. | |
1614 m_client->transitionToCommittedForNewPage(); | |
1615 } | |
1616 break; | |
1617 | |
1618 case FrameLoadTypeReload: | |
1619 case FrameLoadTypeReloadFromOrigin: | |
1620 case FrameLoadTypeSame: | |
1621 case FrameLoadTypeReplace: | |
1622 history()->updateForReload(); | |
1623 m_client->transitionToCommittedForNewPage(); | |
1624 break; | |
1625 | |
1626 case FrameLoadTypeStandard: | |
1627 history()->updateForStandardLoad(); | |
1628 if (m_frame->view()) | |
1629 m_frame->view()->setScrollbarsSuppressed(true); | |
1630 m_client->transitionToCommittedForNewPage(); | |
1631 break; | |
1632 | |
1633 case FrameLoadTypeRedirectWithLockedBackForwardList: | |
1634 history()->updateForRedirectWithLockedBackForwardList(); | |
1635 m_client->transitionToCommittedForNewPage(); | |
1636 break; | |
1637 | |
1638 // FIXME Remove this check when dummy ds is removed (whatever "dummy ds"
is). | |
1639 // An exception should be thrown if we're in the FrameLoadTypeUninitiali
zed state. | |
1640 default: | |
1641 ASSERT_NOT_REACHED(); | |
1642 } | |
1643 | |
1644 m_documentLoader->writer()->setMIMEType(dl->responseMIMEType()); | |
1645 | |
1646 // Tell the client we've committed this URL. | |
1647 ASSERT(m_frame->view()); | |
1648 | |
1649 if (m_stateMachine.creatingInitialEmptyDocument()) | |
1650 return; | |
1651 | |
1652 if (!m_stateMachine.committedFirstRealDocumentLoad()) | |
1653 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmpty
DocumentPostCommit); | |
1654 } | 1586 } |
1655 | 1587 |
1656 void FrameLoader::clientRedirectCancelledOrFinished() | 1588 void FrameLoader::clientRedirectCancelledOrFinished() |
1657 { | 1589 { |
1658 m_client->dispatchDidCancelClientRedirect(); | 1590 m_client->dispatchDidCancelClientRedirect(); |
1659 } | 1591 } |
1660 | 1592 |
1661 void FrameLoader::clientRedirected(const KURL& url, double seconds, double fireD
ate, bool lockBackForwardList) | 1593 void FrameLoader::clientRedirected(const KURL& url, double seconds, double fireD
ate, bool lockBackForwardList) |
1662 { | 1594 { |
1663 m_client->dispatchWillPerformClientRedirect(url, seconds, fireDate); | 1595 m_client->dispatchWillPerformClientRedirect(url, seconds, fireDate); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 | 1856 |
1925 void FrameLoader::didLayout(LayoutMilestones milestones) | 1857 void FrameLoader::didLayout(LayoutMilestones milestones) |
1926 { | 1858 { |
1927 m_client->dispatchDidLayout(milestones); | 1859 m_client->dispatchDidLayout(milestones); |
1928 } | 1860 } |
1929 | 1861 |
1930 void FrameLoader::didFirstLayout() | 1862 void FrameLoader::didFirstLayout() |
1931 { | 1863 { |
1932 if (m_frame->page() && isBackForwardLoadType(m_loadType)) | 1864 if (m_frame->page() && isBackForwardLoadType(m_loadType)) |
1933 history()->restoreScrollPositionAndViewState(); | 1865 history()->restoreScrollPositionAndViewState(); |
1934 | |
1935 if (m_stateMachine.committedFirstRealDocumentLoad() && !m_stateMachine.isDis
playingInitialEmptyDocument() && !m_stateMachine.firstLayoutDone()) | |
1936 m_stateMachine.advanceTo(FrameLoaderStateMachine::FirstLayoutDone); | |
1937 } | 1866 } |
1938 | 1867 |
1939 void FrameLoader::frameLoadCompleted() | 1868 void FrameLoader::frameLoadCompleted() |
1940 { | 1869 { |
1941 // Note: Can be called multiple times. | 1870 // Note: Can be called multiple times. |
1942 history()->updateForFrameLoadCompleted(); | 1871 history()->updateForFrameLoadCompleted(); |
1943 | |
1944 // After a canceled provisional load, firstLayoutDone is false. | |
1945 // Reset it to true if we're displaying a page. | |
1946 if (m_documentLoader && m_stateMachine.committedFirstRealDocumentLoad() && !
m_stateMachine.isDisplayingInitialEmptyDocument() && !m_stateMachine.firstLayout
Done()) | |
1947 m_stateMachine.advanceTo(FrameLoaderStateMachine::FirstLayoutDone); | |
1948 } | 1872 } |
1949 | 1873 |
1950 void FrameLoader::detachChildren() | 1874 void FrameLoader::detachChildren() |
1951 { | 1875 { |
1952 typedef Vector<RefPtr<Frame> > FrameVector; | 1876 typedef Vector<RefPtr<Frame> > FrameVector; |
1953 FrameVector childrenToDetach; | 1877 FrameVector childrenToDetach; |
1954 childrenToDetach.reserveCapacity(m_frame->tree()->childCount()); | 1878 childrenToDetach.reserveCapacity(m_frame->tree()->childCount()); |
1955 for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree
()->previousSibling()) | 1879 for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree
()->previousSibling()) |
1956 childrenToDetach.append(child); | 1880 childrenToDetach.append(child); |
1957 FrameVector::iterator end = childrenToDetach.end(); | 1881 FrameVector::iterator end = childrenToDetach.end(); |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2854 | 2778 |
2855 void FrameLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 2779 void FrameLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
2856 { | 2780 { |
2857 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); | 2781 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); |
2858 info.addMember(m_frame, "frame"); | 2782 info.addMember(m_frame, "frame"); |
2859 info.ignoreMember(m_client); | 2783 info.ignoreMember(m_client); |
2860 info.addMember(m_progressTracker, "progressTracker"); | 2784 info.addMember(m_progressTracker, "progressTracker"); |
2861 info.addMember(m_documentLoader, "documentLoader"); | 2785 info.addMember(m_documentLoader, "documentLoader"); |
2862 info.addMember(m_provisionalDocumentLoader, "provisionalDocumentLoader"); | 2786 info.addMember(m_provisionalDocumentLoader, "provisionalDocumentLoader"); |
2863 info.addMember(m_policyDocumentLoader, "policyDocumentLoader"); | 2787 info.addMember(m_policyDocumentLoader, "policyDocumentLoader"); |
2864 info.addMember(m_pendingStateObject, "pendingStateObject"); | |
2865 info.addMember(m_submittedFormURL, "submittedFormURL"); | 2788 info.addMember(m_submittedFormURL, "submittedFormURL"); |
2866 info.addMember(m_checkTimer, "checkTimer"); | 2789 info.addMember(m_checkTimer, "checkTimer"); |
2867 info.addMember(m_opener, "opener"); | 2790 info.addMember(m_opener, "opener"); |
2868 info.addMember(m_openedFrames, "openedFrames"); | 2791 info.addMember(m_openedFrames, "openedFrames"); |
2869 info.addMember(m_outgoingReferrer, "outgoingReferrer"); | 2792 info.addMember(m_outgoingReferrer, "outgoingReferrer"); |
2870 info.addMember(m_networkingContext, "networkingContext"); | 2793 info.addMember(m_networkingContext, "networkingContext"); |
2871 info.addMember(m_previousURL, "previousURL"); | 2794 info.addMember(m_previousURL, "previousURL"); |
2872 info.addMember(m_requestedHistoryItem, "requestedHistoryItem"); | 2795 info.addMember(m_requestedHistoryItem, "requestedHistoryItem"); |
2873 } | 2796 } |
2874 | 2797 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect); | 2871 FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect); |
2949 | 2872 |
2950 page->chrome()->setWindowRect(newWindowRect); | 2873 page->chrome()->setWindowRect(newWindowRect); |
2951 page->chrome()->show(); | 2874 page->chrome()->show(); |
2952 | 2875 |
2953 created = true; | 2876 created = true; |
2954 return frame; | 2877 return frame; |
2955 } | 2878 } |
2956 | 2879 |
2957 } // namespace WebCore | 2880 } // namespace WebCore |
OLD | NEW |