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

Side by Side Diff: Source/core/loader/FrameLoader.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add LocalFrame::detachView() + more Oilpan frame finalization comments Created 6 years, 3 months 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "core/editing/UndoStack.h" 46 #include "core/editing/UndoStack.h"
47 #include "core/events/PageTransitionEvent.h" 47 #include "core/events/PageTransitionEvent.h"
48 #include "core/fetch/FetchContext.h" 48 #include "core/fetch/FetchContext.h"
49 #include "core/fetch/ResourceFetcher.h" 49 #include "core/fetch/ResourceFetcher.h"
50 #include "core/fetch/ResourceLoader.h" 50 #include "core/fetch/ResourceLoader.h"
51 #include "core/frame/LocalDOMWindow.h" 51 #include "core/frame/LocalDOMWindow.h"
52 #include "core/frame/FrameHost.h" 52 #include "core/frame/FrameHost.h"
53 #include "core/frame/FrameView.h" 53 #include "core/frame/FrameView.h"
54 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
55 #include "core/frame/PinchViewport.h" 55 #include "core/frame/PinchViewport.h"
56 #include "core/frame/Settings.h"
56 #include "core/frame/csp/ContentSecurityPolicy.h" 57 #include "core/frame/csp/ContentSecurityPolicy.h"
57 #include "core/html/HTMLFormElement.h" 58 #include "core/html/HTMLFormElement.h"
58 #include "core/html/HTMLFrameOwnerElement.h" 59 #include "core/html/HTMLFrameOwnerElement.h"
59 #include "core/html/parser/HTMLParserIdioms.h" 60 #include "core/html/parser/HTMLParserIdioms.h"
60 #include "core/inspector/ConsoleMessage.h" 61 #include "core/inspector/ConsoleMessage.h"
61 #include "core/inspector/InspectorController.h" 62 #include "core/inspector/InspectorController.h"
62 #include "core/inspector/InspectorInstrumentation.h" 63 #include "core/inspector/InspectorInstrumentation.h"
63 #include "core/loader/DocumentLoadTiming.h" 64 #include "core/loader/DocumentLoadTiming.h"
64 #include "core/loader/DocumentLoader.h" 65 #include "core/loader/DocumentLoader.h"
65 #include "core/loader/FormState.h" 66 #include "core/loader/FormState.h"
66 #include "core/loader/FormSubmission.h" 67 #include "core/loader/FormSubmission.h"
67 #include "core/loader/FrameFetchContext.h" 68 #include "core/loader/FrameFetchContext.h"
68 #include "core/loader/FrameLoadRequest.h" 69 #include "core/loader/FrameLoadRequest.h"
69 #include "core/loader/FrameLoaderClient.h" 70 #include "core/loader/FrameLoaderClient.h"
70 #include "core/loader/MixedContentChecker.h" 71 #include "core/loader/MixedContentChecker.h"
71 #include "core/loader/ProgressTracker.h" 72 #include "core/loader/ProgressTracker.h"
72 #include "core/loader/UniqueIdentifier.h" 73 #include "core/loader/UniqueIdentifier.h"
73 #include "core/loader/appcache/ApplicationCacheHost.h" 74 #include "core/loader/appcache/ApplicationCacheHost.h"
74 #include "core/page/BackForwardClient.h" 75 #include "core/page/BackForwardClient.h"
75 #include "core/page/Chrome.h" 76 #include "core/page/Chrome.h"
76 #include "core/page/ChromeClient.h" 77 #include "core/page/ChromeClient.h"
77 #include "core/page/CreateWindow.h" 78 #include "core/page/CreateWindow.h"
78 #include "core/page/EventHandler.h" 79 #include "core/page/EventHandler.h"
79 #include "core/page/FrameTree.h" 80 #include "core/page/FrameTree.h"
80 #include "core/page/Page.h" 81 #include "core/page/Page.h"
81 #include "core/frame/Settings.h"
82 #include "core/page/WindowFeatures.h" 82 #include "core/page/WindowFeatures.h"
83 #include "core/page/scrolling/ScrollingCoordinator.h" 83 #include "core/page/scrolling/ScrollingCoordinator.h"
84 #include "core/xml/parser/XMLDocumentParser.h" 84 #include "core/xml/parser/XMLDocumentParser.h"
85 #include "platform/Logging.h" 85 #include "platform/Logging.h"
86 #include "platform/UserGestureIndicator.h" 86 #include "platform/UserGestureIndicator.h"
87 #include "platform/geometry/FloatRect.h" 87 #include "platform/geometry/FloatRect.h"
88 #include "platform/network/HTTPParsers.h" 88 #include "platform/network/HTTPParsers.h"
89 #include "platform/network/ResourceRequest.h" 89 #include "platform/network/ResourceRequest.h"
90 #include "platform/scroll/ScrollAnimator.h" 90 #include "platform/scroll/ScrollAnimator.h"
91 #include "platform/weborigin/SecurityOrigin.h" 91 #include "platform/weborigin/SecurityOrigin.h"
(...skipping 30 matching lines...) Expand all
122 , m_didAccessInitialDocument(false) 122 , m_didAccessInitialDocument(false)
123 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 123 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
124 , m_forcedSandboxFlags(SandboxNone) 124 , m_forcedSandboxFlags(SandboxNone)
125 { 125 {
126 } 126 }
127 127
128 FrameLoader::~FrameLoader() 128 FrameLoader::~FrameLoader()
129 { 129 {
130 } 130 }
131 131
132 void FrameLoader::trace(Visitor* visitor)
133 {
134 visitor->trace(m_frame);
135 visitor->trace(m_fetchContext);
136 }
137
132 void FrameLoader::init() 138 void FrameLoader::init()
133 { 139 {
134 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); 140 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString()));
135 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); 141 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal);
136 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested); 142 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested);
137 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia lRequest, SubstituteData()); 143 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia lRequest, SubstituteData());
138 m_provisionalDocumentLoader->startLoadingMainResource(); 144 m_provisionalDocumentLoader->startLoadingMainResource();
139 m_frame->document()->cancelParsing(); 145 m_frame->document()->cancelParsing();
140 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment); 146 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment);
141 } 147 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (!m_stateMachine.committedFirstRealDocumentLoad()) 238 if (!m_stateMachine.committedFirstRealDocumentLoad())
233 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 239 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
234 240
235 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results 241 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
236 // from a subsequent window.document.open / window.document.write call. 242 // from a subsequent window.document.open / window.document.write call.
237 // Canceling redirection here works for all cases because document.open 243 // Canceling redirection here works for all cases because document.open
238 // implicitly precedes document.write. 244 // implicitly precedes document.write.
239 m_frame->navigationScheduler().cancel(); 245 m_frame->navigationScheduler().cancel();
240 } 246 }
241 247
242 void FrameLoader::clear() 248 void FrameLoader::dispose(DisposeFrameContents disposeFrameContents)
243 { 249 {
250 // dispose() is called during (Local)Frame finalization and when creating
251 // a new Document within it (DocumentLoader::createWriterFor().)
244 if (m_stateMachine.creatingInitialEmptyDocument()) 252 if (m_stateMachine.creatingInitialEmptyDocument())
245 return; 253 return;
246 254
247 m_frame->editor().clear(); 255 if (disposeFrameContents == DoDisposeFrameContents) {
248 m_frame->document()->cancelParsing(); 256 // Oilpan finalization: not needed, handled implicitly when Editor is fi nalized.
249 m_frame->document()->prepareForDestruction(); 257 m_frame->editor().clear();
250 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
251 258
252 m_frame->selection().prepareForDestruction(); 259 // Oilpan: cancelParsing() will detach the parser. The required subset
253 m_frame->eventHandler().clear(); 260 // of that is handled by the DocumentParser finalizers
254 if (m_frame->view()) 261 // (cf. ~HTMLDocumentParser())
255 m_frame->view()->clear(); 262 m_frame->document()->cancelParsing();
263
264 // FIXME: Oilpan: not calling prepareForDestruction() during finalizatio n
265 // practically amounts to not calling Document::detach(), which is a wor ry.
266 m_frame->document()->prepareForDestruction();
267
268 // Oilpan: not needed.
269 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
270
271 // FIXME: Oilpan: by not informing the FrameSelection of pending destruc tion,
272 // the RenderView will not have its selection cleared when the frame is
273 // finalized. And other FrameSelection actions, but this is the only rel evant
274 // external action (by my reckoning.) Have it confirmed that leaving out
275 // this step in its entirety is acceptable.
276 m_frame->selection().prepareForDestruction();
277 m_frame->eventHandler().clear();
278 }
279
280 // Oilpan: as FrameLoader is a part of object of m_frame, it is
281 // assumed safe to access it from here (even when invoked during finalizatio n.)
282
283 if (FrameView* view = m_frame->view())
284 view->clear();
256 285
257 m_frame->script().enableEval(); 286 m_frame->script().enableEval();
258 287
288 // Oilpan: this depends on NavigationScheduler being a part object
289 // of FrameLoader, i.e., the part object is still accessible.
290 //
291 // FIXME: Oilpan: verify this assumption.
259 m_frame->navigationScheduler().cancel(); 292 m_frame->navigationScheduler().cancel();
260 293
261 m_checkTimer.stop(); 294 m_checkTimer.stop();
262 295
263 if (m_stateMachine.isDisplayingInitialEmptyDocument()) 296 if (m_stateMachine.isDisplayingInitialEmptyDocument())
264 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 297 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
265 } 298 }
266 299
267 // This is only called by ScriptController::executeScriptIfJavaScriptURL 300 // This is only called by ScriptController::executeScriptIfJavaScriptURL
268 // and always contains the result of evaluating a javascript: url. 301 // and always contains the result of evaluating a javascript: url.
269 // This is the <iframe src="javascript:'html'"> case. 302 // This is the <iframe src="javascript:'html'"> case.
270 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument) 303 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument)
271 { 304 {
272 if (!m_frame->document()->loader()) 305 if (!m_frame->document()->loader())
273 return; 306 return;
274 307
275 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed, 308 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed,
276 // so protect it with a RefPtr. 309 // so protect it with a RefPtr.
277 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); 310 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader());
278 311
279 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); 312 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL);
280 313
281 // Prepare a DocumentInit before clearing the frame, because it may need to 314 // Prepare a DocumentInit before clearing the frame, because it may need to
282 // inherit an aliased security context. 315 // inherit an aliased security context.
283 DocumentInit init(m_frame->document()->url(), m_frame); 316 DocumentInit init(m_frame->document()->url(), m_frame);
284 init.withNewRegistrationContext(); 317 init.withNewRegistrationContext();
285 318
286 stopAllLoaders(); 319 stopAllLoaders();
287 clear(); 320 dispose(DoDisposeFrameContents);
288 321
289 // clear() potentially detaches the frame from the document. The 322 // dispose() potentially detaches the frame from the document. The
290 // loading cannot continue in that case. 323 // loading cannot continue in that case.
291 if (!m_frame->page()) 324 if (!m_frame->page())
292 return; 325 return;
293 326
294 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); 327 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument);
295 } 328 }
296 329
297 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) 330 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject)
298 { 331 {
299 if (m_provisionalItem) 332 if (m_provisionalItem)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 424 }
392 425
393 void FrameLoader::finishedParsing() 426 void FrameLoader::finishedParsing()
394 { 427 {
395 if (m_stateMachine.creatingInitialEmptyDocument()) 428 if (m_stateMachine.creatingInitialEmptyDocument())
396 return; 429 return;
397 430
398 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 431 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves
399 // because doing so will cause us to re-enter the destructor when protector goes out of scope. 432 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
400 // Null-checking the FrameView indicates whether or not we're in the destruc tor. 433 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
401 RefPtr<LocalFrame> protector = m_frame->view() ? m_frame : 0; 434 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr);
402 435
403 if (client()) 436 if (client())
404 client()->dispatchDidFinishDocumentLoad(); 437 client()->dispatchDidFinishDocumentLoad();
405 438
406 checkCompleted(); 439 checkCompleted();
407 440
408 if (!m_frame->view()) 441 if (!m_frame->view())
409 return; // We are being destroyed by something checkCompleted called. 442 return; // We are being destroyed by something checkCompleted called.
410 443
411 // Check if the scrollbars are really needed for the content. 444 // Check if the scrollbars are really needed for the content.
(...skipping 23 matching lines...) Expand all
435 { 468 {
436 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) { 469 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) {
437 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished()) 470 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished())
438 return false; 471 return false;
439 } 472 }
440 return true; 473 return true;
441 } 474 }
442 475
443 void FrameLoader::checkCompleted() 476 void FrameLoader::checkCompleted()
444 { 477 {
445 RefPtr<LocalFrame> protect(m_frame); 478 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
446 479
447 if (m_frame->view()) 480 if (m_frame->view())
448 m_frame->view()->handleLoadCompleted(); 481 m_frame->view()->handleLoadCompleted();
449 482
450 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad()) 483 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad())
451 return; 484 return;
452 485
453 // Are we still parsing? 486 // Are we still parsing?
454 if (m_frame->document()->parsing()) 487 if (m_frame->document()->parsing())
455 return; 488 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 540
508 void FrameLoader::setOpener(LocalFrame* opener) 541 void FrameLoader::setOpener(LocalFrame* opener)
509 { 542 {
510 // If the frame is already detached, the opener has already been cleared. 543 // If the frame is already detached, the opener has already been cleared.
511 if (client()) 544 if (client())
512 client()->setOpener(opener); 545 client()->setOpener(opener);
513 } 546 }
514 547
515 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) 548 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
516 { 549 {
550 // With Oilpan, a FrameLoader might be accessed after the
551 // FrameHost has been detached. FrameClient will not be
552 // accessible, so bail early.
553 if (!client())
554 return false;
517 Settings* settings = m_frame->settings(); 555 Settings* settings = m_frame->settings();
518 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() ); 556 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() );
519 if (!allowed && reason == AboutToInstantiatePlugin) 557 if (!allowed && reason == AboutToInstantiatePlugin)
520 client()->didNotAllowPlugins(); 558 client()->didNotAllowPlugins();
521 return allowed; 559 return allowed;
522 } 560 }
523 561
524 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type) 562 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type)
525 { 563 {
526 // Update the data source's request with the new URL to fake the URL change 564 // Update the data source's request with the new URL to fake the URL change
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // We need to scroll to the fragment whether or not a hash change occurred, since 615 // We need to scroll to the fragment whether or not a hash change occurred, since
578 // the user might have scrolled since the previous navigation. 616 // the user might have scrolled since the previous navigation.
579 scrollToFragmentWithParentBoundary(url); 617 scrollToFragmentWithParentBoundary(url);
580 checkCompleted(); 618 checkCompleted();
581 619
582 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue()); 620 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue());
583 } 621 }
584 622
585 void FrameLoader::completed() 623 void FrameLoader::completed()
586 { 624 {
587 RefPtr<LocalFrame> protect(m_frame); 625 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
588 626
589 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) { 627 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) {
590 if (descendant->isLocalFrame()) 628 if (descendant->isLocalFrame())
591 toLocalFrame(descendant)->navigationScheduler().startTimer(); 629 toLocalFrame(descendant)->navigationScheduler().startTimer();
592 } 630 }
593 631
594 Frame* parent = m_frame->tree().parent(); 632 Frame* parent = m_frame->tree().parent();
595 if (parent && parent->isLocalFrame()) 633 if (parent && parent->isLocalFrame())
596 toLocalFrame(parent)->loader().checkCompleted(); 634 toLocalFrame(parent)->loader().checkCompleted();
597 635
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 return WebURLRequest::RequestContextInternal; 739 return WebURLRequest::RequestContextInternal;
702 } 740 }
703 ASSERT_NOT_REACHED(); 741 ASSERT_NOT_REACHED();
704 return WebURLRequest::RequestContextHyperlink; 742 return WebURLRequest::RequestContextHyperlink;
705 } 743 }
706 744
707 void FrameLoader::load(const FrameLoadRequest& passedRequest) 745 void FrameLoader::load(const FrameLoadRequest& passedRequest)
708 { 746 {
709 ASSERT(m_frame->document()); 747 ASSERT(m_frame->document());
710 748
711 RefPtr<LocalFrame> protect(m_frame); 749 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
712 750
713 if (m_inStopAllLoaders) 751 if (m_inStopAllLoaders)
714 return; 752 return;
715 753
716 FrameLoadRequest request(passedRequest); 754 FrameLoadRequest request(passedRequest);
717 if (!prepareRequestForThisFrame(request)) 755 if (!prepareRequestForThisFrame(request))
718 return; 756 return;
719 757
720 RefPtr<LocalFrame> targetFrame = request.formState() ? 0 : findFrameForNavig ation(AtomicString(request.frameName()), request.formState() ? request.formState ()->sourceDocument() : m_frame->document()); 758 RefPtrWillBeRawPtr<LocalFrame> targetFrame = request.formState() ? 0 : findF rameForNavigation(AtomicString(request.frameName()), request.formState() ? reque st.formState()->sourceDocument() : m_frame->document());
721 if (targetFrame && targetFrame != m_frame) { 759 if (targetFrame && targetFrame.get() != m_frame) {
722 request.setFrameName("_self"); 760 request.setFrameName("_self");
723 targetFrame->loader().load(request); 761 targetFrame->loader().load(request);
724 if (Page* page = targetFrame->page()) 762 if (Page* page = targetFrame->page())
725 page->chrome().focus(); 763 page->chrome().focus();
726 return; 764 return;
727 } 765 }
728 766
729 FrameLoadType newLoadType = determineFrameLoadType(request); 767 FrameLoadType newLoadType = determineFrameLoadType(request);
730 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent()); 768 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent());
731 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified) 769 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 { 861 {
824 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 862 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
825 return; 863 return;
826 864
827 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 865 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
828 if (m_inStopAllLoaders) 866 if (m_inStopAllLoaders)
829 return; 867 return;
830 868
831 // Calling stopLoading() on the provisional document loader can blow away 869 // Calling stopLoading() on the provisional document loader can blow away
832 // the frame from underneath. 870 // the frame from underneath.
833 RefPtr<LocalFrame> protect(m_frame); 871 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
834 872
835 m_inStopAllLoaders = true; 873 m_inStopAllLoaders = true;
836 874
837 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 875 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
838 if (child->isLocalFrame()) 876 if (child->isLocalFrame())
839 toLocalFrame(child.get())->loader().stopAllLoaders(); 877 toLocalFrame(child.get())->loader().stopAllLoaders();
840 } 878 }
841 if (m_provisionalDocumentLoader) 879 if (m_provisionalDocumentLoader)
842 m_provisionalDocumentLoader->stopLoading(); 880 m_provisionalDocumentLoader->stopLoading();
843 if (m_documentLoader) 881 if (m_documentLoader)
844 m_documentLoader->stopLoading(); 882 m_documentLoader->stopLoading();
845 883
846 if (m_provisionalDocumentLoader) 884 if (m_provisionalDocumentLoader)
847 m_provisionalDocumentLoader->detachFromFrame(); 885 m_provisionalDocumentLoader->detachFromFrame();
(...skipping 14 matching lines...) Expand all
862 // We only need to notify the client once, and only for the main frame. 900 // We only need to notify the client once, and only for the main frame.
863 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { 901 if (isLoadingMainFrame() && !m_didAccessInitialDocument) {
864 m_didAccessInitialDocument = true; 902 m_didAccessInitialDocument = true;
865 // Notify asynchronously, since this is called within a JavaScript secur ity check. 903 // Notify asynchronously, since this is called within a JavaScript secur ity check.
866 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE); 904 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE);
867 } 905 }
868 } 906 }
869 907
870 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*) 908 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*)
871 { 909 {
872 client()->didAccessInitialDocument(); 910 if (client())
911 client()->didAccessInitialDocument();
873 } 912 }
874 913
875 void FrameLoader::notifyIfInitialDocumentAccessed() 914 void FrameLoader::notifyIfInitialDocumentAccessed()
876 { 915 {
877 if (m_didAccessInitialDocumentTimer.isActive()) { 916 if (m_didAccessInitialDocumentTimer.isActive()) {
878 m_didAccessInitialDocumentTimer.stop(); 917 m_didAccessInitialDocumentTimer.stop();
879 didAccessInitialDocumentTimerFired(0); 918 didAccessInitialDocumentTimerFired(0);
880 } 919 }
881 } 920 }
882 921
883 void FrameLoader::commitProvisionalLoad() 922 void FrameLoader::commitProvisionalLoad()
884 { 923 {
885 ASSERT(client()->hasWebView()); 924 ASSERT(client()->hasWebView());
886 ASSERT(m_state == FrameStateProvisional); 925 ASSERT(m_state == FrameStateProvisional);
887 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; 926 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
888 RefPtr<LocalFrame> protect(m_frame); 927 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
889 928
890 // Check if the destination page is allowed to access the previous page's ti ming information. 929 // Check if the destination page is allowed to access the previous page's ti ming information.
891 if (m_frame->document()) { 930 if (m_frame->document()) {
892 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url()); 931 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url());
893 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url())); 932 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url()));
894 } 933 }
895 934
896 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary 935 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary
897 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load, 936 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load,
898 // or the two will stomp each other. 937 // or the two will stomp each other.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 if (document->processingLoadEvent()) 992 if (document->processingLoadEvent())
954 return false; 993 return false;
955 if (document->hasActiveParser()) 994 if (document->hasActiveParser())
956 return false; 995 return false;
957 return true; 996 return true;
958 } 997 }
959 998
960 bool FrameLoader::checkLoadCompleteForThisFrame() 999 bool FrameLoader::checkLoadCompleteForThisFrame()
961 { 1000 {
962 ASSERT(client()->hasWebView()); 1001 ASSERT(client()->hasWebView());
963 RefPtr<LocalFrame> protect(m_frame); 1002 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
964 1003
965 bool allChildrenAreDoneLoading = true; 1004 bool allChildrenAreDoneLoading = true;
966 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 1005 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
967 if (child->isLocalFrame()) 1006 if (child->isLocalFrame())
968 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame(); 1007 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame();
969 } 1008 }
970 1009
971 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { 1010 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
972 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror(); 1011 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror();
973 if (error.isNull()) 1012 if (error.isNull())
974 return false; 1013 return false;
975 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; 1014 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader;
976 client()->dispatchDidFailProvisionalLoad(error); 1015 client()->dispatchDidFailProvisionalLoad(error);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1122
1084 String FrameLoader::userAgent(const KURL& url) const 1123 String FrameLoader::userAgent(const KURL& url) const
1085 { 1124 {
1086 String userAgent = client()->userAgent(url); 1125 String userAgent = client()->userAgent(url);
1087 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); 1126 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
1088 return userAgent; 1127 return userAgent;
1089 } 1128 }
1090 1129
1091 void FrameLoader::detachFromParent() 1130 void FrameLoader::detachFromParent()
1092 { 1131 {
1132 #if !ENABLE(OILPAN)
1093 // The caller must protect a reference to m_frame. 1133 // The caller must protect a reference to m_frame.
1094 ASSERT(m_frame->refCount() > 1); 1134 ASSERT(m_frame->refCount() > 1);
1135 #endif
1095 1136
1096 InspectorInstrumentation::frameDetachedFromParent(m_frame); 1137 InspectorInstrumentation::frameDetachedFromParent(m_frame);
1097 1138
1098 if (m_documentLoader) 1139 if (m_documentLoader)
1099 m_documentLoader->detachFromFrame(); 1140 m_documentLoader->detachFromFrame();
1100 m_documentLoader = nullptr; 1141 m_documentLoader = nullptr;
1101 1142
1102 if (!client()) 1143 if (!client())
1103 return; 1144 return;
1104 1145
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 // After this, we must no longer talk to the client since this clears 1179 // After this, we must no longer talk to the client since this clears
1139 // its owning reference back to our owning LocalFrame. 1180 // its owning reference back to our owning LocalFrame.
1140 client()->detachedFromParent(); 1181 client()->detachedFromParent();
1141 m_frame->clearClient(); 1182 m_frame->clearClient();
1142 } 1183 }
1143 } 1184 }
1144 1185
1145 void FrameLoader::receivedMainResourceError(const ResourceError& error) 1186 void FrameLoader::receivedMainResourceError(const ResourceError& error)
1146 { 1187 {
1147 // Retain because the stop may release the last reference to it. 1188 // Retain because the stop may release the last reference to it.
1148 RefPtr<LocalFrame> protect(m_frame); 1189 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1149 1190
1150 if (m_frame->document()->parser()) 1191 if (m_frame->document()->parser())
1151 m_frame->document()->parser()->stopParsing(); 1192 m_frame->document()->parser()->stopParsing();
1152 1193
1153 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some 1194 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some
1154 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError(). 1195 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError().
1155 ResourceError c(ResourceError::cancelledError(KURL())); 1196 ResourceError c(ResourceError::cancelledError(KURL()));
1156 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) { 1197 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) {
1157 // FIXME: For now, fallback content doesn't work cross process. 1198 // FIXME: For now, fallback content doesn't work cross process.
1158 ASSERT(m_frame->owner()->isLocal()); 1199 ASSERT(m_frame->owner()->isLocal());
(...skipping 21 matching lines...) Expand all
1180 && !m_frame->document()->isFrameSet(); 1221 && !m_frame->document()->isFrameSet();
1181 } 1222 }
1182 1223
1183 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) 1224 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url)
1184 { 1225 {
1185 FrameView* view = m_frame->view(); 1226 FrameView* view = m_frame->view();
1186 if (!view) 1227 if (!view)
1187 return; 1228 return;
1188 1229
1189 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack. 1230 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack.
1190 RefPtr<LocalFrame> boundaryFrame(url.hasFragmentIdentifier() ? m_frame->docu ment()->findUnsafeParentScrollPropagationBoundary() : 0); 1231 RefPtrWillBeRawPtr<LocalFrame> boundaryFrame = url.hasFragmentIdentifier() ? m_frame->document()->findUnsafeParentScrollPropagationBoundary() : 0;
1191 1232
1192 if (boundaryFrame) 1233 if (boundaryFrame)
1193 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); 1234 boundaryFrame->view()->setSafeToPropagateScrollToParent(false);
1194 1235
1195 view->scrollToFragment(url); 1236 view->scrollToFragment(url);
1196 1237
1197 if (boundaryFrame) 1238 if (boundaryFrame)
1198 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); 1239 boundaryFrame->view()->setSafeToPropagateScrollToParent(true);
1199 } 1240 }
1200 1241
1201 bool FrameLoader::shouldClose() 1242 bool FrameLoader::shouldClose()
1202 { 1243 {
1203 Page* page = m_frame->page(); 1244 Page* page = m_frame->page();
1204 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) 1245 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel())
1205 return true; 1246 return true;
1206 1247
1207 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame 1248 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame
1208 Vector<RefPtr<LocalFrame> > targetFrames; 1249 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > targetFrames;
1209 targetFrames.append(m_frame); 1250 targetFrames.append(m_frame);
1210 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) { 1251 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) {
1211 // FIXME: There is not yet any way to dispatch events to out-of-process frames. 1252 // FIXME: There is not yet any way to dispatch events to out-of-process frames.
1212 if (child->isLocalFrame()) 1253 if (child->isLocalFrame())
1213 targetFrames.append(toLocalFrame(child)); 1254 targetFrames.append(toLocalFrame(child));
1214 } 1255 }
1215 1256
1216 bool shouldClose = false; 1257 bool shouldClose = false;
1217 { 1258 {
1218 NavigationDisablerForBeforeUnload navigationDisabler; 1259 NavigationDisablerForBeforeUnload navigationDisabler;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); 1326 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding);
1286 else if (m_documentLoader) 1327 else if (m_documentLoader)
1287 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding()); 1328 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding());
1288 1329
1289 1330
1290 bool isTransitionNavigation = false; 1331 bool isTransitionNavigation = false;
1291 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1332 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1292 isTransitionNavigation = dispatchNavigationTransitionData(); 1333 isTransitionNavigation = dispatchNavigationTransitionData();
1293 1334
1294 // stopAllLoaders can detach the LocalFrame, so protect it. 1335 // stopAllLoaders can detach the LocalFrame, so protect it.
1295 RefPtr<LocalFrame> protect(m_frame); 1336 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1296 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1337 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) {
1297 m_policyDocumentLoader->detachFromFrame(); 1338 m_policyDocumentLoader->detachFromFrame();
1298 m_policyDocumentLoader = nullptr; 1339 m_policyDocumentLoader = nullptr;
1299 checkCompleted(); 1340 checkCompleted();
1300 return; 1341 return;
1301 } 1342 }
1302 1343
1303 if (m_provisionalDocumentLoader) { 1344 if (m_provisionalDocumentLoader) {
1304 m_provisionalDocumentLoader->stopLoading(); 1345 m_provisionalDocumentLoader->stopLoading();
1305 if (m_provisionalDocumentLoader) 1346 if (m_provisionalDocumentLoader)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 { 1447 {
1407 ASSERT(activeDocument); 1448 ASSERT(activeDocument);
1408 Frame* frame = m_frame->tree().find(name); 1449 Frame* frame = m_frame->tree().find(name);
1409 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame))) 1450 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame)))
1410 return 0; 1451 return 0;
1411 return toLocalFrame(frame); 1452 return toLocalFrame(frame);
1412 } 1453 }
1413 1454
1414 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy) 1455 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy)
1415 { 1456 {
1416 RefPtr<LocalFrame> protect(m_frame); 1457 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1417 if (m_frame->page()->defersLoading()) { 1458 if (m_frame->page()->defersLoading()) {
1418 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy); 1459 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1419 return; 1460 return;
1420 } 1461 }
1421 1462
1422 m_provisionalItem = item; 1463 m_provisionalItem = item;
1423 if (historyLoadType == HistorySameDocumentLoad) { 1464 if (historyLoadType == HistorySameDocumentLoad) {
1424 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect); 1465 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect);
1425 restoreScrollPositionAndViewState(); 1466 restoreScrollPositionAndViewState();
1426 return; 1467 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1506 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1466 Frame* parentFrame = m_frame->tree().parent(); 1507 Frame* parentFrame = m_frame->tree().parent();
1467 if (parentFrame && parentFrame->isLocalFrame()) 1508 if (parentFrame && parentFrame->isLocalFrame())
1468 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1509 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1469 if (FrameOwner* frameOwner = m_frame->owner()) 1510 if (FrameOwner* frameOwner = m_frame->owner())
1470 flags |= frameOwner->sandboxFlags(); 1511 flags |= frameOwner->sandboxFlags();
1471 return flags; 1512 return flags;
1472 } 1513 }
1473 1514
1474 } // namespace blink 1515 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698