<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[287654] branches/safari-612-branch/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/287654">287654</a></dd>
<dt>Author</dt> <dd>repstein@apple.com</dd>
<dt>Date</dt> <dd>2022-01-05 15:21:45 -0800 (Wed, 05 Jan 2022)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/287110">r287110</a>. rdar://problem/87124750

    Clean-up: Adopt Page::forEachDocument in some missed spots
    https://bugs.webkit.org/show_bug.cgi?id=234324
    <rdar://problem/85443831>

    Reviewed by Darin Adler.

    Switch manual loops to our 'forEachDocument' style in a few places that were missed
    in earlier refactoring.

    No change in behavior.

    * history/BackForwardCache.cpp:
    (WebCore::setBackForwardCacheState)
    * page/EventHandler.cpp:
    (WebCore::removeDraggedContentDocumentMarkersFromAllFramesInPage):
    * page/Frame.cpp:
    (WebCore::Frame::orientationChanged):
    * page/Page.cpp:
    (WebCore::Page::~Page):
    (WebCore::Page::forEachDocumentFromMainFrame): Added.
    (WebCore::Page::forEachDocument): Use new method.
    (WebCore::Page::forEachFrameFromMainFrame): Added.
    (WebCore::Page::windowScreenDidChange):
    (WebCore::Page::userAgentChanged):
    * page/ios/FrameIOS.mm:
    (WebCore::Frame::dispatchPageHideEventBeforePause):
    (WebCore::Frame::dispatchPageShowEventBeforeResume):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287110 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari612branchSourceWebCoreChangeLog">branches/safari-612-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebCorehistoryBackForwardCachecpp">branches/safari-612-branch/Source/WebCore/history/BackForwardCache.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepageEventHandlercpp">branches/safari-612-branch/Source/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepageFramecpp">branches/safari-612-branch/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePagecpp">branches/safari-612-branch/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCorepagePageh">branches/safari-612-branch/Source/WebCore/page/Page.h</a></li>
<li><a href="#branchessafari612branchSourceWebCorepageiosFrameIOSmm">branches/safari-612-branch/Source/WebCore/page/ios/FrameIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari612branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/ChangeLog      2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog 2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -1,5 +1,69 @@
</span><span class="cx"> 2022-01-05  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r287110. rdar://problem/87124750
+
+    Clean-up: Adopt Page::forEachDocument in some missed spots
+    https://bugs.webkit.org/show_bug.cgi?id=234324
+    <rdar://problem/85443831>
+    
+    Reviewed by Darin Adler.
+    
+    Switch manual loops to our 'forEachDocument' style in a few places that were missed
+    in earlier refactoring.
+    
+    No change in behavior.
+    
+    * history/BackForwardCache.cpp:
+    (WebCore::setBackForwardCacheState)
+    * page/EventHandler.cpp:
+    (WebCore::removeDraggedContentDocumentMarkersFromAllFramesInPage):
+    * page/Frame.cpp:
+    (WebCore::Frame::orientationChanged):
+    * page/Page.cpp:
+    (WebCore::Page::~Page):
+    (WebCore::Page::forEachDocumentFromMainFrame): Added.
+    (WebCore::Page::forEachDocument): Use new method.
+    (WebCore::Page::forEachFrameFromMainFrame): Added.
+    (WebCore::Page::windowScreenDidChange):
+    (WebCore::Page::userAgentChanged):
+    * page/ios/FrameIOS.mm:
+    (WebCore::Frame::dispatchPageHideEventBeforePause):
+    (WebCore::Frame::dispatchPageShowEventBeforeResume):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-12-15  Brent Fulgham  <bfulgham@apple.com>
+
+            Clean-up: Adopt Page::forEachDocument in some missed spots
+            https://bugs.webkit.org/show_bug.cgi?id=234324
+            <rdar://problem/85443831>
+
+            Reviewed by Darin Adler.
+
+            Switch manual loops to our 'forEachDocument' style in a few places that were missed
+            in earlier refactoring.
+
+            No change in behavior.
+
+            * history/BackForwardCache.cpp:
+            (WebCore::setBackForwardCacheState)
+            * page/EventHandler.cpp:
+            (WebCore::removeDraggedContentDocumentMarkersFromAllFramesInPage):
+            * page/Frame.cpp:
+            (WebCore::Frame::orientationChanged):
+            * page/Page.cpp:
+            (WebCore::Page::~Page):
+            (WebCore::Page::forEachDocumentFromMainFrame): Added.
+            (WebCore::Page::forEachDocument): Use new method.
+            (WebCore::Page::forEachFrameFromMainFrame): Added.
+            (WebCore::Page::windowScreenDidChange):
+            (WebCore::Page::userAgentChanged):
+            * page/ios/FrameIOS.mm:
+            (WebCore::Frame::dispatchPageHideEventBeforePause):
+            (WebCore::Frame::dispatchPageShowEventBeforeResume):
+
+2022-01-05  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r287286. rdar://problem/87124952
</span><span class="cx"> 
</span><span class="cx">     Don't include SVGImageForContainers in allCachedSVGImages
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorehistoryBackForwardCachecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/history/BackForwardCache.cpp (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/history/BackForwardCache.cpp   2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/history/BackForwardCache.cpp      2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -388,10 +388,9 @@
</span><span class="cx"> 
</span><span class="cx"> static void setBackForwardCacheState(Page& page, Document::BackForwardCacheState BackForwardCacheState)
</span><span class="cx"> {
</span><del>-    for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        if (auto* document = frame->document())
-            document->setBackForwardCacheState(BackForwardCacheState);
-    }
</del><ins>+    page.forEachDocument([&] (Document& document) {
+        document.setBackForwardCacheState(BackForwardCacheState);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // When entering back/forward cache, tear down the render tree before setting the in-cache flag.
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/EventHandler.cpp (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/EventHandler.cpp  2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/page/EventHandler.cpp     2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -3889,10 +3889,9 @@
</span><span class="cx"> 
</span><span class="cx"> static void removeDraggedContentDocumentMarkersFromAllFramesInPage(Page& page)
</span><span class="cx"> {
</span><del>-    for (RefPtr frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        if (RefPtr document = frame->document())
-            document->markers().removeMarkers(DocumentMarker::DraggedContent);
-    }
</del><ins>+    page.forEachDocument([] (Document& document) {
+        document.markers().removeMarkers(DocumentMarker::DraggedContent);
+    });
</ins><span class="cx"> 
</span><span class="cx">     if (auto* mainFrameRenderer = page.mainFrame().contentRenderer())
</span><span class="cx">         mainFrameRenderer->repaintRootContents();
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/Frame.cpp (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/Frame.cpp 2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/page/Frame.cpp    2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -354,15 +354,9 @@
</span><span class="cx"> #if ENABLE(ORIENTATION_EVENTS)
</span><span class="cx"> void Frame::orientationChanged()
</span><span class="cx"> {
</span><del>-    Vector<Ref<Frame>> frames;
-    for (Frame* frame = this; frame; frame = frame->tree().traverseNext())
-        frames.append(*frame);
-
-    auto newOrientation = orientation();
-    for (auto& frame : frames) {
-        if (Document* document = frame->document())
-            document->orientationChanged(newOrientation);
-    }
</del><ins>+    Page::forEachDocumentFromMainFrame(*this, [newOrientation = orientation()] (Document& document) {
+        document.orientationChanged(newOrientation);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int Frame::orientation() const
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/Page.cpp (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/Page.cpp  2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/page/Page.cpp     2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -395,10 +395,10 @@
</span><span class="cx"> 
</span><span class="cx">     m_inspectorController->inspectedPageDestroyed();
</span><span class="cx"> 
</span><del>-    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        frame->willDetachPage();
-        frame->detachFromPage();
-    }
</del><ins>+    forEachFrameFromMainFrame([] (Frame& frame) {
+        frame.willDetachPage();
+        frame.detachFromPage();
+    });
</ins><span class="cx"> 
</span><span class="cx">     if (m_scrollingCoordinator)
</span><span class="cx">         m_scrollingCoordinator->pageDestroyed();
</span><span class="lines">@@ -1222,10 +1222,9 @@
</span><span class="cx">         m_displayNominalFramesPerSecond = DisplayRefreshMonitorManager::sharedManager().nominalFramesPerSecondForDisplay(m_displayID, chrome().client().displayRefreshMonitorFactory());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        if (frame->document())
-            frame->document()->windowScreenDidChange(displayID);
-    }
</del><ins>+    forEachDocument([&] (Document& document) {
+        document.windowScreenDidChange(displayID);
+    });
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx">     auto mode = preferredDynamicRangeMode(mainFrame().view());
</span><span class="lines">@@ -1957,13 +1956,12 @@
</span><span class="cx"> 
</span><span class="cx"> void Page::userAgentChanged()
</span><span class="cx"> {
</span><del>-    for (auto* frame = &m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) {
-        auto* window = frame->window();
-        if (!window)
-            continue;
-        if (auto* navigator = window->optionalNavigator())
-            navigator->userAgentChanged();
-    }
</del><ins>+    forEachDocument([] (Document& document) {
+        if (auto* window = document.domWindow()) {
+            if (auto* navigator = window->optionalNavigator())
+                navigator->userAgentChanged();
+        }
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Page::invalidateStylesForAllLinks()
</span><span class="lines">@@ -2943,8 +2941,9 @@
</span><span class="cx"> {
</span><span class="cx">     m_hasBeenNotifiedToInjectUserScripts = true;
</span><span class="cx"> 
</span><del>-    for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
-        frame->injectUserScriptsAwaitingNotification();
</del><ins>+    forEachFrameFromMainFrame([] (Frame& frame) {
+        frame.injectUserScriptsAwaitingNotification();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Page::setUserContentProvider(Ref<UserContentProvider>&& userContentProvider)
</span><span class="lines">@@ -3354,10 +3353,10 @@
</span><span class="cx">     return *m_renderingUpdateScheduler;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Page::forEachDocument(const Function<void(Document&)>& functor) const
</del><ins>+void Page::forEachDocumentFromMainFrame(const Frame& mainFrame, const Function<void(Document&)>& functor)
</ins><span class="cx"> {
</span><span class="cx">     Vector<Ref<Document>> documents;
</span><del>-    for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
</del><ins>+    for (auto* frame = &mainFrame; frame; frame = frame->tree().traverseNext()) {
</ins><span class="cx">         auto* document = frame->document();
</span><span class="cx">         if (!document)
</span><span class="cx">             continue;
</span><span class="lines">@@ -3367,6 +3366,11 @@
</span><span class="cx">         functor(document);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Page::forEachDocument(const Function<void(Document&)>& functor) const
+{
+    forEachDocumentFromMainFrame(mainFrame(), functor);
+}
+
</ins><span class="cx"> void Page::forEachMediaElement(const Function<void(HTMLMediaElement&)>& functor)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="lines">@@ -3378,6 +3382,16 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Page::forEachFrameFromMainFrame(const Function<void(Frame&)>& functor)
+{
+    Vector<Ref<Frame>> frames;
+    for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
+        frames.append(*frame);
+
+    for (auto& frame : frames)
+        functor(frame);
+}
+
</ins><span class="cx"> bool Page::allowsLoadFromURL(const URL& url) const
</span><span class="cx"> {
</span><span class="cx">     if (!m_allowedNetworkHosts)
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/Page.h (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/Page.h    2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/page/Page.h       2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -857,6 +857,8 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void forEachDocument(const WTF::Function<void(Document&)>&) const;
</span><span class="cx">     void forEachMediaElement(const WTF::Function<void(HTMLMediaElement&)>&);
</span><ins>+    static void forEachDocumentFromMainFrame(const Frame&, const Function<void(Document&)>&);
+    void forEachFrameFromMainFrame(const Function<void(Frame&)>&);
</ins><span class="cx"> 
</span><span class="cx">     bool shouldDisableCorsForRequestTo(const URL&) const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorepageiosFrameIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/page/ios/FrameIOS.mm (287653 => 287654)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/page/ios/FrameIOS.mm   2022-01-05 23:02:02 UTC (rev 287653)
+++ branches/safari-612-branch/Source/WebCore/page/ios/FrameIOS.mm      2022-01-05 23:21:45 UTC (rev 287654)
</span><span class="lines">@@ -644,8 +644,9 @@
</span><span class="cx">     if (!isMainFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    for (Frame* frame = this; frame; frame = frame->tree().traverseNext(this))
-        frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, true), document());
</del><ins>+    Page::forEachDocumentFromMainFrame(*this, [pagehideEvent = eventNames().pagehideEvent, mainDocument = document()](Document& document) {
+        document.domWindow()->dispatchEvent(PageTransitionEvent::create(pagehideEvent, true), mainDocument);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Frame::dispatchPageShowEventBeforeResume()
</span><span class="lines">@@ -654,8 +655,9 @@
</span><span class="cx">     if (!isMainFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    for (Frame* frame = this; frame; frame = frame->tree().traverseNext(this))
-        frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pageshowEvent, true), document());
</del><ins>+    Page::forEachDocumentFromMainFrame(*this, [pageshowEvent = eventNames().pageshowEvent, mainDocument = document()](Document& document) {
+        document.domWindow()->dispatchEvent(PageTransitionEvent::create(pageshowEvent, true), mainDocument);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Frame::setRangedSelectionBaseToCurrentSelection()
</span></span></pre>
</div>
</div>

</body>
</html>