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

Side by Side Diff: Source/core/frame/DOMWindow.cpp

Issue 292503006: Oilpan: add [WillBeGarbageCollected] for Node. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tidy up removeAllEventListeners() usage from DOMWindow dtor Created 6 years, 7 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
« Source/core/frame/DOMWindow.h ('K') | « Source/core/frame/DOMWindow.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (!m_document) 338 if (!m_document)
339 return; 339 return;
340 340
341 if (m_document->isActive()) { 341 if (m_document->isActive()) {
342 // FIXME: We don't call willRemove here. Why is that OK? 342 // FIXME: We don't call willRemove here. Why is that OK?
343 // This detach() call is also mostly redundant. Most of the calls to 343 // This detach() call is also mostly redundant. Most of the calls to
344 // this function come via DocumentLoader::createWriterFor, which 344 // this function come via DocumentLoader::createWriterFor, which
345 // always detaches the previous Document first. Only XSLTProcessor 345 // always detaches the previous Document first. Only XSLTProcessor
346 // depends on this detach() call, so it seems like there's some room 346 // depends on this detach() call, so it seems like there's some room
347 // for cleanup. 347 // for cleanup.
348 m_document->detach(); 348 m_document->detach();
haraken 2014/05/23 20:53:58 I'm not yet fully convinced about this one. Would
sof 2014/05/23 21:00:15 I don't have a better answer than the one given ea
sof 2014/05/24 05:51:00 Consider the following steps: - A DOMWindow can a
349 } 349 }
350 350
351 // FIXME: This should be part of ActiveDOM Object shutdown 351 // FIXME: This should be part of ActiveDOMObject shutdown
352 clearEventQueue(); 352 clearEventQueue();
353 353
354 m_document->clearDOMWindow(); 354 m_document->clearDOMWindow();
355 m_document = nullptr; 355 m_document = nullptr;
356 } 356 }
357 357
358 void DOMWindow::clearEventQueue() 358 void DOMWindow::clearEventQueue()
359 { 359 {
360 if (!m_eventQueue) 360 if (!m_eventQueue)
361 return; 361 return;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 enqueuePopstateEvent(stateObject); 482 enqueuePopstateEvent(stateObject);
483 else 483 else
484 m_pendingStateObject = stateObject; 484 m_pendingStateObject = stateObject;
485 } 485 }
486 486
487 DOMWindow::~DOMWindow() 487 DOMWindow::~DOMWindow()
488 { 488 {
489 ASSERT(m_hasBeenReset); 489 ASSERT(m_hasBeenReset);
490 reset(); 490 reset();
491 491
492 removeAllEventListeners(); 492 #if ENABLE(OILPAN)
493 // Oilpan: the frame host and document objects are
494 // also garbage collected; cannot notify these
495 // when removing event listeners.
496 removeAllEventListeners(DoNotBroadcastListenerRemoval);
493 497
494 #if ENABLE(OILPAN) 498 // FIXME: This should be part of ActiveDOMObject shutdown
495 ASSERT(m_document->isDisposed()); 499 clearEventQueue();
haraken 2014/05/23 20:53:58 Just help me understand: Why do we need to remove
sof 2014/05/24 05:51:00 It was safe with m_document being a RefPtr<>, no l
sof 2014/05/24 06:53:11 Done.
496 #else 500 #else
501 removeAllEventListeners(DoBroadcastListenerRemoval);
502
497 ASSERT(m_document->isStopped()); 503 ASSERT(m_document->isStopped());
504 clearDocument();
498 #endif 505 #endif
499
500 clearDocument();
501 } 506 }
502 507
503 const AtomicString& DOMWindow::interfaceName() const 508 const AtomicString& DOMWindow::interfaceName() const
504 { 509 {
505 return EventTargetNames::DOMWindow; 510 return EventTargetNames::DOMWindow;
506 } 511 }
507 512
508 ExecutionContext* DOMWindow::executionContext() const 513 ExecutionContext* DOMWindow::executionContext() const
509 { 514 {
510 return m_document.get(); 515 return m_document.get();
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 1611 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
1607 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat chEventOnWindow(frame(), *event, this); 1612 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat chEventOnWindow(frame(), *event, this);
1608 1613
1609 bool result = fireEventListeners(event.get()); 1614 bool result = fireEventListeners(event.get());
1610 1615
1611 InspectorInstrumentation::didDispatchEventOnWindow(cookie); 1616 InspectorInstrumentation::didDispatchEventOnWindow(cookie);
1612 1617
1613 return result; 1618 return result;
1614 } 1619 }
1615 1620
1616 void DOMWindow::removeAllEventListeners() 1621 void DOMWindow::removeAllEventListeners(BroadcastListenerRemoval mode)
1617 { 1622 {
1618 EventTarget::removeAllEventListeners(); 1623 EventTarget::removeAllEventListeners();
1619 1624
1620 lifecycleNotifier().notifyRemoveAllEventListeners(this); 1625 lifecycleNotifier().notifyRemoveAllEventListeners(this);
1621 1626
1622 if (m_frame && m_frame->host()) 1627 if (mode == DoBroadcastListenerRemoval) {
1623 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this) ; 1628 if (m_frame && m_frame->host())
1629 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*t his);
1624 1630
1625 if (Document* document = this->document()) 1631 if (Document* document = this->document())
1626 document->didClearTouchEventHandlers(document); 1632 document->didClearTouchEventHandlers(document);
1633 }
1627 1634
1628 removeAllUnloadEventListeners(this); 1635 removeAllUnloadEventListeners(this);
1629 removeAllBeforeUnloadEventListeners(this); 1636 removeAllBeforeUnloadEventListeners(this);
1630 } 1637 }
1631 1638
1639 void DOMWindow::removeAllEventListeners()
1640 {
1641 removeAllEventListeners(DoBroadcastListenerRemoval);
1642 }
1643
1632 void DOMWindow::finishedLoading() 1644 void DOMWindow::finishedLoading()
1633 { 1645 {
1634 if (m_shouldPrintWhenFinishedLoading) { 1646 if (m_shouldPrintWhenFinishedLoading) {
1635 m_shouldPrintWhenFinishedLoading = false; 1647 m_shouldPrintWhenFinishedLoading = false;
1636 print(); 1648 print();
1637 } 1649 }
1638 } 1650 }
1639 1651
1640 void DOMWindow::setLocation(const String& urlString, DOMWindow* callingWindow, D OMWindow* enteredWindow, SetLocationLocking locking) 1652 void DOMWindow::setLocation(const String& urlString, DOMWindow* callingWindow, D OMWindow* enteredWindow, SetLocationLocking locking)
1641 { 1653 {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); 1880 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier());
1869 } 1881 }
1870 1882
1871 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() 1883 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier()
1872 { 1884 {
1873 return DOMWindowLifecycleNotifier::create(this); 1885 return DOMWindowLifecycleNotifier::create(this);
1874 } 1886 }
1875 1887
1876 void DOMWindow::trace(Visitor* visitor) 1888 void DOMWindow::trace(Visitor* visitor)
1877 { 1889 {
1890 visitor->trace(m_document);
1878 visitor->trace(m_screen); 1891 visitor->trace(m_screen);
1879 visitor->trace(m_history); 1892 visitor->trace(m_history);
1880 visitor->trace(m_locationbar); 1893 visitor->trace(m_locationbar);
1881 visitor->trace(m_menubar); 1894 visitor->trace(m_menubar);
1882 visitor->trace(m_personalbar); 1895 visitor->trace(m_personalbar);
1883 visitor->trace(m_scrollbars); 1896 visitor->trace(m_scrollbars);
1884 visitor->trace(m_statusbar); 1897 visitor->trace(m_statusbar);
1885 visitor->trace(m_toolbar); 1898 visitor->trace(m_toolbar);
1886 visitor->trace(m_console); 1899 visitor->trace(m_console);
1887 visitor->trace(m_navigator); 1900 visitor->trace(m_navigator);
1888 visitor->trace(m_location); 1901 visitor->trace(m_location);
1889 visitor->trace(m_media); 1902 visitor->trace(m_media);
1890 visitor->trace(m_sessionStorage); 1903 visitor->trace(m_sessionStorage);
1891 visitor->trace(m_localStorage); 1904 visitor->trace(m_localStorage);
1892 visitor->trace(m_applicationCache); 1905 visitor->trace(m_applicationCache);
1893 visitor->trace(m_performance); 1906 visitor->trace(m_performance);
1894 visitor->trace(m_css); 1907 visitor->trace(m_css);
1895 WillBeHeapSupplementable<DOMWindow>::trace(visitor); 1908 WillBeHeapSupplementable<DOMWindow>::trace(visitor);
1896 } 1909 }
1897 1910
1898 } // namespace WebCore 1911 } // namespace WebCore
OLDNEW
« Source/core/frame/DOMWindow.h ('K') | « Source/core/frame/DOMWindow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698