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

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: Rebased past r181814 conflict 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/ProgressTracker.h" 71 #include "core/loader/ProgressTracker.h"
71 #include "core/loader/UniqueIdentifier.h" 72 #include "core/loader/UniqueIdentifier.h"
72 #include "core/loader/appcache/ApplicationCacheHost.h" 73 #include "core/loader/appcache/ApplicationCacheHost.h"
73 #include "core/page/BackForwardClient.h" 74 #include "core/page/BackForwardClient.h"
74 #include "core/page/Chrome.h" 75 #include "core/page/Chrome.h"
75 #include "core/page/ChromeClient.h" 76 #include "core/page/ChromeClient.h"
76 #include "core/page/CreateWindow.h" 77 #include "core/page/CreateWindow.h"
77 #include "core/page/EventHandler.h" 78 #include "core/page/EventHandler.h"
78 #include "core/page/FrameTree.h" 79 #include "core/page/FrameTree.h"
79 #include "core/page/Page.h" 80 #include "core/page/Page.h"
80 #include "core/frame/Settings.h"
81 #include "core/page/WindowFeatures.h" 81 #include "core/page/WindowFeatures.h"
82 #include "core/page/scrolling/ScrollingCoordinator.h" 82 #include "core/page/scrolling/ScrollingCoordinator.h"
83 #include "core/xml/parser/XMLDocumentParser.h" 83 #include "core/xml/parser/XMLDocumentParser.h"
84 #include "platform/Logging.h" 84 #include "platform/Logging.h"
85 #include "platform/UserGestureIndicator.h" 85 #include "platform/UserGestureIndicator.h"
86 #include "platform/geometry/FloatRect.h" 86 #include "platform/geometry/FloatRect.h"
87 #include "platform/network/HTTPParsers.h" 87 #include "platform/network/HTTPParsers.h"
88 #include "platform/network/ResourceRequest.h" 88 #include "platform/network/ResourceRequest.h"
89 #include "platform/scroll/ScrollAnimator.h" 89 #include "platform/scroll/ScrollAnimator.h"
90 #include "platform/weborigin/SecurityOrigin.h" 90 #include "platform/weborigin/SecurityOrigin.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 m_frame->editor().clear();
249 m_frame->document()->prepareForDestruction(); 257 // FIXME: Oilpan: check if one or more of these Document-specific action s
250 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); 258 // now needs to be handled implicitly during Document finalization (and
259 // aren't already performed.)
260 m_frame->document()->cancelParsing();
261 m_frame->document()->prepareForDestruction();
262 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
263 // FIXME: Oilpan: the RenderView will not have its selection
264 // cleared when the frame is finalized. Verify that this
265 // is of no particular importance.
haraken 2014/09/11 14:47:26 I guess the above two FIXMEs need to be addressed.
sof 2014/09/12 13:44:02 I've looked into the 2nd quite a bit, how much of
sof 2014/09/16 09:08:36 Gone through the details of what we're not doing i
266 m_frame->selection().prepareForDestruction();
267 m_frame->eventHandler().clear();
268 }
251 269
252 m_frame->selection().prepareForDestruction(); 270 if (FrameView* view = m_frame->view())
haraken 2014/09/11 14:47:26 Add a comment about why it's safe to touch m_frame
sof 2014/09/12 14:47:40 Done.
253 m_frame->eventHandler().clear(); 271 view->clear();
254 if (m_frame->view())
255 m_frame->view()->clear();
256 272
257 m_frame->script().enableEval(); 273 m_frame->script().enableEval();
258 274
275 // Oilpan: this depends on NavigationScheduler being a part object
276 // of FrameLoader, i.e., the part object is still accessible.
277 //
278 // FIXME: Oilpan: verify this assumption.
259 m_frame->navigationScheduler().cancel(); 279 m_frame->navigationScheduler().cancel();
260 280
261 m_checkTimer.stop(); 281 m_checkTimer.stop();
262 282
263 if (m_stateMachine.isDisplayingInitialEmptyDocument()) 283 if (m_stateMachine.isDisplayingInitialEmptyDocument())
264 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 284 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
265 } 285 }
266 286
267 // This is only called by ScriptController::executeScriptIfJavaScriptURL 287 // This is only called by ScriptController::executeScriptIfJavaScriptURL
268 // and always contains the result of evaluating a javascript: url. 288 // and always contains the result of evaluating a javascript: url.
269 // This is the <iframe src="javascript:'html'"> case. 289 // This is the <iframe src="javascript:'html'"> case.
270 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument) 290 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument)
271 { 291 {
272 if (!m_frame->document()->loader()) 292 if (!m_frame->document()->loader())
273 return; 293 return;
274 294
275 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed, 295 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed,
276 // so protect it with a RefPtr. 296 // so protect it with a RefPtr.
277 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); 297 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader());
278 298
279 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); 299 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL);
280 300
281 // Prepare a DocumentInit before clearing the frame, because it may need to 301 // Prepare a DocumentInit before clearing the frame, because it may need to
282 // inherit an aliased security context. 302 // inherit an aliased security context.
283 DocumentInit init(m_frame->document()->url(), m_frame); 303 DocumentInit init(m_frame->document()->url(), m_frame);
284 init.withNewRegistrationContext(); 304 init.withNewRegistrationContext();
285 305
286 stopAllLoaders(); 306 stopAllLoaders();
287 clear(); 307 dispose(DoDisposeFrameContents);
288 308
289 // clear() potentially detaches the frame from the document. The 309 // dispose() potentially detaches the frame from the document. The
290 // loading cannot continue in that case. 310 // loading cannot continue in that case.
291 if (!m_frame->page()) 311 if (!m_frame->page())
292 return; 312 return;
293 313
294 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); 314 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument);
295 } 315 }
296 316
297 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) 317 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject)
298 { 318 {
299 if (m_provisionalItem) 319 if (m_provisionalItem)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 411 }
392 412
393 void FrameLoader::finishedParsing() 413 void FrameLoader::finishedParsing()
394 { 414 {
395 if (m_stateMachine.creatingInitialEmptyDocument()) 415 if (m_stateMachine.creatingInitialEmptyDocument())
396 return; 416 return;
397 417
398 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 418 // 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. 419 // 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. 420 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
401 RefPtr<LocalFrame> protector = m_frame->view() ? m_frame : 0; 421 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr);
402 422
403 if (client()) 423 if (client())
404 client()->dispatchDidFinishDocumentLoad(); 424 client()->dispatchDidFinishDocumentLoad();
405 425
406 checkCompleted(); 426 checkCompleted();
407 427
408 if (!m_frame->view()) 428 if (!m_frame->view())
409 return; // We are being destroyed by something checkCompleted called. 429 return; // We are being destroyed by something checkCompleted called.
410 430
411 // Check if the scrollbars are really needed for the content. 431 // Check if the scrollbars are really needed for the content.
(...skipping 23 matching lines...) Expand all
435 { 455 {
436 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) { 456 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) {
437 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished()) 457 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished())
438 return false; 458 return false;
439 } 459 }
440 return true; 460 return true;
441 } 461 }
442 462
443 void FrameLoader::checkCompleted() 463 void FrameLoader::checkCompleted()
444 { 464 {
445 RefPtr<LocalFrame> protect(m_frame); 465 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
446 466
447 if (m_frame->view()) 467 if (m_frame->view())
448 m_frame->view()->handleLoadCompleted(); 468 m_frame->view()->handleLoadCompleted();
449 469
450 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad()) 470 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad())
451 return; 471 return;
452 472
453 // Are we still parsing? 473 // Are we still parsing?
454 if (m_frame->document()->parsing()) 474 if (m_frame->document()->parsing())
455 return; 475 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 527
508 void FrameLoader::setOpener(LocalFrame* opener) 528 void FrameLoader::setOpener(LocalFrame* opener)
509 { 529 {
510 // If the frame is already detached, the opener has already been cleared. 530 // If the frame is already detached, the opener has already been cleared.
511 if (client()) 531 if (client())
512 client()->setOpener(opener); 532 client()->setOpener(opener);
513 } 533 }
514 534
515 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) 535 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
516 { 536 {
537 // With Oilpan, a FrameLoader might be accessed after the
538 // FrameHost has been detached. FrameClient will not be
539 // accessible, so bail early.
540 if (!client())
541 return false;
517 Settings* settings = m_frame->settings(); 542 Settings* settings = m_frame->settings();
518 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() ); 543 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() );
519 if (!allowed && reason == AboutToInstantiatePlugin) 544 if (!allowed && reason == AboutToInstantiatePlugin)
520 client()->didNotAllowPlugins(); 545 client()->didNotAllowPlugins();
521 return allowed; 546 return allowed;
522 } 547 }
523 548
524 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type) 549 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type)
525 { 550 {
526 // Update the data source's request with the new URL to fake the URL change 551 // 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 602 // 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. 603 // the user might have scrolled since the previous navigation.
579 scrollToFragmentWithParentBoundary(url); 604 scrollToFragmentWithParentBoundary(url);
580 checkCompleted(); 605 checkCompleted();
581 606
582 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue()); 607 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue());
583 } 608 }
584 609
585 void FrameLoader::completed() 610 void FrameLoader::completed()
586 { 611 {
587 RefPtr<LocalFrame> protect(m_frame); 612 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
588 613
589 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) { 614 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) {
590 if (descendant->isLocalFrame()) 615 if (descendant->isLocalFrame())
591 toLocalFrame(descendant)->navigationScheduler().startTimer(); 616 toLocalFrame(descendant)->navigationScheduler().startTimer();
592 } 617 }
593 618
594 Frame* parent = m_frame->tree().parent(); 619 Frame* parent = m_frame->tree().parent();
595 if (parent && parent->isLocalFrame()) 620 if (parent && parent->isLocalFrame())
596 toLocalFrame(parent)->loader().checkCompleted(); 621 toLocalFrame(parent)->loader().checkCompleted();
597 622
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 return WebURLRequest::RequestContextInternal; 726 return WebURLRequest::RequestContextInternal;
702 } 727 }
703 ASSERT_NOT_REACHED(); 728 ASSERT_NOT_REACHED();
704 return WebURLRequest::RequestContextHyperlink; 729 return WebURLRequest::RequestContextHyperlink;
705 } 730 }
706 731
707 void FrameLoader::load(const FrameLoadRequest& passedRequest) 732 void FrameLoader::load(const FrameLoadRequest& passedRequest)
708 { 733 {
709 ASSERT(m_frame->document()); 734 ASSERT(m_frame->document());
710 735
711 RefPtr<LocalFrame> protect(m_frame); 736 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
712 737
713 if (m_inStopAllLoaders) 738 if (m_inStopAllLoaders)
714 return; 739 return;
715 740
716 FrameLoadRequest request(passedRequest); 741 FrameLoadRequest request(passedRequest);
717 if (!prepareRequestForThisFrame(request)) 742 if (!prepareRequestForThisFrame(request))
718 return; 743 return;
719 744
720 RefPtr<LocalFrame> targetFrame = request.formState() ? 0 : findFrameForNavig ation(AtomicString(request.frameName()), request.formState() ? request.formState ()->sourceDocument() : m_frame->document()); 745 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) { 746 if (targetFrame && targetFrame.get() != m_frame) {
722 request.setFrameName("_self"); 747 request.setFrameName("_self");
723 targetFrame->loader().load(request); 748 targetFrame->loader().load(request);
724 if (Page* page = targetFrame->page()) 749 if (Page* page = targetFrame->page())
725 page->chrome().focus(); 750 page->chrome().focus();
726 return; 751 return;
727 } 752 }
728 753
729 FrameLoadType newLoadType = determineFrameLoadType(request); 754 FrameLoadType newLoadType = determineFrameLoadType(request);
730 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent()); 755 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent());
731 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified) 756 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 { 848 {
824 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 849 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
825 return; 850 return;
826 851
827 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 852 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
828 if (m_inStopAllLoaders) 853 if (m_inStopAllLoaders)
829 return; 854 return;
830 855
831 // Calling stopLoading() on the provisional document loader can blow away 856 // Calling stopLoading() on the provisional document loader can blow away
832 // the frame from underneath. 857 // the frame from underneath.
833 RefPtr<LocalFrame> protect(m_frame); 858 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
834 859
835 m_inStopAllLoaders = true; 860 m_inStopAllLoaders = true;
836 861
837 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 862 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
838 if (child->isLocalFrame()) 863 if (child->isLocalFrame())
839 toLocalFrame(child.get())->loader().stopAllLoaders(); 864 toLocalFrame(child.get())->loader().stopAllLoaders();
840 } 865 }
841 if (m_provisionalDocumentLoader) 866 if (m_provisionalDocumentLoader)
842 m_provisionalDocumentLoader->stopLoading(); 867 m_provisionalDocumentLoader->stopLoading();
843 if (m_documentLoader) 868 if (m_documentLoader)
844 m_documentLoader->stopLoading(); 869 m_documentLoader->stopLoading();
845 870
846 if (m_provisionalDocumentLoader) 871 if (m_provisionalDocumentLoader)
847 m_provisionalDocumentLoader->detachFromFrame(); 872 m_provisionalDocumentLoader->detachFromFrame();
(...skipping 14 matching lines...) Expand all
862 // We only need to notify the client once, and only for the main frame. 887 // We only need to notify the client once, and only for the main frame.
863 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { 888 if (isLoadingMainFrame() && !m_didAccessInitialDocument) {
864 m_didAccessInitialDocument = true; 889 m_didAccessInitialDocument = true;
865 // Notify asynchronously, since this is called within a JavaScript secur ity check. 890 // Notify asynchronously, since this is called within a JavaScript secur ity check.
866 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE); 891 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE);
867 } 892 }
868 } 893 }
869 894
870 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*) 895 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*)
871 { 896 {
872 client()->didAccessInitialDocument(); 897 if (client())
898 client()->didAccessInitialDocument();
873 } 899 }
874 900
875 void FrameLoader::notifyIfInitialDocumentAccessed() 901 void FrameLoader::notifyIfInitialDocumentAccessed()
876 { 902 {
877 if (m_didAccessInitialDocumentTimer.isActive()) { 903 if (m_didAccessInitialDocumentTimer.isActive()) {
878 m_didAccessInitialDocumentTimer.stop(); 904 m_didAccessInitialDocumentTimer.stop();
879 didAccessInitialDocumentTimerFired(0); 905 didAccessInitialDocumentTimerFired(0);
880 } 906 }
881 } 907 }
882 908
883 void FrameLoader::commitProvisionalLoad() 909 void FrameLoader::commitProvisionalLoad()
884 { 910 {
885 ASSERT(client()->hasWebView()); 911 ASSERT(client()->hasWebView());
886 ASSERT(m_state == FrameStateProvisional); 912 ASSERT(m_state == FrameStateProvisional);
887 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; 913 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
888 RefPtr<LocalFrame> protect(m_frame); 914 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
889 915
890 // Check if the destination page is allowed to access the previous page's ti ming information. 916 // Check if the destination page is allowed to access the previous page's ti ming information.
891 if (m_frame->document()) { 917 if (m_frame->document()) {
892 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url()); 918 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url());
893 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url())); 919 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url()));
894 } 920 }
895 921
896 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary 922 // 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, 923 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load,
898 // or the two will stomp each other. 924 // or the two will stomp each other.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 if (document->processingLoadEvent()) 979 if (document->processingLoadEvent())
954 return false; 980 return false;
955 if (document->hasActiveParser()) 981 if (document->hasActiveParser())
956 return false; 982 return false;
957 return true; 983 return true;
958 } 984 }
959 985
960 bool FrameLoader::checkLoadCompleteForThisFrame() 986 bool FrameLoader::checkLoadCompleteForThisFrame()
961 { 987 {
962 ASSERT(client()->hasWebView()); 988 ASSERT(client()->hasWebView());
963 RefPtr<LocalFrame> protect(m_frame); 989 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
964 990
965 bool allChildrenAreDoneLoading = true; 991 bool allChildrenAreDoneLoading = true;
966 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 992 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
967 if (child->isLocalFrame()) 993 if (child->isLocalFrame())
968 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame(); 994 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame();
969 } 995 }
970 996
971 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { 997 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
972 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror(); 998 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror();
973 if (error.isNull()) 999 if (error.isNull())
974 return false; 1000 return false;
975 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; 1001 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader;
976 client()->dispatchDidFailProvisionalLoad(error); 1002 client()->dispatchDidFailProvisionalLoad(error);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1109
1084 String FrameLoader::userAgent(const KURL& url) const 1110 String FrameLoader::userAgent(const KURL& url) const
1085 { 1111 {
1086 String userAgent = client()->userAgent(url); 1112 String userAgent = client()->userAgent(url);
1087 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); 1113 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
1088 return userAgent; 1114 return userAgent;
1089 } 1115 }
1090 1116
1091 void FrameLoader::detachFromParent() 1117 void FrameLoader::detachFromParent()
1092 { 1118 {
1119 #if !ENABLE(OILPAN)
1093 // The caller must protect a reference to m_frame. 1120 // The caller must protect a reference to m_frame.
1094 ASSERT(m_frame->refCount() > 1); 1121 ASSERT(m_frame->refCount() > 1);
1122 #endif
1095 1123
1096 InspectorInstrumentation::frameDetachedFromParent(m_frame); 1124 InspectorInstrumentation::frameDetachedFromParent(m_frame);
1097 1125
1098 if (m_documentLoader) 1126 if (m_documentLoader)
1099 m_documentLoader->detachFromFrame(); 1127 m_documentLoader->detachFromFrame();
1100 m_documentLoader = nullptr; 1128 m_documentLoader = nullptr;
1101 1129
1102 if (!client()) 1130 if (!client())
1103 return; 1131 return;
1104 1132
(...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 1166 // After this, we must no longer talk to the client since this clears
1139 // its owning reference back to our owning LocalFrame. 1167 // its owning reference back to our owning LocalFrame.
1140 client()->detachedFromParent(); 1168 client()->detachedFromParent();
1141 m_frame->clearClient(); 1169 m_frame->clearClient();
1142 } 1170 }
1143 } 1171 }
1144 1172
1145 void FrameLoader::receivedMainResourceError(const ResourceError& error) 1173 void FrameLoader::receivedMainResourceError(const ResourceError& error)
1146 { 1174 {
1147 // Retain because the stop may release the last reference to it. 1175 // Retain because the stop may release the last reference to it.
1148 RefPtr<LocalFrame> protect(m_frame); 1176 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1149 1177
1150 if (m_frame->document()->parser()) 1178 if (m_frame->document()->parser())
1151 m_frame->document()->parser()->stopParsing(); 1179 m_frame->document()->parser()->stopParsing();
1152 1180
1153 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some 1181 // 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(). 1182 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError().
1155 ResourceError c(ResourceError::cancelledError(KURL())); 1183 ResourceError c(ResourceError::cancelledError(KURL()));
1156 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) { 1184 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) {
1157 // FIXME: For now, fallback content doesn't work cross process. 1185 // FIXME: For now, fallback content doesn't work cross process.
1158 ASSERT(m_frame->owner()->isLocal()); 1186 ASSERT(m_frame->owner()->isLocal());
(...skipping 21 matching lines...) Expand all
1180 && !m_frame->document()->isFrameSet(); 1208 && !m_frame->document()->isFrameSet();
1181 } 1209 }
1182 1210
1183 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) 1211 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url)
1184 { 1212 {
1185 FrameView* view = m_frame->view(); 1213 FrameView* view = m_frame->view();
1186 if (!view) 1214 if (!view)
1187 return; 1215 return;
1188 1216
1189 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack. 1217 // 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); 1218 RefPtrWillBeRawPtr<LocalFrame> boundaryFrame = url.hasFragmentIdentifier() ? m_frame->document()->findUnsafeParentScrollPropagationBoundary() : 0;
1191 1219
1192 if (boundaryFrame) 1220 if (boundaryFrame)
1193 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); 1221 boundaryFrame->view()->setSafeToPropagateScrollToParent(false);
1194 1222
1195 view->scrollToFragment(url); 1223 view->scrollToFragment(url);
1196 1224
1197 if (boundaryFrame) 1225 if (boundaryFrame)
1198 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); 1226 boundaryFrame->view()->setSafeToPropagateScrollToParent(true);
1199 } 1227 }
1200 1228
1201 bool FrameLoader::shouldClose() 1229 bool FrameLoader::shouldClose()
1202 { 1230 {
1203 Page* page = m_frame->page(); 1231 Page* page = m_frame->page();
1204 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) 1232 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel())
1205 return true; 1233 return true;
1206 1234
1207 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame 1235 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame
1208 Vector<RefPtr<LocalFrame> > targetFrames; 1236 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > targetFrames;
1209 targetFrames.append(m_frame); 1237 targetFrames.append(m_frame);
1210 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) { 1238 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. 1239 // FIXME: There is not yet any way to dispatch events to out-of-process frames.
1212 if (child->isLocalFrame()) 1240 if (child->isLocalFrame())
1213 targetFrames.append(toLocalFrame(child)); 1241 targetFrames.append(toLocalFrame(child));
1214 } 1242 }
1215 1243
1216 bool shouldClose = false; 1244 bool shouldClose = false;
1217 { 1245 {
1218 NavigationDisablerForBeforeUnload navigationDisabler; 1246 NavigationDisablerForBeforeUnload navigationDisabler;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); 1313 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding);
1286 else if (m_documentLoader) 1314 else if (m_documentLoader)
1287 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding()); 1315 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding());
1288 1316
1289 1317
1290 bool isTransitionNavigation = false; 1318 bool isTransitionNavigation = false;
1291 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1319 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1292 isTransitionNavigation = dispatchNavigationTransitionData(); 1320 isTransitionNavigation = dispatchNavigationTransitionData();
1293 1321
1294 // stopAllLoaders can detach the LocalFrame, so protect it. 1322 // stopAllLoaders can detach the LocalFrame, so protect it.
1295 RefPtr<LocalFrame> protect(m_frame); 1323 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1296 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1324 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) {
1297 m_policyDocumentLoader->detachFromFrame(); 1325 m_policyDocumentLoader->detachFromFrame();
1298 m_policyDocumentLoader = nullptr; 1326 m_policyDocumentLoader = nullptr;
1299 checkCompleted(); 1327 checkCompleted();
1300 return; 1328 return;
1301 } 1329 }
1302 1330
1303 if (m_provisionalDocumentLoader) { 1331 if (m_provisionalDocumentLoader) {
1304 m_provisionalDocumentLoader->stopLoading(); 1332 m_provisionalDocumentLoader->stopLoading();
1305 if (m_provisionalDocumentLoader) 1333 if (m_provisionalDocumentLoader)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 { 1434 {
1407 ASSERT(activeDocument); 1435 ASSERT(activeDocument);
1408 Frame* frame = m_frame->tree().find(name); 1436 Frame* frame = m_frame->tree().find(name);
1409 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame))) 1437 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame)))
1410 return 0; 1438 return 0;
1411 return toLocalFrame(frame); 1439 return toLocalFrame(frame);
1412 } 1440 }
1413 1441
1414 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy) 1442 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy)
1415 { 1443 {
1416 RefPtr<LocalFrame> protect(m_frame); 1444 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1417 if (m_frame->page()->defersLoading()) { 1445 if (m_frame->page()->defersLoading()) {
1418 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy); 1446 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1419 return; 1447 return;
1420 } 1448 }
1421 1449
1422 m_provisionalItem = item; 1450 m_provisionalItem = item;
1423 if (historyLoadType == HistorySameDocumentLoad) { 1451 if (historyLoadType == HistorySameDocumentLoad) {
1424 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect); 1452 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect);
1425 restoreScrollPositionAndViewState(); 1453 restoreScrollPositionAndViewState();
1426 return; 1454 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. 1493 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1466 Frame* parentFrame = m_frame->tree().parent(); 1494 Frame* parentFrame = m_frame->tree().parent();
1467 if (parentFrame && parentFrame->isLocalFrame()) 1495 if (parentFrame && parentFrame->isLocalFrame())
1468 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1496 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1469 if (FrameOwner* frameOwner = m_frame->owner()) 1497 if (FrameOwner* frameOwner = m_frame->owner())
1470 flags |= frameOwner->sandboxFlags(); 1498 flags |= frameOwner->sandboxFlags();
1471 return flags; 1499 return flags;
1472 } 1500 }
1473 1501
1474 } // namespace blink 1502 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698