OLD | NEW |
---|---|
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 #include "core/events/DOMWindowEventQueue.h" | 52 #include "core/events/DOMWindowEventQueue.h" |
53 #include "core/events/EventListener.h" | 53 #include "core/events/EventListener.h" |
54 #include "core/events/HashChangeEvent.h" | 54 #include "core/events/HashChangeEvent.h" |
55 #include "core/events/MessageEvent.h" | 55 #include "core/events/MessageEvent.h" |
56 #include "core/events/PageTransitionEvent.h" | 56 #include "core/events/PageTransitionEvent.h" |
57 #include "core/events/PopStateEvent.h" | 57 #include "core/events/PopStateEvent.h" |
58 #include "core/frame/BarProp.h" | 58 #include "core/frame/BarProp.h" |
59 #include "core/frame/Console.h" | 59 #include "core/frame/Console.h" |
60 #include "core/frame/DOMPoint.h" | 60 #include "core/frame/DOMPoint.h" |
61 #include "core/frame/DOMWindowLifecycleNotifier.h" | 61 #include "core/frame/DOMWindowLifecycleNotifier.h" |
62 #include "core/frame/EventHandlerRegistry.h" | |
62 #include "core/frame/FrameConsole.h" | 63 #include "core/frame/FrameConsole.h" |
63 #include "core/frame/FrameHost.h" | 64 #include "core/frame/FrameHost.h" |
64 #include "core/frame/FrameView.h" | 65 #include "core/frame/FrameView.h" |
65 #include "core/frame/History.h" | 66 #include "core/frame/History.h" |
66 #include "core/frame/LocalFrame.h" | 67 #include "core/frame/LocalFrame.h" |
67 #include "core/frame/Location.h" | 68 #include "core/frame/Location.h" |
68 #include "core/frame/Navigator.h" | 69 #include "core/frame/Navigator.h" |
69 #include "core/frame/Screen.h" | 70 #include "core/frame/Screen.h" |
70 #include "core/frame/Settings.h" | 71 #include "core/frame/Settings.h" |
71 #include "core/html/HTMLFrameOwnerElement.h" | 72 #include "core/html/HTMLFrameOwnerElement.h" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 } | 522 } |
522 | 523 |
523 void DOMWindow::frameDestroyed() | 524 void DOMWindow::frameDestroyed() |
524 { | 525 { |
525 FrameDestructionObserver::frameDestroyed(); | 526 FrameDestructionObserver::frameDestroyed(); |
526 reset(); | 527 reset(); |
527 } | 528 } |
528 | 529 |
529 void DOMWindow::willDetachFrameHost() | 530 void DOMWindow::willDetachFrameHost() |
530 { | 531 { |
532 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); | |
531 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); | 533 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); |
532 } | 534 } |
533 | 535 |
534 void DOMWindow::willDestroyDocumentInFrame() | 536 void DOMWindow::willDestroyDocumentInFrame() |
535 { | 537 { |
536 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may | 538 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may |
537 // unregister themselves from the DOMWindow as a result of the call to willD estroyGlobalObjectInFrame. | 539 // unregister themselves from the DOMWindow as a result of the call to willD estroyGlobalObjectInFrame. |
538 Vector<DOMWindowProperty*> properties; | 540 Vector<DOMWindowProperty*> properties; |
539 copyToVector(m_properties, properties); | 541 copyToVector(m_properties, properties); |
540 for (size_t i = 0; i < properties.size(); ++i) | 542 for (size_t i = 0; i < properties.size(); ++i) |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 // simplify the work done by the system. | 1494 // simplify the work done by the system. |
1493 window->localStorage(IGNORE_EXCEPTION); | 1495 window->localStorage(IGNORE_EXCEPTION); |
1494 window->sessionStorage(IGNORE_EXCEPTION); | 1496 window->sessionStorage(IGNORE_EXCEPTION); |
1495 } | 1497 } |
1496 | 1498 |
1497 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<Event Listener> listener, bool useCapture) | 1499 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<Event Listener> listener, bool useCapture) |
1498 { | 1500 { |
1499 if (!EventTarget::addEventListener(eventType, listener, useCapture)) | 1501 if (!EventTarget::addEventListener(eventType, listener, useCapture)) |
1500 return false; | 1502 return false; |
1501 | 1503 |
1504 if (m_frame && m_frame->host()) | |
1505 m_frame->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype); | |
1506 | |
1502 if (Document* document = this->document()) { | 1507 if (Document* document = this->document()) { |
1503 document->addListenerTypeIfNeeded(eventType); | 1508 document->addListenerTypeIfNeeded(eventType); |
1504 if (isTouchEventType(eventType)) | 1509 if (isTouchEventType(eventType)) |
1505 document->didAddTouchEventHandler(document); | 1510 document->didAddTouchEventHandler(document); |
1506 else if (eventType == EventTypeNames::storage) | 1511 else if (eventType == EventTypeNames::storage) |
1507 didAddStorageEventListener(this); | 1512 didAddStorageEventListener(this); |
1508 } | 1513 } |
1509 | 1514 |
1510 lifecycleNotifier().notifyAddEventListener(this, eventType); | 1515 lifecycleNotifier().notifyAddEventListener(this, eventType); |
abarth-chromium
2014/05/07 17:14:02
We can't listen for this notification via this pat
| |
1511 | 1516 |
1512 if (eventType == EventTypeNames::unload) { | 1517 if (eventType == EventTypeNames::unload) { |
1513 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); | 1518 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); |
1514 addUnloadEventListener(this); | 1519 addUnloadEventListener(this); |
1515 } else if (eventType == EventTypeNames::beforeunload) { | 1520 } else if (eventType == EventTypeNames::beforeunload) { |
1516 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered ); | 1521 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered ); |
1517 if (allowsBeforeUnloadListeners(this)) { | 1522 if (allowsBeforeUnloadListeners(this)) { |
1518 // This is confusingly named. It doesn't actually add the listener. It just increments a count | 1523 // This is confusingly named. It doesn't actually add the listener. It just increments a count |
1519 // so that we know we have listeners registered for the purposes of determining if we can | 1524 // so that we know we have listeners registered for the purposes of determining if we can |
1520 // fast terminate the renderer process. | 1525 // fast terminate the renderer process. |
1521 addBeforeUnloadEventListener(this); | 1526 addBeforeUnloadEventListener(this); |
1522 } else { | 1527 } else { |
1523 // Subframes return false from allowsBeforeUnloadListeners. | 1528 // Subframes return false from allowsBeforeUnloadListeners. |
1524 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); | 1529 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); |
1525 } | 1530 } |
1526 } | 1531 } |
1527 | 1532 |
1528 return true; | 1533 return true; |
1529 } | 1534 } |
1530 | 1535 |
1531 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture) | 1536 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture) |
1532 { | 1537 { |
1533 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) | 1538 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) |
1534 return false; | 1539 return false; |
1535 | 1540 |
1541 if (m_frame && m_frame->host()) | |
1542 m_frame->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType); | |
1543 | |
1536 if (Document* document = this->document()) { | 1544 if (Document* document = this->document()) { |
1537 if (isTouchEventType(eventType)) | 1545 if (isTouchEventType(eventType)) |
1538 document->didRemoveTouchEventHandler(document); | 1546 document->didRemoveTouchEventHandler(document); |
1539 } | 1547 } |
1540 | 1548 |
1541 lifecycleNotifier().notifyRemoveEventListener(this, eventType); | 1549 lifecycleNotifier().notifyRemoveEventListener(this, eventType); |
1542 | 1550 |
1543 if (eventType == EventTypeNames::unload) { | 1551 if (eventType == EventTypeNames::unload) { |
1544 removeUnloadEventListener(this); | 1552 removeUnloadEventListener(this); |
1545 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { | 1553 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1596 | 1604 |
1597 return result; | 1605 return result; |
1598 } | 1606 } |
1599 | 1607 |
1600 void DOMWindow::removeAllEventListeners() | 1608 void DOMWindow::removeAllEventListeners() |
1601 { | 1609 { |
1602 EventTarget::removeAllEventListeners(); | 1610 EventTarget::removeAllEventListeners(); |
1603 | 1611 |
1604 lifecycleNotifier().notifyRemoveAllEventListeners(this); | 1612 lifecycleNotifier().notifyRemoveAllEventListeners(this); |
1605 | 1613 |
1614 if (m_frame && m_frame->host()) | |
1615 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this) ; | |
1616 | |
1606 if (Document* document = this->document()) | 1617 if (Document* document = this->document()) |
1607 document->didClearTouchEventHandlers(document); | 1618 document->didClearTouchEventHandlers(document); |
1608 | 1619 |
1609 removeAllUnloadEventListeners(this); | 1620 removeAllUnloadEventListeners(this); |
1610 removeAllBeforeUnloadEventListeners(this); | 1621 removeAllBeforeUnloadEventListeners(this); |
1611 } | 1622 } |
1612 | 1623 |
1613 void DOMWindow::finishedLoading() | 1624 void DOMWindow::finishedLoading() |
1614 { | 1625 { |
1615 if (m_shouldPrintWhenFinishedLoading) { | 1626 if (m_shouldPrintWhenFinishedLoading) { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1870 visitor->trace(m_media); | 1881 visitor->trace(m_media); |
1871 visitor->trace(m_sessionStorage); | 1882 visitor->trace(m_sessionStorage); |
1872 visitor->trace(m_localStorage); | 1883 visitor->trace(m_localStorage); |
1873 visitor->trace(m_applicationCache); | 1884 visitor->trace(m_applicationCache); |
1874 visitor->trace(m_performance); | 1885 visitor->trace(m_performance); |
1875 visitor->trace(m_css); | 1886 visitor->trace(m_css); |
1876 WillBeHeapSupplementable<DOMWindow>::trace(visitor); | 1887 WillBeHeapSupplementable<DOMWindow>::trace(visitor); |
1877 } | 1888 } |
1878 | 1889 |
1879 } // namespace WebCore | 1890 } // namespace WebCore |
OLD | NEW |