Changeset 287110 in webkit
- Timestamp:
- Dec 15, 2021, 3:19:57 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
history/BackForwardCache.cpp (modified) (1 diff)
-
page/EventHandler.cpp (modified) (1 diff)
-
page/Frame.cpp (modified) (1 diff)
-
page/Page.cpp (modified) (7 diffs)
-
page/Page.h (modified) (1 diff)
-
page/ios/FrameIOS.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287108 r287110 1 2021-12-15 Brent Fulgham <bfulgham@apple.com> 2 3 Clean-up: Adopt Page::forEachDocument in some missed spots 4 https://bugs.webkit.org/show_bug.cgi?id=234324 5 <rdar://problem/85443831> 6 7 Reviewed by Darin Adler. 8 9 Switch manual loops to our 'forEachDocument' style in a few places that were missed 10 in earlier refactoring. 11 12 No change in behavior. 13 14 * history/BackForwardCache.cpp: 15 (WebCore::setBackForwardCacheState) 16 * page/EventHandler.cpp: 17 (WebCore::removeDraggedContentDocumentMarkersFromAllFramesInPage): 18 * page/Frame.cpp: 19 (WebCore::Frame::orientationChanged): 20 * page/Page.cpp: 21 (WebCore::Page::~Page): 22 (WebCore::Page::forEachDocumentFromMainFrame): Added. 23 (WebCore::Page::forEachDocument): Use new method. 24 (WebCore::Page::forEachFrameFromMainFrame): Added. 25 (WebCore::Page::windowScreenDidChange): 26 (WebCore::Page::userAgentChanged): 27 * page/ios/FrameIOS.mm: 28 (WebCore::Frame::dispatchPageHideEventBeforePause): 29 (WebCore::Frame::dispatchPageShowEventBeforeResume): 30 1 31 2021-12-15 Alex Christensen <achristensen@webkit.org> 2 32 -
trunk/Source/WebCore/history/BackForwardCache.cpp
r282191 r287110 389 389 static void setBackForwardCacheState(Page& page, Document::BackForwardCacheState BackForwardCacheState) 390 390 { 391 for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) { 392 if (auto* document = frame->document()) 393 document->setBackForwardCacheState(BackForwardCacheState); 394 } 391 page.forEachDocument([&] (Document& document) { 392 document.setBackForwardCacheState(BackForwardCacheState); 393 }); 395 394 } 396 395 -
trunk/Source/WebCore/page/EventHandler.cpp
r286415 r287110 3926 3926 static void removeDraggedContentDocumentMarkersFromAllFramesInPage(Page& page) 3927 3927 { 3928 for (RefPtr frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) { 3929 if (RefPtr document = frame->document()) 3930 document->markers().removeMarkers(DocumentMarker::DraggedContent); 3931 } 3928 page.forEachDocument([] (Document& document) { 3929 document.markers().removeMarkers(DocumentMarker::DraggedContent); 3930 }); 3932 3931 3933 3932 if (auto* mainFrameRenderer = page.mainFrame().contentRenderer()) -
trunk/Source/WebCore/page/Frame.cpp
r286825 r287110 363 363 void Frame::orientationChanged() 364 364 { 365 Vector<Ref<Frame>> frames; 366 for (Frame* frame = this; frame; frame = frame->tree().traverseNext()) 367 frames.append(*frame); 368 369 auto newOrientation = orientation(); 370 for (auto& frame : frames) { 371 if (Document* document = frame->document()) 372 document->orientationChanged(newOrientation); 373 } 365 Page::forEachDocumentFromMainFrame(*this, [newOrientation = orientation()] (Document& document) { 366 document.orientationChanged(newOrientation); 367 }); 374 368 } 375 369 -
trunk/Source/WebCore/page/Page.cpp
r287021 r287110 408 408 m_inspectorController->inspectedPageDestroyed(); 409 409 410 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {411 frame ->willDetachPage();412 frame ->detachFromPage();413 } 410 forEachFrameFromMainFrame([] (Frame& frame) { 411 frame.willDetachPage(); 412 frame.detachFromPage(); 413 }); 414 414 415 415 if (m_scrollingCoordinator) … … 1244 1244 } 1245 1245 1246 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 1247 if (frame->document()) 1248 frame->document()->windowScreenDidChange(displayID); 1249 } 1246 forEachDocument([&] (Document& document) { 1247 document.windowScreenDidChange(displayID); 1248 }); 1250 1249 1251 1250 #if ENABLE(VIDEO) … … 1985 1984 void Page::userAgentChanged() 1986 1985 { 1987 for (auto* frame = &m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) { 1988 auto* window = frame->window(); 1989 if (!window) 1990 continue; 1991 if (auto* navigator = window->optionalNavigator()) 1992 navigator->userAgentChanged(); 1993 } 1986 forEachDocument([] (Document& document) { 1987 if (auto* window = document.domWindow()) { 1988 if (auto* navigator = window->optionalNavigator()) 1989 navigator->userAgentChanged(); 1990 } 1991 }); 1994 1992 } 1995 1993 … … 2994 2992 m_hasBeenNotifiedToInjectUserScripts = true; 2995 2993 2996 for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) 2997 frame->injectUserScriptsAwaitingNotification(); 2994 forEachFrameFromMainFrame([] (Frame& frame) { 2995 frame.injectUserScriptsAwaitingNotification(); 2996 }); 2998 2997 } 2999 2998 … … 3405 3404 } 3406 3405 3407 void Page::forEachDocument (const Function<void(Document&)>& functor) const3406 void Page::forEachDocumentFromMainFrame(const Frame& mainFrame, const Function<void(Document&)>& functor) 3408 3407 { 3409 3408 Vector<Ref<Document>> documents; 3410 for (auto* frame = &mainFrame (); frame; frame = frame->tree().traverseNext()) {3409 for (auto* frame = &mainFrame; frame; frame = frame->tree().traverseNext()) { 3411 3410 auto* document = frame->document(); 3412 3411 if (!document) … … 3418 3417 } 3419 3418 3419 void Page::forEachDocument(const Function<void(Document&)>& functor) const 3420 { 3421 forEachDocumentFromMainFrame(mainFrame(), functor); 3422 } 3423 3420 3424 void Page::forEachMediaElement(const Function<void(HTMLMediaElement&)>& functor) 3421 3425 { … … 3427 3431 UNUSED_PARAM(functor); 3428 3432 #endif 3433 } 3434 3435 void Page::forEachFrameFromMainFrame(const Function<void(Frame&)>& functor) 3436 { 3437 Vector<Ref<Frame>> frames; 3438 for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) 3439 frames.append(*frame); 3440 3441 for (auto& frame : frames) 3442 functor(frame); 3429 3443 } 3430 3444 -
trunk/Source/WebCore/page/Page.h
r286905 r287110 893 893 WEBCORE_EXPORT void forEachDocument(const Function<void(Document&)>&) const; 894 894 void forEachMediaElement(const Function<void(HTMLMediaElement&)>&); 895 static void forEachDocumentFromMainFrame(const Frame&, const Function<void(Document&)>&); 896 void forEachFrameFromMainFrame(const Function<void(Frame&)>&); 895 897 896 898 bool shouldDisableCorsForRequestTo(const URL&) const; -
trunk/Source/WebCore/page/ios/FrameIOS.mm
r284095 r287110 645 645 return; 646 646 647 for (Frame* frame = this; frame; frame = frame->tree().traverseNext(this)) 648 frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, true), document()); 647 Page::forEachDocumentFromMainFrame(*this, [pagehideEvent = eventNames().pagehideEvent, mainDocument = document()](Document& document) { 648 document.domWindow()->dispatchEvent(PageTransitionEvent::create(pagehideEvent, true), mainDocument); 649 }); 649 650 } 650 651 … … 655 656 return; 656 657 657 for (Frame* frame = this; frame; frame = frame->tree().traverseNext(this)) 658 frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pageshowEvent, true), document()); 658 Page::forEachDocumentFromMainFrame(*this, [pageshowEvent = eventNames().pageshowEvent, mainDocument = document()](Document& document) { 659 document.domWindow()->dispatchEvent(PageTransitionEvent::create(pageshowEvent, true), mainDocument); 660 }); 659 661 } 660 662
Note:
See TracChangeset
for help on using the changeset viewer.