| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "core/loader/FrameLoaderClient.h" | 63 #include "core/loader/FrameLoaderClient.h" |
| 64 #include "core/loader/IconController.h" | 64 #include "core/loader/IconController.h" |
| 65 #include "core/loader/ProgressTracker.h" | 65 #include "core/loader/ProgressTracker.h" |
| 66 #include "core/loader/UniqueIdentifier.h" | 66 #include "core/loader/UniqueIdentifier.h" |
| 67 #include "core/loader/appcache/ApplicationCacheHost.h" | 67 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 68 #include "core/page/Chrome.h" | 68 #include "core/page/Chrome.h" |
| 69 #include "core/page/ChromeClient.h" | 69 #include "core/page/ChromeClient.h" |
| 70 #include "core/frame/ContentSecurityPolicy.h" | 70 #include "core/frame/ContentSecurityPolicy.h" |
| 71 #include "core/frame/ContentSecurityPolicyResponseHeaders.h" | 71 #include "core/frame/ContentSecurityPolicyResponseHeaders.h" |
| 72 #include "core/frame/DOMWindow.h" | 72 #include "core/frame/DOMWindow.h" |
| 73 #include "core/page/BackForwardClient.h" |
| 73 #include "core/page/EventHandler.h" | 74 #include "core/page/EventHandler.h" |
| 74 #include "core/frame/Frame.h" | 75 #include "core/frame/Frame.h" |
| 75 #include "core/page/FrameTree.h" | 76 #include "core/page/FrameTree.h" |
| 76 #include "core/frame/FrameView.h" | 77 #include "core/frame/FrameView.h" |
| 77 #include "core/page/Page.h" | 78 #include "core/page/Page.h" |
| 78 #include "core/page/Settings.h" | 79 #include "core/page/Settings.h" |
| 79 #include "core/page/WindowFeatures.h" | 80 #include "core/page/WindowFeatures.h" |
| 80 #include "core/platform/ScrollAnimator.h" | 81 #include "core/platform/ScrollAnimator.h" |
| 81 #include "core/platform/network/ResourceRequest.h" | 82 #include "core/platform/network/ResourceRequest.h" |
| 82 #include "core/xml/parser/XMLDocumentParser.h" | 83 #include "core/xml/parser/XMLDocumentParser.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 { | 147 { |
| 147 } | 148 } |
| 148 | 149 |
| 149 Frame* m_frame; | 150 Frame* m_frame; |
| 150 bool m_inProgress; | 151 bool m_inProgress; |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client) | 154 FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client) |
| 154 : m_frame(frame) | 155 : m_frame(frame) |
| 155 , m_client(client) | 156 , m_client(client) |
| 156 , m_history(frame) | 157 , m_history(frame->page()->history()) |
| 157 , m_icon(adoptPtr(new IconController(frame))) | 158 , m_icon(adoptPtr(new IconController(frame))) |
| 158 , m_fetchContext(FrameFetchContext::create(frame)) | 159 , m_fetchContext(FrameFetchContext::create(frame)) |
| 159 , m_mixedContentChecker(frame) | 160 , m_mixedContentChecker(frame) |
| 160 , m_state(FrameStateProvisional) | 161 , m_state(FrameStateProvisional) |
| 161 , m_loadType(FrameLoadTypeStandard) | 162 , m_loadType(FrameLoadTypeStandard) |
| 162 , m_inStopAllLoaders(false) | 163 , m_inStopAllLoaders(false) |
| 163 , m_isComplete(false) | 164 , m_isComplete(false) |
| 164 , m_containsPlugins(false) | 165 , m_containsPlugins(false) |
| 165 , m_checkTimer(this, &FrameLoader::checkTimerFired) | 166 , m_checkTimer(this, &FrameLoader::checkTimerFired) |
| 166 , m_shouldCallCheckCompleted(false) | 167 , m_shouldCallCheckCompleted(false) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // FIXME: Should the DatabaseManager watch for something like ActiveDOMO
bject::stop() rather than being special-cased here? | 229 // FIXME: Should the DatabaseManager watch for something like ActiveDOMO
bject::stop() rather than being special-cased here? |
| 229 DatabaseManager::manager().stopDatabases(doc, 0); | 230 DatabaseManager::manager().stopDatabases(doc, 0); |
| 230 } | 231 } |
| 231 | 232 |
| 232 // FIXME: This will cancel redirection timer, which really needs to be resta
rted when restoring the frame from b/f cache. | 233 // FIXME: This will cancel redirection timer, which really needs to be resta
rted when restoring the frame from b/f cache. |
| 233 m_frame->navigationScheduler()->cancel(); | 234 m_frame->navigationScheduler()->cancel(); |
| 234 } | 235 } |
| 235 | 236 |
| 236 bool FrameLoader::closeURL() | 237 bool FrameLoader::closeURL() |
| 237 { | 238 { |
| 238 history()->saveDocumentAndScrollState(); | 239 history()->saveDocumentAndScrollState(m_frame); |
| 239 | 240 |
| 240 // Should only send the pagehide event here if the current document exists. | 241 // Should only send the pagehide event here if the current document exists. |
| 241 if (m_frame->document()) | 242 if (m_frame->document()) |
| 242 m_frame->document()->dispatchUnloadEvents(); | 243 m_frame->document()->dispatchUnloadEvents(); |
| 243 stopLoading(); | 244 stopLoading(); |
| 244 | 245 |
| 245 m_frame->editor().clearUndoRedoOperations(); | 246 m_frame->editor().clearUndoRedoOperations(); |
| 246 return true; | 247 return true; |
| 247 } | 248 } |
| 248 | 249 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 void FrameLoader::setOutgoingReferrer(const KURL& url) | 322 void FrameLoader::setOutgoingReferrer(const KURL& url) |
| 322 { | 323 { |
| 323 m_outgoingReferrer = url.strippedForUseAsReferrer(); | 324 m_outgoingReferrer = url.strippedForUseAsReferrer(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 void FrameLoader::didBeginDocument(bool dispatch) | 327 void FrameLoader::didBeginDocument(bool dispatch) |
| 327 { | 328 { |
| 328 m_isComplete = false; | 329 m_isComplete = false; |
| 329 m_frame->document()->setReadyState(Document::Loading); | 330 m_frame->document()->setReadyState(Document::Loading); |
| 330 | 331 |
| 331 if (history()->currentItem() && m_loadType == FrameLoadTypeBackForward) | 332 if (history()->currentItem(m_frame) && m_loadType == FrameLoadTypeBackForwar
d) |
| 332 m_frame->document()->statePopped(history()->currentItem()->stateObject()
); | 333 m_frame->document()->statePopped(history()->currentItem(m_frame)->stateO
bject()); |
| 333 | 334 |
| 334 if (dispatch) | 335 if (dispatch) |
| 335 dispatchDidClearWindowObjectsInAllWorlds(); | 336 dispatchDidClearWindowObjectsInAllWorlds(); |
| 336 | 337 |
| 337 m_frame->document()->initContentSecurityPolicy(m_documentLoader ? ContentSec
urityPolicyResponseHeaders(m_documentLoader->response()) : ContentSecurityPolicy
ResponseHeaders()); | 338 m_frame->document()->initContentSecurityPolicy(m_documentLoader ? ContentSec
urityPolicyResponseHeaders(m_documentLoader->response()) : ContentSecurityPolicy
ResponseHeaders()); |
| 338 | 339 |
| 339 Settings* settings = m_frame->document()->settings(); | 340 Settings* settings = m_frame->document()->settings(); |
| 340 if (settings) { | 341 if (settings) { |
| 341 m_frame->document()->fetcher()->setImagesEnabled(settings->areImagesEnab
led()); | 342 m_frame->document()->fetcher()->setImagesEnabled(settings->areImagesEnab
led()); |
| 342 m_frame->document()->fetcher()->setAutoLoadImages(settings->loadsImagesA
utomatically()); | 343 m_frame->document()->fetcher()->setAutoLoadImages(settings->loadsImagesA
utomatically()); |
| 343 } | 344 } |
| 344 | 345 |
| 345 if (m_documentLoader) { | 346 if (m_documentLoader) { |
| 346 String dnsPrefetchControl = m_documentLoader->response().httpHeaderField
("X-DNS-Prefetch-Control"); | 347 String dnsPrefetchControl = m_documentLoader->response().httpHeaderField
("X-DNS-Prefetch-Control"); |
| 347 if (!dnsPrefetchControl.isEmpty()) | 348 if (!dnsPrefetchControl.isEmpty()) |
| 348 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchContro
l); | 349 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchContro
l); |
| 349 | 350 |
| 350 String headerContentLanguage = m_documentLoader->response().httpHeaderFi
eld("Content-Language"); | 351 String headerContentLanguage = m_documentLoader->response().httpHeaderFi
eld("Content-Language"); |
| 351 if (!headerContentLanguage.isEmpty()) { | 352 if (!headerContentLanguage.isEmpty()) { |
| 352 size_t commaIndex = headerContentLanguage.find(','); | 353 size_t commaIndex = headerContentLanguage.find(','); |
| 353 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do
n't truncate | 354 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do
n't truncate |
| 354 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML
Space<UChar>); | 355 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML
Space<UChar>); |
| 355 if (!headerContentLanguage.isEmpty()) | 356 if (!headerContentLanguage.isEmpty()) |
| 356 m_frame->document()->setContentLanguage(headerContentLanguage); | 357 m_frame->document()->setContentLanguage(headerContentLanguage); |
| 357 } | 358 } |
| 358 } | 359 } |
| 359 | 360 |
| 360 history()->restoreDocumentState(); | 361 history()->restoreDocumentState(m_frame); |
| 361 } | 362 } |
| 362 | 363 |
| 363 void FrameLoader::finishedParsing() | 364 void FrameLoader::finishedParsing() |
| 364 { | 365 { |
| 365 if (m_stateMachine.creatingInitialEmptyDocument()) | 366 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 366 return; | 367 return; |
| 367 | 368 |
| 368 // This can be called from the Frame's destructor, in which case we shouldn'
t protect ourselves | 369 // This can be called from the Frame's destructor, in which case we shouldn'
t protect ourselves |
| 369 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. | 370 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. |
| 370 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. | 371 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // Update the data source's request with the new URL to fake the URL change | 531 // Update the data source's request with the new URL to fake the URL change |
| 531 KURL oldURL = m_frame->document()->url(); | 532 KURL oldURL = m_frame->document()->url(); |
| 532 m_frame->document()->setURL(newURL); | 533 m_frame->document()->setURL(newURL); |
| 533 setOutgoingReferrer(newURL); | 534 setOutgoingReferrer(newURL); |
| 534 documentLoader()->replaceRequestURLForSameDocumentNavigation(newURL); | 535 documentLoader()->replaceRequestURLForSameDocumentNavigation(newURL); |
| 535 | 536 |
| 536 // updateBackForwardListForFragmentScroll() must happen after | 537 // updateBackForwardListForFragmentScroll() must happen after |
| 537 // replaceRequestURLForSameDocumentNavigation(), since we add based on | 538 // replaceRequestURLForSameDocumentNavigation(), since we add based on |
| 538 // the current request. | 539 // the current request. |
| 539 if (updateBackForwardList == UpdateBackForwardList) | 540 if (updateBackForwardList == UpdateBackForwardList) |
| 540 history()->updateBackForwardListForFragmentScroll(); | 541 history()->updateBackForwardListForFragmentScroll(m_frame); |
| 541 | 542 |
| 542 if (sameDocumentNavigationSource == SameDocumentNavigationDefault) | 543 if (sameDocumentNavigationSource == SameDocumentNavigationDefault) |
| 543 history()->updateForSameDocumentNavigation(); | 544 history()->updateForSameDocumentNavigation(m_frame); |
| 544 else if (sameDocumentNavigationSource == SameDocumentNavigationPushState) | 545 else if (sameDocumentNavigationSource == SameDocumentNavigationPushState) |
| 545 history()->pushState(data, newURL.string()); | 546 history()->pushState(m_frame, data, newURL.string()); |
| 546 else if (sameDocumentNavigationSource == SameDocumentNavigationReplaceState) | 547 else if (sameDocumentNavigationSource == SameDocumentNavigationReplaceState) |
| 547 history()->replaceState(data, newURL.string()); | 548 history()->replaceState(m_frame, data, newURL.string()); |
| 548 else | 549 else |
| 549 ASSERT_NOT_REACHED(); | 550 ASSERT_NOT_REACHED(); |
| 550 | 551 |
| 551 // Generate start and stop notifications only when loader is completed so th
at we | 552 // Generate start and stop notifications only when loader is completed so th
at we |
| 552 // don't fire them for fragment redirection that happens in window.onload ha
ndler. | 553 // don't fire them for fragment redirection that happens in window.onload ha
ndler. |
| 553 // See https://bugs.webkit.org/show_bug.cgi?id=31838 | 554 // See https://bugs.webkit.org/show_bug.cgi?id=31838 |
| 554 if (m_frame->document()->loadEventFinished()) | 555 if (m_frame->document()->loadEventFinished()) |
| 555 m_client->postProgressStartedNotification(); | 556 m_client->postProgressStartedNotification(); |
| 556 | 557 |
| 557 m_documentLoader->clearRedirectChain(); | 558 m_documentLoader->clearRedirectChain(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 616 } |
| 616 | 617 |
| 617 void FrameLoader::started() | 618 void FrameLoader::started() |
| 618 { | 619 { |
| 619 for (Frame* frame = m_frame; frame; frame = frame->tree()->parent()) | 620 for (Frame* frame = m_frame; frame; frame = frame->tree()->parent()) |
| 620 frame->loader()->m_isComplete = false; | 621 frame->loader()->m_isComplete = false; |
| 621 } | 622 } |
| 622 | 623 |
| 623 void FrameLoader::prepareForHistoryNavigation() | 624 void FrameLoader::prepareForHistoryNavigation() |
| 624 { | 625 { |
| 625 // If there is no currentItem, but we still want to engage in | |
| 626 // history navigation we need to manufacture one, and update | |
| 627 // the state machine of this frame to impersonate having | |
| 628 // loaded it. | |
| 629 RefPtr<HistoryItem> currentItem = history()->currentItem(); | |
| 630 if (!currentItem) { | |
| 631 insertDummyHistoryItem(); | |
| 632 ASSERT(stateMachine()->isDisplayingInitialEmptyDocument()); | |
| 633 stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoa
d); | |
| 634 } | |
| 635 } | 626 } |
| 636 | 627 |
| 637 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen
dReferrer shouldSendReferrer) | 628 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen
dReferrer shouldSendReferrer) |
| 638 { | 629 { |
| 639 if (shouldSendReferrer == NeverSendReferrer) { | 630 if (shouldSendReferrer == NeverSendReferrer) { |
| 640 request.clearHTTPReferrer(); | 631 request.clearHTTPReferrer(); |
| 641 return; | 632 return; |
| 642 } | 633 } |
| 643 | 634 |
| 644 String argsReferrer(request.httpReferrer()); | 635 String argsReferrer(request.httpReferrer()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 658 // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motiva
tion for this. | 649 // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motiva
tion for this. |
| 659 if (!m_frame->tree()->parent() || UserGestureIndicator::processingUserGestur
e()) | 650 if (!m_frame->tree()->parent() || UserGestureIndicator::processingUserGestur
e()) |
| 660 return false; | 651 return false; |
| 661 return request.formState() && request.formState()->formSubmissionTrigger() =
= SubmittedByJavaScript; | 652 return request.formState() && request.formState()->formSubmissionTrigger() =
= SubmittedByJavaScript; |
| 662 } | 653 } |
| 663 | 654 |
| 664 FrameLoadType FrameLoader::determineFrameLoadType(const FrameLoadRequest& reques
t) | 655 FrameLoadType FrameLoader::determineFrameLoadType(const FrameLoadRequest& reques
t) |
| 665 { | 656 { |
| 666 if (m_frame->tree()->parent() && !m_stateMachine.startedFirstRealLoad()) | 657 if (m_frame->tree()->parent() && !m_stateMachine.startedFirstRealLoad()) |
| 667 return FrameLoadTypeInitialInChildFrame; | 658 return FrameLoadTypeInitialInChildFrame; |
| 668 if (!m_frame->tree()->parent() && !history()->currentItem()) | 659 if (!m_frame->tree()->parent() && !m_frame->page()->backForward().backForwar
dListCount()) |
| 669 return FrameLoadTypeStandard; | 660 return FrameLoadTypeStandard; |
| 670 if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData) | 661 if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData) |
| 671 return FrameLoadTypeReload; | 662 return FrameLoadTypeReload; |
| 672 if (request.lockBackForwardList() || isScriptTriggeredFormSubmissionInChildF
rame(request)) | 663 if (request.lockBackForwardList() || isScriptTriggeredFormSubmissionInChildF
rame(request)) |
| 673 return FrameLoadTypeRedirectWithLockedBackForwardList; | 664 return FrameLoadTypeRedirectWithLockedBackForwardList; |
| 674 if (!request.requester() && shouldTreatURLAsSameAsCurrent(request.resourceRe
quest().url())) | 665 if (!request.requester() && shouldTreatURLAsSameAsCurrent(request.resourceRe
quest().url())) |
| 675 return FrameLoadTypeSame; | 666 return FrameLoadTypeSame; |
| 676 if (shouldTreatURLAsSameAsCurrent(request.substituteData().failingURL()) &&
m_loadType == FrameLoadTypeReload) | 667 if (shouldTreatURLAsSameAsCurrent(request.substituteData().failingURL()) &&
m_loadType == FrameLoadTypeReload) |
| 677 return FrameLoadTypeReload; | 668 return FrameLoadTypeReload; |
| 678 return FrameLoadTypeStandard; | 669 return FrameLoadTypeStandard; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 770 |
| 780 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve
l, "Not allowed to load local resource: " + url); | 771 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve
l, "Not allowed to load local resource: " + url); |
| 781 } | 772 } |
| 782 | 773 |
| 783 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
st String& overrideEncoding) | 774 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
st String& overrideEncoding) |
| 784 { | 775 { |
| 785 DocumentLoader* documentLoader = activeDocumentLoader(); | 776 DocumentLoader* documentLoader = activeDocumentLoader(); |
| 786 if (!documentLoader) | 777 if (!documentLoader) |
| 787 return; | 778 return; |
| 788 | 779 |
| 789 if (m_state == FrameStateProvisional) | |
| 790 insertDummyHistoryItem(); | |
| 791 | |
| 792 ResourceRequest request = documentLoader->request(); | 780 ResourceRequest request = documentLoader->request(); |
| 793 // FIXME: We need to reset cache policy to prevent it from being incorrectly
propagted to the reload. | 781 // FIXME: We need to reset cache policy to prevent it from being incorrectly
propagted to the reload. |
| 794 // Do we need to propagate anything other than the url? | 782 // Do we need to propagate anything other than the url? |
| 795 request.setCachePolicy(UseProtocolCachePolicy); | 783 request.setCachePolicy(UseProtocolCachePolicy); |
| 796 if (!overrideURL.isEmpty()) | 784 if (!overrideURL.isEmpty()) |
| 797 request.setURL(overrideURL); | 785 request.setURL(overrideURL); |
| 798 else if (!documentLoader->unreachableURL().isEmpty()) | 786 else if (!documentLoader->unreachableURL().isEmpty()) |
| 799 request.setURL(documentLoader->unreachableURL()); | 787 request.setURL(documentLoader->unreachableURL()); |
| 800 | 788 |
| 801 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro
mOrigin : FrameLoadTypeReload; | 789 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro
mOrigin : FrameLoadTypeReload; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 if (pdl != m_provisionalDocumentLoader) | 888 if (pdl != m_provisionalDocumentLoader) |
| 901 return; | 889 return; |
| 902 if (m_documentLoader) | 890 if (m_documentLoader) |
| 903 m_documentLoader->detachFromFrame(); | 891 m_documentLoader->detachFromFrame(); |
| 904 m_documentLoader = m_provisionalDocumentLoader.release(); | 892 m_documentLoader = m_provisionalDocumentLoader.release(); |
| 905 m_state = FrameStateCommittedPage; | 893 m_state = FrameStateCommittedPage; |
| 906 | 894 |
| 907 if (isLoadingMainFrame()) | 895 if (isLoadingMainFrame()) |
| 908 m_frame->page()->chrome().client().needTouchEvents(false); | 896 m_frame->page()->chrome().client().needTouchEvents(false); |
| 909 | 897 |
| 910 history()->updateForCommit(); | 898 history()->updateForCommit(m_frame); |
| 911 m_client->transitionToCommittedForNewPage(); | 899 m_client->transitionToCommittedForNewPage(); |
| 912 | 900 |
| 913 m_frame->navigationScheduler()->cancel(); | 901 m_frame->navigationScheduler()->cancel(); |
| 914 m_frame->editor().clearLastEditCommand(); | 902 m_frame->editor().clearLastEditCommand(); |
| 915 | 903 |
| 916 // If we are still in the process of initializing an empty document then | 904 // If we are still in the process of initializing an empty document then |
| 917 // its frame is not in a consistent state for rendering, so avoid setJSStatu
sBarText | 905 // its frame is not in a consistent state for rendering, so avoid setJSStatu
sBarText |
| 918 // since it may cause clients to attempt to render the frame. | 906 // since it may cause clients to attempt to render the frame. |
| 919 if (!m_stateMachine.creatingInitialEmptyDocument()) { | 907 if (!m_stateMachine.creatingInitialEmptyDocument()) { |
| 920 DOMWindow* window = m_frame->domWindow(); | 908 DOMWindow* window = m_frame->domWindow(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 | 1004 |
| 1017 m_state = FrameStateComplete; | 1005 m_state = FrameStateComplete; |
| 1018 | 1006 |
| 1019 // FIXME: Is this subsequent work important if we already navigated away? | 1007 // FIXME: Is this subsequent work important if we already navigated away? |
| 1020 // Maybe there are bugs because of that, or extra work we can skip because | 1008 // Maybe there are bugs because of that, or extra work we can skip because |
| 1021 // the new page is ready. | 1009 // the new page is ready. |
| 1022 | 1010 |
| 1023 // If the user had a scroll point, scroll to it, overriding the anchor point
if any. | 1011 // If the user had a scroll point, scroll to it, overriding the anchor point
if any. |
| 1024 if (m_frame->page()) { | 1012 if (m_frame->page()) { |
| 1025 if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeRelo
ad || m_loadType == FrameLoadTypeReloadFromOrigin) | 1013 if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeRelo
ad || m_loadType == FrameLoadTypeReloadFromOrigin) |
| 1026 history()->restoreScrollPositionAndViewState(); | 1014 history()->restoreScrollPositionAndViewState(m_frame); |
| 1027 } | 1015 } |
| 1028 | 1016 |
| 1029 if (!m_stateMachine.committedFirstRealDocumentLoad()) | 1017 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
| 1030 return; | 1018 return; |
| 1031 | 1019 |
| 1032 m_progressTracker->progressCompleted(); | 1020 m_progressTracker->progressCompleted(); |
| 1033 | 1021 |
| 1034 const ResourceError& error = m_documentLoader->mainDocumentError(); | 1022 const ResourceError& error = m_documentLoader->mainDocumentError(); |
| 1035 if (!error.isNull()) | 1023 if (!error.isNull()) |
| 1036 m_client->dispatchDidFailLoad(error); | 1024 m_client->dispatchDidFailLoad(error); |
| 1037 else | 1025 else |
| 1038 m_client->dispatchDidFinishLoad(); | 1026 m_client->dispatchDidFinishLoad(); |
| 1039 m_loadType = FrameLoadTypeStandard; | 1027 m_loadType = FrameLoadTypeStandard; |
| 1040 } | 1028 } |
| 1041 | 1029 |
| 1042 void FrameLoader::didFirstLayout() | 1030 void FrameLoader::didFirstLayout() |
| 1043 { | 1031 { |
| 1044 if (m_frame->page() && isBackForwardLoadType(m_loadType)) | 1032 if (m_frame->page() && isBackForwardLoadType(m_loadType)) |
| 1045 history()->restoreScrollPositionAndViewState(); | 1033 history()->restoreScrollPositionAndViewState(m_frame); |
| 1046 } | 1034 } |
| 1047 | 1035 |
| 1048 void FrameLoader::detachChildren() | 1036 void FrameLoader::detachChildren() |
| 1049 { | 1037 { |
| 1050 typedef Vector<RefPtr<Frame> > FrameVector; | 1038 typedef Vector<RefPtr<Frame> > FrameVector; |
| 1051 FrameVector childrenToDetach; | 1039 FrameVector childrenToDetach; |
| 1052 childrenToDetach.reserveCapacity(m_frame->tree()->childCount()); | 1040 childrenToDetach.reserveCapacity(m_frame->tree()->childCount()); |
| 1053 for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree
()->previousSibling()) | 1041 for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree
()->previousSibling()) |
| 1054 childrenToDetach.append(child); | 1042 childrenToDetach.append(child); |
| 1055 FrameVector::iterator end = childrenToDetach.end(); | 1043 FrameVector::iterator end = childrenToDetach.end(); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 if (!m_documentLoader->shouldContinueForNavigationPolicy(request, DocumentLo
ader::PolicyCheckFragment)) | 1230 if (!m_documentLoader->shouldContinueForNavigationPolicy(request, DocumentLo
ader::PolicyCheckFragment)) |
| 1243 return; | 1231 return; |
| 1244 | 1232 |
| 1245 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 1233 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
| 1246 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis
ionalDocumentLoader->request().url(), request.url())) { | 1234 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis
ionalDocumentLoader->request().url(), request.url())) { |
| 1247 m_provisionalDocumentLoader->stopLoading(); | 1235 m_provisionalDocumentLoader->stopLoading(); |
| 1248 if (m_provisionalDocumentLoader) | 1236 if (m_provisionalDocumentLoader) |
| 1249 m_provisionalDocumentLoader->detachFromFrame(); | 1237 m_provisionalDocumentLoader->detachFromFrame(); |
| 1250 m_provisionalDocumentLoader = 0; | 1238 m_provisionalDocumentLoader = 0; |
| 1251 } | 1239 } |
| 1252 history()->setProvisionalItem(0); | 1240 history()->clearProvisionalEntry(); |
| 1253 loadInSameDocument(request.url(), 0, isNewNavigation); | 1241 loadInSameDocument(request.url(), 0, isNewNavigation); |
| 1254 } | 1242 } |
| 1255 | 1243 |
| 1256 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S
tring& httpMethod, FrameLoadType loadType, const KURL& url) | 1244 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S
tring& httpMethod, FrameLoadType loadType, const KURL& url) |
| 1257 { | 1245 { |
| 1258 ASSERT(loadType != FrameLoadTypeBackForward); | 1246 ASSERT(loadType != FrameLoadTypeBackForward); |
| 1259 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); | 1247 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); |
| 1260 // We don't do this if we are submitting a form with method other than "GET"
, explicitly reloading, | 1248 // We don't do this if we are submitting a form with method other than "GET"
, explicitly reloading, |
| 1261 // currently displaying a frameset, or if the URL does not have a fragment. | 1249 // currently displaying a frameset, or if the URL does not have a fragment. |
| 1262 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) | 1250 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 m_frame->document()->addConsoleMessageWithRequestIdentifier(JSMessageSou
rce, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encountered when loadi
ng '" + url.elidedString() + "': '" + content + "' is not a recognized directive
. The header will be ignored.", requestIdentifier); | 1469 m_frame->document()->addConsoleMessageWithRequestIdentifier(JSMessageSou
rce, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encountered when loadi
ng '" + url.elidedString() + "': '" + content + "' is not a recognized directive
. The header will be ignored.", requestIdentifier); |
| 1482 return false; | 1470 return false; |
| 1483 default: | 1471 default: |
| 1484 ASSERT_NOT_REACHED(); | 1472 ASSERT_NOT_REACHED(); |
| 1485 return false; | 1473 return false; |
| 1486 } | 1474 } |
| 1487 } | 1475 } |
| 1488 | 1476 |
| 1489 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const | 1477 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const |
| 1490 { | 1478 { |
| 1491 if (!history()->currentItem()) | 1479 return url == m_frame->document()->url() || url == m_documentLoader->origina
lURL(); |
| 1492 return false; | |
| 1493 return url == history()->currentItem()->url() || url == history()->currentIt
em()->originalURL(); | |
| 1494 } | 1480 } |
| 1495 | 1481 |
| 1496 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const | 1482 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const |
| 1497 { | 1483 { |
| 1498 if (!equalIgnoringCase(url.string(), "about:srcdoc")) | 1484 if (!equalIgnoringCase(url.string(), "about:srcdoc")) |
| 1499 return false; | 1485 return false; |
| 1500 HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement(); | 1486 HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement(); |
| 1501 if (!ownerElement) | 1487 if (!ownerElement) |
| 1502 return false; | 1488 return false; |
| 1503 if (!ownerElement->hasTagName(iframeTag)) | 1489 if (!ownerElement->hasTagName(iframeTag)) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1529 ASSERT(frame != m_frame); | 1515 ASSERT(frame != m_frame); |
| 1530 } | 1516 } |
| 1531 | 1517 |
| 1532 if (!activeDocument->canNavigate(frame)) | 1518 if (!activeDocument->canNavigate(frame)) |
| 1533 return 0; | 1519 return 0; |
| 1534 return frame; | 1520 return frame; |
| 1535 } | 1521 } |
| 1536 | 1522 |
| 1537 void FrameLoader::loadHistoryItem(HistoryItem* item) | 1523 void FrameLoader::loadHistoryItem(HistoryItem* item) |
| 1538 { | 1524 { |
| 1539 HistoryItem* currentItem = history()->currentItem(); | 1525 if (shouldTreatURLAsSameAsCurrent(item->url())) { |
| 1540 | |
| 1541 if (currentItem && item->shouldDoSameDocumentNavigationTo(currentItem)) { | |
| 1542 history()->setCurrentItem(item); | |
| 1543 loadInSameDocument(item->url(), item->stateObject(), false); | 1526 loadInSameDocument(item->url(), item->stateObject(), false); |
| 1544 return; | 1527 return; |
| 1545 } | 1528 } |
| 1546 | 1529 |
| 1547 // Remember this item so we can traverse any child items as child frames loa
d | 1530 RefPtr<Frame> protect(m_frame); |
| 1548 history()->setProvisionalItem(item); | 1531 m_frame->page()->mainFrame()->loader()->stopAllLoaders(); |
| 1549 | 1532 |
| 1550 RefPtr<FormData> formData = item->formData(); | 1533 RefPtr<FormData> formData = item->formData(); |
| 1551 ResourceRequest request(item->url()); | 1534 ResourceRequest request(item->url()); |
| 1552 request.setHTTPReferrer(item->referrer()); | 1535 request.setHTTPReferrer(item->referrer()); |
| 1553 if (formData) { | 1536 if (formData) { |
| 1554 request.setHTTPMethod("POST"); | 1537 request.setHTTPMethod("POST"); |
| 1555 request.setHTTPBody(formData); | 1538 request.setHTTPBody(formData); |
| 1556 request.setHTTPContentType(item->formContentType()); | 1539 request.setHTTPContentType(item->formContentType()); |
| 1557 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString
(item->referrer()); | 1540 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString
(item->referrer()); |
| 1558 addHTTPOriginIfNeeded(request, securityOrigin->toString()); | 1541 addHTTPOriginIfNeeded(request, securityOrigin->toString()); |
| 1559 } | 1542 } |
| 1560 | 1543 |
| 1561 loadWithNavigationAction(request, NavigationAction(request, FrameLoadTypeBac
kForward, formData), FrameLoadTypeBackForward, 0, SubstituteData()); | 1544 loadWithNavigationAction(request, NavigationAction(request, FrameLoadTypeBac
kForward, formData), FrameLoadTypeBackForward, 0, SubstituteData()); |
| 1562 } | 1545 } |
| 1563 | 1546 |
| 1564 void FrameLoader::insertDummyHistoryItem() | 1547 void FrameLoader::insertDummyHistoryItem() |
| 1565 { | 1548 { |
| 1566 RefPtr<HistoryItem> currentItem = HistoryItem::create(); | |
| 1567 history()->setCurrentItem(currentItem.get()); | |
| 1568 } | 1549 } |
| 1569 | 1550 |
| 1570 void FrameLoader::dispatchDocumentElementAvailable() | 1551 void FrameLoader::dispatchDocumentElementAvailable() |
| 1571 { | 1552 { |
| 1572 m_client->documentElementAvailable(); | 1553 m_client->documentElementAvailable(); |
| 1573 } | 1554 } |
| 1574 | 1555 |
| 1575 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds() | 1556 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds() |
| 1576 { | 1557 { |
| 1577 if (!m_frame->script()->canExecuteScripts(NotAboutToExecuteScript)) | 1558 if (!m_frame->script()->canExecuteScripts(NotAboutToExecuteScript)) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1600 { | 1581 { |
| 1601 SandboxFlags flags = m_forcedSandboxFlags; | 1582 SandboxFlags flags = m_forcedSandboxFlags; |
| 1602 if (Frame* parentFrame = m_frame->tree()->parent()) | 1583 if (Frame* parentFrame = m_frame->tree()->parent()) |
| 1603 flags |= parentFrame->document()->sandboxFlags(); | 1584 flags |= parentFrame->document()->sandboxFlags(); |
| 1604 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1585 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
| 1605 flags |= ownerElement->sandboxFlags(); | 1586 flags |= ownerElement->sandboxFlags(); |
| 1606 return flags; | 1587 return flags; |
| 1607 } | 1588 } |
| 1608 | 1589 |
| 1609 } // namespace WebCore | 1590 } // namespace WebCore |
| OLD | NEW |