OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 { | 360 { |
361 if (m_frame->document() && m_frame->document()->parser()) | 361 if (m_frame->document() && m_frame->document()->parser()) |
362 m_frame->document()->parser()->stopParsing(); | 362 m_frame->document()->parser()->stopParsing(); |
363 | 363 |
364 if (unloadEventPolicy != UnloadEventPolicyNone) { | 364 if (unloadEventPolicy != UnloadEventPolicyNone) { |
365 if (m_frame->document()) { | 365 if (m_frame->document()) { |
366 if (m_didCallImplicitClose && !m_wasUnloadEventEmitted) { | 366 if (m_didCallImplicitClose && !m_wasUnloadEventEmitted) { |
367 Node* currentFocusedNode = m_frame->document()->focusedNode(); | 367 Node* currentFocusedNode = m_frame->document()->focusedNode(); |
368 if (currentFocusedNode) | 368 if (currentFocusedNode) |
369 currentFocusedNode->aboutToUnload(); | 369 currentFocusedNode->aboutToUnload(); |
370 if (m_frame->domWindow()) { | 370 if (m_frame->domWindow() && m_pageDismissalEventBeingDispatched
== NoDismissal) { |
371 if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide)
{ | 371 if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide)
{ |
372 m_pageDismissalEventBeingDispatched = PageHideDismissal; | 372 m_pageDismissalEventBeingDispatched = PageHideDismissal; |
373 m_frame->domWindow()->dispatchEvent(PageTransitionEvent:
:create(eventNames().pagehideEvent, m_frame->document()->inPageCache()), m_frame
->document()); | 373 m_frame->domWindow()->dispatchEvent(PageTransitionEvent:
:create(eventNames().pagehideEvent, m_frame->document()->inPageCache()), m_frame
->document()); |
374 } | 374 } |
375 if (!m_frame->document()->inPageCache()) { | 375 if (!m_frame->document()->inPageCache()) { |
376 RefPtr<Event> unloadEvent(Event::create(eventNames().unl
oadEvent, false, false)); | 376 RefPtr<Event> unloadEvent(Event::create(eventNames().unl
oadEvent, false, false)); |
377 // The DocumentLoader (and thus its DocumentLoadTiming)
might get destroyed | 377 // The DocumentLoader (and thus its DocumentLoadTiming)
might get destroyed |
378 // while dispatching the event, so protect it to prevent
writing the end | 378 // while dispatching the event, so protect it to prevent
writing the end |
379 // time into freed memory. | 379 // time into freed memory. |
380 RefPtr<DocumentLoader> documentLoader = m_provisionalDoc
umentLoader; | 380 RefPtr<DocumentLoader> documentLoader = m_provisionalDoc
umentLoader; |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 | 1671 |
1672 ASSERT(loader != m_documentLoader); | 1672 ASSERT(loader != m_documentLoader); |
1673 ASSERT(!loader || loader->frameLoader() == this); | 1673 ASSERT(!loader || loader->frameLoader() == this); |
1674 | 1674 |
1675 m_client->prepareForDataSourceReplacement(); | 1675 m_client->prepareForDataSourceReplacement(); |
1676 detachChildren(); | 1676 detachChildren(); |
1677 if (m_documentLoader) | 1677 if (m_documentLoader) |
1678 m_documentLoader->detachFromFrame(); | 1678 m_documentLoader->detachFromFrame(); |
1679 | 1679 |
1680 m_documentLoader = loader; | 1680 m_documentLoader = loader; |
| 1681 |
| 1682 // The following abomination is brought to you by the unload event. |
| 1683 // The detachChildren() call above may trigger a child frame's unload event, |
| 1684 // which could do something obnoxious like call document.write("") on |
| 1685 // the main frame, which results in detaching children while detaching child
ren. |
| 1686 // This can cause the new m_documentLoader to be detached from its Frame*, b
ut still |
| 1687 // be alive. To make matters worse, DocumentLoaders with a null Frame* aren'
t supposed |
| 1688 // to happen when they're still alive (and many places below us on the stack
think the |
| 1689 // DocumentLoader is still usable). Ergo, we reattach loader to its Frame, a
nd pretend |
| 1690 // like nothing ever happened. |
| 1691 if (m_documentLoader && !m_documentLoader->frame()) { |
| 1692 ASSERT(!m_documentLoader->isLoading()); |
| 1693 m_documentLoader->setFrame(m_frame); |
| 1694 } |
1681 } | 1695 } |
1682 | 1696 |
1683 void FrameLoader::setPolicyDocumentLoader(DocumentLoader* loader) | 1697 void FrameLoader::setPolicyDocumentLoader(DocumentLoader* loader) |
1684 { | 1698 { |
1685 if (m_policyDocumentLoader == loader) | 1699 if (m_policyDocumentLoader == loader) |
1686 return; | 1700 return; |
1687 | 1701 |
1688 ASSERT(m_frame); | 1702 ASSERT(m_frame); |
1689 if (loader) | 1703 if (loader) |
1690 loader->setFrame(m_frame); | 1704 loader->setFrame(m_frame); |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 history()->updateForFrameLoadCompleted(); | 2355 history()->updateForFrameLoadCompleted(); |
2342 | 2356 |
2343 // After a canceled provisional load, firstLayoutDone is false. | 2357 // After a canceled provisional load, firstLayoutDone is false. |
2344 // Reset it to true if we're displaying a page. | 2358 // Reset it to true if we're displaying a page. |
2345 if (m_documentLoader && m_stateMachine.committedFirstRealDocumentLoad() && !
m_stateMachine.isDisplayingInitialEmptyDocument() && !m_stateMachine.firstLayout
Done()) | 2359 if (m_documentLoader && m_stateMachine.committedFirstRealDocumentLoad() && !
m_stateMachine.isDisplayingInitialEmptyDocument() && !m_stateMachine.firstLayout
Done()) |
2346 m_stateMachine.advanceTo(FrameLoaderStateMachine::FirstLayoutDone); | 2360 m_stateMachine.advanceTo(FrameLoaderStateMachine::FirstLayoutDone); |
2347 } | 2361 } |
2348 | 2362 |
2349 void FrameLoader::detachChildren() | 2363 void FrameLoader::detachChildren() |
2350 { | 2364 { |
2351 // FIXME: Is it really necessary to do this in reverse order? | 2365 typedef Vector<RefPtr<Frame> > FrameVector; |
2352 Frame* previous; | 2366 FrameVector childrenToDetach; |
2353 for (Frame* child = m_frame->tree()->lastChild(); child; child = previous) { | 2367 childrenToDetach.reserveCapacity(m_frame->tree()->childCount()); |
2354 previous = child->tree()->previousSibling(); | 2368 for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree
()->previousSibling()) |
2355 child->loader()->detachFromParent(); | 2369 childrenToDetach.append(child); |
2356 } | 2370 FrameVector::iterator end = childrenToDetach.end(); |
| 2371 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; it++) |
| 2372 (*it)->loader()->detachFromParent(); |
2357 } | 2373 } |
2358 | 2374 |
2359 void FrameLoader::closeAndRemoveChild(Frame* child) | 2375 void FrameLoader::closeAndRemoveChild(Frame* child) |
2360 { | 2376 { |
2361 child->tree()->detachFromParent(); | 2377 child->tree()->detachFromParent(); |
2362 | 2378 |
2363 child->setView(0); | 2379 child->setView(0); |
2364 if (child->ownerElement() && child->page()) | 2380 if (child->ownerElement() && child->page()) |
2365 child->page()->decrementFrameCount(); | 2381 child->page()->decrementFrameCount(); |
2366 // FIXME: The page isn't being destroyed, so it's not right to call a functi
on named pageDestroyed(). | 2382 // FIXME: The page isn't being destroyed, so it's not right to call a functi
on named pageDestroyed(). |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3303 windowRect.setHeight(features.height + (windowRect.height() - pageSize.h
eight())); | 3319 windowRect.setHeight(features.height + (windowRect.height() - pageSize.h
eight())); |
3304 page->chrome()->setWindowRect(windowRect); | 3320 page->chrome()->setWindowRect(windowRect); |
3305 | 3321 |
3306 page->chrome()->show(); | 3322 page->chrome()->show(); |
3307 | 3323 |
3308 created = true; | 3324 created = true; |
3309 return frame; | 3325 return frame; |
3310 } | 3326 } |
3311 | 3327 |
3312 } // namespace WebCore | 3328 } // namespace WebCore |
OLD | NEW |