⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287110 in webkit


Ignore:
Timestamp:
Dec 15, 2021, 3:19:57 PM (5 years ago)
Author:
Brent Fulgham
Message:

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):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287108 r287110  
     12021-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
    1312021-12-15  Alex Christensen  <achristensen@webkit.org>
    232
  • trunk/Source/WebCore/history/BackForwardCache.cpp

    r282191 r287110  
    389389static void setBackForwardCacheState(Page& page, Document::BackForwardCacheState BackForwardCacheState)
    390390{
    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    });
    395394}
    396395
  • trunk/Source/WebCore/page/EventHandler.cpp

    r286415 r287110  
    39263926static void removeDraggedContentDocumentMarkersFromAllFramesInPage(Page& page)
    39273927{
    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    });
    39323931
    39333932    if (auto* mainFrameRenderer = page.mainFrame().contentRenderer())
  • trunk/Source/WebCore/page/Frame.cpp

    r286825 r287110  
    363363void Frame::orientationChanged()
    364364{
    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    });
    374368}
    375369
  • trunk/Source/WebCore/page/Page.cpp

    r287021 r287110  
    408408    m_inspectorController->inspectedPageDestroyed();
    409409
    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    });
    414414
    415415    if (m_scrollingCoordinator)
    … …  
    12441244    }
    12451245
    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    });
    12501249
    12511250#if ENABLE(VIDEO)
    … …  
    19851984void Page::userAgentChanged()
    19861985{
    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    });
    19941992}
    19951993
    … …  
    29942992    m_hasBeenNotifiedToInjectUserScripts = true;
    29952993
    2996     for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
    2997         frame->injectUserScriptsAwaitingNotification();
     2994    forEachFrameFromMainFrame([] (Frame& frame) {
     2995        frame.injectUserScriptsAwaitingNotification();
     2996    });
    29982997}
    29992998
    … …  
    34053404}
    34063405
    3407 void Page::forEachDocument(const Function<void(Document&)>& functor) const
     3406void Page::forEachDocumentFromMainFrame(const Frame& mainFrame, const Function<void(Document&)>& functor)
    34083407{
    34093408    Vector<Ref<Document>> documents;
    3410     for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
     3409    for (auto* frame = &mainFrame; frame; frame = frame->tree().traverseNext()) {
    34113410        auto* document = frame->document();
    34123411        if (!document)
    … …  
    34183417}
    34193418
     3419void Page::forEachDocument(const Function<void(Document&)>& functor) const
     3420{
     3421    forEachDocumentFromMainFrame(mainFrame(), functor);
     3422}
     3423
    34203424void Page::forEachMediaElement(const Function<void(HTMLMediaElement&)>& functor)
    34213425{
    … …  
    34273431    UNUSED_PARAM(functor);
    34283432#endif
     3433}
     3434
     3435void 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);
    34293443}
    34303444
  • trunk/Source/WebCore/page/Page.h

    r286905 r287110  
    893893    WEBCORE_EXPORT void forEachDocument(const Function<void(Document&)>&) const;
    894894    void forEachMediaElement(const Function<void(HTMLMediaElement&)>&);
     895    static void forEachDocumentFromMainFrame(const Frame&, const Function<void(Document&)>&);
     896    void forEachFrameFromMainFrame(const Function<void(Frame&)>&);
    895897
    896898    bool shouldDisableCorsForRequestTo(const URL&) const;
  • trunk/Source/WebCore/page/ios/FrameIOS.mm

    r284095 r287110  
    645645        return;
    646646
    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    });
    649650}
    650651
    … …  
    655656        return;
    656657
    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    });
    659661}
    660662
Note: See TracChangeset for help on using the changeset viewer.