Diff
Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (287653 => 287654)
--- 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)
@@ -1,5 +1,69 @@
2022-01-05 Russell Epstein <repst...@apple.com>
+ 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 <bfulg...@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 <repst...@apple.com>
+
Cherry-pick r287286. rdar://problem/87124952
Don't include SVGImageForContainers in allCachedSVGImages
Modified: branches/safari-612-branch/Source/WebCore/history/BackForwardCache.cpp (287653 => 287654)
--- 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)
@@ -388,10 +388,9 @@
static void setBackForwardCacheState(Page& page, Document::BackForwardCacheState BackForwardCacheState)
{
- for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (auto* document = frame->document())
- document->setBackForwardCacheState(BackForwardCacheState);
- }
+ page.forEachDocument([&] (Document& document) {
+ document.setBackForwardCacheState(BackForwardCacheState);
+ });
}
// When entering back/forward cache, tear down the render tree before setting the in-cache flag.
Modified: branches/safari-612-branch/Source/WebCore/page/EventHandler.cpp (287653 => 287654)
--- 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)
@@ -3889,10 +3889,9 @@
static void removeDraggedContentDocumentMarkersFromAllFramesInPage(Page& page)
{
- for (RefPtr frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (RefPtr document = frame->document())
- document->markers().removeMarkers(DocumentMarker::DraggedContent);
- }
+ page.forEachDocument([] (Document& document) {
+ document.markers().removeMarkers(DocumentMarker::DraggedContent);
+ });
if (auto* mainFrameRenderer = page.mainFrame().contentRenderer())
mainFrameRenderer->repaintRootContents();
Modified: branches/safari-612-branch/Source/WebCore/page/Frame.cpp (287653 => 287654)
--- 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)
@@ -354,15 +354,9 @@
#if ENABLE(ORIENTATION_EVENTS)
void Frame::orientationChanged()
{
- 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);
- }
+ Page::forEachDocumentFromMainFrame(*this, [newOrientation = orientation()] (Document& document) {
+ document.orientationChanged(newOrientation);
+ });
}
int Frame::orientation() const
Modified: branches/safari-612-branch/Source/WebCore/page/Page.cpp (287653 => 287654)
--- 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)
@@ -395,10 +395,10 @@
m_inspectorController->inspectedPageDestroyed();
- for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
- frame->willDetachPage();
- frame->detachFromPage();
- }
+ forEachFrameFromMainFrame([] (Frame& frame) {
+ frame.willDetachPage();
+ frame.detachFromPage();
+ });
if (m_scrollingCoordinator)
m_scrollingCoordinator->pageDestroyed();
@@ -1222,10 +1222,9 @@
m_displayNominalFramesPerSecond = DisplayRefreshMonitorManager::sharedManager().nominalFramesPerSecondForDisplay(m_displayID, chrome().client().displayRefreshMonitorFactory());
}
- for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (frame->document())
- frame->document()->windowScreenDidChange(displayID);
- }
+ forEachDocument([&] (Document& document) {
+ document.windowScreenDidChange(displayID);
+ });
#if ENABLE(VIDEO)
auto mode = preferredDynamicRangeMode(mainFrame().view());
@@ -1957,13 +1956,12 @@
void Page::userAgentChanged()
{
- 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();
- }
+ forEachDocument([] (Document& document) {
+ if (auto* window = document.domWindow()) {
+ if (auto* navigator = window->optionalNavigator())
+ navigator->userAgentChanged();
+ }
+ });
}
void Page::invalidateStylesForAllLinks()
@@ -2943,8 +2941,9 @@
{
m_hasBeenNotifiedToInjectUserScripts = true;
- for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
- frame->injectUserScriptsAwaitingNotification();
+ forEachFrameFromMainFrame([] (Frame& frame) {
+ frame.injectUserScriptsAwaitingNotification();
+ });
}
void Page::setUserContentProvider(Ref<UserContentProvider>&& userContentProvider)
@@ -3354,10 +3353,10 @@
return *m_renderingUpdateScheduler;
}
-void Page::forEachDocument(const Function<void(Document&)>& functor) const
+void Page::forEachDocumentFromMainFrame(const Frame& mainFrame, const Function<void(Document&)>& functor)
{
Vector<Ref<Document>> documents;
- for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ for (auto* frame = &mainFrame; frame; frame = frame->tree().traverseNext()) {
auto* document = frame->document();
if (!document)
continue;
@@ -3367,6 +3366,11 @@
functor(document);
}
+void Page::forEachDocument(const Function<void(Document&)>& functor) const
+{
+ forEachDocumentFromMainFrame(mainFrame(), functor);
+}
+
void Page::forEachMediaElement(const Function<void(HTMLMediaElement&)>& functor)
{
#if ENABLE(VIDEO)
@@ -3378,6 +3382,16 @@
#endif
}
+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);
+}
+
bool Page::allowsLoadFromURL(const URL& url) const
{
if (!m_allowedNetworkHosts)
Modified: branches/safari-612-branch/Source/WebCore/page/Page.h (287653 => 287654)
--- 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)
@@ -857,6 +857,8 @@
WEBCORE_EXPORT void forEachDocument(const WTF::Function<void(Document&)>&) const;
void forEachMediaElement(const WTF::Function<void(HTMLMediaElement&)>&);
+ static void forEachDocumentFromMainFrame(const Frame&, const Function<void(Document&)>&);
+ void forEachFrameFromMainFrame(const Function<void(Frame&)>&);
bool shouldDisableCorsForRequestTo(const URL&) const;
Modified: branches/safari-612-branch/Source/WebCore/page/ios/FrameIOS.mm (287653 => 287654)
--- 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)
@@ -644,8 +644,9 @@
if (!isMainFrame())
return;
- for (Frame* frame = this; frame; frame = frame->tree().traverseNext(this))
- frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, true), document());
+ Page::forEachDocumentFromMainFrame(*this, [pagehideEvent = eventNames().pagehideEvent, mainDocument = document()](Document& document) {
+ document.domWindow()->dispatchEvent(PageTransitionEvent::create(pagehideEvent, true), mainDocument);
+ });
}
void Frame::dispatchPageShowEventBeforeResume()
@@ -654,8 +655,9 @@
if (!isMainFrame())
return;
- for (Frame* frame = this; frame; frame = frame->tree().traverseNext(this))
- frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pageshowEvent, true), document());
+ Page::forEachDocumentFromMainFrame(*this, [pageshowEvent = eventNames().pageshowEvent, mainDocument = document()](Document& document) {
+ document.domWindow()->dispatchEvent(PageTransitionEvent::create(pageshowEvent, true), mainDocument);
+ });
}
void Frame::setRangedSelectionBaseToCurrentSelection()