Chromium Code Reviews| 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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 PageVisibilityState Document::pageVisibilityState() const | 1361 PageVisibilityState Document::pageVisibilityState() const |
| 1362 { | 1362 { |
| 1363 // The visibility of the document is inherited from the visibility of the | 1363 // The visibility of the document is inherited from the visibility of the |
| 1364 // page. If there is no page associated with the document, we will assume | 1364 // page. If there is no page associated with the document, we will assume |
| 1365 // that the page is hidden, as specified by the spec: | 1365 // that the page is hidden, as specified by the spec: |
| 1366 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview. html#dom-document-hidden | 1366 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview. html#dom-document-hidden |
| 1367 if (!m_frame || !m_frame->page()) | 1367 if (!m_frame || !m_frame->page()) |
| 1368 return PageVisibilityStateHidden; | 1368 return PageVisibilityStateHidden; |
| 1369 // While visibilitychange is being dispatched during unloading it is | |
| 1370 // expected that the visibility is hidden regardless of the page's | |
| 1371 // visibility. | |
| 1372 if (m_loadEventProgress == UnloadVisibilityChangeInProgress) | |
| 1373 return PageVisibilityStateHidden; | |
|
dcheng
2016/03/10 22:46:33
I think we should update pageDismissalEventBeingDi
kinuko
2016/03/11 04:13:05
Oh yeah we should. Done.
| |
| 1369 return m_frame->page()->visibilityState(); | 1374 return m_frame->page()->visibilityState(); |
| 1370 } | 1375 } |
| 1371 | 1376 |
| 1372 String Document::visibilityState() const | 1377 String Document::visibilityState() const |
| 1373 { | 1378 { |
| 1374 return pageVisibilityStateString(pageVisibilityState()); | 1379 return pageVisibilityStateString(pageVisibilityState()); |
| 1375 } | 1380 } |
| 1376 | 1381 |
| 1377 bool Document::hidden() const | 1382 bool Document::hidden() const |
| 1378 { | 1383 { |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2772 Element* currentFocusedElement = focusedElement(); | 2777 Element* currentFocusedElement = focusedElement(); |
| 2773 if (isHTMLInputElement(currentFocusedElement)) | 2778 if (isHTMLInputElement(currentFocusedElement)) |
| 2774 toHTMLInputElement(*currentFocusedElement).endEditing(); | 2779 toHTMLInputElement(*currentFocusedElement).endEditing(); |
| 2775 if (m_loadEventProgress < PageHideInProgress) { | 2780 if (m_loadEventProgress < PageHideInProgress) { |
| 2776 m_loadEventProgress = PageHideInProgress; | 2781 m_loadEventProgress = PageHideInProgress; |
| 2777 if (LocalDOMWindow* window = domWindow()) | 2782 if (LocalDOMWindow* window = domWindow()) |
| 2778 window->dispatchEvent(PageTransitionEvent::create(EventTypeNames ::pagehide, false), this); | 2783 window->dispatchEvent(PageTransitionEvent::create(EventTypeNames ::pagehide, false), this); |
| 2779 if (!m_frame) | 2784 if (!m_frame) |
| 2780 return; | 2785 return; |
| 2781 | 2786 |
| 2787 PageVisibilityState visibilityState = pageVisibilityState(); | |
| 2788 m_loadEventProgress = UnloadVisibilityChangeInProgress; | |
| 2789 if (visibilityState != PageVisibilityStateHidden && RuntimeEnabledFe atures::visibilityChangeOnUnloadEnabled()) { | |
| 2790 // Dispatch visibilitychange event, but don't bother doing | |
| 2791 // other notifications as we're about to be unloaded. | |
| 2792 dispatchEvent(Event::createBubble(EventTypeNames::visibilitychan ge)); | |
| 2793 dispatchEvent(Event::createBubble(EventTypeNames::webkitvisibili tychange)); | |
| 2794 } | |
| 2795 if (!m_frame) | |
| 2796 return; | |
| 2797 | |
| 2782 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed | 2798 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed |
| 2783 // while dispatching the event, so protect it to prevent writing the end | 2799 // while dispatching the event, so protect it to prevent writing the end |
| 2784 // time into freed memory. | 2800 // time into freed memory. |
| 2785 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = m_frame->loader( ).provisionalDocumentLoader(); | 2801 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = m_frame->loader( ).provisionalDocumentLoader(); |
| 2786 m_loadEventProgress = UnloadEventInProgress; | 2802 m_loadEventProgress = UnloadEventInProgress; |
| 2787 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames:: unload)); | 2803 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames:: unload)); |
| 2788 if (documentLoader && !documentLoader->timing().unloadEventStart() & & !documentLoader->timing().unloadEventEnd()) { | 2804 if (documentLoader && !documentLoader->timing().unloadEventStart() & & !documentLoader->timing().unloadEventEnd()) { |
| 2789 DocumentLoadTiming& timing = documentLoader->timing(); | 2805 DocumentLoadTiming& timing = documentLoader->timing(); |
| 2790 ASSERT(timing.navigationStart()); | 2806 ASSERT(timing.navigationStart()); |
| 2791 timing.markUnloadEventStart(); | 2807 timing.markUnloadEventStart(); |
| (...skipping 3203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5995 #ifndef NDEBUG | 6011 #ifndef NDEBUG |
| 5996 using namespace blink; | 6012 using namespace blink; |
| 5997 void showLiveDocumentInstances() | 6013 void showLiveDocumentInstances() |
| 5998 { | 6014 { |
| 5999 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6015 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 6000 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6016 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6001 for (Document* document : set) | 6017 for (Document* document : set) |
| 6002 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); | 6018 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); |
| 6003 } | 6019 } |
| 6004 #endif | 6020 #endif |
| OLD | NEW |