Changeset 214014 in webkit
- Timestamp:
- Mar 15, 2017 3:44:59 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r214010 r214014 1 2017-03-15 Daniel Bates <dabates@apple.com> 2 3 Iteratively dispatch DOM events after restoring a cached page 4 https://bugs.webkit.org/show_bug.cgi?id=169703 5 <rdar://problem/31075903> 6 7 Reviewed by Brady Eidson. 8 9 Make dispatching of DOM events when restoring a page from the page cache symmetric with 10 dispatching of events when saving a page to the page cache. 11 12 * history/CachedFrame.cpp: 13 (WebCore::CachedFrameBase::restore): Move code to dispatch events from here to FrameLoader::didRestoreFromCachedPage(). 14 * loader/FrameLoader.cpp: 15 (WebCore::FrameLoader::commitProvisionalLoad): Ensure that no DOM events are dispatched during 16 restoration of a cached page. Call didRestoreFromCachedPage() after restoring the page to 17 dispatch DOM events on the restored frames. 18 (WebCore::FrameLoader::willRestoreFromCachedPage): Renamed; formerly named prepareForCachedPageRestore(). 19 (WebCore::FrameLoader::didRestoreFromCachedPage): Added. 20 (WebCore::FrameLoader::prepareForCachedPageRestore): Renamed to willRestoreFromCachedPage(). 21 * loader/FrameLoader.h: 22 * page/FrameTree.cpp: 23 (WebCore::FrameTree::traverseNextInPostOrderWithWrap): Returns the next Frame* in a post-order 24 traversal of the frame tree optionally wrapping around to the deepest first child in the tree. 25 (WebCore::FrameTree::deepFirstChild): Added. 26 * page/FrameTree.h: 27 1 28 2017-03-15 Dave Hyatt <hyatt@apple.com> 2 29 -
trunk/Source/WebCore/history/CachedFrame.cpp
r212173 r214014 36 36 #include "FrameLoaderClient.h" 37 37 #include "FrameView.h" 38 #include "HistoryController.h"39 #include "HistoryItem.h"40 38 #include "Logging.h" 41 39 #include "MainFrame.h" 42 40 #include "Page.h" 43 41 #include "PageCache.h" 44 #include "PageTransitionEvent.h"45 42 #include "SVGDocumentExtensions.h" 46 43 #include "ScriptController.h" … … 117 114 frame.tree().appendChild(childFrame->view()->frame()); 118 115 childFrame->open(); 116 ASSERT_WITH_SECURITY_IMPLICATION(m_document == frame.document()); 119 117 } 120 118 … … 132 130 #endif 133 131 134 // FIXME: update Page Visibility state here.135 // https://bugs.webkit.org/show_bug.cgi?id=116770136 m_document->enqueuePageshowEvent(PageshowEventPersisted);137 138 HistoryItem* historyItem = frame.loader().history().currentItem();139 if (historyItem && historyItem->stateObject())140 m_document->enqueuePopstateEvent(historyItem->stateObject());141 142 132 frame.view()->didRestoreFromPageCache(); 143 133 } -
trunk/Source/WebCore/loader/FrameLoader.cpp
r213621 r214014 87 87 #include "MemoryCache.h" 88 88 #include "MemoryRelease.h" 89 #include "NoEventDispatchAssertion.h" 89 90 #include "Page.h" 90 91 #include "PageCache.h" … … 1814 1815 m_frame.page()->chrome().setDispatchViewportDataDidChangeSuppressed(true); 1815 1816 #endif 1816 prepareForCachedPageRestore();1817 willRestoreFromCachedPage(); 1817 1818 1818 1819 // Start request for the main resource and dispatch didReceiveResponse before the load is committed for … … 1826 1827 std::optional<HasInsecureContent> hasInsecureContent = cachedPage->cachedMainFrame()->hasInsecureContent(); 1827 1828 1828 // FIXME: This API should be turned around so that we ground CachedPage into the Page. 1829 cachedPage->restore(*m_frame.page()); 1829 { 1830 // Do not dispatch DOM events as their JavaScript listeners could cause the page to be put 1831 // into the page cache before we have finished restoring it from the page cache. 1832 NoEventDispatchAssertion assertNoEventDispatch; 1833 1834 // FIXME: This API should be turned around so that we ground CachedPage into the Page. 1835 cachedPage->restore(*m_frame.page()); 1836 } 1830 1837 1831 1838 dispatchDidCommitLoad(hasInsecureContent); 1839 1840 didRestoreFromCachedPage(); 1841 1832 1842 #if PLATFORM(IOS) 1833 1843 m_frame.page()->chrome().setDispatchViewportDataDidChangeSuppressed(false); … … 2048 2058 } 2049 2059 2050 void FrameLoader:: prepareForCachedPageRestore()2060 void FrameLoader::willRestoreFromCachedPage() 2051 2061 { 2052 2062 ASSERT(!m_frame.tree().parent()); … … 2064 2074 window->setStatus(String()); 2065 2075 window->setDefaultStatus(String()); 2076 } 2077 } 2078 2079 void FrameLoader::didRestoreFromCachedPage() 2080 { 2081 // Dispatching JavaScript events can cause frame destruction. 2082 auto& mainFrame = m_frame.page()->mainFrame(); 2083 Vector<Ref<Frame>> childFrames; 2084 for (auto* child = mainFrame.tree().traverseNextInPostOrderWithWrap(true); child; child = child->tree().traverseNextInPostOrderWithWrap(false)) 2085 childFrames.append(*child); 2086 2087 for (auto& child : childFrames) { 2088 if (!child->tree().isDescendantOf(&mainFrame)) 2089 continue; 2090 auto* document = child->document(); 2091 if (!document) 2092 continue; 2093 2094 // FIXME: Update Page Visibility state here. 2095 // https://bugs.webkit.org/show_bug.cgi?id=116770 2096 document->enqueuePageshowEvent(PageshowEventPersisted); 2097 2098 auto* historyItem = child->loader().history().currentItem(); 2099 if (historyItem && historyItem->stateObject()) 2100 document->enqueuePopstateEvent(historyItem->stateObject()); 2066 2101 } 2067 2102 } -
trunk/Source/WebCore/loader/FrameLoader.h
r213590 r214014 346 346 347 347 void closeOldDataSources(); 348 void prepareForCachedPageRestore(); 348 void willRestoreFromCachedPage(); 349 void didRestoreFromCachedPage(); 349 350 350 351 bool shouldReloadToHandleUnreachableURL(DocumentLoader*); -
trunk/Source/WebCore/page/FrameTree.cpp
r211033 r214014 432 432 } 433 433 434 Frame* FrameTree::traverseNextInPostOrderWithWrap(bool wrap) const 435 { 436 if (m_nextSibling) 437 return m_nextSibling->tree().deepFirstChild(); 438 if (m_parent) 439 return m_parent; 440 if (wrap) 441 return deepFirstChild(); 442 return nullptr; 443 } 444 445 Frame* FrameTree::deepFirstChild() const 446 { 447 Frame* result = &m_thisFrame; 448 while (auto* next = result->tree().firstChild()) 449 result = next; 450 return result; 451 } 452 434 453 Frame* FrameTree::deepLastChild() const 435 454 { -
trunk/Source/WebCore/page/FrameTree.h
r211033 r214014 65 65 WEBCORE_EXPORT Frame* traverseNextWithWrap(bool) const; 66 66 WEBCORE_EXPORT Frame* traversePreviousWithWrap(bool) const; 67 67 68 Frame* traverseNextInPostOrderWithWrap(bool) const; 69 68 70 WEBCORE_EXPORT void appendChild(Frame&); 69 71 void detachFromParent() { m_parent = nullptr; } … … 86 88 87 89 private: 90 Frame* deepFirstChild() const; 88 91 Frame* deepLastChild() const; 89 92
Note: See TracChangeset
for help on using the changeset viewer.