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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 { | 375 { |
376 if (!frame) | 376 if (!frame) |
377 return false; | 377 return false; |
378 FrameHost* host = frame->host(); | 378 FrameHost* host = frame->host(); |
379 if (!host) | 379 if (!host) |
380 return false; | 380 return false; |
381 return host->chrome().canRunModalNow(); | 381 return host->chrome().canRunModalNow(); |
382 } | 382 } |
383 | 383 |
384 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) | 384 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) |
385 : DOMWindowLifecycleNotifier(this) | 385 : m_frameObserver(WindowFrameObserver::create(this, frame)) |
386 , m_frameObserver(WindowFrameObserver::create(this, frame)) | |
387 , m_shouldPrintWhenFinishedLoading(false) | 386 , m_shouldPrintWhenFinishedLoading(false) |
388 #if ENABLE(ASSERT) | 387 #if ENABLE(ASSERT) |
389 , m_hasBeenReset(false) | 388 , m_hasBeenReset(false) |
390 #endif | 389 #endif |
391 { | 390 { |
392 } | 391 } |
393 | 392 |
394 void LocalDOMWindow::clearDocument() | 393 void LocalDOMWindow::clearDocument() |
395 { | 394 { |
396 if (!m_document) | 395 if (!m_document) |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 { | 893 { |
895 if (!frame()) | 894 if (!frame()) |
896 return; | 895 return; |
897 | 896 |
898 FrameHost* host = frame()->host(); | 897 FrameHost* host = frame()->host(); |
899 if (!host) | 898 if (!host) |
900 return; | 899 return; |
901 | 900 |
902 ASSERT(context); | 901 ASSERT(context); |
903 | 902 |
904 bool allowFocus = context->isWindowInteractionAllowed(); | 903 bool allowFocus = context->isWindowFocusAllowed(); |
905 if (allowFocus) { | 904 if (allowFocus) { |
906 context->consumeWindowInteraction(); | 905 context->consumeWindowFocus(); |
907 } else { | 906 } else { |
908 ASSERT(isMainThread()); | 907 ASSERT(isMainThread()); |
909 allowFocus = opener() && (opener() != this) && (toDocument(context)->dom
Window() == opener()); | 908 allowFocus = opener() && (opener() != this) && (toDocument(context)->dom
Window() == opener()); |
910 } | 909 } |
911 | 910 |
912 // If we're a top level window, bring the window to the front. | 911 // If we're a top level window, bring the window to the front. |
913 if (frame()->isMainFrame() && allowFocus) | 912 if (frame()->isMainFrame() && allowFocus) |
914 host->chrome().focus(); | 913 host->chrome().focus(); |
915 | 914 |
916 frame()->eventHandler().focusDocumentView(); | 915 frame()->eventHandler().focusDocumentView(); |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 if (!EventTarget::addEventListener(eventType, listener, useCapture)) | 1498 if (!EventTarget::addEventListener(eventType, listener, useCapture)) |
1500 return false; | 1499 return false; |
1501 | 1500 |
1502 if (frame() && frame()->host()) | 1501 if (frame() && frame()->host()) |
1503 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT
ype); | 1502 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT
ype); |
1504 | 1503 |
1505 if (Document* document = this->document()) { | 1504 if (Document* document = this->document()) { |
1506 document->addListenerTypeIfNeeded(eventType); | 1505 document->addListenerTypeIfNeeded(eventType); |
1507 } | 1506 } |
1508 | 1507 |
1509 notifyAddEventListener(this, eventType); | 1508 lifecycleNotifier().notifyAddEventListener(this, eventType); |
1510 | 1509 |
1511 if (eventType == EventTypeNames::unload) { | 1510 if (eventType == EventTypeNames::unload) { |
1512 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); | 1511 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); |
1513 addUnloadEventListener(this); | 1512 addUnloadEventListener(this); |
1514 } else if (eventType == EventTypeNames::beforeunload) { | 1513 } else if (eventType == EventTypeNames::beforeunload) { |
1515 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered
); | 1514 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered
); |
1516 if (allowsBeforeUnloadListeners(this)) { | 1515 if (allowsBeforeUnloadListeners(this)) { |
1517 // This is confusingly named. It doesn't actually add the listener.
It just increments a count | 1516 // This is confusingly named. It doesn't actually add the listener.
It just increments a count |
1518 // so that we know we have listeners registered for the purposes of
determining if we can | 1517 // so that we know we have listeners registered for the purposes of
determining if we can |
1519 // fast terminate the renderer process. | 1518 // fast terminate the renderer process. |
1520 addBeforeUnloadEventListener(this); | 1519 addBeforeUnloadEventListener(this); |
1521 } else { | 1520 } else { |
1522 // Subframes return false from allowsBeforeUnloadListeners. | 1521 // Subframes return false from allowsBeforeUnloadListeners. |
1523 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist
ered); | 1522 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist
ered); |
1524 } | 1523 } |
1525 } | 1524 } |
1526 | 1525 |
1527 return true; | 1526 return true; |
1528 } | 1527 } |
1529 | 1528 |
1530 bool LocalDOMWindow::removeEventListener(const AtomicString& eventType, PassRefP
tr<EventListener> listener, bool useCapture) | 1529 bool LocalDOMWindow::removeEventListener(const AtomicString& eventType, PassRefP
tr<EventListener> listener, bool useCapture) |
1531 { | 1530 { |
1532 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) | 1531 if (!EventTarget::removeEventListener(eventType, listener, useCapture)) |
1533 return false; | 1532 return false; |
1534 | 1533 |
1535 if (frame() && frame()->host()) | 1534 if (frame() && frame()->host()) |
1536 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve
ntType); | 1535 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve
ntType); |
1537 | 1536 |
1538 notifyRemoveEventListener(this, eventType); | 1537 lifecycleNotifier().notifyRemoveEventListener(this, eventType); |
1539 | 1538 |
1540 if (eventType == EventTypeNames::unload) { | 1539 if (eventType == EventTypeNames::unload) { |
1541 removeUnloadEventListener(this); | 1540 removeUnloadEventListener(this); |
1542 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi
steners(this)) { | 1541 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi
steners(this)) { |
1543 removeBeforeUnloadEventListener(this); | 1542 removeBeforeUnloadEventListener(this); |
1544 } | 1543 } |
1545 | 1544 |
1546 return true; | 1545 return true; |
1547 } | 1546 } |
1548 | 1547 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 InspectorInstrumentation::didDispatchEventOnWindow(cookie); | 1591 InspectorInstrumentation::didDispatchEventOnWindow(cookie); |
1593 | 1592 |
1594 return result; | 1593 return result; |
1595 } | 1594 } |
1596 | 1595 |
1597 void LocalDOMWindow::removeAllEventListenersInternal(BroadcastListenerRemoval mo
de) | 1596 void LocalDOMWindow::removeAllEventListenersInternal(BroadcastListenerRemoval mo
de) |
1598 { | 1597 { |
1599 EventTarget::removeAllEventListeners(); | 1598 EventTarget::removeAllEventListeners(); |
1600 | 1599 |
1601 if (mode == DoBroadcastListenerRemoval) { | 1600 if (mode == DoBroadcastListenerRemoval) { |
1602 notifyRemoveAllEventListeners(this); | 1601 lifecycleNotifier().notifyRemoveAllEventListeners(this); |
1603 if (frame() && frame()->host()) | 1602 if (frame() && frame()->host()) |
1604 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*t
his); | 1603 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*t
his); |
1605 } | 1604 } |
1606 | 1605 |
1607 removeAllUnloadEventListeners(this); | 1606 removeAllUnloadEventListeners(this); |
1608 removeAllBeforeUnloadEventListeners(this); | 1607 removeAllBeforeUnloadEventListeners(this); |
1609 } | 1608 } |
1610 | 1609 |
1611 void LocalDOMWindow::removeAllEventListeners() | 1610 void LocalDOMWindow::removeAllEventListeners() |
1612 { | 1611 { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 | 1784 |
1786 WindowFeatures windowFeatures(dialogFeaturesString, screenAvailableRect(fram
e()->view())); | 1785 WindowFeatures windowFeatures(dialogFeaturesString, screenAvailableRect(fram
e()->view())); |
1787 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, | 1786 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, |
1788 *callingWindow, *firstFrame, *frame(), function, functionContext); | 1787 *callingWindow, *firstFrame, *frame(), function, functionContext); |
1789 if (!dialogFrame) | 1788 if (!dialogFrame) |
1790 return; | 1789 return; |
1791 UserGestureIndicatorDisabler disabler; | 1790 UserGestureIndicatorDisabler disabler; |
1792 dialogFrame->host()->chrome().runModal(); | 1791 dialogFrame->host()->chrome().runModal(); |
1793 } | 1792 } |
1794 | 1793 |
| 1794 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() |
| 1795 { |
| 1796 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); |
| 1797 } |
| 1798 |
| 1799 PassOwnPtr<LifecycleNotifier<LocalDOMWindow>> LocalDOMWindow::createLifecycleNot
ifier() |
| 1800 { |
| 1801 return DOMWindowLifecycleNotifier::create(this); |
| 1802 } |
| 1803 |
1795 void LocalDOMWindow::trace(Visitor* visitor) | 1804 void LocalDOMWindow::trace(Visitor* visitor) |
1796 { | 1805 { |
1797 #if ENABLE(OILPAN) | 1806 #if ENABLE(OILPAN) |
1798 visitor->trace(m_frameObserver); | 1807 visitor->trace(m_frameObserver); |
1799 visitor->trace(m_document); | 1808 visitor->trace(m_document); |
1800 visitor->trace(m_properties); | 1809 visitor->trace(m_properties); |
1801 visitor->trace(m_screen); | 1810 visitor->trace(m_screen); |
1802 visitor->trace(m_history); | 1811 visitor->trace(m_history); |
1803 visitor->trace(m_locationbar); | 1812 visitor->trace(m_locationbar); |
1804 visitor->trace(m_menubar); | 1813 visitor->trace(m_menubar); |
1805 visitor->trace(m_personalbar); | 1814 visitor->trace(m_personalbar); |
1806 visitor->trace(m_scrollbars); | 1815 visitor->trace(m_scrollbars); |
1807 visitor->trace(m_statusbar); | 1816 visitor->trace(m_statusbar); |
1808 visitor->trace(m_toolbar); | 1817 visitor->trace(m_toolbar); |
1809 visitor->trace(m_console); | 1818 visitor->trace(m_console); |
1810 visitor->trace(m_navigator); | 1819 visitor->trace(m_navigator); |
1811 visitor->trace(m_location); | 1820 visitor->trace(m_location); |
1812 visitor->trace(m_media); | 1821 visitor->trace(m_media); |
1813 visitor->trace(m_applicationCache); | 1822 visitor->trace(m_applicationCache); |
1814 visitor->trace(m_performance); | 1823 visitor->trace(m_performance); |
1815 visitor->trace(m_css); | 1824 visitor->trace(m_css); |
1816 visitor->trace(m_eventQueue); | 1825 visitor->trace(m_eventQueue); |
1817 visitor->trace(m_postMessageTimers); | 1826 visitor->trace(m_postMessageTimers); |
1818 HeapSupplementable<LocalDOMWindow>::trace(visitor); | 1827 HeapSupplementable<LocalDOMWindow>::trace(visitor); |
1819 #endif | 1828 #endif |
1820 DOMWindow::trace(visitor); | 1829 DOMWindow::trace(visitor); |
1821 DOMWindowLifecycleNotifier::trace(visitor); | 1830 LifecycleContext<LocalDOMWindow>::trace(visitor); |
1822 } | 1831 } |
1823 | 1832 |
1824 LocalFrame* LocalDOMWindow::frame() const | 1833 LocalFrame* LocalDOMWindow::frame() const |
1825 { | 1834 { |
1826 return m_frameObserver->frame(); | 1835 return m_frameObserver->frame(); |
1827 } | 1836 } |
1828 | 1837 |
1829 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) | 1838 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) |
1830 { | 1839 { |
1831 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. | 1840 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. |
1832 return v8::Handle<v8::Object>(); | 1841 return v8::Handle<v8::Object>(); |
1833 } | 1842 } |
1834 | 1843 |
1835 } // namespace blink | 1844 } // namespace blink |
OLD | NEW |