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

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

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tests now seem to pass. Created 6 years, 9 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 if (m_frame->page() && m_frame->view()) { 399 if (m_frame->page() && m_frame->view()) {
400 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) { 400 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) {
401 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_frame- >view(), HorizontalScrollbar); 401 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_frame- >view(), HorizontalScrollbar);
402 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_frame- >view(), VerticalScrollbar); 402 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_frame- >view(), VerticalScrollbar);
403 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_frame->vi ew()); 403 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_frame->vi ew());
404 } 404 }
405 } 405 }
406 406
407 m_frame->selection().updateSecureKeyboardEntryIfActive(); 407 m_frame->selection().updateSecureKeyboardEntryIfActive();
408
409 if (m_frame->isMainFrame()) {
410 m_frame->notifyChromeClientWheelEventHandlerCountChanged();
411 if (m_document->hasTouchEventHandlers())
412 m_frame->host()->chrome().client().needTouchEvents(true);
413 }
414
415 return m_document; 408 return m_document;
416 } 409 }
417 410
418 EventQueue* DOMWindow::eventQueue() const 411 EventQueue* DOMWindow::eventQueue() const
419 { 412 {
420 return m_eventQueue.get(); 413 return m_eventQueue.get();
421 } 414 }
422 415
423 void DOMWindow::enqueueWindowEvent(PassRefPtr<Event> event) 416 void DOMWindow::enqueueWindowEvent(PassRefPtr<Event> event)
424 { 417 {
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 window->sessionStorage(IGNORE_EXCEPTION); 1503 window->sessionStorage(IGNORE_EXCEPTION);
1511 } 1504 }
1512 1505
1513 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<Event Listener> listener, bool useCapture) 1506 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<Event Listener> listener, bool useCapture)
1514 { 1507 {
1515 if (!EventTarget::addEventListener(eventType, listener, useCapture)) 1508 if (!EventTarget::addEventListener(eventType, listener, useCapture))
1516 return false; 1509 return false;
1517 1510
1518 if (Document* document = this->document()) { 1511 if (Document* document = this->document()) {
1519 document->addListenerTypeIfNeeded(eventType); 1512 document->addListenerTypeIfNeeded(eventType);
1520 if (isTouchEventType(eventType)) 1513 if (eventType == EventTypeNames::storage)
1521 document->didAddTouchEventHandler(document);
1522 else if (eventType == EventTypeNames::storage)
1523 didAddStorageEventListener(this); 1514 didAddStorageEventListener(this);
1524 } 1515 }
1525 1516
1526 lifecycleNotifier().notifyAddEventListener(this, eventType); 1517 lifecycleNotifier().notifyAddEventListener(this, eventType);
1527 1518
1528 if (eventType == EventTypeNames::unload) { 1519 if (eventType == EventTypeNames::unload) {
1529 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); 1520 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered);
1530 addUnloadEventListener(this); 1521 addUnloadEventListener(this);
1531 } else if (eventType == EventTypeNames::beforeunload) { 1522 } else if (eventType == EventTypeNames::beforeunload) {
1532 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered ); 1523 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered );
1533 if (allowsBeforeUnloadListeners(this)) { 1524 if (allowsBeforeUnloadListeners(this)) {
1534 // This is confusingly named. It doesn't actually add the listener. It just increments a count 1525 // This is confusingly named. It doesn't actually add the listener. It just increments a count
1535 // so that we know we have listeners registered for the purposes of determining if we can 1526 // so that we know we have listeners registered for the purposes of determining if we can
1536 // fast terminate the renderer process. 1527 // fast terminate the renderer process.
1537 addBeforeUnloadEventListener(this); 1528 addBeforeUnloadEventListener(this);
1538 } else { 1529 } else {
1539 // Subframes return false from allowsBeforeUnloadListeners. 1530 // Subframes return false from allowsBeforeUnloadListeners.
1540 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); 1531 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered);
1541 } 1532 }
1542 } 1533 }
1543 1534
1544 return true; 1535 return true;
1545 } 1536 }
1546 1537
1547 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture) 1538 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener * listener, bool useCapture)
1548 { 1539 {
1549 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) 1540 if (!EventTarget::removeEventListener(eventType, listener, useCapture))
1550 return false; 1541 return false;
1551 1542
1552 if (Document* document = this->document()) {
1553 if (isTouchEventType(eventType))
1554 document->didRemoveTouchEventHandler(document);
1555 }
1556
1557 lifecycleNotifier().notifyRemoveEventListener(this, eventType); 1543 lifecycleNotifier().notifyRemoveEventListener(this, eventType);
1558 1544
1559 if (eventType == EventTypeNames::unload) { 1545 if (eventType == EventTypeNames::unload) {
1560 removeUnloadEventListener(this); 1546 removeUnloadEventListener(this);
1561 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { 1547 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) {
1562 removeBeforeUnloadEventListener(this); 1548 removeBeforeUnloadEventListener(this);
1563 } 1549 }
1564 1550
1565 return true; 1551 return true;
1566 } 1552 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 1594
1609 return result; 1595 return result;
1610 } 1596 }
1611 1597
1612 void DOMWindow::removeAllEventListeners() 1598 void DOMWindow::removeAllEventListeners()
1613 { 1599 {
1614 EventTarget::removeAllEventListeners(); 1600 EventTarget::removeAllEventListeners();
1615 1601
1616 lifecycleNotifier().notifyRemoveAllEventListeners(this); 1602 lifecycleNotifier().notifyRemoveAllEventListeners(this);
1617 1603
1618 if (Document* document = this->document())
1619 document->didClearTouchEventHandlers(document);
1620
1621 removeAllUnloadEventListeners(this); 1604 removeAllUnloadEventListeners(this);
1622 removeAllBeforeUnloadEventListeners(this); 1605 removeAllBeforeUnloadEventListeners(this);
1623 } 1606 }
1624 1607
1625 void DOMWindow::finishedLoading() 1608 void DOMWindow::finishedLoading()
1626 { 1609 {
1627 if (m_shouldPrintWhenFinishedLoading) { 1610 if (m_shouldPrintWhenFinishedLoading) {
1628 m_shouldPrintWhenFinishedLoading = false; 1611 m_shouldPrintWhenFinishedLoading = false;
1629 print(); 1612 print();
1630 } 1613 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); 1844 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier());
1862 } 1845 }
1863 1846
1864 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() 1847 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier()
1865 { 1848 {
1866 return DOMWindowLifecycleNotifier::create(this); 1849 return DOMWindowLifecycleNotifier::create(this);
1867 } 1850 }
1868 1851
1869 1852
1870 } // namespace WebCore 1853 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698