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