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

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

Issue 1942723004: Change EventTarget callback APIs for add/RemoveEventListenerInternal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win32 signed/unsigned issue Created 4 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
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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 document->cancelIdleCallback(id); 1322 document->cancelIdleCallback(id);
1323 } 1323 }
1324 1324
1325 CustomElementsRegistry* LocalDOMWindow::customElements() const 1325 CustomElementsRegistry* LocalDOMWindow::customElements() const
1326 { 1326 {
1327 if (!m_customElements) 1327 if (!m_customElements)
1328 m_customElements = CustomElementsRegistry::create(); 1328 m_customElements = CustomElementsRegistry::create();
1329 return m_customElements.get(); 1329 return m_customElements.get();
1330 } 1330 }
1331 1331
1332 bool LocalDOMWindow::addEventListenerInternal(const AtomicString& eventType, Eve ntListener* listener, const EventListenerOptions& options) 1332 void LocalDOMWindow::addedEventListener(const AtomicString& eventType, Registere dEventListener& registeredListener)
1333 { 1333 {
1334 if (!EventTarget::addEventListenerInternal(eventType, listener, options)) 1334 DOMWindow::addedEventListener(eventType, registeredListener);
1335 return false; 1335 if (frame() && frame()->host())
1336 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype, registeredListener.options());
1336 1337
1337 if (frame() && frame()->host()) 1338 if (Document* document = this->document())
1338 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype, options);
1339
1340 if (Document* document = this->document()) {
1341 document->addListenerTypeIfNeeded(eventType); 1339 document->addListenerTypeIfNeeded(eventType);
1342 }
1343 1340
1344 notifyAddEventListener(this, eventType); 1341 notifyAddEventListener(this, eventType);
1345 1342
1346 if (eventType == EventTypeNames::unload) { 1343 if (eventType == EventTypeNames::unload) {
1347 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); 1344 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered);
1348 addUnloadEventListener(this); 1345 addUnloadEventListener(this);
1349 } else if (eventType == EventTypeNames::beforeunload) { 1346 } else if (eventType == EventTypeNames::beforeunload) {
1350 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered ); 1347 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered );
1351 if (allowsBeforeUnloadListeners(this)) { 1348 if (allowsBeforeUnloadListeners(this)) {
1352 // This is confusingly named. It doesn't actually add the listener. It just increments a count 1349 // This is confusingly named. It doesn't actually add the listener. It just increments a count
1353 // so that we know we have listeners registered for the purposes of determining if we can 1350 // so that we know we have listeners registered for the purposes of determining if we can
1354 // fast terminate the renderer process. 1351 // fast terminate the renderer process.
1355 addBeforeUnloadEventListener(this); 1352 addBeforeUnloadEventListener(this);
1356 } else { 1353 } else {
1357 // Subframes return false from allowsBeforeUnloadListeners. 1354 // Subframes return false from allowsBeforeUnloadListeners.
1358 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); 1355 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered);
1359 } 1356 }
1360 } 1357 }
1361
1362 return true;
1363 } 1358 }
1364 1359
1365 bool LocalDOMWindow::removeEventListenerInternal(const AtomicString& eventType, EventListener* listener, const EventListenerOptions& options) 1360 void LocalDOMWindow::removedEventListener(const AtomicString& eventType, const R egisteredEventListener& registeredListener)
1366 { 1361 {
1367 if (!EventTarget::removeEventListenerInternal(eventType, listener, options)) 1362 DOMWindow::removedEventListener(eventType, registeredListener);
1368 return false;
1369
1370 if (frame() && frame()->host()) 1363 if (frame() && frame()->host())
1371 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType, options); 1364 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType, registeredListener.options());
1372 1365
1373 notifyRemoveEventListener(this, eventType); 1366 notifyRemoveEventListener(this, eventType);
1374 1367
1375 if (eventType == EventTypeNames::unload) { 1368 if (eventType == EventTypeNames::unload) {
1376 removeUnloadEventListener(this); 1369 removeUnloadEventListener(this);
1377 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { 1370 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) {
1378 removeBeforeUnloadEventListener(this); 1371 removeBeforeUnloadEventListener(this);
1379 } 1372 }
1380
1381 return true;
1382 } 1373 }
1383 1374
1384 void LocalDOMWindow::dispatchLoadEvent() 1375 void LocalDOMWindow::dispatchLoadEvent()
1385 { 1376 {
1386 Event* loadEvent(Event::create(EventTypeNames::load)); 1377 Event* loadEvent(Event::create(EventTypeNames::load));
1387 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { 1378 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) {
1388 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching 1379 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching
1389 // the event, so protect it to prevent writing the end time into freed m emory. 1380 // the event, so protect it to prevent writing the end time into freed m emory.
1390 DocumentLoader* documentLoader = frame()->loader().documentLoader(); 1381 DocumentLoader* documentLoader = frame()->loader().documentLoader();
1391 DocumentLoadTiming& timing = documentLoader->timing(); 1382 DocumentLoadTiming& timing = documentLoader->timing();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 { 1528 {
1538 // If the LocalDOMWindow still has a frame reference, that frame must point 1529 // If the LocalDOMWindow still has a frame reference, that frame must point
1539 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1530 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1540 // where script execution leaks between different LocalDOMWindows. 1531 // where script execution leaks between different LocalDOMWindows.
1541 if (m_frameObserver->frame()) 1532 if (m_frameObserver->frame())
1542 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this); 1533 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this);
1543 return m_frameObserver->frame(); 1534 return m_frameObserver->frame();
1544 } 1535 }
1545 1536
1546 } // namespace blink 1537 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698