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

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

Issue 38143002: Have LifecycleContext::lifecycleNotifier() return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 2 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
« no previous file with comments | « Source/core/frame/DOMWindow.h ('k') | Source/core/page/Page.h » ('j') | 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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 return false; 1436 return false;
1437 1437
1438 if (Document* document = this->document()) { 1438 if (Document* document = this->document()) {
1439 document->addListenerTypeIfNeeded(eventType); 1439 document->addListenerTypeIfNeeded(eventType);
1440 if (isTouchEventType(eventType)) 1440 if (isTouchEventType(eventType))
1441 document->didAddTouchEventHandler(document); 1441 document->didAddTouchEventHandler(document);
1442 else if (eventType == EventTypeNames::storage) 1442 else if (eventType == EventTypeNames::storage)
1443 didAddStorageEventListener(this); 1443 didAddStorageEventListener(this);
1444 } 1444 }
1445 1445
1446 lifecycleNotifier()->notifyAddEventListener(this, eventType); 1446 lifecycleNotifier().notifyAddEventListener(this, eventType);
1447 1447
1448 if (eventType == EventTypeNames::unload) { 1448 if (eventType == EventTypeNames::unload) {
1449 addUnloadEventListener(this); 1449 addUnloadEventListener(this);
1450 } else if (eventType == EventTypeNames::beforeunload) { 1450 } else if (eventType == EventTypeNames::beforeunload) {
1451 if (allowsBeforeUnloadListeners(this)) { 1451 if (allowsBeforeUnloadListeners(this)) {
1452 // This is confusingly named. It doesn't actually add the listener. It just increments a count 1452 // This is confusingly named. It doesn't actually add the listener. It just increments a count
1453 // so that we know we have listeners registered for the purposes of determining if we can 1453 // so that we know we have listeners registered for the purposes of determining if we can
1454 // fast terminate the renderer process. 1454 // fast terminate the renderer process.
1455 addBeforeUnloadEventListener(this); 1455 addBeforeUnloadEventListener(this);
1456 } else { 1456 } else {
(...skipping 11 matching lines...) Expand all
1468 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture) 1468 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture)
1469 { 1469 {
1470 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) 1470 if (!EventTarget::removeEventListener(eventType, listener, useCapture))
1471 return false; 1471 return false;
1472 1472
1473 if (Document* document = this->document()) { 1473 if (Document* document = this->document()) {
1474 if (isTouchEventType(eventType)) 1474 if (isTouchEventType(eventType))
1475 document->didRemoveTouchEventHandler(document); 1475 document->didRemoveTouchEventHandler(document);
1476 } 1476 }
1477 1477
1478 lifecycleNotifier()->notifyRemoveEventListener(this, eventType); 1478 lifecycleNotifier().notifyRemoveEventListener(this, eventType);
1479 1479
1480 if (eventType == EventTypeNames::unload) { 1480 if (eventType == EventTypeNames::unload) {
1481 removeUnloadEventListener(this); 1481 removeUnloadEventListener(this);
1482 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { 1482 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) {
1483 removeBeforeUnloadEventListener(this); 1483 removeBeforeUnloadEventListener(this);
1484 } else if (eventType == EventTypeNames::deviceorientation) { 1484 } else if (eventType == EventTypeNames::deviceorientation) {
1485 if (NewDeviceOrientationController* controller = NewDeviceOrientationCon troller::from(document())) 1485 if (NewDeviceOrientationController* controller = NewDeviceOrientationCon troller::from(document()))
1486 controller->stopUpdating(); 1486 controller->stopUpdating();
1487 } 1487 }
1488 1488
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 1528
1529 InspectorInstrumentation::didDispatchEventOnWindow(cookie); 1529 InspectorInstrumentation::didDispatchEventOnWindow(cookie);
1530 1530
1531 return result; 1531 return result;
1532 } 1532 }
1533 1533
1534 void DOMWindow::removeAllEventListeners() 1534 void DOMWindow::removeAllEventListeners()
1535 { 1535 {
1536 EventTarget::removeAllEventListeners(); 1536 EventTarget::removeAllEventListeners();
1537 1537
1538 lifecycleNotifier()->notifyRemoveAllEventListeners(this); 1538 lifecycleNotifier().notifyRemoveAllEventListeners(this);
1539 1539
1540 if (NewDeviceOrientationController* controller = NewDeviceOrientationControl ler::from(document())) 1540 if (NewDeviceOrientationController* controller = NewDeviceOrientationControl ler::from(document()))
1541 controller->stopUpdating(); 1541 controller->stopUpdating();
1542 if (Document* document = this->document()) 1542 if (Document* document = this->document())
1543 document->didRemoveEventTargetNode(document); 1543 document->didRemoveEventTargetNode(document);
1544 1544
1545 removeAllUnloadEventListeners(this); 1545 removeAllUnloadEventListeners(this);
1546 removeAllBeforeUnloadEventListeners(this); 1546 removeAllBeforeUnloadEventListeners(this);
1547 } 1547 }
1548 1548
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 if (!frame) 1765 if (!frame)
1766 return 0; 1766 return 0;
1767 1767
1768 Frame* child = frame->tree().scopedChild(index); 1768 Frame* child = frame->tree().scopedChild(index);
1769 if (child) 1769 if (child)
1770 return child->domWindow(); 1770 return child->domWindow();
1771 1771
1772 return 0; 1772 return 0;
1773 } 1773 }
1774 1774
1775 DOMWindowLifecycleNotifier* DOMWindow::lifecycleNotifier() 1775 DOMWindowLifecycleNotifier& DOMWindow::lifecycleNotifier()
1776 { 1776 {
1777 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN otifier()); 1777 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext::lifecycleN otifier());
1778 } 1778 }
1779 1779
1780 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() 1780 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier()
1781 { 1781 {
1782 return DOMWindowLifecycleNotifier::create(this); 1782 return DOMWindowLifecycleNotifier::create(this);
1783 } 1783 }
1784 1784
1785 1785
1786 } // namespace WebCore 1786 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/DOMWindow.h ('k') | Source/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698