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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2134063002: Remove DOMWindowLifecycleObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 5 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, 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 492 }
493 493
494 MediaQueryList* LocalDOMWindow::matchMedia(const String& media) 494 MediaQueryList* LocalDOMWindow::matchMedia(const String& media)
495 { 495 {
496 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null ptr; 496 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null ptr;
497 } 497 }
498 498
499 void LocalDOMWindow::willDetachFrameHost() 499 void LocalDOMWindow::willDetachFrameHost()
500 { 500 {
501 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); 501 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this);
502 LocalDOMWindow::notifyContextDestroyed();
503 } 502 }
504 503
505 void LocalDOMWindow::frameDestroyed() 504 void LocalDOMWindow::frameDestroyed()
506 { 505 {
507 willDestroyDocumentInFrame(); 506 willDestroyDocumentInFrame();
508 resetLocation(); 507 resetLocation();
509 m_properties.clear(); 508 m_properties.clear();
510 removeAllEventListeners(); 509 removeAllEventListeners();
511 } 510 }
512 511
(...skipping 12 matching lines...) Expand all
525 void LocalDOMWindow::registerProperty(DOMWindowProperty* property) 524 void LocalDOMWindow::registerProperty(DOMWindowProperty* property)
526 { 525 {
527 m_properties.add(property); 526 m_properties.add(property);
528 } 527 }
529 528
530 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property) 529 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property)
531 { 530 {
532 m_properties.remove(property); 531 m_properties.remove(property);
533 } 532 }
534 533
534 void LocalDOMWindow::registerEventListenerObserver(EventListenerObserver* eventL istenerObserver)
535 {
536 m_eventListenerObservers.add(eventListenerObserver);
537 }
538
535 void LocalDOMWindow::reset() 539 void LocalDOMWindow::reset()
536 { 540 {
537 m_frameObserver->contextDestroyed(); 541 m_frameObserver->contextDestroyed();
538 542
539 m_screen = nullptr; 543 m_screen = nullptr;
540 m_history = nullptr; 544 m_history = nullptr;
541 m_locationbar = nullptr; 545 m_locationbar = nullptr;
542 m_menubar = nullptr; 546 m_menubar = nullptr;
543 m_personalbar = nullptr; 547 m_personalbar = nullptr;
544 m_scrollbars = nullptr; 548 m_scrollbars = nullptr;
545 m_statusbar = nullptr; 549 m_statusbar = nullptr;
546 m_toolbar = nullptr; 550 m_toolbar = nullptr;
547 m_navigator = nullptr; 551 m_navigator = nullptr;
548 m_media = nullptr; 552 m_media = nullptr;
549 m_customElements = nullptr; 553 m_customElements = nullptr;
550 m_applicationCache = nullptr; 554 m_applicationCache = nullptr;
551
552 LocalDOMWindow::notifyContextDestroyed();
553 } 555 }
554 556
555 void LocalDOMWindow::sendOrientationChangeEvent() 557 void LocalDOMWindow::sendOrientationChangeEvent()
556 { 558 {
557 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 559 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled());
558 ASSERT(frame()->isMainFrame()); 560 ASSERT(frame()->isMainFrame());
559 561
560 // Before dispatching the event, build a list of all frames in the page 562 // Before dispatching the event, build a list of all frames in the page
561 // to send the event to, to mitigate side effects from event handlers 563 // to send the event to, to mitigate side effects from event handlers
562 // potentially interfering with others. 564 // potentially interfering with others.
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 1362
1361 void LocalDOMWindow::addedEventListener(const AtomicString& eventType, Registere dEventListener& registeredListener) 1363 void LocalDOMWindow::addedEventListener(const AtomicString& eventType, Registere dEventListener& registeredListener)
1362 { 1364 {
1363 DOMWindow::addedEventListener(eventType, registeredListener); 1365 DOMWindow::addedEventListener(eventType, registeredListener);
1364 if (frame() && frame()->host()) 1366 if (frame() && frame()->host())
1365 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype, registeredListener.options()); 1367 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype, registeredListener.options());
1366 1368
1367 if (Document* document = this->document()) 1369 if (Document* document = this->document())
1368 document->addListenerTypeIfNeeded(eventType); 1370 document->addListenerTypeIfNeeded(eventType);
1369 1371
1370 notifyAddEventListener(this, eventType); 1372 for (auto& it : m_eventListenerObservers) {
1373 it->didAddEventListener(this, eventType);
1374 }
1371 1375
1372 if (eventType == EventTypeNames::unload) { 1376 if (eventType == EventTypeNames::unload) {
1373 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); 1377 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered);
1374 addUnloadEventListener(this); 1378 addUnloadEventListener(this);
1375 } else if (eventType == EventTypeNames::beforeunload) { 1379 } else if (eventType == EventTypeNames::beforeunload) {
1376 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered ); 1380 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered );
1377 if (allowsBeforeUnloadListeners(this)) { 1381 if (allowsBeforeUnloadListeners(this)) {
1378 // This is confusingly named. It doesn't actually add the listener. It just increments a count 1382 // This is confusingly named. It doesn't actually add the listener. It just increments a count
1379 // so that we know we have listeners registered for the purposes of determining if we can 1383 // so that we know we have listeners registered for the purposes of determining if we can
1380 // fast terminate the renderer process. 1384 // fast terminate the renderer process.
1381 addBeforeUnloadEventListener(this); 1385 addBeforeUnloadEventListener(this);
1382 } else { 1386 } else {
1383 // Subframes return false from allowsBeforeUnloadListeners. 1387 // Subframes return false from allowsBeforeUnloadListeners.
1384 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); 1388 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered);
1385 } 1389 }
1386 } 1390 }
1387 } 1391 }
1388 1392
1389 void LocalDOMWindow::removedEventListener(const AtomicString& eventType, const R egisteredEventListener& registeredListener) 1393 void LocalDOMWindow::removedEventListener(const AtomicString& eventType, const R egisteredEventListener& registeredListener)
1390 { 1394 {
1391 DOMWindow::removedEventListener(eventType, registeredListener); 1395 DOMWindow::removedEventListener(eventType, registeredListener);
1392 if (frame() && frame()->host()) 1396 if (frame() && frame()->host())
1393 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType, registeredListener.options()); 1397 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType, registeredListener.options());
1394 1398
1395 notifyRemoveEventListener(this, eventType); 1399 for (auto& it : m_eventListenerObservers) {
1400 it->didRemoveEventListener(this, eventType);
1401 }
1396 1402
1397 if (eventType == EventTypeNames::unload) { 1403 if (eventType == EventTypeNames::unload) {
1398 removeUnloadEventListener(this); 1404 removeUnloadEventListener(this);
1399 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { 1405 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) {
1400 removeBeforeUnloadEventListener(this); 1406 removeBeforeUnloadEventListener(this);
1401 } 1407 }
1402 } 1408 }
1403 1409
1404 void LocalDOMWindow::dispatchLoadEvent() 1410 void LocalDOMWindow::dispatchLoadEvent()
1405 { 1411 {
(...skipping 29 matching lines...) Expand all
1435 event->setEventPhase(Event::AT_TARGET); 1441 event->setEventPhase(Event::AT_TARGET);
1436 1442
1437 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*event)); 1443 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*event));
1438 return fireEventListeners(event); 1444 return fireEventListeners(event);
1439 } 1445 }
1440 1446
1441 void LocalDOMWindow::removeAllEventListeners() 1447 void LocalDOMWindow::removeAllEventListeners()
1442 { 1448 {
1443 EventTarget::removeAllEventListeners(); 1449 EventTarget::removeAllEventListeners();
1444 1450
1445 notifyRemoveAllEventListeners(this); 1451 for (auto& it : m_eventListenerObservers) {
1452 it->didRemoveAllEventListeners(this);
1453 }
1454
1446 if (frame() && frame()->host()) 1455 if (frame() && frame()->host())
1447 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this) ; 1456 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this) ;
1448 1457
1449 removeAllUnloadEventListeners(this); 1458 removeAllUnloadEventListeners(this);
1450 removeAllBeforeUnloadEventListeners(this); 1459 removeAllBeforeUnloadEventListeners(this);
1451 } 1460 }
1452 1461
1453 void LocalDOMWindow::finishedLoading() 1462 void LocalDOMWindow::finishedLoading()
1454 { 1463 {
1455 if (m_shouldPrintWhenFinishedLoading) { 1464 if (m_shouldPrintWhenFinishedLoading) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 visitor->trace(m_scrollbars); 1549 visitor->trace(m_scrollbars);
1541 visitor->trace(m_statusbar); 1550 visitor->trace(m_statusbar);
1542 visitor->trace(m_toolbar); 1551 visitor->trace(m_toolbar);
1543 visitor->trace(m_navigator); 1552 visitor->trace(m_navigator);
1544 visitor->trace(m_media); 1553 visitor->trace(m_media);
1545 visitor->trace(m_customElements); 1554 visitor->trace(m_customElements);
1546 visitor->trace(m_applicationCache); 1555 visitor->trace(m_applicationCache);
1547 visitor->trace(m_eventQueue); 1556 visitor->trace(m_eventQueue);
1548 visitor->trace(m_postMessageTimers); 1557 visitor->trace(m_postMessageTimers);
1549 visitor->trace(m_visualViewport); 1558 visitor->trace(m_visualViewport);
1559 visitor->trace(m_eventListenerObservers);
1550 DOMWindow::trace(visitor); 1560 DOMWindow::trace(visitor);
1551 Supplementable<LocalDOMWindow>::trace(visitor); 1561 Supplementable<LocalDOMWindow>::trace(visitor);
1552 DOMWindowLifecycleNotifier::trace(visitor);
1553 } 1562 }
1554 1563
1555 LocalFrame* LocalDOMWindow::frame() const 1564 LocalFrame* LocalDOMWindow::frame() const
1556 { 1565 {
1557 // If the LocalDOMWindow still has a frame reference, that frame must point 1566 // If the LocalDOMWindow still has a frame reference, that frame must point
1558 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1567 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1559 // where script execution leaks between different LocalDOMWindows. 1568 // where script execution leaks between different LocalDOMWindows.
1560 if (m_frameObserver->frame()) 1569 if (m_frameObserver->frame())
1561 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this); 1570 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this);
1562 return m_frameObserver->frame(); 1571 return m_frameObserver->frame();
1563 } 1572 }
1564 1573
1565 } // namespace blink 1574 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalDOMWindow.h ('k') | third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698