OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 } | 1360 } |
1361 | 1361 |
1362 PageVisibilityState Document::pageVisibilityState() const | 1362 PageVisibilityState Document::pageVisibilityState() const |
1363 { | 1363 { |
1364 // The visibility of the document is inherited from the visibility of the | 1364 // The visibility of the document is inherited from the visibility of the |
1365 // page. If there is no page associated with the document, we will assume | 1365 // page. If there is no page associated with the document, we will assume |
1366 // that the page is hidden, as specified by the spec: | 1366 // that the page is hidden, as specified by the spec: |
1367 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.
html#dom-document-hidden | 1367 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.
html#dom-document-hidden |
1368 if (!m_frame || !m_frame->page()) | 1368 if (!m_frame || !m_frame->page()) |
1369 return PageVisibilityStateHidden; | 1369 return PageVisibilityStateHidden; |
| 1370 // While visibilitychange is being dispatched during unloading it is |
| 1371 // expected that the visibility is hidden regardless of the page's |
| 1372 // visibility. |
| 1373 if (m_loadEventProgress >= UnloadVisibilityChangeInProgress) |
| 1374 return PageVisibilityStateHidden; |
1370 return m_frame->page()->visibilityState(); | 1375 return m_frame->page()->visibilityState(); |
1371 } | 1376 } |
1372 | 1377 |
1373 String Document::visibilityState() const | 1378 String Document::visibilityState() const |
1374 { | 1379 { |
1375 return pageVisibilityStateString(pageVisibilityState()); | 1380 return pageVisibilityStateString(pageVisibilityState()); |
1376 } | 1381 } |
1377 | 1382 |
1378 bool Document::hidden() const | 1383 bool Document::hidden() const |
1379 { | 1384 { |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2773 Element* currentFocusedElement = focusedElement(); | 2778 Element* currentFocusedElement = focusedElement(); |
2774 if (isHTMLInputElement(currentFocusedElement)) | 2779 if (isHTMLInputElement(currentFocusedElement)) |
2775 toHTMLInputElement(*currentFocusedElement).endEditing(); | 2780 toHTMLInputElement(*currentFocusedElement).endEditing(); |
2776 if (m_loadEventProgress < PageHideInProgress) { | 2781 if (m_loadEventProgress < PageHideInProgress) { |
2777 m_loadEventProgress = PageHideInProgress; | 2782 m_loadEventProgress = PageHideInProgress; |
2778 if (LocalDOMWindow* window = domWindow()) | 2783 if (LocalDOMWindow* window = domWindow()) |
2779 window->dispatchEvent(PageTransitionEvent::create(EventTypeNames
::pagehide, false), this); | 2784 window->dispatchEvent(PageTransitionEvent::create(EventTypeNames
::pagehide, false), this); |
2780 if (!m_frame) | 2785 if (!m_frame) |
2781 return; | 2786 return; |
2782 | 2787 |
| 2788 PageVisibilityState visibilityState = pageVisibilityState(); |
| 2789 m_loadEventProgress = UnloadVisibilityChangeInProgress; |
| 2790 if (visibilityState != PageVisibilityStateHidden && RuntimeEnabledFe
atures::visibilityChangeOnUnloadEnabled()) { |
| 2791 // Dispatch visibilitychange event, but don't bother doing |
| 2792 // other notifications as we're about to be unloaded. |
| 2793 dispatchEvent(Event::createBubble(EventTypeNames::visibilitychan
ge)); |
| 2794 dispatchEvent(Event::createBubble(EventTypeNames::webkitvisibili
tychange)); |
| 2795 } |
| 2796 if (!m_frame) |
| 2797 return; |
| 2798 |
2783 // The DocumentLoader (and thus its DocumentLoadTiming) might get de
stroyed | 2799 // The DocumentLoader (and thus its DocumentLoadTiming) might get de
stroyed |
2784 // while dispatching the event, so protect it to prevent writing the
end | 2800 // while dispatching the event, so protect it to prevent writing the
end |
2785 // time into freed memory. | 2801 // time into freed memory. |
2786 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = m_frame->loader(
).provisionalDocumentLoader(); | 2802 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = m_frame->loader(
).provisionalDocumentLoader(); |
2787 m_loadEventProgress = UnloadEventInProgress; | 2803 m_loadEventProgress = UnloadEventInProgress; |
2788 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames::
unload)); | 2804 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames::
unload)); |
2789 if (documentLoader && !documentLoader->timing().unloadEventStart() &
& !documentLoader->timing().unloadEventEnd()) { | 2805 if (documentLoader && !documentLoader->timing().unloadEventStart() &
& !documentLoader->timing().unloadEventEnd()) { |
2790 DocumentLoadTiming& timing = documentLoader->timing(); | 2806 DocumentLoadTiming& timing = documentLoader->timing(); |
2791 ASSERT(timing.navigationStart()); | 2807 ASSERT(timing.navigationStart()); |
2792 timing.markUnloadEventStart(); | 2808 timing.markUnloadEventStart(); |
(...skipping 11 matching lines...) Expand all Loading... |
2804 | 2820 |
2805 // Don't remove event listeners from a transitional empty document (see http
s://bugs.webkit.org/show_bug.cgi?id=28716 for more information). | 2821 // Don't remove event listeners from a transitional empty document (see http
s://bugs.webkit.org/show_bug.cgi?id=28716 for more information). |
2806 bool keepEventListeners = m_frame->loader().provisionalDocumentLoader() | 2822 bool keepEventListeners = m_frame->loader().provisionalDocumentLoader() |
2807 && m_frame->shouldReuseDefaultView(m_frame->loader().provisionalDocument
Loader()->url()); | 2823 && m_frame->shouldReuseDefaultView(m_frame->loader().provisionalDocument
Loader()->url()); |
2808 if (!keepEventListeners) | 2824 if (!keepEventListeners) |
2809 removeAllEventListenersRecursively(); | 2825 removeAllEventListenersRecursively(); |
2810 } | 2826 } |
2811 | 2827 |
2812 Document::PageDismissalType Document::pageDismissalEventBeingDispatched() const | 2828 Document::PageDismissalType Document::pageDismissalEventBeingDispatched() const |
2813 { | 2829 { |
2814 if (m_loadEventProgress == BeforeUnloadEventInProgress) | 2830 switch (m_loadEventProgress) { |
| 2831 case BeforeUnloadEventInProgress: |
2815 return BeforeUnloadDismissal; | 2832 return BeforeUnloadDismissal; |
2816 if (m_loadEventProgress == PageHideInProgress) | 2833 case PageHideInProgress: |
2817 return PageHideDismissal; | 2834 return PageHideDismissal; |
2818 if (m_loadEventProgress == UnloadEventInProgress) | 2835 case UnloadVisibilityChangeInProgress: |
| 2836 return UnloadVisibilityChangeDismissal; |
| 2837 case UnloadEventInProgress: |
2819 return UnloadDismissal; | 2838 return UnloadDismissal; |
| 2839 |
| 2840 case LoadEventNotRun: |
| 2841 case LoadEventInProgress: |
| 2842 case LoadEventCompleted: |
| 2843 case BeforeUnloadEventCompleted: |
| 2844 case UnloadEventHandled: |
| 2845 return NoDismissal; |
| 2846 } |
| 2847 ASSERT_NOT_REACHED(); |
2820 return NoDismissal; | 2848 return NoDismissal; |
2821 } | 2849 } |
2822 | 2850 |
2823 void Document::setParsingState(ParsingState parsingState) | 2851 void Document::setParsingState(ParsingState parsingState) |
2824 { | 2852 { |
2825 m_parsingState = parsingState; | 2853 m_parsingState = parsingState; |
2826 | 2854 |
2827 if (parsing() && !m_elementDataCache) | 2855 if (parsing() && !m_elementDataCache) |
2828 m_elementDataCache = ElementDataCache::create(); | 2856 m_elementDataCache = ElementDataCache::create(); |
2829 } | 2857 } |
(...skipping 3166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5996 #ifndef NDEBUG | 6024 #ifndef NDEBUG |
5997 using namespace blink; | 6025 using namespace blink; |
5998 void showLiveDocumentInstances() | 6026 void showLiveDocumentInstances() |
5999 { | 6027 { |
6000 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6028 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
6001 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6029 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6002 for (Document* document : set) | 6030 for (Document* document : set) |
6003 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6031 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
6004 } | 6032 } |
6005 #endif | 6033 #endif |
OLD | NEW |