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

Side by Side Diff: Source/core/loader/FrameLoader.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
63 #include "core/loader/DocumentLoader.h" 63 #include "core/loader/DocumentLoader.h"
64 #include "core/loader/FormState.h" 64 #include "core/loader/FormState.h"
65 #include "core/loader/FormSubmission.h" 65 #include "core/loader/FormSubmission.h"
66 #include "core/loader/FrameFetchContext.h" 66 #include "core/loader/FrameFetchContext.h"
67 #include "core/loader/FrameLoadRequest.h" 67 #include "core/loader/FrameLoadRequest.h"
68 #include "core/loader/FrameLoaderClient.h" 68 #include "core/loader/FrameLoaderClient.h"
69 #include "core/loader/IconController.h" 69 #include "core/loader/IconController.h"
70 #include "core/loader/ProgressTracker.h" 70 #include "core/loader/ProgressTracker.h"
71 #include "core/loader/UniqueIdentifier.h" 71 #include "core/loader/UniqueIdentifier.h"
72 #include "core/loader/appcache/ApplicationCacheHost.h" 72 #include "core/loader/appcache/ApplicationCacheHost.h"
73 #include "core/page/BackForwardClient.h"
73 #include "core/page/Chrome.h" 74 #include "core/page/Chrome.h"
74 #include "core/page/ChromeClient.h" 75 #include "core/page/ChromeClient.h"
75 #include "core/page/EventHandler.h" 76 #include "core/page/EventHandler.h"
76 #include "core/page/FrameTree.h" 77 #include "core/page/FrameTree.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/xml/parser/XMLDocumentParser.h" 82 #include "core/xml/parser/XMLDocumentParser.h"
82 #include "modules/webdatabase/DatabaseManager.h" 83 #include "modules/webdatabase/DatabaseManager.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 { 136 {
136 } 137 }
137 138
138 Frame* m_frame; 139 Frame* m_frame;
139 bool m_inProgress; 140 bool m_inProgress;
140 }; 141 };
141 142
142 FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client) 143 FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client)
143 : m_frame(frame) 144 : m_frame(frame)
144 , m_client(client) 145 , m_client(client)
145 , m_history(frame)
146 , m_icon(adoptPtr(new IconController(frame))) 146 , m_icon(adoptPtr(new IconController(frame)))
147 , m_mixedContentChecker(frame) 147 , m_mixedContentChecker(frame)
148 , m_state(FrameStateProvisional) 148 , m_state(FrameStateProvisional)
149 , m_loadType(FrameLoadTypeStandard) 149 , m_loadType(FrameLoadTypeStandard)
150 , m_fetchContext(FrameFetchContext::create(frame)) 150 , m_fetchContext(FrameFetchContext::create(frame))
151 , m_inStopAllLoaders(false) 151 , m_inStopAllLoaders(false)
152 , m_isComplete(false) 152 , m_isComplete(false)
153 , m_checkTimer(this, &FrameLoader::checkTimerFired) 153 , m_checkTimer(this, &FrameLoader::checkTimerFired)
154 , m_shouldCallCheckCompleted(false) 154 , m_shouldCallCheckCompleted(false)
155 , m_opener(0) 155 , m_opener(0)
(...skipping 19 matching lines...) Expand all
175 { 175 {
176 // This somewhat odd set of steps gives the frame an initial empty document. 176 // This somewhat odd set of steps gives the frame an initial empty document.
177 m_provisionalDocumentLoader = m_client->createDocumentLoader(ResourceRequest (KURL(ParsedURLString, emptyString())), SubstituteData()); 177 m_provisionalDocumentLoader = m_client->createDocumentLoader(ResourceRequest (KURL(ParsedURLString, emptyString())), SubstituteData());
178 m_provisionalDocumentLoader->setFrame(m_frame); 178 m_provisionalDocumentLoader->setFrame(m_frame);
179 m_provisionalDocumentLoader->startLoadingMainResource(); 179 m_provisionalDocumentLoader->startLoadingMainResource();
180 m_frame->document()->cancelParsing(); 180 m_frame->document()->cancelParsing();
181 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment); 181 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment);
182 m_progressTracker = FrameProgressTracker::create(m_frame); 182 m_progressTracker = FrameProgressTracker::create(m_frame);
183 } 183 }
184 184
185 HistoryController* FrameLoader::history() const
186 {
187 return m_frame->page() ? m_frame->page()->history() : 0;
188 }
189
185 void FrameLoader::setDefersLoading(bool defers) 190 void FrameLoader::setDefersLoading(bool defers)
186 { 191 {
187 if (m_documentLoader) 192 if (m_documentLoader)
188 m_documentLoader->setDefersLoading(defers); 193 m_documentLoader->setDefersLoading(defers);
189 if (m_provisionalDocumentLoader) 194 if (m_provisionalDocumentLoader)
190 m_provisionalDocumentLoader->setDefersLoading(defers); 195 m_provisionalDocumentLoader->setDefersLoading(defers);
191 if (m_policyDocumentLoader) 196 if (m_policyDocumentLoader)
192 m_policyDocumentLoader->setDefersLoading(defers); 197 m_policyDocumentLoader->setDefersLoading(defers);
193 history()->setDefersLoading(defers); 198 history()->setDefersLoading(defers);
194 199
(...skipping 20 matching lines...) Expand all
215 // FIXME: Should the DatabaseManager watch for something like ActiveDOMO bject::stop() rather than being special-cased here? 220 // FIXME: Should the DatabaseManager watch for something like ActiveDOMO bject::stop() rather than being special-cased here?
216 DatabaseManager::manager().stopDatabases(doc, 0); 221 DatabaseManager::manager().stopDatabases(doc, 0);
217 } 222 }
218 223
219 // FIXME: This will cancel redirection timer, which really needs to be resta rted when restoring the frame from b/f cache. 224 // FIXME: This will cancel redirection timer, which really needs to be resta rted when restoring the frame from b/f cache.
220 m_frame->navigationScheduler().cancel(); 225 m_frame->navigationScheduler().cancel();
221 } 226 }
222 227
223 bool FrameLoader::closeURL() 228 bool FrameLoader::closeURL()
224 { 229 {
225 history()->saveDocumentAndScrollState(); 230 if (m_frame->page())
231 history()->saveDocumentAndScrollState(m_frame);
226 232
227 // Should only send the pagehide event here if the current document exists. 233 // Should only send the pagehide event here if the current document exists.
228 if (m_frame->document()) 234 if (m_frame->document())
229 m_frame->document()->dispatchUnloadEvents(); 235 m_frame->document()->dispatchUnloadEvents();
230 stopLoading(); 236 stopLoading();
231 237
232 m_frame->editor().clearUndoRedoOperations(); 238 m_frame->editor().clearUndoRedoOperations();
233 return true; 239 return true;
234 } 240 }
235 241
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 void FrameLoader::setOutgoingReferrer(const KURL& url) 312 void FrameLoader::setOutgoingReferrer(const KURL& url)
307 { 313 {
308 m_outgoingReferrer = url.strippedForUseAsReferrer(); 314 m_outgoingReferrer = url.strippedForUseAsReferrer();
309 } 315 }
310 316
311 void FrameLoader::didBeginDocument(bool dispatch) 317 void FrameLoader::didBeginDocument(bool dispatch)
312 { 318 {
313 m_isComplete = false; 319 m_isComplete = false;
314 m_frame->document()->setReadyState(Document::Loading); 320 m_frame->document()->setReadyState(Document::Loading);
315 321
316 if (history()->currentItem() && m_loadType == FrameLoadTypeBackForward) 322 if (history()->currentItem(m_frame) && m_loadType == FrameLoadTypeBackForwar d)
317 m_frame->domWindow()->statePopped(history()->currentItem()->stateObject( )); 323 m_frame->domWindow()->statePopped(history()->currentItem(m_frame)->state Object());
318 324
319 if (dispatch) 325 if (dispatch)
320 dispatchDidClearWindowObjectsInAllWorlds(); 326 dispatchDidClearWindowObjectsInAllWorlds();
321 327
322 m_frame->document()->initContentSecurityPolicy(m_documentLoader ? ContentSec urityPolicyResponseHeaders(m_documentLoader->response()) : ContentSecurityPolicy ResponseHeaders()); 328 m_frame->document()->initContentSecurityPolicy(m_documentLoader ? ContentSec urityPolicyResponseHeaders(m_documentLoader->response()) : ContentSecurityPolicy ResponseHeaders());
323 329
324 Settings* settings = m_frame->document()->settings(); 330 Settings* settings = m_frame->document()->settings();
325 if (settings) { 331 if (settings) {
326 m_frame->document()->fetcher()->setImagesEnabled(settings->areImagesEnab led()); 332 m_frame->document()->fetcher()->setImagesEnabled(settings->areImagesEnab led());
327 m_frame->document()->fetcher()->setAutoLoadImages(settings->loadsImagesA utomatically()); 333 m_frame->document()->fetcher()->setAutoLoadImages(settings->loadsImagesA utomatically());
328 } 334 }
329 335
330 if (m_documentLoader) { 336 if (m_documentLoader) {
331 String dnsPrefetchControl = m_documentLoader->response().httpHeaderField ("X-DNS-Prefetch-Control"); 337 String dnsPrefetchControl = m_documentLoader->response().httpHeaderField ("X-DNS-Prefetch-Control");
332 if (!dnsPrefetchControl.isEmpty()) 338 if (!dnsPrefetchControl.isEmpty())
333 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchContro l); 339 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchContro l);
334 340
335 String headerContentLanguage = m_documentLoader->response().httpHeaderFi eld("Content-Language"); 341 String headerContentLanguage = m_documentLoader->response().httpHeaderFi eld("Content-Language");
336 if (!headerContentLanguage.isEmpty()) { 342 if (!headerContentLanguage.isEmpty()) {
337 size_t commaIndex = headerContentLanguage.find(','); 343 size_t commaIndex = headerContentLanguage.find(',');
338 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do n't truncate 344 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do n't truncate
339 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML Space<UChar>); 345 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML Space<UChar>);
340 if (!headerContentLanguage.isEmpty()) 346 if (!headerContentLanguage.isEmpty())
341 m_frame->document()->setContentLanguage(headerContentLanguage); 347 m_frame->document()->setContentLanguage(headerContentLanguage);
342 } 348 }
343 } 349 }
344 350
345 history()->restoreDocumentState(); 351 history()->restoreDocumentState(m_frame);
346 } 352 }
347 353
348 void FrameLoader::finishedParsing() 354 void FrameLoader::finishedParsing()
349 { 355 {
350 if (m_stateMachine.creatingInitialEmptyDocument()) 356 if (m_stateMachine.creatingInitialEmptyDocument())
351 return; 357 return;
352 358
353 // This can be called from the Frame's destructor, in which case we shouldn' t protect ourselves 359 // This can be called from the Frame's destructor, in which case we shouldn' t protect ourselves
354 // because doing so will cause us to re-enter the destructor when protector goes out of scope. 360 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
355 // Null-checking the FrameView indicates whether or not we're in the destruc tor. 361 // 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
515 // Update the data source's request with the new URL to fake the URL change 521 // Update the data source's request with the new URL to fake the URL change
516 KURL oldURL = m_frame->document()->url(); 522 KURL oldURL = m_frame->document()->url();
517 m_frame->document()->setURL(newURL); 523 m_frame->document()->setURL(newURL);
518 setOutgoingReferrer(newURL); 524 setOutgoingReferrer(newURL);
519 documentLoader()->replaceRequestURLForSameDocumentNavigation(newURL); 525 documentLoader()->replaceRequestURLForSameDocumentNavigation(newURL);
520 526
521 // updateBackForwardListForFragmentScroll() must happen after 527 // updateBackForwardListForFragmentScroll() must happen after
522 // replaceRequestURLForSameDocumentNavigation(), since we add based on 528 // replaceRequestURLForSameDocumentNavigation(), since we add based on
523 // the current request. 529 // the current request.
524 if (updateBackForwardList == UpdateBackForwardList) 530 if (updateBackForwardList == UpdateBackForwardList)
525 history()->updateBackForwardListForFragmentScroll(); 531 history()->updateBackForwardListForFragmentScroll(m_frame);
526 532
527 if (sameDocumentNavigationSource == SameDocumentNavigationDefault) 533 if (sameDocumentNavigationSource == SameDocumentNavigationDefault)
528 history()->updateForSameDocumentNavigation(); 534 history()->updateForSameDocumentNavigation(m_frame);
529 else if (sameDocumentNavigationSource == SameDocumentNavigationPushState) 535 else if (sameDocumentNavigationSource == SameDocumentNavigationPushState)
530 history()->pushState(data, newURL.string()); 536 history()->pushState(m_frame, data, newURL.string());
531 else if (sameDocumentNavigationSource == SameDocumentNavigationReplaceState) 537 else if (sameDocumentNavigationSource == SameDocumentNavigationReplaceState)
532 history()->replaceState(data, newURL.string()); 538 history()->replaceState(m_frame, data, newURL.string());
533 else 539 else
534 ASSERT_NOT_REACHED(); 540 ASSERT_NOT_REACHED();
535 541
536 // Generate start and stop notifications only when loader is completed so th at we 542 // Generate start and stop notifications only when loader is completed so th at we
537 // don't fire them for fragment redirection that happens in window.onload ha ndler. 543 // don't fire them for fragment redirection that happens in window.onload ha ndler.
538 // See https://bugs.webkit.org/show_bug.cgi?id=31838 544 // See https://bugs.webkit.org/show_bug.cgi?id=31838
539 if (m_frame->document()->loadEventFinished()) 545 if (m_frame->document()->loadEventFinished())
540 m_client->postProgressStartedNotification(); 546 m_client->postProgressStartedNotification();
541 547
542 m_documentLoader->clearRedirectChain(); 548 m_documentLoader->clearRedirectChain();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 if (m_frame->view()) 604 if (m_frame->view())
599 m_frame->view()->maintainScrollPositionAtAnchor(0); 605 m_frame->view()->maintainScrollPositionAtAnchor(0);
600 } 606 }
601 607
602 void FrameLoader::started() 608 void FrameLoader::started()
603 { 609 {
604 for (Frame* frame = m_frame; frame; frame = frame->tree().parent()) 610 for (Frame* frame = m_frame; frame; frame = frame->tree().parent())
605 frame->loader().m_isComplete = false; 611 frame->loader().m_isComplete = false;
606 } 612 }
607 613
608 void FrameLoader::prepareForHistoryNavigation()
609 {
610 // If there is no currentItem, but we still want to engage in
611 // history navigation we need to manufacture one, and update
612 // the state machine of this frame to impersonate having
613 // loaded it.
614 RefPtr<HistoryItem> currentItem = history()->currentItem();
615 if (!currentItem) {
616 insertDummyHistoryItem();
617 ASSERT(stateMachine()->isDisplayingInitialEmptyDocument());
618 stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoa d);
619 }
620 }
621
622 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen dReferrer shouldSendReferrer) 614 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen dReferrer shouldSendReferrer)
623 { 615 {
624 if (shouldSendReferrer == NeverSendReferrer) { 616 if (shouldSendReferrer == NeverSendReferrer) {
625 request.clearHTTPReferrer(); 617 request.clearHTTPReferrer();
626 return; 618 return;
627 } 619 }
628 620
629 String argsReferrer(request.httpReferrer()); 621 String argsReferrer(request.httpReferrer());
630 if (argsReferrer.isEmpty()) 622 if (argsReferrer.isEmpty())
631 argsReferrer = outgoingReferrer(); 623 argsReferrer = outgoingReferrer();
(...skipping 11 matching lines...) Expand all
643 // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motiva tion for this. 635 // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motiva tion for this.
644 if (!m_frame->tree().parent() || UserGestureIndicator::processingUserGesture ()) 636 if (!m_frame->tree().parent() || UserGestureIndicator::processingUserGesture ())
645 return false; 637 return false;
646 return request.formState() && request.formState()->formSubmissionTrigger() = = SubmittedByJavaScript; 638 return request.formState() && request.formState()->formSubmissionTrigger() = = SubmittedByJavaScript;
647 } 639 }
648 640
649 FrameLoadType FrameLoader::determineFrameLoadType(const FrameLoadRequest& reques t) 641 FrameLoadType FrameLoader::determineFrameLoadType(const FrameLoadRequest& reques t)
650 { 642 {
651 if (m_frame->tree().parent() && !m_stateMachine.startedFirstRealLoad()) 643 if (m_frame->tree().parent() && !m_stateMachine.startedFirstRealLoad())
652 return FrameLoadTypeInitialInChildFrame; 644 return FrameLoadTypeInitialInChildFrame;
653 if (!m_frame->tree().parent() && !history()->currentItem()) 645 if (!m_frame->tree().parent() && !m_frame->page()->backForward().backForward ListCount())
654 return FrameLoadTypeStandard; 646 return FrameLoadTypeStandard;
655 if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData) 647 if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
656 return FrameLoadTypeReload; 648 return FrameLoadTypeReload;
657 if (request.lockBackForwardList() || isScriptTriggeredFormSubmissionInChildF rame(request)) 649 if (request.lockBackForwardList() || isScriptTriggeredFormSubmissionInChildF rame(request))
658 return FrameLoadTypeRedirectWithLockedBackForwardList; 650 return FrameLoadTypeRedirectWithLockedBackForwardList;
659 if (!request.requester() && shouldTreatURLAsSameAsCurrent(request.resourceRe quest().url())) 651 if (!request.requester() && shouldTreatURLAsSameAsCurrent(request.resourceRe quest().url()))
660 return FrameLoadTypeSame; 652 return FrameLoadTypeSame;
661 if (shouldTreatURLAsSameAsCurrent(request.substituteData().failingURL()) && m_loadType == FrameLoadTypeReload) 653 if (shouldTreatURLAsSameAsCurrent(request.substituteData().failingURL()) && m_loadType == FrameLoadTypeReload)
662 return FrameLoadTypeReload; 654 return FrameLoadTypeReload;
663 return FrameLoadTypeStandard; 655 return FrameLoadTypeStandard;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 743
752 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve l, "Not allowed to load local resource: " + url); 744 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve l, "Not allowed to load local resource: " + url);
753 } 745 }
754 746
755 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con st String& overrideEncoding) 747 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con st String& overrideEncoding)
756 { 748 {
757 DocumentLoader* documentLoader = activeDocumentLoader(); 749 DocumentLoader* documentLoader = activeDocumentLoader();
758 if (!documentLoader) 750 if (!documentLoader)
759 return; 751 return;
760 752
761 if (m_state == FrameStateProvisional)
762 insertDummyHistoryItem();
763
764 ResourceRequest request = documentLoader->request(); 753 ResourceRequest request = documentLoader->request();
765 // FIXME: We need to reset cache policy to prevent it from being incorrectly propagted to the reload. 754 // FIXME: We need to reset cache policy to prevent it from being incorrectly propagted to the reload.
766 // Do we need to propagate anything other than the url? 755 // Do we need to propagate anything other than the url?
767 request.setCachePolicy(UseProtocolCachePolicy); 756 request.setCachePolicy(UseProtocolCachePolicy);
768 if (!overrideURL.isEmpty()) 757 if (!overrideURL.isEmpty())
769 request.setURL(overrideURL); 758 request.setURL(overrideURL);
770 else if (!documentLoader->unreachableURL().isEmpty()) 759 else if (!documentLoader->unreachableURL().isEmpty())
771 request.setURL(documentLoader->unreachableURL()); 760 request.setURL(documentLoader->unreachableURL());
772 761
773 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload; 762 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 if (pdl != m_provisionalDocumentLoader) 861 if (pdl != m_provisionalDocumentLoader)
873 return; 862 return;
874 if (m_documentLoader) 863 if (m_documentLoader)
875 m_documentLoader->detachFromFrame(); 864 m_documentLoader->detachFromFrame();
876 m_documentLoader = m_provisionalDocumentLoader.release(); 865 m_documentLoader = m_provisionalDocumentLoader.release();
877 m_state = FrameStateCommittedPage; 866 m_state = FrameStateCommittedPage;
878 867
879 if (isLoadingMainFrame()) 868 if (isLoadingMainFrame())
880 m_frame->page()->chrome().client().needTouchEvents(false); 869 m_frame->page()->chrome().client().needTouchEvents(false);
881 870
882 history()->updateForCommit(); 871 history()->updateForCommit(m_frame);
883 m_client->transitionToCommittedForNewPage(); 872 m_client->transitionToCommittedForNewPage();
884 873
885 m_frame->navigationScheduler().cancel(); 874 m_frame->navigationScheduler().cancel();
886 m_frame->editor().clearLastEditCommand(); 875 m_frame->editor().clearLastEditCommand();
887 876
888 // If we are still in the process of initializing an empty document then 877 // If we are still in the process of initializing an empty document then
889 // its frame is not in a consistent state for rendering, so avoid setJSStatu sBarText 878 // its frame is not in a consistent state for rendering, so avoid setJSStatu sBarText
890 // since it may cause clients to attempt to render the frame. 879 // since it may cause clients to attempt to render the frame.
891 if (!m_stateMachine.creatingInitialEmptyDocument()) { 880 if (!m_stateMachine.creatingInitialEmptyDocument()) {
892 DOMWindow* window = m_frame->domWindow(); 881 DOMWindow* window = m_frame->domWindow();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 976
988 m_state = FrameStateComplete; 977 m_state = FrameStateComplete;
989 978
990 // FIXME: Is this subsequent work important if we already navigated away? 979 // FIXME: Is this subsequent work important if we already navigated away?
991 // Maybe there are bugs because of that, or extra work we can skip because 980 // Maybe there are bugs because of that, or extra work we can skip because
992 // the new page is ready. 981 // the new page is ready.
993 982
994 // If the user had a scroll point, scroll to it, overriding the anchor point if any. 983 // If the user had a scroll point, scroll to it, overriding the anchor point if any.
995 if (m_frame->page()) { 984 if (m_frame->page()) {
996 if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeRelo ad || m_loadType == FrameLoadTypeReloadFromOrigin) 985 if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeRelo ad || m_loadType == FrameLoadTypeReloadFromOrigin)
997 history()->restoreScrollPositionAndViewState(); 986 history()->restoreScrollPositionAndViewState(m_frame);
998 } 987 }
999 988
1000 if (!m_stateMachine.committedFirstRealDocumentLoad()) 989 if (!m_stateMachine.committedFirstRealDocumentLoad())
1001 return; 990 return;
1002 991
1003 m_progressTracker->progressCompleted(); 992 m_progressTracker->progressCompleted();
1004 993
1005 const ResourceError& error = m_documentLoader->mainDocumentError(); 994 const ResourceError& error = m_documentLoader->mainDocumentError();
1006 if (!error.isNull()) 995 if (!error.isNull())
1007 m_client->dispatchDidFailLoad(error); 996 m_client->dispatchDidFailLoad(error);
1008 else 997 else
1009 m_client->dispatchDidFinishLoad(); 998 m_client->dispatchDidFinishLoad();
1010 m_loadType = FrameLoadTypeStandard; 999 m_loadType = FrameLoadTypeStandard;
1011 } 1000 }
1012 1001
1013 void FrameLoader::didFirstLayout() 1002 void FrameLoader::didFirstLayout()
1014 { 1003 {
1015 if (!m_frame->page()) 1004 if (!m_frame->page())
1016 return; 1005 return;
1017 1006
1018 if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload | | m_loadType == FrameLoadTypeReloadFromOrigin) 1007 if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload | | m_loadType == FrameLoadTypeReloadFromOrigin)
1019 history()->restoreScrollPositionAndViewState(); 1008 history()->restoreScrollPositionAndViewState(m_frame);
1020 } 1009 }
1021 1010
1022 void FrameLoader::detachChildren() 1011 void FrameLoader::detachChildren()
1023 { 1012 {
1024 typedef Vector<RefPtr<Frame> > FrameVector; 1013 typedef Vector<RefPtr<Frame> > FrameVector;
1025 FrameVector childrenToDetach; 1014 FrameVector childrenToDetach;
1026 childrenToDetach.reserveCapacity(m_frame->tree().childCount()); 1015 childrenToDetach.reserveCapacity(m_frame->tree().childCount());
1027 for (Frame* child = m_frame->tree().lastChild(); child; child = child->tree( ).previousSibling()) 1016 for (Frame* child = m_frame->tree().lastChild(); child; child = child->tree( ).previousSibling())
1028 childrenToDetach.append(child); 1017 childrenToDetach.append(child);
1029 FrameVector::iterator end = childrenToDetach.end(); 1018 FrameVector::iterator end = childrenToDetach.end();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 if (!m_documentLoader->shouldContinueForNavigationPolicy(request, DocumentLo ader::PolicyCheckFragment)) 1205 if (!m_documentLoader->shouldContinueForNavigationPolicy(request, DocumentLo ader::PolicyCheckFragment))
1217 return; 1206 return;
1218 1207
1219 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 1208 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
1220 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis ionalDocumentLoader->request().url(), request.url())) { 1209 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis ionalDocumentLoader->request().url(), request.url())) {
1221 m_provisionalDocumentLoader->stopLoading(); 1210 m_provisionalDocumentLoader->stopLoading();
1222 if (m_provisionalDocumentLoader) 1211 if (m_provisionalDocumentLoader)
1223 m_provisionalDocumentLoader->detachFromFrame(); 1212 m_provisionalDocumentLoader->detachFromFrame();
1224 m_provisionalDocumentLoader = 0; 1213 m_provisionalDocumentLoader = 0;
1225 } 1214 }
1226 history()->setProvisionalItem(0); 1215 history()->clearProvisionalEntry();
1227 loadInSameDocument(request.url(), 0, isNewNavigation, clientRedirect); 1216 loadInSameDocument(request.url(), 0, isNewNavigation, clientRedirect);
1228 } 1217 }
1229 1218
1230 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) 1219 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url)
1231 { 1220 {
1232 ASSERT(loadType != FrameLoadTypeBackForward); 1221 ASSERT(loadType != FrameLoadTypeBackForward);
1233 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); 1222 ASSERT(loadType != FrameLoadTypeReloadFromOrigin);
1234 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, 1223 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading,
1235 // currently displaying a frameset, or if the URL does not have a fragment. 1224 // currently displaying a frameset, or if the URL does not have a fragment.
1236 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) 1225 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET"))
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 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); 1443 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);
1455 return false; 1444 return false;
1456 default: 1445 default:
1457 ASSERT_NOT_REACHED(); 1446 ASSERT_NOT_REACHED();
1458 return false; 1447 return false;
1459 } 1448 }
1460 } 1449 }
1461 1450
1462 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const 1451 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const
1463 { 1452 {
1464 if (!history()->currentItem()) 1453 HistoryItem* item = history()->currentItem(m_frame);
1454 if (!item)
1465 return false; 1455 return false;
1466 return url == history()->currentItem()->url() || url == history()->currentIt em()->originalURL(); 1456 return url == item->url() || url == item->originalURL();
1467 } 1457 }
1468 1458
1469 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const 1459 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const
1470 { 1460 {
1471 if (!equalIgnoringCase(url.string(), "about:srcdoc")) 1461 if (!equalIgnoringCase(url.string(), "about:srcdoc"))
1472 return false; 1462 return false;
1473 HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement(); 1463 HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement();
1474 if (!ownerElement) 1464 if (!ownerElement)
1475 return false; 1465 return false;
1476 if (!ownerElement->hasTagName(iframeTag)) 1466 if (!ownerElement->hasTagName(iframeTag))
(...skipping 23 matching lines...) Expand all
1500 } 1490 }
1501 } 1491 }
1502 ASSERT(frame != m_frame); 1492 ASSERT(frame != m_frame);
1503 } 1493 }
1504 1494
1505 if (!activeDocument->canNavigate(frame)) 1495 if (!activeDocument->canNavigate(frame))
1506 return 0; 1496 return 0;
1507 return frame; 1497 return frame;
1508 } 1498 }
1509 1499
1510 void FrameLoader::loadHistoryItem(HistoryItem* item) 1500 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type)
1511 { 1501 {
1512 HistoryItem* currentItem = history()->currentItem(); 1502 if (historyLoadType == HistorySameDocumentLoad) {
1513
1514 if (currentItem && item->shouldDoSameDocumentNavigationTo(currentItem)) {
1515 history()->setCurrentItem(item);
1516 loadInSameDocument(item->url(), item->stateObject(), false, NotClientRed irect); 1503 loadInSameDocument(item->url(), item->stateObject(), false, NotClientRed irect);
1517 return; 1504 return;
1518 } 1505 }
1519 1506
1520 // Remember this item so we can traverse any child items as child frames loa d
1521 history()->setProvisionalItem(item);
1522
1523 RefPtr<FormData> formData = item->formData(); 1507 RefPtr<FormData> formData = item->formData();
1524 ResourceRequest request(item->url()); 1508 ResourceRequest request(item->url());
1525 request.setHTTPReferrer(item->referrer()); 1509 request.setHTTPReferrer(item->referrer());
1526 if (formData) { 1510 if (formData) {
1527 request.setHTTPMethod("POST"); 1511 request.setHTTPMethod("POST");
1528 request.setHTTPBody(formData); 1512 request.setHTTPBody(formData);
1529 request.setHTTPContentType(item->formContentType()); 1513 request.setHTTPContentType(item->formContentType());
1530 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer()); 1514 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer());
1531 addHTTPOriginIfNeeded(request, securityOrigin->toString()); 1515 addHTTPOriginIfNeeded(request, securityOrigin->toString());
1532 } 1516 }
1533 1517
1534 loadWithNavigationAction(request, NavigationAction(request, FrameLoadTypeBac kForward, formData), FrameLoadTypeBackForward, 0, SubstituteData()); 1518 loadWithNavigationAction(request, NavigationAction(request, FrameLoadTypeBac kForward, formData), FrameLoadTypeBackForward, 0, SubstituteData());
1535 } 1519 }
1536 1520
1537 void FrameLoader::insertDummyHistoryItem()
1538 {
1539 RefPtr<HistoryItem> currentItem = HistoryItem::create();
1540 history()->setCurrentItem(currentItem.get());
1541 }
1542
1543 void FrameLoader::dispatchDocumentElementAvailable() 1521 void FrameLoader::dispatchDocumentElementAvailable()
1544 { 1522 {
1545 m_client->documentElementAvailable(); 1523 m_client->documentElementAvailable();
1546 } 1524 }
1547 1525
1548 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds() 1526 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
1549 { 1527 {
1550 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1528 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
1551 return; 1529 return;
1552 1530
(...skipping 20 matching lines...) Expand all
1573 { 1551 {
1574 SandboxFlags flags = m_forcedSandboxFlags; 1552 SandboxFlags flags = m_forcedSandboxFlags;
1575 if (Frame* parentFrame = m_frame->tree().parent()) 1553 if (Frame* parentFrame = m_frame->tree().parent())
1576 flags |= parentFrame->document()->sandboxFlags(); 1554 flags |= parentFrame->document()->sandboxFlags();
1577 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1555 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1578 flags |= ownerElement->sandboxFlags(); 1556 flags |= ownerElement->sandboxFlags();
1579 return flags; 1557 return flags;
1580 } 1558 }
1581 1559
1582 } // namespace WebCore 1560 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698