Title: [271013] trunk/Source
Revision
271013
Author
[email protected]
Date
2020-12-20 08:29:14 -0800 (Sun, 20 Dec 2020)

Log Message

Convert remaining FrameLoaderType enums to enum classes
https://bugs.webkit.org/show_bug.cgi?id=219898

Patch by Rob Buis <[email protected]> on 2020-12-20
Reviewed by Sam Weinig.

Source/WebCore:

Convert remaining FrameLoaderType enums to enum classes.
Not converted is ShouldReplaceDocumentIfJavaScriptURL
since it should be removed eventually.

* dom/Document.cpp:
(WebCore::Document::open):
* history/BackForwardCache.cpp:
(WebCore::canCacheFrame):
(WebCore::firePageHideEventRecursively):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::stopLoading):
(WebCore::DocumentLoader::isLoadingInAPISense const):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::FrameLoader):
(WebCore::FrameLoader::initForSynthesizedDocument):
(WebCore::FrameLoader::stopLoading):
(WebCore::FrameLoader::closeURL):
(WebCore::FrameLoader::setupForReplace):
(WebCore::FrameLoader::stopAllLoaders):
(WebCore::FrameLoader::activeDocumentLoader const):
(WebCore::FrameLoader::setState):
(WebCore::FrameLoader::clearProvisionalLoad):
(WebCore::FrameLoader::transitionToCommitted):
(WebCore::FrameLoader::checkLoadCompleteForThisFrame):
(WebCore::FrameLoader::detachFromParent):
(WebCore::FrameLoader::receivedMainResourceError):
(WebCore::FrameLoader::dispatchUnloadEvents):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad):
(WebCore::FrameLoader::shouldSuppressTextInputFromEditing const):
* loader/FrameLoader.h:
* loader/FrameLoaderTypes.h:
* loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::schedule):
* loader/SubframeLoader.cpp:
(WebCore::FrameLoader::SubframeLoader::loadSubframe):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::load):
* page/FrameView.cpp:
(WebCore::FrameView::shouldSuspendScrollAnimations const):

Source/WebKit:

Adapt to enum class changes.

* WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFrameGetFrameLoadState):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271012 => 271013)


--- trunk/Source/WebCore/ChangeLog	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/ChangeLog	2020-12-20 16:29:14 UTC (rev 271013)
@@ -1,3 +1,51 @@
+2020-12-20  Rob Buis  <[email protected]>
+
+        Convert remaining FrameLoaderType enums to enum classes
+        https://bugs.webkit.org/show_bug.cgi?id=219898
+
+        Reviewed by Sam Weinig.
+
+        Convert remaining FrameLoaderType enums to enum classes.
+        Not converted is ShouldReplaceDocumentIfJavaScriptURL
+        since it should be removed eventually.
+
+        * dom/Document.cpp:
+        (WebCore::Document::open):
+        * history/BackForwardCache.cpp:
+        (WebCore::canCacheFrame):
+        (WebCore::firePageHideEventRecursively):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::stopLoading):
+        (WebCore::DocumentLoader::isLoadingInAPISense const):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::FrameLoader):
+        (WebCore::FrameLoader::initForSynthesizedDocument):
+        (WebCore::FrameLoader::stopLoading):
+        (WebCore::FrameLoader::closeURL):
+        (WebCore::FrameLoader::setupForReplace):
+        (WebCore::FrameLoader::stopAllLoaders):
+        (WebCore::FrameLoader::activeDocumentLoader const):
+        (WebCore::FrameLoader::setState):
+        (WebCore::FrameLoader::clearProvisionalLoad):
+        (WebCore::FrameLoader::transitionToCommitted):
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        (WebCore::FrameLoader::detachFromParent):
+        (WebCore::FrameLoader::receivedMainResourceError):
+        (WebCore::FrameLoader::dispatchUnloadEvents):
+        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
+        (WebCore::FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad):
+        (WebCore::FrameLoader::shouldSuppressTextInputFromEditing const):
+        * loader/FrameLoader.h:
+        * loader/FrameLoaderTypes.h:
+        * loader/NavigationScheduler.cpp:
+        (WebCore::NavigationScheduler::schedule):
+        * loader/SubframeLoader.cpp:
+        (WebCore::FrameLoader::SubframeLoader::loadSubframe):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::load):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::shouldSuspendScrollAnimations const):
+
 2020-12-20  Zalan Bujtas  <[email protected]>
 
         [LFC] Move content height logic to the formatting contexts.

Modified: trunk/Source/WebCore/dom/Document.cpp (271012 => 271013)


--- trunk/Source/WebCore/dom/Document.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/dom/Document.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -2889,7 +2889,7 @@
 
         if (m_frame->loader().policyChecker().delegateIsDecidingNavigationPolicy())
             m_frame->loader().policyChecker().stopCheck();
-        if (m_frame && m_frame->loader().state() == FrameStateProvisional)
+        if (m_frame && m_frame->loader().state() == FrameState::Provisional)
             m_frame->loader().stopAllLoaders();
     }
 

Modified: trunk/Source/WebCore/history/BackForwardCache.cpp (271012 => 271013)


--- trunk/Source/WebCore/history/BackForwardCache.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/history/BackForwardCache.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -80,7 +80,7 @@
 
     // Prevent page caching if a subframe is still in provisional load stage.
     // We only do this check for subframes because the main frame is reused when navigating to a new page.
-    if (!frame.isMainFrame() && frameLoader.state() == FrameStateProvisional) {
+    if (!frame.isMainFrame() && frameLoader.state() == FrameState::Provisional) {
         PCLOG("   -Frame is in provisional load stage");
         logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::provisionalLoadKey());
         return false;
@@ -420,7 +420,7 @@
     // https://html.spec.whatwg.org/multipage/browsers.html#unload-a-document
     IgnoreOpensDuringUnloadCountIncrementer ignoreOpensDuringUnloadCountIncrementer(document);
 
-    frame.loader().stopLoading(UnloadEventPolicyUnloadAndPageHide);
+    frame.loader().stopLoading(UnloadEventPolicy::UnloadAndPageHide);
 
     for (RefPtr<Frame> child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
         firePageHideEventRecursively(*child);

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (271012 => 271013)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -320,7 +320,7 @@
         Document* doc = m_frame->document();
         
         if (loading || doc->parsing())
-            m_frame->loader().stopLoading(UnloadEventPolicyNone);
+            m_frame->loader().stopLoading(UnloadEventPolicy::None);
     }
 
     for (auto callbackIdentifier : m_iconLoaders.values())
@@ -1464,7 +1464,7 @@
 {
     // Once a frame has loaded, we no longer need to consider subresources,
     // but we still need to consider subframes.
-    if (frameLoader()->state() != FrameStateComplete) {
+    if (frameLoader()->state() != FrameState::Complete) {
         if (m_frame->settings().needsIsLoadingInAPISenseQuirk() && !m_subresourceLoaders.isEmpty())
             return true;
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (271012 => 271013)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -297,7 +297,7 @@
     , m_history(makeUnique<HistoryController>(frame))
     , m_notifier(frame)
     , m_subframeLoader(makeUnique<SubframeLoader>(frame))
-    , m_state(FrameStateProvisional)
+    , m_state(FrameState::Provisional)
     , m_loadType(FrameLoadType::Standard)
     , m_quickRedirectComing(false)
     , m_sentRedirectNotification(false)
@@ -367,7 +367,7 @@
 
     m_didCallImplicitClose = true;
     m_isComplete = true;
-    m_state = FrameStateComplete;
+    m_state = FrameState::Complete;
     m_needsClear = true;
 
     m_networkingContext = m_client->createNetworkingContext();
@@ -522,7 +522,7 @@
     if (m_frame.document() && m_frame.document()->parser())
         m_frame.document()->parser()->stopParsing();
 
-    if (unloadEventPolicy != UnloadEventPolicyNone)
+    if (unloadEventPolicy != UnloadEventPolicy::None)
         dispatchUnloadEvents(unloadEventPolicy);
 
     m_isComplete = true; // to avoid calling completed() in finishedParsing()
@@ -564,10 +564,10 @@
     UnloadEventPolicy unloadEventPolicy;
     if (m_frame.page() && m_frame.page()->chrome().client().isSVGImageChromeClient()) {
         // If this is the SVGDocument of an SVGImage, no need to dispatch events or recalcStyle.
-        unloadEventPolicy = UnloadEventPolicyNone;
+        unloadEventPolicy = UnloadEventPolicy::None;
     } else {
         // Should only send the pagehide event here if the current document exists and has not been placed in the back/forward cache.
-        unloadEventPolicy = currentDocument && currentDocument->backForwardCacheState() == Document::NotInBackForwardCache ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly;
+        unloadEventPolicy = currentDocument && currentDocument->backForwardCacheState() == Document::NotInBackForwardCache ? UnloadEventPolicy::UnloadAndPageHide : UnloadEventPolicy::UnloadOnly;
     }
 
     stopLoading(unloadEventPolicy);
@@ -1220,7 +1220,7 @@
 void FrameLoader::setupForReplace()
 {
     m_client->revertToProvisionalState(m_documentLoader.get());
-    setState(FrameStateProvisional);
+    setState(FrameState::Provisional);
     m_provisionalDocumentLoader = m_documentLoader;
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "setupForReplace: Setting provisional document loader (m_provisionalDocumentLoader=%p)", m_provisionalDocumentLoader.get());
     m_documentLoader = nullptr;
@@ -1776,7 +1776,7 @@
     loadWithDocumentLoader(loader.ptr(), frameLoadTypeForReloadOptions(options), { }, AllowNavigationToInvalidURL::Yes);
 }
 
-void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy, StopLoadingPolicy stopLoadingPolicy)
+void FrameLoader::stopAllLoaders(ClearProvisionalItem clearProvisionalItem, StopLoadingPolicy stopLoadingPolicy)
 {
     if (m_frame.document() && m_frame.document()->backForwardCacheState() == Document::InBackForwardCache)
         return;
@@ -1801,11 +1801,11 @@
 
     // If no new load is in progress, we should clear the provisional item from history
     // before we call stopLoading.
-    if (clearProvisionalItemPolicy == ShouldClearProvisionalItem)
+    if (clearProvisionalItem == ClearProvisionalItem::Yes)
         history().setProvisionalItem(nullptr);
 
     for (RefPtr<Frame> child = m_frame.tree().firstChild(); child; child = child->tree().nextSibling())
-        child->loader().stopAllLoaders(clearProvisionalItemPolicy);
+        child->loader().stopAllLoaders(clearProvisionalItem);
 
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "stopAllLoaders: m_provisionalDocumentLoader=%p, m_documentLoader=%p", m_provisionalDocumentLoader.get(), m_documentLoader.get());
 
@@ -1881,7 +1881,7 @@
 
 DocumentLoader* FrameLoader::activeDocumentLoader() const
 {
-    if (m_state == FrameStateProvisional)
+    if (m_state == FrameState::Provisional)
         return m_provisionalDocumentLoader.get();
     return m_documentLoader.get();
 }
@@ -1965,9 +1965,9 @@
     FrameState oldState = m_state;
     m_state = newState;
     
-    if (newState == FrameStateProvisional)
+    if (newState == FrameState::Provisional)
         provisionalLoadStarted();
-    else if (newState == FrameStateComplete) {
+    else if (newState == FrameState::Complete) {
         frameLoadCompleted();
         if (m_documentLoader)
             m_documentLoader->stopRecordingResponses();
@@ -1983,7 +1983,7 @@
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "clearProvisionalLoad: Clearing provisional document loader (m_provisionalDocumentLoader=%p)", m_provisionalDocumentLoader.get());
     setProvisionalDocumentLoader(nullptr);
     m_progressTracker->progressCompleted();
-    setState(FrameStateComplete);
+    setState(FrameState::Complete);
 }
 
 void FrameLoader::commitProvisionalLoad()
@@ -2129,9 +2129,9 @@
 void FrameLoader::transitionToCommitted(CachedPage* cachedPage)
 {
     ASSERT(m_client->hasWebView());
-    ASSERT(m_state == FrameStateProvisional);
+    ASSERT(m_state == FrameState::Provisional);
 
-    if (m_state != FrameStateProvisional)
+    if (m_state != FrameState::Provisional)
         return;
 
     if (FrameView* view = m_frame.view()) {
@@ -2166,7 +2166,7 @@
     setProvisionalDocumentLoader(nullptr);
 
     // Nothing else can interrupt this commit - set the Provisional->Committed transition in stone
-    setState(FrameStateCommittedPage);
+    setState(FrameState::CommittedPage);
 
     // Handle adding the URL to the back/forward list.
     auto documentLoader = m_documentLoader;
@@ -2478,134 +2478,136 @@
         return;
 
     switch (m_state) {
-        case FrameStateProvisional: {
-            // FIXME: Prohibiting any provisional load failures from being sent to clients
-            // while handling provisional load failures is too heavy. For example, the current
-            // load will fail to cancel another ongoing load. That might prevent clients' page
-            // load state being handled properly.
-            if (!m_provisionalLoadErrorBeingHandledURL.isEmpty())
-                return;
+    case FrameState::Provisional: {
+        // FIXME: Prohibiting any provisional load failures from being sent to clients
+        // while handling provisional load failures is too heavy. For example, the current
+        // load will fail to cancel another ongoing load. That might prevent clients' page
+        // load state being handled properly.
+        if (!m_provisionalLoadErrorBeingHandledURL.isEmpty())
+            return;
 
-            RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
-            if (!pdl)
-                return;
-                
-            // If we've received any errors we may be stuck in the provisional state and actually complete.
-            const ResourceError& error = pdl->mainDocumentError();
-            if (error.isNull())
-                return;
+        RefPtr<DocumentLoader> protector = m_provisionalDocumentLoader;
+        if (!protector)
+            return;
 
-            // Check all children first.
-            RefPtr<HistoryItem> item;
-            if (Page* page = m_frame.page())
-                if (isBackForwardLoadType(loadType()))
-                    // Reset the back forward list to the last committed history item at the top level.
-                    item = page->mainFrame().loader().history().currentItem();
-                
-            // Only reset if we aren't already going to a new provisional item.
-            bool shouldReset = !history().provisionalItem();
-            if (!pdl->isLoadingInAPISense() || pdl->isStopping()) {
-                FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Failed provisional load (isTimeout = %d, isCancellation = %d, errorCode = %d)", error.isTimeout(), error.isCancellation(), error.errorCode());
+        // If we've received any errors we may be stuck in the provisional state and actually complete.
+        const ResourceError& error = protector->mainDocumentError();
+        if (error.isNull())
+            return;
 
-                dispatchDidFailProvisionalLoad(*pdl, error);
-                ASSERT(!pdl->isLoading());
+        // Check all children first.
+        RefPtr<HistoryItem> item;
+        if (Page* page = m_frame.page()) {
+            if (isBackForwardLoadType(loadType())) {
+                // Reset the back forward list to the last committed history item at the top level.
+                item = page->mainFrame().loader().history().currentItem();
+            }
+        }
 
-                // If we're in the middle of loading multipart data, we need to restore the document loader.
-                if (isReplacing() && !m_documentLoader.get())
+        // Only reset if we aren't already going to a new provisional item.
+        bool shouldReset = !history().provisionalItem();
+        if (!protector->isLoadingInAPISense() || protector->isStopping()) {
+            FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Failed provisional load (isTimeout = %d, isCancellation = %d, errorCode = %d)", error.isTimeout(), error.isCancellation(), error.errorCode());
+
+            dispatchDidFailProvisionalLoad(*protector, error);
+            ASSERT(!protector->isLoading());
+
+            // If we're in the middle of loading multipart data, we need to restore the document loader.
+            if (isReplacing() && !m_documentLoader.get())
                     setDocumentLoader(m_provisionalDocumentLoader.get());
 
-                // Finish resetting the load state, but only if another load hasn't been started by the
-                // delegate callback.
-                if (pdl == m_provisionalDocumentLoader)
-                    clearProvisionalLoad();
-                else if (activeDocumentLoader()) {
-                    URL unreachableURL = activeDocumentLoader()->unreachableURL();
-                    if (!unreachableURL.isEmpty() && unreachableURL == pdl->request().url())
-                        shouldReset = false;
-                }
+            // Finish resetting the load state, but only if another load hasn't been started by the
+            // delegate callback.
+            if (protector == m_provisionalDocumentLoader)
+                clearProvisionalLoad();
+            else if (activeDocumentLoader()) {
+                URL unreachableURL = activeDocumentLoader()->unreachableURL();
+                if (!unreachableURL.isEmpty() && unreachableURL == protector->request().url())
+                    shouldReset = false;
             }
-            if (shouldReset && item)
-                if (Page* page = m_frame.page()) {
-                    page->backForward().setCurrentItem(*item);
-                }
-            return;
         }
+        if (shouldReset && item) {
+            if (Page* page = m_frame.page())
+                page->backForward().setCurrentItem(*item);
+        }
+        return;
+    }
         
-        case FrameStateCommittedPage: {
-            if (!m_documentLoader)
-                return;
-            if (m_documentLoader->isLoadingInAPISense() && !m_documentLoader->isStopping() && !m_checkingLoadCompleteForDetachment)
-                return;
+    case FrameState::CommittedPage: {
+        if (!m_documentLoader)
+            return;
+        if (m_documentLoader->isLoadingInAPISense() && !m_documentLoader->isStopping() && !m_checkingLoadCompleteForDetachment)
+            return;
 
-            setState(FrameStateComplete);
+        setState(FrameState::Complete);
 
-            // FIXME: Is this subsequent work important if we already navigated away?
-            // Maybe there are bugs because of that, or extra work we can skip because
-            // the new page is ready.
+        // FIXME: Is this subsequent work important if we already navigated away?
+        // Maybe there are bugs because of that, or extra work we can skip because
+        // the new page is ready.
 
-            m_client->forceLayoutForNonHTML();
+        m_client->forceLayoutForNonHTML();
              
-            // If the user had a scroll point, scroll to it, overriding the anchor point if any.
-            if (m_frame.page()) {
-                if (isBackForwardLoadType(m_loadType) || isReload(m_loadType))
-                    history().restoreScrollPositionAndViewState();
-            }
+        // If the user had a scroll point, scroll to it, overriding the anchor point if any.
+        if (m_frame.page()) {
+            if (isBackForwardLoadType(m_loadType) || isReload(m_loadType))
+                history().restoreScrollPositionAndViewState();
+        }
 
-            if (m_stateMachine.creatingInitialEmptyDocument() || !m_stateMachine.committedFirstRealDocumentLoad())
-                return;
+        if (m_stateMachine.creatingInitialEmptyDocument() || !m_stateMachine.committedFirstRealDocumentLoad())
+            return;
 
-            m_progressTracker->progressCompleted();
-            Page* page = m_frame.page();
-            if (page) {
-                if (m_frame.isMainFrame()) {
-                    tracePoint(MainResourceLoadDidEnd);
-                    page->didFinishLoad();
-                }
+        m_progressTracker->progressCompleted();
+        Page* page = m_frame.page();
+        if (page) {
+            if (m_frame.isMainFrame()) {
+                tracePoint(MainResourceLoadDidEnd);
+                page->didFinishLoad();
             }
+        }
 
-            const ResourceError& error = m_documentLoader->mainDocumentError();
+        const ResourceError& error = m_documentLoader->mainDocumentError();
 
-            AXObjectCache::AXLoadingEvent loadingEvent;
-            if (!error.isNull()) {
-                FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Finished frame load with error (isTimeout = %d, isCancellation = %d, errorCode = %d)", error.isTimeout(), error.isCancellation(), error.errorCode());
-                m_client->dispatchDidFailLoad(error);
-                loadingEvent = AXObjectCache::AXLoadingFailed;
-            } else {
-                FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Finished frame load");
+        AXObjectCache::AXLoadingEvent loadingEvent;
+        if (!error.isNull()) {
+            FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Finished frame load with error (isTimeout = %d, isCancellation = %d, errorCode = %d)", error.isTimeout(), error.isCancellation(), error.errorCode());
+            m_client->dispatchDidFailLoad(error);
+            loadingEvent = AXObjectCache::AXLoadingFailed;
+        } else {
+            FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Finished frame load");
 #if ENABLE(DATA_DETECTION)
-                auto document = m_frame.document();
-                auto types = OptionSet<DataDetectorType> { m_frame.settings().dataDetectorTypes() };
-                if (document && types) {
-                    m_frame.setDataDetectionResults(DataDetection::detectContentInRange(makeRangeSelectingNodeContents(*document), types, m_client->dataDetectionContext()));
-                    if (m_frame.isMainFrame())
-                        m_client->dispatchDidFinishDataDetection(m_frame.dataDetectionResults());
-                }
+            auto document = m_frame.document();
+            auto types = OptionSet<DataDetectorType> { m_frame.settings().dataDetectorTypes() };
+            if (document && types) {
+                m_frame.setDataDetectionResults(DataDetection::detectContentInRange(makeRangeSelectingNodeContents(*document), types, m_client->dataDetectionContext()));
+                if (m_frame.isMainFrame())
+                    m_client->dispatchDidFinishDataDetection(m_frame.dataDetectionResults());
+            }
 #endif
-                m_client->dispatchDidFinishLoad();
-                loadingEvent = AXObjectCache::AXLoadingFinished;
-            }
+            m_client->dispatchDidFinishLoad();
+            loadingEvent = AXObjectCache::AXLoadingFinished;
+        }
 
-            // Notify accessibility.
-            if (auto* document = m_frame.document()) {
-                if (AXObjectCache* cache = document->existingAXObjectCache())
-                    cache->frameLoadingEventNotification(&m_frame, loadingEvent);
-            }
+        // Notify accessibility.
+        if (auto* document = m_frame.document()) {
+            if (AXObjectCache* cache = document->existingAXObjectCache())
+                cache->frameLoadingEventNotification(&m_frame, loadingEvent);
+        }
 
-            // The above calls to dispatchDidFinishLoad() might have detached the Frame
-            // from its Page and also might have caused Page to be deleted.
-            // Don't assume 'page' is still available to use.
-            if (m_frame.isMainFrame() && m_frame.page()) {
-                ASSERT(&m_frame.page()->mainFrame() == &m_frame);
-                m_frame.page()->diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageLoadedKey(), emptyString(), error.isNull() ? DiagnosticLoggingResultPass : DiagnosticLoggingResultFail, ShouldSample::Yes);
-            }
+        // The above calls to dispatchDidFinishLoad() might have detached the Frame
+        // from its Page and also might have caused Page to be deleted.
+        // Don't assume 'page' is still available to use.
+        if (m_frame.isMainFrame() && m_frame.page()) {
+            ASSERT(&m_frame.page()->mainFrame() == &m_frame);
+            m_frame.page()->diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageLoadedKey(), emptyString(), error.isNull() ? DiagnosticLoggingResultPass : DiagnosticLoggingResultFail, ShouldSample::Yes);
+        }
 
-            return;
-        }
+        return;
+    }
         
-        case FrameStateComplete:
-            m_loadType = FrameLoadType::Standard;
-            frameLoadCompleted();
-            return;
+    case FrameState::Complete:
+        m_loadType = FrameLoadType::Standard;
+        frameLoadCompleted();
+        return;
     }
 
     ASSERT_NOT_REACHED();
@@ -2818,7 +2820,7 @@
         // stopAllLoaders() needs to be called after detachChildren() if the document is not in the back/forward cache,
         // because detachedChildren() will trigger the unload event handlers of any child frames, and those event
         // handlers might start a new subresource load in this frame.
-        stopAllLoaders(ShouldClearProvisionalItem, StopLoadingPolicy::AlwaysStopLoading);
+        stopAllLoaders(ClearProvisionalItem::Yes, StopLoadingPolicy::AlwaysStopLoading);
     }
 
     InspectorInstrumentation::frameDetachedFromParent(m_frame);
@@ -3133,7 +3135,7 @@
             downcast<HTMLObjectElement>(*owner).renderFallbackContent();
     }
 
-    if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
+    if (m_state == FrameState::Provisional && m_provisionalDocumentLoader) {
         if (m_submittedFormURL == m_provisionalDocumentLoader->originalRequestCopy().url())
             m_submittedFormURL = URL();
             
@@ -3279,7 +3281,7 @@
         if (is<HTMLInputElement>(currentFocusedElement))
             downcast<HTMLInputElement>(*currentFocusedElement).endEditing();
         if (m_pageDismissalEventBeingDispatched == PageDismissalType::None) {
-            if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
+            if (unloadEventPolicy == UnloadEventPolicy::UnloadAndPageHide) {
                 m_pageDismissalEventBeingDispatched = PageDismissalType::PageHide;
                 m_frame.document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()->backForwardCacheState() == Document::AboutToEnterBackForwardCache), m_frame.document());
             }
@@ -3451,7 +3453,7 @@
 
     FrameLoadType type = policyChecker().loadType();
     // A new navigation is in progress, so don't clear the history's provisional item.
-    stopAllLoaders(ShouldNotClearProvisionalItem);
+    stopAllLoaders(ClearProvisionalItem::No);
     
     // <rdar://problem/6250856> - In certain circumstances on pages with multiple frames, stopAllLoaders()
     // might detach the current FrameLoader, in which case we should bail on this newly defunct load. 
@@ -3463,7 +3465,7 @@
     setProvisionalDocumentLoader(m_policyDocumentLoader.get());
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "continueLoadAfterNavigationPolicy: Setting provisional document loader (m_provisionalDocumentLoader=%p)", m_provisionalDocumentLoader.get());
     m_loadType = type;
-    setState(FrameStateProvisional);
+    setState(FrameState::Provisional);
 
     setPolicyDocumentLoader(nullptr);
 
@@ -3847,7 +3849,7 @@
 
 void FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad()
 {
-    ASSERT(m_state == FrameStateProvisional);
+    ASSERT(m_state == FrameState::Provisional);
     ASSERT(!m_loadingFromCachedPage);
     ASSERT(history().provisionalItem());
     ASSERT(history().provisionalItem()->formData());
@@ -3856,7 +3858,7 @@
     FrameLoadType loadType = m_loadType;
     HistoryItem* item = history().provisionalItem();
 
-    stopAllLoaders(ShouldNotClearProvisionalItem);
+    stopAllLoaders(ClearProvisionalItem::No);
     if (item)
         loadDifferentDocumentItem(*item, history().currentItem(), loadType, MayNotAttemptCacheOnlyLoadForFormSubmissionItem, ShouldTreatAsContinuingLoad::No);
     else {
@@ -4176,7 +4178,7 @@
 
 bool FrameLoader::shouldSuppressTextInputFromEditing() const
 {
-    return m_frame.settings().shouldSuppressTextInputFromEditingDuringProvisionalNavigation() && m_state == FrameStateProvisional;
+    return m_frame.settings().shouldSuppressTextInputFromEditingDuringProvisionalNavigation() && m_state == FrameState::Provisional;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/FrameLoader.h (271012 => 271013)


--- trunk/Source/WebCore/loader/FrameLoader.h	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2020-12-20 16:29:14 UTC (rev 271013)
@@ -144,7 +144,7 @@
 
     // FIXME: These are all functions which stop loads. We have too many.
     void stopAllLoadersAndCheckCompleteness();
-    WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItemPolicy = ShouldClearProvisionalItem, StopLoadingPolicy = StopLoadingPolicy::PreventDuringUnloadEvents);
+    WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItem = ClearProvisionalItem::Yes, StopLoadingPolicy = StopLoadingPolicy::PreventDuringUnloadEvents);
     WEBCORE_EXPORT void stopForUserCancel(bool deferCheckLoadComplete = false);
     void stopForBackForwardCache();
     void stop();

Modified: trunk/Source/WebCore/loader/FrameLoaderTypes.h (271012 => 271013)


--- trunk/Source/WebCore/loader/FrameLoaderTypes.h	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/FrameLoaderTypes.h	2020-12-20 16:29:14 UTC (rev 271013)
@@ -35,12 +35,12 @@
 
 namespace WebCore {
 
-enum FrameState {
-    FrameStateProvisional,
+enum class FrameState : uint8_t {
+    Provisional,
     // This state indicates we are ready to commit to a page,
     // which means the view will transition to use the new data source.
-    FrameStateCommittedPage,
-    FrameStateComplete
+    CommittedPage,
+    Complete
 };
 
 enum class PolicyAction : uint8_t {
@@ -143,9 +143,9 @@
     Unknown,
 };
 
-enum ClearProvisionalItemPolicy {
-    ShouldClearProvisionalItem,
-    ShouldNotClearProvisionalItem
+enum class ClearProvisionalItem : bool {
+    Yes,
+    No
 };
 
 enum class StopLoadingPolicy {
@@ -160,10 +160,10 @@
     PlugIn,
 };
 
-enum UnloadEventPolicy {
-    UnloadEventPolicyNone,
-    UnloadEventPolicyUnloadOnly,
-    UnloadEventPolicyUnloadAndPageHide
+enum class UnloadEventPolicy {
+    None,
+    UnloadOnly,
+    UnloadAndPageHide
 };
 
 // Passed to FrameLoader::urlSelected() and ScriptController::executeIfJavaScriptURL()

Modified: trunk/Source/WebCore/loader/NavigationScheduler.cpp (271012 => 271013)


--- trunk/Source/WebCore/loader/NavigationScheduler.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/NavigationScheduler.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -563,7 +563,7 @@
     if (redirect->wasDuringLoad()) {
         if (DocumentLoader* provisionalDocumentLoader = m_frame.loader().provisionalDocumentLoader())
             provisionalDocumentLoader->stopLoading();
-        m_frame.loader().stopLoading(UnloadEventPolicyUnloadAndPageHide);
+        m_frame.loader().stopLoading(UnloadEventPolicy::UnloadAndPageHide);
     }
 
     cancel();

Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (271012 => 271013)


--- trunk/Source/WebCore/loader/SubframeLoader.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -317,7 +317,7 @@
     // FIXME: In this case the Frame will have finished loading before 
     // it's being added to the child list. It would be a good idea to
     // create the child first, then invoke the loader separately.
-    if (frame->loader().state() == FrameStateComplete && !frame->loader().policyDocumentLoader())
+    if (frame->loader().state() == FrameState::Complete && !frame->loader().policyDocumentLoader())
         frame->loader().checkCompleted();
 
     if (!frame->tree().parent())

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (271012 => 271013)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -244,7 +244,7 @@
     FrameLoader& frameLoader = frame.loader();
     if (m_options.securityCheck == SecurityCheckPolicy::DoSecurityCheck && !m_options.keepAlive && !shouldUsePingLoad(type())) {
         while (true) {
-            if (frameLoader.state() == FrameStateProvisional)
+            if (frameLoader.state() == FrameState::Provisional)
                 RELEASE_LOG_IF_ALLOWED_WITH_FRAME("load: Failed security check -- state is provisional", frame);
             else if (!frameLoader.activeDocumentLoader())
                 RELEASE_LOG_IF_ALLOWED_WITH_FRAME("load: Failed security check -- not active document", frame);

Modified: trunk/Source/WebCore/page/FrameView.cpp (271012 => 271013)


--- trunk/Source/WebCore/page/FrameView.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebCore/page/FrameView.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -3946,7 +3946,7 @@
 
 bool FrameView::shouldSuspendScrollAnimations() const
 {
-    return frame().loader().state() != FrameStateComplete;
+    return frame().loader().state() != FrameState::Complete;
 }
 
 void FrameView::scrollbarStyleChanged(ScrollbarStyle newStyle, bool forceUpdate)

Modified: trunk/Source/WebKit/ChangeLog (271012 => 271013)


--- trunk/Source/WebKit/ChangeLog	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebKit/ChangeLog	2020-12-20 16:29:14 UTC (rev 271013)
@@ -1,3 +1,17 @@
+2020-12-20  Rob Buis  <[email protected]>
+
+        Convert remaining FrameLoaderType enums to enum classes
+        https://bugs.webkit.org/show_bug.cgi?id=219898
+
+        Reviewed by Sam Weinig.
+
+        Adapt to enum class changes.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameGetFrameLoadState):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
+
 2020-12-19  Rob Buis  <[email protected]>
 
         Move FrameLoader::arePluginsEnabled to Frame

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp (271012 => 271013)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -77,11 +77,11 @@
         return kWKFrameLoadStateFinished;
 
     switch (coreFrame->loader().state()) {
-    case WebCore::FrameStateProvisional:
+    case WebCore::FrameState::Provisional:
         return kWKFrameLoadStateProvisional;
-    case WebCore::FrameStateCommittedPage:
+    case WebCore::FrameState::CommittedPage:
         return kWKFrameLoadStateCommitted;
-    case WebCore::FrameStateComplete:
+    case WebCore::FrameState::Complete:
         return kWKFrameLoadStateFinished;
     }
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (271012 => 271013)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2020-12-20 15:11:09 UTC (rev 271012)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2020-12-20 16:29:14 UTC (rev 271013)
@@ -342,7 +342,7 @@
 
     WebDocumentLoader* documentLoader = static_cast<WebDocumentLoader*>(m_frame->coreFrame()->loader().provisionalDocumentLoader());
     if (!documentLoader) {
-        WEBFRAMELOADERCLIENT_RELEASE_LOG_FAULT(Loading, "dispatchDidReceiveServerRedirectForProvisionalLoad: Called with no provisional DocumentLoader (frameState=%i, stateForDebugging=%i)", m_frame->coreFrame()->loader().state(), m_frame->coreFrame()->loader().stateMachine().stateForDebugging());
+        WEBFRAMELOADERCLIENT_RELEASE_LOG_FAULT(Loading, "dispatchDidReceiveServerRedirectForProvisionalLoad: Called with no provisional DocumentLoader (frameState=%hhu, stateForDebugging=%i)", m_frame->coreFrame()->loader().state(), m_frame->coreFrame()->loader().stateMachine().stateForDebugging());
         return;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to