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

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: Update OilpanExpectations 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/ContentSecurityPolicyResponseHeaders.h" 87 #include "platform/network/ContentSecurityPolicyResponseHeaders.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"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 , m_didAccessInitialDocument(false) 123 , m_didAccessInitialDocument(false)
124 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 124 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
125 , m_forcedSandboxFlags(SandboxNone) 125 , m_forcedSandboxFlags(SandboxNone)
126 { 126 {
127 } 127 }
128 128
129 FrameLoader::~FrameLoader() 129 FrameLoader::~FrameLoader()
130 { 130 {
131 } 131 }
132 132
133 void FrameLoader::trace(Visitor* visitor)
134 {
135 visitor->trace(m_frame);
136 visitor->trace(m_fetchContext);
137 }
138
133 void FrameLoader::init() 139 void FrameLoader::init()
134 { 140 {
135 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); 141 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString()));
136 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); 142 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal);
137 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested); 143 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested);
138 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia lRequest, SubstituteData()); 144 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia lRequest, SubstituteData());
139 m_provisionalDocumentLoader->startLoadingMainResource(); 145 m_provisionalDocumentLoader->startLoadingMainResource();
140 m_frame->document()->cancelParsing(); 146 m_frame->document()->cancelParsing();
141 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment); 147 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment);
142 } 148 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!m_stateMachine.committedFirstRealDocumentLoad()) 239 if (!m_stateMachine.committedFirstRealDocumentLoad())
234 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 240 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
235 241
236 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results 242 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
237 // from a subsequent window.document.open / window.document.write call. 243 // from a subsequent window.document.open / window.document.write call.
238 // Canceling redirection here works for all cases because document.open 244 // Canceling redirection here works for all cases because document.open
239 // implicitly precedes document.write. 245 // implicitly precedes document.write.
240 m_frame->navigationScheduler().cancel(); 246 m_frame->navigationScheduler().cancel();
241 } 247 }
242 248
243 void FrameLoader::clear() 249 void FrameLoader::dispose(bool clearFrameContents)
dcheng 2014/09/07 22:26:34 Nit: don't use a bool parameter here. Use an enum.
haraken 2014/09/08 07:25:58 clearFrameContents => isDuringFrameDestruction ?
sof 2014/09/08 21:17:46 Done.
244 { 250 {
251 // dispose() is called during (Local)Frame finalization and when creating
252 // a new Document within it (DocumentLoader::createWriterFor().)
245 if (m_stateMachine.creatingInitialEmptyDocument()) 253 if (m_stateMachine.creatingInitialEmptyDocument())
246 return; 254 return;
247 255
248 m_frame->editor().clear(); 256 if (clearFrameContents) {
249 m_frame->document()->cancelParsing(); 257 m_frame->editor().clear();
250 m_frame->document()->prepareForDestruction(); 258 m_frame->document()->cancelParsing();
251 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); 259 m_frame->document()->prepareForDestruction();
260 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
261 // FIXME: Oilpan: the RenderView will not have its selection
262 // cleared when the frame is finalized. Verify that this
263 // is of no particular importance.
264 m_frame->selection().prepareForDestruction();
265 m_frame->eventHandler().clear();
266 }
252 267
253 m_frame->selection().prepareForDestruction(); 268 if (FrameView* view = m_frame->view())
254 m_frame->eventHandler().clear(); 269 view->clear();
255 if (m_frame->view())
256 m_frame->view()->clear();
257 270
258 m_frame->script().enableEval(); 271 m_frame->script().enableEval();
haraken 2014/09/08 07:25:58 Is it to safe to touch m_frame here if the dispose
259 272
273 // Oilpan: this depends on NavigationScheduler being a part object
274 // of FrameLoader, i.e., the part object is still accessible.
275 //
276 // FIXME: Oilpan: verify this assumption.
260 m_frame->navigationScheduler().cancel(); 277 m_frame->navigationScheduler().cancel();
haraken 2014/09/08 07:25:58 Ditto. It looks not safe to touch m_frame here.
sof 2014/09/08 21:17:46 See the FIXME above? :) If NavigationScheduler is
261 278
262 m_checkTimer.stop(); 279 m_checkTimer.stop();
263 280
264 if (m_stateMachine.isDisplayingInitialEmptyDocument()) 281 if (m_stateMachine.isDisplayingInitialEmptyDocument())
265 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 282 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
266 } 283 }
267 284
268 // This is only called by ScriptController::executeScriptIfJavaScriptURL 285 // This is only called by ScriptController::executeScriptIfJavaScriptURL
269 // and always contains the result of evaluating a javascript: url. 286 // and always contains the result of evaluating a javascript: url.
270 // This is the <iframe src="javascript:'html'"> case. 287 // This is the <iframe src="javascript:'html'"> case.
271 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument) 288 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument)
272 { 289 {
273 if (!m_frame->document()->loader()) 290 if (!m_frame->document()->loader())
274 return; 291 return;
275 292
276 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed, 293 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed,
277 // so protect it with a RefPtr. 294 // so protect it with a RefPtr.
278 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); 295 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader());
279 296
280 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); 297 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL);
281 298
282 // Prepare a DocumentInit before clearing the frame, because it may need to 299 // Prepare a DocumentInit before clearing the frame, because it may need to
283 // inherit an aliased security context. 300 // inherit an aliased security context.
284 DocumentInit init(m_frame->document()->url(), m_frame); 301 DocumentInit init(m_frame->document()->url(), m_frame);
285 init.withNewRegistrationContext(); 302 init.withNewRegistrationContext();
286 303
287 stopAllLoaders(); 304 stopAllLoaders();
288 clear(); 305 dispose(true);
289 306
290 // clear() potentially detaches the frame from the document. The 307 // dispose() potentially detaches the frame from the document. The
291 // loading cannot continue in that case. 308 // loading cannot continue in that case.
292 if (!m_frame->page()) 309 if (!m_frame->page())
293 return; 310 return;
294 311
295 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); 312 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument);
296 } 313 }
297 314
298 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) 315 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject)
299 { 316 {
300 if (m_provisionalItem) 317 if (m_provisionalItem)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 client()->dispatchDidCommitLoad(m_frame, m_currentItem.get(), historyCommitT ype); 367 client()->dispatchDidCommitLoad(m_frame, m_currentItem.get(), historyCommitT ype);
351 368
352 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); 369 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get());
353 m_frame->page()->didCommitLoad(m_frame); 370 m_frame->page()->didCommitLoad(m_frame);
354 dispatchDidClearDocumentOfWindowObject(); 371 dispatchDidClearDocumentOfWindowObject();
355 } 372 }
356 373
357 static void didFailContentSecurityPolicyCheck(FrameLoader* loader) 374 static void didFailContentSecurityPolicyCheck(FrameLoader* loader)
358 { 375 {
359 // load event and stopAllLoaders can detach the LocalFrame, so protect it. 376 // load event and stopAllLoaders can detach the LocalFrame, so protect it.
360 RefPtr<LocalFrame> frame(loader->frame()); 377 RefPtrWillBeRawPtr<LocalFrame> frame = loader->frame();
361 378
362 // Move the page to a unique origin, and cancel the load. 379 // Move the page to a unique origin, and cancel the load.
363 frame->document()->enforceSandboxFlags(SandboxOrigin); 380 frame->document()->enforceSandboxFlags(SandboxOrigin);
364 loader->stopAllLoaders(); 381 loader->stopAllLoaders();
365 382
366 // Fire a load event, as timing attacks would otherwise reveal that the 383 // Fire a load event, as timing attacks would otherwise reveal that the
367 // frame was blocked. This way, it looks like every other cross-origin 384 // frame was blocked. This way, it looks like every other cross-origin
368 // page. 385 // page.
369 if (FrameOwner* frameOwner = frame->owner()) 386 if (FrameOwner* frameOwner = frame->owner())
370 frameOwner->dispatchLoad(); 387 frameOwner->dispatchLoad();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 430 }
414 431
415 void FrameLoader::finishedParsing() 432 void FrameLoader::finishedParsing()
416 { 433 {
417 if (m_stateMachine.creatingInitialEmptyDocument()) 434 if (m_stateMachine.creatingInitialEmptyDocument())
418 return; 435 return;
419 436
420 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 437 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves
421 // because doing so will cause us to re-enter the destructor when protector goes out of scope. 438 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
422 // Null-checking the FrameView indicates whether or not we're in the destruc tor. 439 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
423 RefPtr<LocalFrame> protector = m_frame->view() ? m_frame : 0; 440 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr);
424 441
425 if (client()) 442 if (client())
426 client()->dispatchDidFinishDocumentLoad(); 443 client()->dispatchDidFinishDocumentLoad();
427 444
428 checkCompleted(); 445 checkCompleted();
429 446
430 if (!m_frame->view()) 447 if (!m_frame->view())
431 return; // We are being destroyed by something checkCompleted called. 448 return; // We are being destroyed by something checkCompleted called.
432 449
433 // Check if the scrollbars are really needed for the content. 450 // Check if the scrollbars are really needed for the content.
(...skipping 23 matching lines...) Expand all
457 { 474 {
458 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) { 475 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) {
459 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished()) 476 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished())
460 return false; 477 return false;
461 } 478 }
462 return true; 479 return true;
463 } 480 }
464 481
465 void FrameLoader::checkCompleted() 482 void FrameLoader::checkCompleted()
466 { 483 {
467 RefPtr<LocalFrame> protect(m_frame); 484 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
468 485
469 if (m_frame->view()) 486 if (m_frame->view())
470 m_frame->view()->handleLoadCompleted(); 487 m_frame->view()->handleLoadCompleted();
471 488
472 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad()) 489 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad())
473 return; 490 return;
474 491
475 // Are we still parsing? 492 // Are we still parsing?
476 if (m_frame->document()->parsing()) 493 if (m_frame->document()->parsing())
477 return; 494 return;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // We need to scroll to the fragment whether or not a hash change occurred, since 616 // We need to scroll to the fragment whether or not a hash change occurred, since
600 // the user might have scrolled since the previous navigation. 617 // the user might have scrolled since the previous navigation.
601 scrollToFragmentWithParentBoundary(url); 618 scrollToFragmentWithParentBoundary(url);
602 checkCompleted(); 619 checkCompleted();
603 620
604 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue()); 621 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue());
605 } 622 }
606 623
607 void FrameLoader::completed() 624 void FrameLoader::completed()
608 { 625 {
609 RefPtr<LocalFrame> protect(m_frame); 626 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
610 627
611 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) { 628 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) {
612 if (descendant->isLocalFrame()) 629 if (descendant->isLocalFrame())
613 toLocalFrame(descendant)->navigationScheduler().startTimer(); 630 toLocalFrame(descendant)->navigationScheduler().startTimer();
614 } 631 }
615 632
616 Frame* parent = m_frame->tree().parent(); 633 Frame* parent = m_frame->tree().parent();
617 if (parent && parent->isLocalFrame()) 634 if (parent && parent->isLocalFrame())
618 toLocalFrame(parent)->loader().checkCompleted(); 635 toLocalFrame(parent)->loader().checkCompleted();
619 636
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return WebURLRequest::RequestContextInternal; 740 return WebURLRequest::RequestContextInternal;
724 } 741 }
725 ASSERT_NOT_REACHED(); 742 ASSERT_NOT_REACHED();
726 return WebURLRequest::RequestContextHyperlink; 743 return WebURLRequest::RequestContextHyperlink;
727 } 744 }
728 745
729 void FrameLoader::load(const FrameLoadRequest& passedRequest) 746 void FrameLoader::load(const FrameLoadRequest& passedRequest)
730 { 747 {
731 ASSERT(m_frame->document()); 748 ASSERT(m_frame->document());
732 749
733 RefPtr<LocalFrame> protect(m_frame); 750 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
734 751
735 if (m_inStopAllLoaders) 752 if (m_inStopAllLoaders)
736 return; 753 return;
737 754
738 FrameLoadRequest request(passedRequest); 755 FrameLoadRequest request(passedRequest);
739 if (!prepareRequestForThisFrame(request)) 756 if (!prepareRequestForThisFrame(request))
740 return; 757 return;
741 758
742 RefPtr<LocalFrame> targetFrame = request.formState() ? 0 : findFrameForNavig ation(AtomicString(request.frameName()), request.formState() ? request.formState ()->sourceDocument() : m_frame->document()); 759 RefPtrWillBeRawPtr<LocalFrame> targetFrame = request.formState() ? 0 : findF rameForNavigation(AtomicString(request.frameName()), request.formState() ? reque st.formState()->sourceDocument() : m_frame->document());
743 if (targetFrame && targetFrame != m_frame) { 760 if (targetFrame && targetFrame.get() != m_frame) {
744 request.setFrameName("_self"); 761 request.setFrameName("_self");
745 targetFrame->loader().load(request); 762 targetFrame->loader().load(request);
746 if (Page* page = targetFrame->page()) 763 if (Page* page = targetFrame->page())
747 page->chrome().focus(); 764 page->chrome().focus();
748 return; 765 return;
749 } 766 }
750 767
751 FrameLoadType newLoadType = determineFrameLoadType(request); 768 FrameLoadType newLoadType = determineFrameLoadType(request);
752 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent()); 769 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent());
753 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified) 770 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 { 862 {
846 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 863 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
847 return; 864 return;
848 865
849 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 866 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
850 if (m_inStopAllLoaders) 867 if (m_inStopAllLoaders)
851 return; 868 return;
852 869
853 // Calling stopLoading() on the provisional document loader can blow away 870 // Calling stopLoading() on the provisional document loader can blow away
854 // the frame from underneath. 871 // the frame from underneath.
855 RefPtr<LocalFrame> protect(m_frame); 872 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
856 873
857 m_inStopAllLoaders = true; 874 m_inStopAllLoaders = true;
858 875
859 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 876 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
860 if (child->isLocalFrame()) 877 if (child->isLocalFrame())
861 toLocalFrame(child.get())->loader().stopAllLoaders(); 878 toLocalFrame(child.get())->loader().stopAllLoaders();
862 } 879 }
863 if (m_provisionalDocumentLoader) 880 if (m_provisionalDocumentLoader)
864 m_provisionalDocumentLoader->stopLoading(); 881 m_provisionalDocumentLoader->stopLoading();
865 if (m_documentLoader) 882 if (m_documentLoader)
866 m_documentLoader->stopLoading(); 883 m_documentLoader->stopLoading();
867 884
868 if (m_provisionalDocumentLoader) 885 if (m_provisionalDocumentLoader)
869 m_provisionalDocumentLoader->detachFromFrame(); 886 m_provisionalDocumentLoader->detachFromFrame();
(...skipping 14 matching lines...) Expand all
884 // We only need to notify the client once, and only for the main frame. 901 // We only need to notify the client once, and only for the main frame.
885 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { 902 if (isLoadingMainFrame() && !m_didAccessInitialDocument) {
886 m_didAccessInitialDocument = true; 903 m_didAccessInitialDocument = true;
887 // Notify asynchronously, since this is called within a JavaScript secur ity check. 904 // Notify asynchronously, since this is called within a JavaScript secur ity check.
888 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE); 905 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE);
889 } 906 }
890 } 907 }
891 908
892 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*) 909 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*)
893 { 910 {
894 client()->didAccessInitialDocument(); 911 if (client())
haraken 2014/09/08 07:25:58 Why was this check not needed before this CL but i
sof 2014/09/08 21:17:46 The FrameClient is cleared upon calling close() on
912 client()->didAccessInitialDocument();
895 } 913 }
896 914
897 void FrameLoader::notifyIfInitialDocumentAccessed() 915 void FrameLoader::notifyIfInitialDocumentAccessed()
898 { 916 {
899 if (m_didAccessInitialDocumentTimer.isActive()) { 917 if (m_didAccessInitialDocumentTimer.isActive()) {
900 m_didAccessInitialDocumentTimer.stop(); 918 m_didAccessInitialDocumentTimer.stop();
901 didAccessInitialDocumentTimerFired(0); 919 didAccessInitialDocumentTimerFired(0);
902 } 920 }
903 } 921 }
904 922
905 bool FrameLoader::isLoading() const 923 bool FrameLoader::isLoading() const
906 { 924 {
907 if (m_provisionalDocumentLoader) 925 if (m_provisionalDocumentLoader)
908 return true; 926 return true;
909 return m_documentLoader && m_documentLoader->isLoading(); 927 return m_documentLoader && m_documentLoader->isLoading();
910 } 928 }
911 929
912 void FrameLoader::commitProvisionalLoad() 930 void FrameLoader::commitProvisionalLoad()
913 { 931 {
914 ASSERT(client()->hasWebView()); 932 ASSERT(client()->hasWebView());
915 ASSERT(m_state == FrameStateProvisional); 933 ASSERT(m_state == FrameStateProvisional);
916 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; 934 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
917 RefPtr<LocalFrame> protect(m_frame); 935 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
918 936
919 // Check if the destination page is allowed to access the previous page's ti ming information. 937 // Check if the destination page is allowed to access the previous page's ti ming information.
920 if (m_frame->document()) { 938 if (m_frame->document()) {
921 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url()); 939 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url());
922 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url())); 940 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url()));
923 } 941 }
924 942
925 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary 943 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary
926 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load, 944 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load,
927 // or the two will stomp each other. 945 // or the two will stomp each other.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 if (document->processingLoadEvent()) 1000 if (document->processingLoadEvent())
983 return false; 1001 return false;
984 if (document->hasActiveParser()) 1002 if (document->hasActiveParser())
985 return false; 1003 return false;
986 return true; 1004 return true;
987 } 1005 }
988 1006
989 bool FrameLoader::checkLoadCompleteForThisFrame() 1007 bool FrameLoader::checkLoadCompleteForThisFrame()
990 { 1008 {
991 ASSERT(client()->hasWebView()); 1009 ASSERT(client()->hasWebView());
992 RefPtr<LocalFrame> protect(m_frame); 1010 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
993 1011
994 bool allChildrenAreDoneLoading = true; 1012 bool allChildrenAreDoneLoading = true;
995 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 1013 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
996 if (child->isLocalFrame()) 1014 if (child->isLocalFrame())
997 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame(); 1015 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame();
998 } 1016 }
999 1017
1000 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { 1018 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
1001 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror(); 1019 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror();
1002 if (error.isNull()) 1020 if (error.isNull())
1003 return false; 1021 return false;
1004 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; 1022 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader;
1005 client()->dispatchDidFailProvisionalLoad(error); 1023 client()->dispatchDidFailProvisionalLoad(error);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 String FrameLoader::userAgent(const KURL& url) const 1131 String FrameLoader::userAgent(const KURL& url) const
1114 { 1132 {
1115 String userAgent = client()->userAgent(url); 1133 String userAgent = client()->userAgent(url);
1116 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); 1134 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
1117 return userAgent; 1135 return userAgent;
1118 } 1136 }
1119 1137
1120 void FrameLoader::detachFromParent() 1138 void FrameLoader::detachFromParent()
1121 { 1139 {
1122 // The caller must protect a reference to m_frame. 1140 // The caller must protect a reference to m_frame.
1141 #if !ENABLE(OILPAN)
1123 ASSERT(m_frame->refCount() > 1); 1142 ASSERT(m_frame->refCount() > 1);
1143 #endif
1124 1144
1125 InspectorInstrumentation::frameDetachedFromParent(m_frame); 1145 InspectorInstrumentation::frameDetachedFromParent(m_frame);
1126 1146
1127 if (m_documentLoader) 1147 if (m_documentLoader)
1128 m_documentLoader->detachFromFrame(); 1148 m_documentLoader->detachFromFrame();
1129 m_documentLoader = nullptr; 1149 m_documentLoader = nullptr;
1130 1150
1131 if (!client()) 1151 if (!client())
1132 return; 1152 return;
1133 1153
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 // After this, we must no longer talk to the client since this clears 1187 // After this, we must no longer talk to the client since this clears
1168 // its owning reference back to our owning LocalFrame. 1188 // its owning reference back to our owning LocalFrame.
1169 client()->detachedFromParent(); 1189 client()->detachedFromParent();
1170 m_frame->clearClient(); 1190 m_frame->clearClient();
1171 } 1191 }
1172 } 1192 }
1173 1193
1174 void FrameLoader::receivedMainResourceError(const ResourceError& error) 1194 void FrameLoader::receivedMainResourceError(const ResourceError& error)
1175 { 1195 {
1176 // Retain because the stop may release the last reference to it. 1196 // Retain because the stop may release the last reference to it.
1177 RefPtr<LocalFrame> protect(m_frame); 1197 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1178 1198
1179 if (m_frame->document()->parser()) 1199 if (m_frame->document()->parser())
1180 m_frame->document()->parser()->stopParsing(); 1200 m_frame->document()->parser()->stopParsing();
1181 1201
1182 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some 1202 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some
1183 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError(). 1203 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError().
1184 ResourceError c(ResourceError::cancelledError(KURL())); 1204 ResourceError c(ResourceError::cancelledError(KURL()));
1185 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) { 1205 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) {
1186 // FIXME: For now, fallback content doesn't work cross process. 1206 // FIXME: For now, fallback content doesn't work cross process.
1187 ASSERT(m_frame->owner()->isLocal()); 1207 ASSERT(m_frame->owner()->isLocal());
(...skipping 21 matching lines...) Expand all
1209 && !m_frame->document()->isFrameSet(); 1229 && !m_frame->document()->isFrameSet();
1210 } 1230 }
1211 1231
1212 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) 1232 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url)
1213 { 1233 {
1214 FrameView* view = m_frame->view(); 1234 FrameView* view = m_frame->view();
1215 if (!view) 1235 if (!view)
1216 return; 1236 return;
1217 1237
1218 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack. 1238 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack.
1219 RefPtr<LocalFrame> boundaryFrame(url.hasFragmentIdentifier() ? m_frame->docu ment()->findUnsafeParentScrollPropagationBoundary() : 0); 1239 RefPtrWillBeRawPtr<LocalFrame> boundaryFrame = url.hasFragmentIdentifier() ? m_frame->document()->findUnsafeParentScrollPropagationBoundary() : 0;
1220 1240
1221 if (boundaryFrame) 1241 if (boundaryFrame)
1222 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); 1242 boundaryFrame->view()->setSafeToPropagateScrollToParent(false);
1223 1243
1224 view->scrollToFragment(url); 1244 view->scrollToFragment(url);
1225 1245
1226 if (boundaryFrame) 1246 if (boundaryFrame)
1227 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); 1247 boundaryFrame->view()->setSafeToPropagateScrollToParent(true);
1228 } 1248 }
1229 1249
1230 bool FrameLoader::shouldClose() 1250 bool FrameLoader::shouldClose()
1231 { 1251 {
1232 Page* page = m_frame->page(); 1252 Page* page = m_frame->page();
1233 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) 1253 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel())
1234 return true; 1254 return true;
1235 1255
1236 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame 1256 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame
1237 Vector<RefPtr<LocalFrame> > targetFrames; 1257 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > targetFrames;
1238 targetFrames.append(m_frame); 1258 targetFrames.append(m_frame);
1239 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) { 1259 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) {
1240 // FIXME: There is not yet any way to dispatch events to out-of-process frames. 1260 // FIXME: There is not yet any way to dispatch events to out-of-process frames.
1241 if (child->isLocalFrame()) 1261 if (child->isLocalFrame())
1242 targetFrames.append(toLocalFrame(child)); 1262 targetFrames.append(toLocalFrame(child));
1243 } 1263 }
1244 1264
1245 bool shouldClose = false; 1265 bool shouldClose = false;
1246 { 1266 {
1247 NavigationDisablerForBeforeUnload navigationDisabler; 1267 NavigationDisablerForBeforeUnload navigationDisabler;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); 1334 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding);
1315 else if (m_documentLoader) 1335 else if (m_documentLoader)
1316 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding()); 1336 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding());
1317 1337
1318 1338
1319 bool isTransitionNavigation = false; 1339 bool isTransitionNavigation = false;
1320 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1340 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1321 isTransitionNavigation = dispatchNavigationTransitionData(); 1341 isTransitionNavigation = dispatchNavigationTransitionData();
1322 1342
1323 // stopAllLoaders can detach the LocalFrame, so protect it. 1343 // stopAllLoaders can detach the LocalFrame, so protect it.
1324 RefPtr<LocalFrame> protect(m_frame); 1344 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
haraken 2014/09/08 07:25:58 .get() is needed? The same comment for other parts
sof 2014/09/08 21:17:46 Ambiguity results, if not: Member<LocalFrame> can
1325 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1345 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) {
1326 m_policyDocumentLoader->detachFromFrame(); 1346 m_policyDocumentLoader->detachFromFrame();
1327 m_policyDocumentLoader = nullptr; 1347 m_policyDocumentLoader = nullptr;
1328 checkCompleted(); 1348 checkCompleted();
1329 return; 1349 return;
1330 } 1350 }
1331 1351
1332 if (m_provisionalDocumentLoader) { 1352 if (m_provisionalDocumentLoader) {
1333 m_provisionalDocumentLoader->stopLoading(); 1353 m_provisionalDocumentLoader->stopLoading();
1334 if (m_provisionalDocumentLoader) 1354 if (m_provisionalDocumentLoader)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 { 1455 {
1436 ASSERT(activeDocument); 1456 ASSERT(activeDocument);
1437 Frame* frame = m_frame->tree().find(name); 1457 Frame* frame = m_frame->tree().find(name);
1438 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame))) 1458 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame)))
1439 return 0; 1459 return 0;
1440 return toLocalFrame(frame); 1460 return toLocalFrame(frame);
1441 } 1461 }
1442 1462
1443 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy) 1463 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy)
1444 { 1464 {
1445 RefPtr<LocalFrame> protect(m_frame); 1465 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1446 if (m_frame->page()->defersLoading()) { 1466 if (m_frame->page()->defersLoading()) {
1447 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy); 1467 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1448 return; 1468 return;
1449 } 1469 }
1450 1470
1451 m_provisionalItem = item; 1471 m_provisionalItem = item;
1452 if (historyLoadType == HistorySameDocumentLoad) { 1472 if (historyLoadType == HistorySameDocumentLoad) {
1453 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect); 1473 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect);
1454 restoreScrollPositionAndViewState(); 1474 restoreScrollPositionAndViewState();
1455 return; 1475 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1514 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1495 Frame* parentFrame = m_frame->tree().parent(); 1515 Frame* parentFrame = m_frame->tree().parent();
1496 if (parentFrame && parentFrame->isLocalFrame()) 1516 if (parentFrame && parentFrame->isLocalFrame())
1497 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1517 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1498 if (FrameOwner* frameOwner = m_frame->owner()) 1518 if (FrameOwner* frameOwner = m_frame->owner())
1499 flags |= frameOwner->sandboxFlags(); 1519 flags |= frameOwner->sandboxFlags();
1500 return flags; 1520 return flags;
1501 } 1521 }
1502 1522
1503 } // namespace blink 1523 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698