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

Changeset 243094 in webkit


Ignore:
Timestamp:
Mar 18, 2019, 1:23:47 PM (7 years ago)
Author:
Chris Dumez
Message:

Delay WebProcess launch until a load is triggered in a Web view
https://bugs.webkit.org/show_bug.cgi?id=195758
<rdar://problem/48126013>

Reviewed by Geoff Garen.

Source/WebKit:

This is achieved by constructing WebPageProxy objects with a WebProcessProxy that is in
terminated state (because it never launched its process). This is convenient because
it is a state that the WebPageProxy supports, which normally happened by the WebProcess
crashes. When trying to do a load, we were already checking if the WebPageProxy's process
was running (via an isValid() check) and we would re-launch the WebProcess if necessary
by calling reattachToWebProcess(). For clarity, given that this state is no longer
indicating that the WebProcess crashed, I renamed isValid() to hasRunningProcess() and
reattachToWebProcess() to launchProcess().

The reason delaying the WebProcess launch until the first load is useful is because it
allows us to leverage the WebProcessCache given that we now know which registrable
domain is going to be loaded in the process.

This is a progression from a power usage standpoint. When it comes to page load time,
it would be a progression if we found a suitable process in the cache. I do not expect
a performance hit when no process is found in the cache because of process prewarming.

  • Shared/API/Cocoa/RemoteObjectRegistry.h:
  • Shared/API/Cocoa/RemoteObjectRegistry.mm:

(WebKit::m_launchInitialProcessIfNecessary):
(WebKit::RemoteObjectRegistry::sendInvocation):

  • UIProcess/API/Cocoa/WKProcessPool.mm:

(-[WKProcessPool _processCacheSize]):

  • UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _isValid]):

  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::WebAutomationSession::willShowJavaScriptDialog):

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

(WebKit::WebPageProxy::performDictionaryLookupAtLocation):
(WebKit::WebPageProxy::performDictionaryLookupOfCurrentSelection):

  • UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:

(WebKit::DrawingAreaProxyCoordinatedGraphics::sendUpdateBackingStoreState):
(WebKit::DrawingAreaProxyCoordinatedGraphics::waitForAndDispatchDidUpdateBackingStoreState):
(WebKit::DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing):

  • UIProcess/DrawingAreaProxy.cpp:

(WebKit::DrawingAreaProxy::setViewExposedRect):
(WebKit::DrawingAreaProxy::viewExposedRectChangedTimerFired):

  • UIProcess/GeolocationPermissionRequestManagerProxy.cpp:

(WebKit::GeolocationPermissionRequestManagerProxy::didReceiveGeolocationPermissionDecision):

  • UIProcess/InspectorTargetProxy.cpp:

(WebKit::InspectorTargetProxy::connect):
(WebKit::InspectorTargetProxy::disconnect):
(WebKit::InspectorTargetProxy::sendMessageToTargetBackend):

  • UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:

(WebKit::RemoteLayerTreeDrawingAreaProxy::sizeDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay):
(WebKit::RemoteLayerTreeDrawingAreaProxy::dispatchAfterEnsuringDrawing):

  • UIProcess/UserMediaPermissionRequestManagerProxy.cpp:

(WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
(WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied):
(WebKit::UserMediaPermissionRequestManagerProxy::denyRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted):
(WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
(WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
(WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged):

  • UIProcess/ViewGestureController.cpp:

(WebKit::ViewGestureController::ViewGestureController):

  • UIProcess/WebBackForwardList.cpp:

(WebKit::WebBackForwardList::~WebBackForwardList):

  • UIProcess/WebCookieManagerProxy.cpp:

(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):

  • UIProcess/WebEditCommandProxy.cpp:

(WebKit::WebEditCommandProxy::unapply):
(WebKit::WebEditCommandProxy::reapply):

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::stopLoading const):

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::WebInspectorProxy):

  • UIProcess/WebPageProxy.cpp:

(WebKit::m_resetRecentCrashCountTimer):
(WebKit::WebPageProxy::hasRunningProcess const):
(WebKit::WebPageProxy::setUIClient):
(WebKit::WebPageProxy::setIconLoadingClient):
(WebKit::WebPageProxy::launchProcess):
(WebKit::WebPageProxy::swapToWebProcess):
(WebKit::WebPageProxy::finishAttachingToWebProcess):
(WebKit::WebPageProxy::didAttachToRunningProcess):
(WebKit::WebPageProxy::launchProcessForReload):
(WebKit::WebPageProxy::launchProcessWithItem):
(WebKit::WebPageProxy::initializeWebPage):
(WebKit::WebPageProxy::tryClose):
(WebKit::WebPageProxy::loadRequest):
(WebKit::WebPageProxy::loadFile):
(WebKit::WebPageProxy::loadData):
(WebKit::WebPageProxy::loadAlternateHTML):
(WebKit::WebPageProxy::loadWebArchiveData):
(WebKit::WebPageProxy::navigateToPDFLinkWithSimulatedClick):
(WebKit::WebPageProxy::stopLoading):
(WebKit::WebPageProxy::reload):
(WebKit::WebPageProxy::goToBackForwardItem):
(WebKit::WebPageProxy::tryRestoreScrollPosition):
(WebKit::WebPageProxy::setControlledByAutomation):
(WebKit::WebPageProxy::setIndicating):
(WebKit::WebPageProxy::setBackgroundColor):
(WebKit::WebPageProxy::setTopContentInset):
(WebKit::WebPageProxy::setUnderlayColor):
(WebKit::WebPageProxy::viewWillStartLiveResize):
(WebKit::WebPageProxy::viewWillEndLiveResize):
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::layerHostingModeDidChange):
(WebKit::WebPageProxy::waitForDidUpdateActivityState):
(WebKit::WebPageProxy::setInitialFocus):
(WebKit::WebPageProxy::clearSelection):
(WebKit::WebPageProxy::restoreSelectionInFocusedEditableElement):
(WebKit::WebPageProxy::validateCommand):
(WebKit::WebPageProxy::increaseListLevel):
(WebKit::WebPageProxy::decreaseListLevel):
(WebKit::WebPageProxy::changeListType):
(WebKit::WebPageProxy::setBaseWritingDirection):
(WebKit::WebPageProxy::setNeedsFontAttributes):
(WebKit::WebPageProxy::executeEditCommand):
(WebKit::WebPageProxy::requestFontAttributesAtSelectionStart):
(WebKit::WebPageProxy::setEditable):
(WebKit::WebPageProxy::performDragControllerAction):
(WebKit::WebPageProxy::dragEnded):
(WebKit::WebPageProxy::didStartDrag):
(WebKit::WebPageProxy::dragCancelled):
(WebKit::WebPageProxy::handleMouseEvent):
(WebKit::WebPageProxy::processNextQueuedMouseEvent):
(WebKit::WebPageProxy::handleWheelEvent):
(WebKit::WebPageProxy::handleKeyboardEvent):
(WebKit::WebPageProxy::handleGestureEvent):
(WebKit::WebPageProxy::handleTouchEventSynchronously):
(WebKit::WebPageProxy::handleTouchEventAsynchronously):
(WebKit::WebPageProxy::handleTouchEvent):
(WebKit::WebPageProxy::scrollBy):
(WebKit::WebPageProxy::centerSelectionInVisibleArea):
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::setUserAgent):
(WebKit::WebPageProxy::resumeActiveDOMObjectsAndAnimations):
(WebKit::WebPageProxy::suspendActiveDOMObjectsAndAnimations):
(WebKit::WebPageProxy::setCustomTextEncodingName):
(WebKit::WebPageProxy::setTextZoomFactor):
(WebKit::WebPageProxy::setPageZoomFactor):
(WebKit::WebPageProxy::setPageAndTextZoomFactors):
(WebKit::WebPageProxy::scalePage):
(WebKit::WebPageProxy::scalePageInViewCoordinates):
(WebKit::WebPageProxy::scaleView):
(WebKit::WebPageProxy::windowScreenDidChange):
(WebKit::WebPageProxy::setCustomDeviceScaleFactor):
(WebKit::WebPageProxy::accessibilitySettingsDidChange):
(WebKit::WebPageProxy::updateAccessibilityEventsEnabled):
(WebKit::WebPageProxy::setUseFixedLayout):
(WebKit::WebPageProxy::setFixedLayoutSize):
(WebKit::WebPageProxy::setAlwaysShowsHorizontalScroller):
(WebKit::WebPageProxy::setAlwaysShowsVerticalScroller):
(WebKit::WebPageProxy::listenForLayoutMilestones):
(WebKit::WebPageProxy::setSuppressScrollbarAnimations):
(WebKit::WebPageProxy::setEnableVerticalRubberBanding):
(WebKit::WebPageProxy::setEnableHorizontalRubberBanding):
(WebKit::WebPageProxy::setBackgroundExtendsBeyondPage):
(WebKit::WebPageProxy::setPaginationMode):
(WebKit::WebPageProxy::setPaginationBehavesLikeColumns):
(WebKit::WebPageProxy::setPageLength):
(WebKit::WebPageProxy::setGapBetweenPages):
(WebKit::WebPageProxy::setPaginationLineGridEnabled):
(WebKit::WebPageProxy::countStringMatches):
(WebKit::WebPageProxy::replaceMatches):
(WebKit::WebPageProxy::launchInitialProcessIfNecessary):
(WebKit::WebPageProxy::runJavaScriptInMainFrame):
(WebKit::WebPageProxy::runJavaScriptInMainFrameScriptWorld):
(WebKit::WebPageProxy::getRenderTreeExternalRepresentation):
(WebKit::WebPageProxy::getSourceForFrame):
(WebKit::WebPageProxy::getContentsAsString):
(WebKit::WebPageProxy::getContentsAsAttributedString):
(WebKit::WebPageProxy::getBytecodeProfile):
(WebKit::WebPageProxy::getSamplingProfilerOutput):
(WebKit::WebPageProxy::getContentsAsMHTMLData):
(WebKit::WebPageProxy::getSelectionOrContentsAsString):
(WebKit::WebPageProxy::getSelectionAsWebArchiveData):
(WebKit::WebPageProxy::getMainResourceDataOfFrame):
(WebKit::WebPageProxy::getResourceDataFromFrame):
(WebKit::WebPageProxy::getWebArchiveOfFrame):
(WebKit::WebPageProxy::forceRepaint):
(WebKit::WebPageProxy::preferencesDidChange):
(WebKit::WebPageProxy::setMediaVolume):
(WebKit::WebPageProxy::setMuted):
(WebKit::WebPageProxy::setMediaCaptureEnabled):
(WebKit::WebPageProxy::stopMediaCapture):
(WebKit::WebPageProxy::stopAllMediaPlayback):
(WebKit::WebPageProxy::suspendAllMediaPlayback):
(WebKit::WebPageProxy::resumeAllMediaPlayback):
(WebKit::WebPageProxy::handleMediaEvent):
(WebKit::WebPageProxy::setVolumeOfMediaElement):
(WebKit::WebPageProxy::setMayStartMediaWhenInWindow):
(WebKit::WebPageProxy::didChooseColor):
(WebKit::WebPageProxy::didEndColorPicker):
(WebKit::WebPageProxy::didSelectOption):
(WebKit::WebPageProxy::inspector const):
(WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
(WebKit::WebPageProxy::didChooseFilesForOpenPanel):
(WebKit::WebPageProxy::didCancelForOpenPanel):
(WebKit::WebPageProxy::removeEditCommand):
(WebKit::WebPageProxy::processDidBecomeUnresponsive):
(WebKit::WebPageProxy::processDidBecomeResponsive):
(WebKit::WebPageProxy::processDidTerminate):
(WebKit::WebPageProxy::processWillBecomeSuspended):
(WebKit::WebPageProxy::processWillBecomeForeground):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
(WebKit::WebPageProxy::setCanRunModal):
(WebKit::WebPageProxy::canRunModal):
(WebKit::WebPageProxy::computePagesForPrinting):
(WebKit::WebPageProxy::drawRectToImage):
(WebKit::WebPageProxy::drawPagesToPDF):
(WebKit::WebPageProxy::drawPagesForPrinting):
(WebKit::WebPageProxy::updateBackingStoreDiscardableState):
(WebKit::WebPageProxy::setViewLayoutSize):
(WebKit::WebPageProxy::setAutoSizingShouldExpandToViewHeight):
(WebKit::WebPageProxy::setViewportSizeForCSSViewportUnits):
(WebKit::WebPageProxy::setComposition):
(WebKit::WebPageProxy::confirmComposition):
(WebKit::WebPageProxy::cancelComposition):
(WebKit::WebPageProxy::setScrollPinningBehavior):
(WebKit::WebPageProxy::setOverlayScrollbarStyle):
(WebKit::WebPageProxy::changeFontAttributes):
(WebKit::WebPageProxy::changeFont):
(WebKit::WebPageProxy::setTextAsync):
(WebKit::WebPageProxy::insertTextAsync):
(WebKit::WebPageProxy::getMarkedRangeAsync):
(WebKit::WebPageProxy::getSelectedRangeAsync):
(WebKit::WebPageProxy::characterIndexForPointAsync):
(WebKit::WebPageProxy::firstRectForCharacterRangeAsync):
(WebKit::WebPageProxy::setCompositionAsync):
(WebKit::WebPageProxy::confirmCompositionAsync):
(WebKit::WebPageProxy::takeSnapshot):
(WebKit::WebPageProxy::requestActiveNowPlayingSessionInfo):
(WebKit::WebPageProxy::setUseSystemAppearance):
(WebKit::WebPageProxy::installActivityStateChangeCompletionHandler):
(WebKit::WebPageProxy::setPlaybackTarget):
(WebKit::WebPageProxy::externalOutputDeviceAvailableDidChange):
(WebKit::WebPageProxy::setShouldPlayToPlaybackTarget):
(WebKit::WebPageProxy::clearWheelEventTestTrigger):
(WebKit::WebPageProxy::callAfterNextPresentationUpdate):
(WebKit::WebPageProxy::setShouldScaleViewToFitDocument):
(WebKit::WebPageProxy::getLoadDecisionForIcon):
(WebKit::WebPageProxy::setResourceCachingDisabled):
(WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
(WebKit::WebPageProxy::effectiveAppearanceDidChange):
(WebKit::WebPageProxy::insertAttachment):
(WebKit::WebPageProxy::updateAttachmentAttributes):
(WebKit::WebPageProxy::getApplicationManifest):
(WebKit::WebPageProxy::textInputContextsInRect):
(WebKit::WebPageProxy::focusTextInputContext):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::setAnyPageGroupMightHavePrivateBrowsingEnabled):
(WebKit::WebProcessPool::initializeNewWebProcess):
(WebKit::WebProcessPool::disconnectProcess):
(WebKit::WebProcessPool::createWebPage):
(WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):

  • UIProcess/WebProcessPool.h:
  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::create):
(WebKit::WebProcessProxy::addExistingWebPage):
(WebKit::WebProcessProxy::maybeShutDown):

  • UIProcess/WebProcessProxy.h:
  • UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp:

(WebKit::InstallMissingMediaPluginsPermissionRequest::allow):
(WebKit::InstallMissingMediaPluginsPermissionRequest::didEndRequestInstallMissingMediaPlugins):

  • UIProcess/gtk/WebInspectorProxyGtk.cpp:

(WebKit::WebInspectorProxy::platformDetach):

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView setupInteraction]):
(-[WKContentView _webTouchEventsRecognized:]):
(-[WKContentView _hoverGestureRecognizerChanged:]):

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::requestFocusedElementInformation):
(WebKit::WebPageProxy::updateVisibleContentRects):
(WebKit::WebPageProxy::updateStringForFind):
(WebKit::WebPageProxy::dynamicViewportSizeUpdate):
(WebKit::WebPageProxy::setViewportConfigurationViewLayoutSize):
(WebKit::WebPageProxy::setForceAlwaysUserScalable):
(WebKit::WebPageProxy::setMaximumUnobscuredSize):
(WebKit::WebPageProxy::setDeviceOrientation):
(WebKit::WebPageProxy::setOverrideViewportArguments):
(WebKit::WebPageProxy::selectWithGesture):
(WebKit::WebPageProxy::updateSelectionWithTouches):
(WebKit::WebPageProxy::requestAutocorrectionData):
(WebKit::WebPageProxy::applyAutocorrection):
(WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
(WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
(WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
(WebKit::WebPageProxy::selectPositionAtPoint):
(WebKit::WebPageProxy::beginSelectionInDirection):
(WebKit::WebPageProxy::updateSelectionWithExtentPoint):
(WebKit::WebPageProxy::updateSelectionWithExtentPointAndBoundary):
(WebKit::WebPageProxy::requestDictationContext):
(WebKit::WebPageProxy::getSelectionContext):
(WebKit::WebPageProxy::selectWithTwoTouches):
(WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
(WebKit::WebPageProxy::requestRectsAtSelectionOffsetWithText):
(WebKit::WebPageProxy::moveSelectionByOffset):
(WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
(WebKit::WebPageProxy::focusNextFocusedElement):
(WebKit::WebPageProxy::computePagesForPrintingAndDrawToPDF):
(WebKit::WebPageProxy::requestEvasionRectsAboveSelection):
(WebKit::WebPageProxy::requestDragStart):
(WebKit::WebPageProxy::requestAdditionalItemsForDragSession):

  • UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:

(WebKit::TiledCoreAnimationDrawingAreaProxy::sizeDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::viewLayoutSizeDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
(WebKit::TiledCoreAnimationDrawingAreaProxy::dispatchAfterEnsuringDrawing):

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::windowAndViewFramesChanged):
(WebKit::WebPageProxy::setMainFrameIsScrollable):
(WebKit::WebPageProxy::insertDictatedTextAsync):
(WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync):
(WebKit::WebPageProxy::fontAtSelection):
(WebKit::WebPageProxy::stringSelectionForPasteboard):
(WebKit::WebPageProxy::dataSelectionForPasteboard):
(WebKit::WebPageProxy::readSelectionFromPasteboard):
(WebKit::WebPageProxy::sendComplexTextInputToPlugin):
(WebKit::WebPageProxy::registerWebProcessAccessibilityToken):
(WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
(WebKit::WebPageProxy::acceptsFirstMouse):

  • UIProcess/win/WebInspectorProxyWin.cpp:

(WebKit::WebInspectorProxy::platformDetach):

  • UIProcess/win/WebView.cpp:

(WebKit::WebView::cursorToShow const):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::m_hostFileDescriptor):

Tools:

Add API test coverage. Also update some existing API tests to not expect
constructing a WKWebView to launch both a WebProcess and a NetworkProcess.

  • TestWebKitAPI/Tests/WebKit/NetworkProcessCrashWithPendingConnection.mm:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebKit/mac/GetBackingScaleFactor.mm:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessPreWarming.mm:

(TEST):

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
  • TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:

(TEST):

  • TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:

(TEST):
(testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript):

Location:
trunk
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r243092 r243094  
     12019-03-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Delay WebProcess launch until a load is triggered in a Web view
     4        https://bugs.webkit.org/show_bug.cgi?id=195758
     5        <rdar://problem/48126013>
     6
     7        Reviewed by Geoff Garen.
     8
     9        This is achieved by constructing WebPageProxy objects with a WebProcessProxy that is in
     10        terminated state (because it never launched its process). This is convenient because
     11        it is a state that the WebPageProxy supports, which normally happened by the WebProcess
     12        crashes. When trying to do a load, we were already checking if the WebPageProxy's process
     13        was running (via an isValid() check) and we would re-launch the WebProcess if necessary
     14        by calling reattachToWebProcess(). For clarity, given that this state is no longer
     15        indicating that the WebProcess crashed, I renamed isValid() to hasRunningProcess() and
     16        reattachToWebProcess() to launchProcess().
     17
     18        The reason delaying the WebProcess launch until the first load is useful is because it
     19        allows us to leverage the WebProcessCache given that we now know which registrable
     20        domain is going to be loaded in the process.
     21
     22        This is a progression from a power usage standpoint. When it comes to page load time,
     23        it would be a progression if we found a suitable process in the cache. I do not expect
     24        a performance hit when no process is found in the cache because of process prewarming.
     25
     26        * Shared/API/Cocoa/RemoteObjectRegistry.h:
     27        * Shared/API/Cocoa/RemoteObjectRegistry.mm:
     28        (WebKit::m_launchInitialProcessIfNecessary):
     29        (WebKit::RemoteObjectRegistry::sendInvocation):
     30        * UIProcess/API/Cocoa/WKProcessPool.mm:
     31        (-[WKProcessPool _processCacheSize]):
     32        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
     33        * UIProcess/API/Cocoa/WKWebView.mm:
     34        (-[WKWebView _isValid]):
     35        * UIProcess/Automation/WebAutomationSession.cpp:
     36        (WebKit::WebAutomationSession::willShowJavaScriptDialog):
     37        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     38        (WebKit::WebPageProxy::performDictionaryLookupAtLocation):
     39        (WebKit::WebPageProxy::performDictionaryLookupOfCurrentSelection):
     40        * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
     41        (WebKit::DrawingAreaProxyCoordinatedGraphics::sendUpdateBackingStoreState):
     42        (WebKit::DrawingAreaProxyCoordinatedGraphics::waitForAndDispatchDidUpdateBackingStoreState):
     43        (WebKit::DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing):
     44        * UIProcess/DrawingAreaProxy.cpp:
     45        (WebKit::DrawingAreaProxy::setViewExposedRect):
     46        (WebKit::DrawingAreaProxy::viewExposedRectChangedTimerFired):
     47        * UIProcess/GeolocationPermissionRequestManagerProxy.cpp:
     48        (WebKit::GeolocationPermissionRequestManagerProxy::didReceiveGeolocationPermissionDecision):
     49        * UIProcess/InspectorTargetProxy.cpp:
     50        (WebKit::InspectorTargetProxy::connect):
     51        (WebKit::InspectorTargetProxy::disconnect):
     52        (WebKit::InspectorTargetProxy::sendMessageToTargetBackend):
     53        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
     54        (WebKit::RemoteLayerTreeDrawingAreaProxy::sizeDidChange):
     55        (WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay):
     56        (WebKit::RemoteLayerTreeDrawingAreaProxy::dispatchAfterEnsuringDrawing):
     57        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
     58        (WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
     59        (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied):
     60        (WebKit::UserMediaPermissionRequestManagerProxy::denyRequest):
     61        (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted):
     62        (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
     63        (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
     64        (WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
     65        (WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged):
     66        * UIProcess/ViewGestureController.cpp:
     67        (WebKit::ViewGestureController::ViewGestureController):
     68        * UIProcess/WebBackForwardList.cpp:
     69        (WebKit::WebBackForwardList::~WebBackForwardList):
     70        * UIProcess/WebCookieManagerProxy.cpp:
     71        (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
     72        * UIProcess/WebEditCommandProxy.cpp:
     73        (WebKit::WebEditCommandProxy::unapply):
     74        (WebKit::WebEditCommandProxy::reapply):
     75        * UIProcess/WebFrameProxy.cpp:
     76        (WebKit::WebFrameProxy::stopLoading const):
     77        * UIProcess/WebInspectorProxy.cpp:
     78        (WebKit::WebInspectorProxy::WebInspectorProxy):
     79        * UIProcess/WebPageProxy.cpp:
     80        (WebKit::m_resetRecentCrashCountTimer):
     81        (WebKit::WebPageProxy::hasRunningProcess const):
     82        (WebKit::WebPageProxy::setUIClient):
     83        (WebKit::WebPageProxy::setIconLoadingClient):
     84        (WebKit::WebPageProxy::launchProcess):
     85        (WebKit::WebPageProxy::swapToWebProcess):
     86        (WebKit::WebPageProxy::finishAttachingToWebProcess):
     87        (WebKit::WebPageProxy::didAttachToRunningProcess):
     88        (WebKit::WebPageProxy::launchProcessForReload):
     89        (WebKit::WebPageProxy::launchProcessWithItem):
     90        (WebKit::WebPageProxy::initializeWebPage):
     91        (WebKit::WebPageProxy::tryClose):
     92        (WebKit::WebPageProxy::loadRequest):
     93        (WebKit::WebPageProxy::loadFile):
     94        (WebKit::WebPageProxy::loadData):
     95        (WebKit::WebPageProxy::loadAlternateHTML):
     96        (WebKit::WebPageProxy::loadWebArchiveData):
     97        (WebKit::WebPageProxy::navigateToPDFLinkWithSimulatedClick):
     98        (WebKit::WebPageProxy::stopLoading):
     99        (WebKit::WebPageProxy::reload):
     100        (WebKit::WebPageProxy::goToBackForwardItem):
     101        (WebKit::WebPageProxy::tryRestoreScrollPosition):
     102        (WebKit::WebPageProxy::setControlledByAutomation):
     103        (WebKit::WebPageProxy::setIndicating):
     104        (WebKit::WebPageProxy::setBackgroundColor):
     105        (WebKit::WebPageProxy::setTopContentInset):
     106        (WebKit::WebPageProxy::setUnderlayColor):
     107        (WebKit::WebPageProxy::viewWillStartLiveResize):
     108        (WebKit::WebPageProxy::viewWillEndLiveResize):
     109        (WebKit::WebPageProxy::dispatchActivityStateChange):
     110        (WebKit::WebPageProxy::layerHostingModeDidChange):
     111        (WebKit::WebPageProxy::waitForDidUpdateActivityState):
     112        (WebKit::WebPageProxy::setInitialFocus):
     113        (WebKit::WebPageProxy::clearSelection):
     114        (WebKit::WebPageProxy::restoreSelectionInFocusedEditableElement):
     115        (WebKit::WebPageProxy::validateCommand):
     116        (WebKit::WebPageProxy::increaseListLevel):
     117        (WebKit::WebPageProxy::decreaseListLevel):
     118        (WebKit::WebPageProxy::changeListType):
     119        (WebKit::WebPageProxy::setBaseWritingDirection):
     120        (WebKit::WebPageProxy::setNeedsFontAttributes):
     121        (WebKit::WebPageProxy::executeEditCommand):
     122        (WebKit::WebPageProxy::requestFontAttributesAtSelectionStart):
     123        (WebKit::WebPageProxy::setEditable):
     124        (WebKit::WebPageProxy::performDragControllerAction):
     125        (WebKit::WebPageProxy::dragEnded):
     126        (WebKit::WebPageProxy::didStartDrag):
     127        (WebKit::WebPageProxy::dragCancelled):
     128        (WebKit::WebPageProxy::handleMouseEvent):
     129        (WebKit::WebPageProxy::processNextQueuedMouseEvent):
     130        (WebKit::WebPageProxy::handleWheelEvent):
     131        (WebKit::WebPageProxy::handleKeyboardEvent):
     132        (WebKit::WebPageProxy::handleGestureEvent):
     133        (WebKit::WebPageProxy::handleTouchEventSynchronously):
     134        (WebKit::WebPageProxy::handleTouchEventAsynchronously):
     135        (WebKit::WebPageProxy::handleTouchEvent):
     136        (WebKit::WebPageProxy::scrollBy):
     137        (WebKit::WebPageProxy::centerSelectionInVisibleArea):
     138        (WebKit::WebPageProxy::receivedPolicyDecision):
     139        (WebKit::WebPageProxy::setUserAgent):
     140        (WebKit::WebPageProxy::resumeActiveDOMObjectsAndAnimations):
     141        (WebKit::WebPageProxy::suspendActiveDOMObjectsAndAnimations):
     142        (WebKit::WebPageProxy::setCustomTextEncodingName):
     143        (WebKit::WebPageProxy::setTextZoomFactor):
     144        (WebKit::WebPageProxy::setPageZoomFactor):
     145        (WebKit::WebPageProxy::setPageAndTextZoomFactors):
     146        (WebKit::WebPageProxy::scalePage):
     147        (WebKit::WebPageProxy::scalePageInViewCoordinates):
     148        (WebKit::WebPageProxy::scaleView):
     149        (WebKit::WebPageProxy::windowScreenDidChange):
     150        (WebKit::WebPageProxy::setCustomDeviceScaleFactor):
     151        (WebKit::WebPageProxy::accessibilitySettingsDidChange):
     152        (WebKit::WebPageProxy::updateAccessibilityEventsEnabled):
     153        (WebKit::WebPageProxy::setUseFixedLayout):
     154        (WebKit::WebPageProxy::setFixedLayoutSize):
     155        (WebKit::WebPageProxy::setAlwaysShowsHorizontalScroller):
     156        (WebKit::WebPageProxy::setAlwaysShowsVerticalScroller):
     157        (WebKit::WebPageProxy::listenForLayoutMilestones):
     158        (WebKit::WebPageProxy::setSuppressScrollbarAnimations):
     159        (WebKit::WebPageProxy::setEnableVerticalRubberBanding):
     160        (WebKit::WebPageProxy::setEnableHorizontalRubberBanding):
     161        (WebKit::WebPageProxy::setBackgroundExtendsBeyondPage):
     162        (WebKit::WebPageProxy::setPaginationMode):
     163        (WebKit::WebPageProxy::setPaginationBehavesLikeColumns):
     164        (WebKit::WebPageProxy::setPageLength):
     165        (WebKit::WebPageProxy::setGapBetweenPages):
     166        (WebKit::WebPageProxy::setPaginationLineGridEnabled):
     167        (WebKit::WebPageProxy::countStringMatches):
     168        (WebKit::WebPageProxy::replaceMatches):
     169        (WebKit::WebPageProxy::launchInitialProcessIfNecessary):
     170        (WebKit::WebPageProxy::runJavaScriptInMainFrame):
     171        (WebKit::WebPageProxy::runJavaScriptInMainFrameScriptWorld):
     172        (WebKit::WebPageProxy::getRenderTreeExternalRepresentation):
     173        (WebKit::WebPageProxy::getSourceForFrame):
     174        (WebKit::WebPageProxy::getContentsAsString):
     175        (WebKit::WebPageProxy::getContentsAsAttributedString):
     176        (WebKit::WebPageProxy::getBytecodeProfile):
     177        (WebKit::WebPageProxy::getSamplingProfilerOutput):
     178        (WebKit::WebPageProxy::getContentsAsMHTMLData):
     179        (WebKit::WebPageProxy::getSelectionOrContentsAsString):
     180        (WebKit::WebPageProxy::getSelectionAsWebArchiveData):
     181        (WebKit::WebPageProxy::getMainResourceDataOfFrame):
     182        (WebKit::WebPageProxy::getResourceDataFromFrame):
     183        (WebKit::WebPageProxy::getWebArchiveOfFrame):
     184        (WebKit::WebPageProxy::forceRepaint):
     185        (WebKit::WebPageProxy::preferencesDidChange):
     186        (WebKit::WebPageProxy::setMediaVolume):
     187        (WebKit::WebPageProxy::setMuted):
     188        (WebKit::WebPageProxy::setMediaCaptureEnabled):
     189        (WebKit::WebPageProxy::stopMediaCapture):
     190        (WebKit::WebPageProxy::stopAllMediaPlayback):
     191        (WebKit::WebPageProxy::suspendAllMediaPlayback):
     192        (WebKit::WebPageProxy::resumeAllMediaPlayback):
     193        (WebKit::WebPageProxy::handleMediaEvent):
     194        (WebKit::WebPageProxy::setVolumeOfMediaElement):
     195        (WebKit::WebPageProxy::setMayStartMediaWhenInWindow):
     196        (WebKit::WebPageProxy::didChooseColor):
     197        (WebKit::WebPageProxy::didEndColorPicker):
     198        (WebKit::WebPageProxy::didSelectOption):
     199        (WebKit::WebPageProxy::inspector const):
     200        (WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
     201        (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
     202        (WebKit::WebPageProxy::didCancelForOpenPanel):
     203        (WebKit::WebPageProxy::removeEditCommand):
     204        (WebKit::WebPageProxy::processDidBecomeUnresponsive):
     205        (WebKit::WebPageProxy::processDidBecomeResponsive):
     206        (WebKit::WebPageProxy::processDidTerminate):
     207        (WebKit::WebPageProxy::processWillBecomeSuspended):
     208        (WebKit::WebPageProxy::processWillBecomeForeground):
     209        (WebKit::WebPageProxy::resetStateAfterProcessExited):
     210        (WebKit::WebPageProxy::setCanRunModal):
     211        (WebKit::WebPageProxy::canRunModal):
     212        (WebKit::WebPageProxy::computePagesForPrinting):
     213        (WebKit::WebPageProxy::drawRectToImage):
     214        (WebKit::WebPageProxy::drawPagesToPDF):
     215        (WebKit::WebPageProxy::drawPagesForPrinting):
     216        (WebKit::WebPageProxy::updateBackingStoreDiscardableState):
     217        (WebKit::WebPageProxy::setViewLayoutSize):
     218        (WebKit::WebPageProxy::setAutoSizingShouldExpandToViewHeight):
     219        (WebKit::WebPageProxy::setViewportSizeForCSSViewportUnits):
     220        (WebKit::WebPageProxy::setComposition):
     221        (WebKit::WebPageProxy::confirmComposition):
     222        (WebKit::WebPageProxy::cancelComposition):
     223        (WebKit::WebPageProxy::setScrollPinningBehavior):
     224        (WebKit::WebPageProxy::setOverlayScrollbarStyle):
     225        (WebKit::WebPageProxy::changeFontAttributes):
     226        (WebKit::WebPageProxy::changeFont):
     227        (WebKit::WebPageProxy::setTextAsync):
     228        (WebKit::WebPageProxy::insertTextAsync):
     229        (WebKit::WebPageProxy::getMarkedRangeAsync):
     230        (WebKit::WebPageProxy::getSelectedRangeAsync):
     231        (WebKit::WebPageProxy::characterIndexForPointAsync):
     232        (WebKit::WebPageProxy::firstRectForCharacterRangeAsync):
     233        (WebKit::WebPageProxy::setCompositionAsync):
     234        (WebKit::WebPageProxy::confirmCompositionAsync):
     235        (WebKit::WebPageProxy::takeSnapshot):
     236        (WebKit::WebPageProxy::requestActiveNowPlayingSessionInfo):
     237        (WebKit::WebPageProxy::setUseSystemAppearance):
     238        (WebKit::WebPageProxy::installActivityStateChangeCompletionHandler):
     239        (WebKit::WebPageProxy::setPlaybackTarget):
     240        (WebKit::WebPageProxy::externalOutputDeviceAvailableDidChange):
     241        (WebKit::WebPageProxy::setShouldPlayToPlaybackTarget):
     242        (WebKit::WebPageProxy::clearWheelEventTestTrigger):
     243        (WebKit::WebPageProxy::callAfterNextPresentationUpdate):
     244        (WebKit::WebPageProxy::setShouldScaleViewToFitDocument):
     245        (WebKit::WebPageProxy::getLoadDecisionForIcon):
     246        (WebKit::WebPageProxy::setResourceCachingDisabled):
     247        (WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
     248        (WebKit::WebPageProxy::effectiveAppearanceDidChange):
     249        (WebKit::WebPageProxy::insertAttachment):
     250        (WebKit::WebPageProxy::updateAttachmentAttributes):
     251        (WebKit::WebPageProxy::getApplicationManifest):
     252        (WebKit::WebPageProxy::textInputContextsInRect):
     253        (WebKit::WebPageProxy::focusTextInputContext):
     254        * UIProcess/WebPageProxy.h:
     255        * UIProcess/WebProcessPool.cpp:
     256        (WebKit::WebProcessPool::setAnyPageGroupMightHavePrivateBrowsingEnabled):
     257        (WebKit::WebProcessPool::initializeNewWebProcess):
     258        (WebKit::WebProcessPool::disconnectProcess):
     259        (WebKit::WebProcessPool::createWebPage):
     260        (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
     261        * UIProcess/WebProcessPool.h:
     262        * UIProcess/WebProcessProxy.cpp:
     263        (WebKit::WebProcessProxy::create):
     264        (WebKit::WebProcessProxy::addExistingWebPage):
     265        (WebKit::WebProcessProxy::maybeShutDown):
     266        * UIProcess/WebProcessProxy.h:
     267        * UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp:
     268        (WebKit::InstallMissingMediaPluginsPermissionRequest::allow):
     269        (WebKit::InstallMissingMediaPluginsPermissionRequest::didEndRequestInstallMissingMediaPlugins):
     270        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
     271        (WebKit::WebInspectorProxy::platformDetach):
     272        * UIProcess/ios/WKContentViewInteraction.mm:
     273        (-[WKContentView setupInteraction]):
     274        (-[WKContentView _webTouchEventsRecognized:]):
     275        (-[WKContentView _hoverGestureRecognizerChanged:]):
     276        * UIProcess/ios/WebPageProxyIOS.mm:
     277        (WebKit::WebPageProxy::requestFocusedElementInformation):
     278        (WebKit::WebPageProxy::updateVisibleContentRects):
     279        (WebKit::WebPageProxy::updateStringForFind):
     280        (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
     281        (WebKit::WebPageProxy::setViewportConfigurationViewLayoutSize):
     282        (WebKit::WebPageProxy::setForceAlwaysUserScalable):
     283        (WebKit::WebPageProxy::setMaximumUnobscuredSize):
     284        (WebKit::WebPageProxy::setDeviceOrientation):
     285        (WebKit::WebPageProxy::setOverrideViewportArguments):
     286        (WebKit::WebPageProxy::selectWithGesture):
     287        (WebKit::WebPageProxy::updateSelectionWithTouches):
     288        (WebKit::WebPageProxy::requestAutocorrectionData):
     289        (WebKit::WebPageProxy::applyAutocorrection):
     290        (WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
     291        (WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
     292        (WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
     293        (WebKit::WebPageProxy::selectPositionAtPoint):
     294        (WebKit::WebPageProxy::beginSelectionInDirection):
     295        (WebKit::WebPageProxy::updateSelectionWithExtentPoint):
     296        (WebKit::WebPageProxy::updateSelectionWithExtentPointAndBoundary):
     297        (WebKit::WebPageProxy::requestDictationContext):
     298        (WebKit::WebPageProxy::getSelectionContext):
     299        (WebKit::WebPageProxy::selectWithTwoTouches):
     300        (WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
     301        (WebKit::WebPageProxy::requestRectsAtSelectionOffsetWithText):
     302        (WebKit::WebPageProxy::moveSelectionByOffset):
     303        (WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
     304        (WebKit::WebPageProxy::focusNextFocusedElement):
     305        (WebKit::WebPageProxy::computePagesForPrintingAndDrawToPDF):
     306        (WebKit::WebPageProxy::requestEvasionRectsAboveSelection):
     307        (WebKit::WebPageProxy::requestDragStart):
     308        (WebKit::WebPageProxy::requestAdditionalItemsForDragSession):
     309        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
     310        (WebKit::TiledCoreAnimationDrawingAreaProxy::sizeDidChange):
     311        (WebKit::TiledCoreAnimationDrawingAreaProxy::viewLayoutSizeDidChange):
     312        (WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
     313        (WebKit::TiledCoreAnimationDrawingAreaProxy::dispatchAfterEnsuringDrawing):
     314        * UIProcess/mac/WebPageProxyMac.mm:
     315        (WebKit::WebPageProxy::windowAndViewFramesChanged):
     316        (WebKit::WebPageProxy::setMainFrameIsScrollable):
     317        (WebKit::WebPageProxy::insertDictatedTextAsync):
     318        (WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync):
     319        (WebKit::WebPageProxy::fontAtSelection):
     320        (WebKit::WebPageProxy::stringSelectionForPasteboard):
     321        (WebKit::WebPageProxy::dataSelectionForPasteboard):
     322        (WebKit::WebPageProxy::readSelectionFromPasteboard):
     323        (WebKit::WebPageProxy::sendComplexTextInputToPlugin):
     324        (WebKit::WebPageProxy::registerWebProcessAccessibilityToken):
     325        (WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
     326        (WebKit::WebPageProxy::acceptsFirstMouse):
     327        * UIProcess/win/WebInspectorProxyWin.cpp:
     328        (WebKit::WebInspectorProxy::platformDetach):
     329        * UIProcess/win/WebView.cpp:
     330        (WebKit::WebView::cursorToShow const):
     331        * WebProcess/WebPage/WebPage.cpp:
     332        (WebKit::m_hostFileDescriptor):
     333
    13342019-03-18  Antti Koivisto  <antti@apple.com>
    2335
  • trunk/Source/WebKit/Shared/API/Cocoa/RemoteObjectRegistry.h

    r241183 r243094  
    6868    IPC::MessageSender& m_messageSender;
    6969    WTF::Function<ProcessThrottler::BackgroundActivityToken()> m_takeBackgroundActivityToken;
     70    WTF::Function<void()> m_launchInitialProcessIfNecessary;
    7071    HashMap<uint64_t, ProcessThrottler::BackgroundActivityToken> m_pendingReplies;
    7172};
  • trunk/Source/WebKit/Shared/API/Cocoa/RemoteObjectRegistry.mm

    r242339 r243094  
    5050    , m_messageSender(page)
    5151    , m_takeBackgroundActivityToken([&page] { return page.process().throttler().backgroundActivityToken(); })
     52    , m_launchInitialProcessIfNecessary([&page] { page.launchInitialProcessIfNecessary(); })
    5253{
    5354}
     
    6061void RemoteObjectRegistry::sendInvocation(const RemoteObjectInvocation& invocation)
    6162{
     63    // For backward-compatibility, support invoking injected bundle methods before having done any load in the WebView.
     64    if (m_launchInitialProcessIfNecessary)
     65        m_launchInitialProcessIfNecessary();
     66
    6267    if (auto* replyInfo = invocation.replyInfo()) {
    6368        ASSERT(!m_pendingReplies.contains(replyInfo->replyID));
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm

    r242726 r243094  
    523523}
    524524
     525- (NSUInteger)_processCacheSize
     526{
     527    return _processPool->webProcessCache().size();
     528}
     529
    525530- (size_t)_serviceWorkerProcessCount
    526531{
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h

    r242339 r243094  
    103103- (NSUInteger)_maximumSuspendedPageCount WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    104104- (NSUInteger)_processCacheCapacity WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     105- (NSUInteger)_processCacheSize WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    105106
    106107// Test only. Returns web processes running web pages (does not include web processes running service workers)
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r243012 r243094  
    392392- (BOOL)_isValid
    393393{
    394     return _page && _page->isValid();
     394    return _page && _page->hasRunningProcess();
    395395}
    396396
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r241001 r243094  
    643643    // operation with an unexpected alert open error.
    644644    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), page = makeRef(page)] {
    645         if (!page->isValid() || !m_client || !m_client->isShowingJavaScriptDialogOnPage(*this, page))
     645        if (!page->hasRunningProcess() || !m_client || !m_client->isShowingJavaScriptDialogOnPage(*this, page))
    646646            return;
    647647
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r243002 r243094  
    200200void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
    201201{
    202     if (!isValid())
     202    if (!hasRunningProcess())
    203203        return;
    204204   
     
    208208void WebPageProxy::performDictionaryLookupOfCurrentSelection()
    209209{
    210     if (!isValid())
     210    if (!hasRunningProcess())
    211211        return;
    212212   
  • trunk/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp

    r242346 r243094  
    304304    ASSERT(m_currentBackingStoreStateID < m_nextBackingStoreStateID);
    305305
    306     if (!m_webPageProxy.isValid())
     306    if (!m_webPageProxy.hasRunningProcess())
    307307        return;
    308308
     
    335335    ASSERT(m_isWaitingForDidUpdateBackingStoreState);
    336336
    337     if (!m_webPageProxy.isValid())
     337    if (!m_webPageProxy.hasRunningProcess())
    338338        return;
    339339    if (process().state() == WebProcessProxy::State::Launching)
     
    466466void DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing(WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    467467{
    468     if (!m_webPageProxy.isValid()) {
     468    if (!m_webPageProxy.hasRunningProcess()) {
    469469        callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
    470470        return;
  • trunk/Source/WebKit/UIProcess/DrawingAreaProxy.cpp

    r241988 r243094  
    8888void DrawingAreaProxy::setViewExposedRect(Optional<WebCore::FloatRect> viewExposedRect)
    8989{
    90     if (!m_webPageProxy.isValid())
     90    if (!m_webPageProxy.hasRunningProcess())
    9191        return;
    9292
     
    9999void DrawingAreaProxy::viewExposedRectChangedTimerFired()
    100100{
    101     if (!m_webPageProxy.isValid())
     101    if (!m_webPageProxy.hasRunningProcess())
    102102        return;
    103103
  • trunk/Source/WebKit/UIProcess/GeolocationPermissionRequestManagerProxy.cpp

    r216794 r243094  
    5555void GeolocationPermissionRequestManagerProxy::didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed)
    5656{
    57     if (!m_page.isValid())
     57    if (!m_page.hasRunningProcess())
    5858        return;
    5959
  • trunk/Source/WebKit/UIProcess/InspectorTargetProxy.cpp

    r238330 r243094  
    4949void InspectorTargetProxy::connect(Inspector::FrontendChannel& channel)
    5050{
    51     if (m_page.isValid())
     51    if (m_page.hasRunningProcess())
    5252        m_page.process().send(Messages::WebPage::ConnectInspector(identifier(), channel.connectionType()), m_page.pageID());
    5353}
     
    5555void InspectorTargetProxy::disconnect(Inspector::FrontendChannel&)
    5656{
    57     if (m_page.isValid())
     57    if (m_page.hasRunningProcess())
    5858        m_page.process().send(Messages::WebPage::DisconnectInspector(identifier()), m_page.pageID());
    5959}
     
    6161void InspectorTargetProxy::sendMessageToTargetBackend(const String& message)
    6262{
    63     if (m_page.isValid())
     63    if (m_page.hasRunningProcess())
    6464        m_page.process().send(Messages::WebPage::SendMessageToTargetBackend(identifier(), message), m_page.pageID());
    6565}
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm

    r242687 r243094  
    151151void RemoteLayerTreeDrawingAreaProxy::sizeDidChange()
    152152{
    153     if (!m_webPageProxy.isValid())
     153    if (!m_webPageProxy.hasRunningProcess())
    154154        return;
    155155
     
    417417void RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay()
    418418{
    419     if (!m_webPageProxy.isValid())
     419    if (!m_webPageProxy.hasRunningProcess())
    420420        return;
    421421
     
    469469void RemoteLayerTreeDrawingAreaProxy::dispatchAfterEnsuringDrawing(WTF::Function<void (CallbackBase::Error)>&& callbackFunction)
    470470{
    471     if (!m_webPageProxy.isValid()) {
     471    if (!m_webPageProxy.hasRunningProcess()) {
    472472        callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
    473473        return;
  • trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp

    r242142 r243094  
    103103{
    104104#if ENABLE(MEDIA_STREAM)
    105     if (!m_page.isValid() || !m_page.mainFrame())
     105    if (!m_page.hasRunningProcess() || !m_page.mainFrame())
    106106        return;
    107107
    108108    auto handler = [this](Optional<bool> originHasPersistentAccess) mutable {
    109         if (!originHasPersistentAccess || !m_page.isValid())
     109        if (!originHasPersistentAccess || !m_page.hasRunningProcess())
    110110            return;
    111111
     
    153153void UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied(uint64_t userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason reason)
    154154{
    155     if (!m_page.isValid())
     155    if (!m_page.hasRunningProcess())
    156156        return;
    157157
     
    168168void UserMediaPermissionRequestManagerProxy::denyRequest(uint64_t userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason reason, const String& invalidConstraint)
    169169{
    170     ASSERT(m_page.isValid());
     170    ASSERT(m_page.hasRunningProcess());
    171171
    172172#if ENABLE(MEDIA_STREAM)
     
    182182    ASSERT(audioDevice || videoDevice);
    183183
    184     if (!m_page.isValid())
     184    if (!m_page.hasRunningProcess())
    185185        return;
    186186
     
    329329    }
    330330
    331     if (!m_page.isValid())
     331    if (!m_page.hasRunningProcess())
    332332        return;
    333333
     
    364364                return;
    365365
    366             if (!m_page.isValid())
     366            if (!m_page.hasRunningProcess())
    367367                return;
    368368
     
    374374                return;
    375375
    376             if (!m_page.isValid() || !m_page.mainFrame())
     376            if (!m_page.hasRunningProcess() || !m_page.mainFrame())
    377377                return;
    378378
     
    553553            return;
    554554
    555         if (!m_page.isValid())
     555        if (!m_page.hasRunningProcess())
    556556            return;
    557557
     
    565565                return;
    566566
    567             if (!m_page.isValid())
     567            if (!m_page.hasRunningProcess())
    568568                return;
    569569
     
    597597void UserMediaPermissionRequestManagerProxy::captureStateChanged(MediaProducer::MediaStateFlags oldState, MediaProducer::MediaStateFlags newState)
    598598{
    599     if (!m_page.isValid())
     599    if (!m_page.hasRunningProcess())
    600600        return;
    601601
  • trunk/Source/WebKit/UIProcess/ViewGestureController.cpp

    r241224 r243094  
    8484#endif
    8585{
    86     connectToProcess();
     86    if (webPageProxy.hasRunningProcess())
     87        connectToProcess();
    8788
    8889    viewGestureControllersForAllPages().add(webPageProxy.pageID(), this);
  • trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp

    r241751 r243094  
    5353
    5454    // A WebBackForwardList should never be destroyed unless it's associated page has been closed or is invalid.
    55     ASSERT((!m_page && !m_currentIndex) || !m_page->isValid());
     55    ASSERT((!m_page && !m_currentIndex) || !m_page->hasRunningProcess());
    5656}
    5757
  • trunk/Source/WebKit/UIProcess/WebCookieManagerProxy.cpp

    r241903 r243094  
    249249#endif
    250250
    251     if (!processPool()->networkProcess()) {
    252         callbackFunction(CallbackBase::Error::None);
    253         return;
    254     }
    255 
    256251    auto callbackID = m_callbacks.put(WTFMove(callbackFunction), processPool()->ensureNetworkProcess().throttler().backgroundActivityToken());
    257252    processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy, OptionalCallbackID(callbackID)));
  • trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp

    r240342 r243094  
    5353void WebEditCommandProxy::unapply()
    5454{
    55     if (!m_page || !m_page->isValid())
     55    if (!m_page || !m_page->hasRunningProcess())
    5656        return;
    5757
     
    6262void WebEditCommandProxy::reapply()
    6363{
    64     if (!m_page || !m_page->isValid())
     64    if (!m_page || !m_page->hasRunningProcess())
    6565        return;
    6666
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp

    r242836 r243094  
    100100        return;
    101101
    102     if (!m_page->isValid())
     102    if (!m_page->hasRunningProcess())
    103103        return;
    104104
  • trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp

    r242339 r243094  
    6161
    6262WebInspectorProxy::WebInspectorProxy(WebPageProxy* inspectedPage)
    63     : m_inspectedPage(inspectedPage)
    6463#if PLATFORM(MAC)
    65     , m_closeFrontendAfterInactivityTimer(RunLoop::main(), this, &WebInspectorProxy::closeFrontendAfterInactivityTimerFired)
     64    : m_closeFrontendAfterInactivityTimer(RunLoop::main(), this, &WebInspectorProxy::closeFrontendAfterInactivityTimerFired)
    6665#endif
    6766{
    68     m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this);
     67    if (inspectedPage && inspectedPage->hasRunningProcess()) {
     68        m_inspectedPage = inspectedPage;
     69        m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this);
     70    }
    6971}
    7072
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r243028 r243094  
    435435    , m_backForwardList(WebBackForwardList::create(*this))
    436436    , m_waitsForPaintAfterViewDidMoveToWindow(m_configuration->waitsForPaintAfterViewDidMoveToWindow())
     437    , m_hasRunningProcess(process.state() != WebProcessProxy::State::Terminated)
    437438    , m_pageID(pageID)
    438439    , m_controlledByAutomation(m_configuration->isControlledByAutomation())
     
    447448#endif
    448449    , m_resetRecentCrashCountTimer(RunLoop::main(), this, &WebPageProxy::resetRecentCrashCount)
    449 #if HAVE(PENCILKIT)
    450     , m_editableImageController(std::make_unique<EditableImageController>(*this))
    451 #endif
    452450{
    453451    RELEASE_LOG_IF_ALLOWED(Loading, "constructor: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     
    479477
    480478    m_inspector = WebInspectorProxy::create(this);
    481 #if ENABLE(FULLSCREEN_API)
    482     m_fullScreenManager = std::make_unique<WebFullScreenManagerProxy>(*this, WebPageProxy::pageClient().fullScreenManagerProxyClient());
    483 #endif
    484 #if PLATFORM(IOS_FAMILY) && HAVE(AVKIT) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
    485     m_playbackSessionManager = PlaybackSessionManagerProxy::create(*this);
    486     m_videoFullscreenManager = VideoFullscreenManagerProxy::create(*this, *m_playbackSessionManager);
    487 #endif
    488 
    489 #if ENABLE(APPLE_PAY)
    490     m_paymentCoordinator = std::make_unique<WebPaymentCoordinatorProxy>(*this);
    491 #endif
    492 
    493 #if USE(SYSTEM_PREVIEW)
    494     m_systemPreviewController = std::make_unique<SystemPreviewController>(*this);
    495 #endif
    496 
    497 #if ENABLE(WEB_AUTHN)
    498     m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
    499 #endif
     479
     480    if (hasRunningProcess())
     481        didAttachToRunningProcess();
    500482
    501483    m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
     
    579561}
    580562
    581 bool WebPageProxy::isValid() const
     563bool WebPageProxy::hasRunningProcess() const
    582564{
    583565    // A page that has been explicitly closed is never valid.
     
    585567        return false;
    586568
    587     return m_isValid;
     569    return m_hasRunningProcess;
    588570}
    589571
     
    644626    m_uiClient = WTFMove(uiClient);
    645627
    646     if (!isValid())
    647         return;
    648 
    649     m_process->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient->canRunBeforeUnloadConfirmPanel()), m_pageID);
     628    if (hasRunningProcess())
     629        m_process->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient->canRunBeforeUnloadConfirmPanel()), m_pageID);
     630
    650631    setCanRunModal(m_uiClient->canRunModal());
    651632    setNeedsFontAttributes(m_uiClient->needsFontAttributes());
     
    660641        m_iconLoadingClient = WTFMove(iconLoadingClient);
    661642
    662     if (!isValid())
     643    if (!hasRunningProcess())
    663644        return;
    664645
     
    736717}
    737718
    738 void WebPageProxy::reattachToWebProcess(const RegistrableDomain& registrableDomain)
     719void WebPageProxy::launchProcess(const RegistrableDomain& registrableDomain)
    739720{
    740721    ASSERT(!m_isClosed);
    741     ASSERT(!isValid());
    742 
    743     RELEASE_LOG_IF_ALLOWED(Loading, "reattachToWebProcess: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     722    ASSERT(!hasRunningProcess());
     723
     724    RELEASE_LOG_IF_ALLOWED(Loading, "launchProcess: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    744725
    745726    m_process->removeWebPage(*this, WebProcessProxy::EndsUsingDataStore::Yes);
     
    748729    auto& processPool = m_process->processPool();
    749730    m_process = processPool.processForRegistrableDomain(m_websiteDataStore.get(), this, registrableDomain);
    750     m_isValid = true;
     731    m_hasRunningProcess = true;
    751732
    752733    m_process->addExistingWebPage(*this, WebProcessProxy::BeginsUsingDataStore::Yes);
     
    822803    ASSERT(!m_mainFrame);
    823804    m_mainFrame = WTFMove(mainFrame);
    824     m_isValid = true;
     805    m_hasRunningProcess = true;
    825806
    826807    m_process->addExistingWebPage(*this, WebProcessProxy::BeginsUsingDataStore::No);
     
    845826    updateThrottleState();
    846827
    847 #if ENABLE(FULLSCREEN_API)
    848     m_fullScreenManager = std::make_unique<WebFullScreenManagerProxy>(*this, pageClient().fullScreenManagerProxyClient());
    849 #endif
    850 #if PLATFORM(IOS_FAMILY) && HAVE(AVKIT) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
    851     m_playbackSessionManager = PlaybackSessionManagerProxy::create(*this);
    852     m_videoFullscreenManager = VideoFullscreenManagerProxy::create(*this, *m_playbackSessionManager);
    853 #endif
    854 
    855 #if ENABLE(APPLE_PAY)
    856     m_paymentCoordinator = std::make_unique<WebPaymentCoordinatorProxy>(*this);
    857 #endif
    858 
    859 #if USE(SYSTEM_PREVIEW)
    860     m_systemPreviewController = std::make_unique<SystemPreviewController>(*this);
    861 #endif
    862 
    863 #if ENABLE(WEB_AUTHN)
    864     m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
    865 #endif
    866 
    867 #if HAVE(PENCILKIT)
    868     m_editableImageController = std::make_unique<EditableImageController>(*this);
    869 #endif
     828    didAttachToRunningProcess();
    870829
    871830    // In the process-swap case, the ProvisionalPageProxy already took care of initializing the WebPage in the WebProcess.
     
    887846}
    888847
    889 RefPtr<API::Navigation> WebPageProxy::reattachToWebProcessForReload()
    890 {
    891     RELEASE_LOG_IF_ALLOWED(Loading, "reattachToWebProcessForReload: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     848void WebPageProxy::didAttachToRunningProcess()
     849{
     850    ASSERT(hasRunningProcess());
     851
     852#if ENABLE(FULLSCREEN_API)
     853    ASSERT(!m_fullScreenManager);
     854    m_fullScreenManager = std::make_unique<WebFullScreenManagerProxy>(*this, pageClient().fullScreenManagerProxyClient());
     855#endif
     856#if PLATFORM(IOS_FAMILY) && HAVE(AVKIT) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     857    ASSERT(!m_playbackSessionManager);
     858    m_playbackSessionManager = PlaybackSessionManagerProxy::create(*this);
     859    ASSERT(!m_videoFullscreenManager);
     860    m_videoFullscreenManager = VideoFullscreenManagerProxy::create(*this, *m_playbackSessionManager);
     861#endif
     862
     863#if ENABLE(APPLE_PAY)
     864    ASSERT(!m_paymentCoordinator);
     865    m_paymentCoordinator = std::make_unique<WebPaymentCoordinatorProxy>(*this);
     866#endif
     867
     868#if USE(SYSTEM_PREVIEW)
     869    ASSERT(!m_systemPreviewController);
     870    m_systemPreviewController = std::make_unique<SystemPreviewController>(*this);
     871#endif
     872
     873#if ENABLE(WEB_AUTHN)
     874    ASSERT(!m_credentialsMessenger);
     875    m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
     876#endif
     877
     878#if HAVE(PENCILKIT)
     879    ASSERT(!m_editableImageController);
     880    m_editableImageController = std::make_unique<EditableImageController>(*this);
     881#endif
     882}
     883
     884RefPtr<API::Navigation> WebPageProxy::launchProcessForReload()
     885{
     886    RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessForReload: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    892887
    893888    if (m_isClosed) {
    894         RELEASE_LOG_IF_ALLOWED(Loading, "reattachToWebProcessForReload: page is closed: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     889        RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessForReload: page is closed: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    895890        return nullptr;
    896891    }
    897892   
    898     ASSERT(!isValid());
     893    ASSERT(!hasRunningProcess());
    899894    auto registrableDomain = m_backForwardList->currentItem() ? RegistrableDomain { URL(URL(), m_backForwardList->currentItem()->url()) } : RegistrableDomain { };
    900     reattachToWebProcess(registrableDomain);
     895    launchProcess(registrableDomain);
    901896
    902897    if (!m_backForwardList->currentItem()) {
    903         RELEASE_LOG_IF_ALLOWED(Loading, "reattachToWebProcessForReload: no current item to reload: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     898        RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessForReload: no current item to reload: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    904899        return nullptr;
    905900    }
     
    914909}
    915910
    916 RefPtr<API::Navigation> WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem& item)
    917 {
    918     RELEASE_LOG_IF_ALLOWED(Loading, "reattachToWebProcessWithItem: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     911RefPtr<API::Navigation> WebPageProxy::launchProcessWithItem(WebBackForwardListItem& item)
     912{
     913    RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessWithItem: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    919914
    920915    if (m_isClosed) {
    921         RELEASE_LOG_IF_ALLOWED(Loading, "reattachToWebProcessWithItem: page is closed: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
     916        RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessWithItem: page is closed: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    922917        return nullptr;
    923918    }
    924919
    925     ASSERT(!isValid());
    926     reattachToWebProcess(RegistrableDomain { URL(URL(), item.url()) });
     920    ASSERT(!hasRunningProcess());
     921    launchProcess(RegistrableDomain { URL(URL(), item.url()) });
    927922
    928923    if (&item != m_backForwardList->currentItem())
     
    956951void WebPageProxy::initializeWebPage()
    957952{
    958     ASSERT(isValid());
     953    if (!hasRunningProcess())
     954        return;
    959955
    960956    setDrawingArea(pageClient().createDrawingAreaProxy(m_process));
     
    10541050bool WebPageProxy::tryClose()
    10551051{
    1056     if (!isValid())
     1052    if (!hasRunningProcess())
    10571053        return true;
    10581054
     
    10971093    RELEASE_LOG_IF_ALLOWED(Loading, "loadRequest: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    10981094
    1099     if (!isValid())
    1100         reattachToWebProcess(RegistrableDomain { request.url() });
     1095    if (!hasRunningProcess())
     1096        launchProcess(RegistrableDomain { request.url() });
    11011097
    11021098    auto navigation = m_navigationState->createLoadRequestNavigation(ResourceRequest(request), m_backForwardList->currentItem());
     
    11451141    }
    11461142
    1147     if (!isValid())
    1148         reattachToWebProcess({ });
     1143    if (!hasRunningProcess())
     1144        launchProcess({ });
    11491145
    11501146    URL fileURL = URL(URL(), fileURLString);
     
    11971193    }
    11981194
    1199     if (!isValid())
    1200         reattachToWebProcess({ });
     1195    if (!hasRunningProcess())
     1196        launchProcess({ });
    12011197
    12021198    auto navigation = m_navigationState->createLoadDataNavigation(std::make_unique<API::SubstituteData>(data.vector(), MIMEType, encoding, baseURL, userData));
     
    12461242        m_isLoadingAlternateHTMLStringForFailingProvisionalLoad = true;
    12471243
    1248     if (!isValid())
    1249         reattachToWebProcess(RegistrableDomain { baseURL });
     1244    if (!hasRunningProcess())
     1245        launchProcess(RegistrableDomain { baseURL });
    12501246
    12511247    auto transaction = m_pageLoadState.transaction();
     
    12831279    }
    12841280
    1285     if (!isValid())
    1286         reattachToWebProcess({ });
     1281    if (!hasRunningProcess())
     1282        launchProcess({ });
    12871283
    12881284    auto transaction = m_pageLoadState.transaction();
     
    13131309        return;
    13141310
    1315     if (!isValid())
    1316         reattachToWebProcess(RegistrableDomain { URL(URL(), urlString) });
     1311    if (!hasRunningProcess())
     1312        launchProcess(RegistrableDomain { URL(URL(), urlString) });
    13171313
    13181314    m_process->send(Messages::WebPage::NavigateToPDFLinkWithSimulatedClick(urlString, documentPoint, screenPoint), m_pageID);
     
    13241320    RELEASE_LOG_IF_ALLOWED(Loading, "stopLoading: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    13251321
    1326     if (!isValid()) {
     1322    if (!hasRunningProcess()) {
    13271323        RELEASE_LOG_IF_ALLOWED(Loading, "navigateToPDFLinkWithSimulatedClick: page is not valid: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    13281324        return;
     
    13541350    }
    13551351
    1356     if (!isValid())
    1357         return reattachToWebProcessForReload();
     1352    if (!hasRunningProcess())
     1353        return launchProcessForReload();
    13581354   
    13591355    auto navigation = m_navigationState->createReloadNavigation();
     
    14191415    LOG(Loading, "WebPageProxy %p goToBackForwardItem to item URL %s", this, item.url().utf8().data());
    14201416
    1421     if (!isValid())
    1422         return reattachToWebProcessWithItem(item);
     1417    if (!hasRunningProcess())
     1418        return launchProcessWithItem(item);
    14231419
    14241420    auto transaction = m_pageLoadState.transaction();
     
    14401436    RELEASE_LOG_IF_ALLOWED(Loading, "tryRestoreScrollPosition: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    14411437
    1442     if (!isValid()) {
     1438    if (!hasRunningProcess()) {
    14431439        RELEASE_LOG_IF_ALLOWED(Loading, "tryRestoreScrollPosition: page is not valid: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    14441440        return;
     
    15041500    m_controlledByAutomation = controlled;
    15051501
    1506     if (!isValid())
     1502    if (!hasRunningProcess())
    15071503        return;
    15081504
     
    15291525void WebPageProxy::setIndicating(bool indicating)
    15301526{
    1531     if (!isValid())
     1527    if (!hasRunningProcess())
    15321528        return;
    15331529
     
    15781574
    15791575    m_backgroundColor = color;
    1580     if (isValid())
     1576    if (hasRunningProcess())
    15811577        m_process->send(Messages::WebPage::SetBackgroundColor(color), m_pageID);
    15821578}
     
    15891585    m_topContentInset = contentInset;
    15901586
    1591     if (!isValid())
     1587    if (!hasRunningProcess())
    15921588        return;
    15931589#if PLATFORM(COCOA)
     
    16081604    m_underlayColor = color;
    16091605
    1610     if (isValid())
     1606    if (hasRunningProcess())
    16111607        m_process->send(Messages::WebPage::SetUnderlayColor(color), m_pageID);
    16121608}
     
    16141610void WebPageProxy::viewWillStartLiveResize()
    16151611{
    1616     if (!isValid())
     1612    if (!hasRunningProcess())
    16171613        return;
    16181614
     
    16231619void WebPageProxy::viewWillEndLiveResize()
    16241620{
    1625     if (!isValid())
     1621    if (!hasRunningProcess())
    16261622        return;
    16271623    m_process->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
     
    17291725#endif
    17301726
    1731     if (!isValid())
     1727    if (!hasRunningProcess())
    17321728        return;
    17331729
     
    18631859void WebPageProxy::layerHostingModeDidChange()
    18641860{
    1865     if (!isValid())
     1861    if (!hasRunningProcess())
    18661862        return;
    18671863
     
    18761872void WebPageProxy::waitForDidUpdateActivityState(ActivityStateChangeID activityStateChangeID)
    18771873{
    1878     if (!isValid())
     1874    if (!hasRunningProcess())
    18791875        return;
    18801876
     
    19071903void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent, WTF::Function<void (CallbackBase::Error)>&& callbackFunction)
    19081904{
    1909     if (!isValid()) {
     1905    if (!hasRunningProcess()) {
    19101906        callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
    19111907        return;
     
    19181914void WebPageProxy::clearSelection()
    19191915{
    1920     if (!isValid())
     1916    if (!hasRunningProcess())
    19211917        return;
    19221918    m_process->send(Messages::WebPage::ClearSelection(), m_pageID);
     
    19251921void WebPageProxy::restoreSelectionInFocusedEditableElement()
    19261922{
    1927     if (!isValid())
     1923    if (!hasRunningProcess())
    19281924        return;
    19291925    m_process->send(Messages::WebPage::RestoreSelectionInFocusedEditableElement(), m_pageID);
     
    19321928void WebPageProxy::validateCommand(const String& commandName, WTF::Function<void (const String&, bool, int32_t, CallbackBase::Error)>&& callbackFunction)
    19331929{
    1934     if (!isValid()) {
     1930    if (!hasRunningProcess()) {
    19351931        callbackFunction(String(), false, 0, CallbackBase::Error::Unknown);
    19361932        return;
     
    19431939void WebPageProxy::increaseListLevel()
    19441940{
    1945     if (!isValid())
     1941    if (!hasRunningProcess())
    19461942        return;
    19471943
     
    19511947void WebPageProxy::decreaseListLevel()
    19521948{
    1953     if (!isValid())
     1949    if (!hasRunningProcess())
    19541950        return;
    19551951
     
    19591955void WebPageProxy::changeListType()
    19601956{
    1961     if (!isValid())
     1957    if (!hasRunningProcess())
    19621958        return;
    19631959
     
    19671963void WebPageProxy::setBaseWritingDirection(WritingDirection direction)
    19681964{
    1969     if (!isValid())
     1965    if (!hasRunningProcess())
    19701966        return;
    19711967
     
    19931989    m_needsFontAttributes = needsFontAttributes;
    19941990
    1995     if (isValid())
     1991    if (hasRunningProcess())
    19961992        m_process->send(Messages::WebPage::SetNeedsFontAttributes(needsFontAttributes), m_pageID);
    19971993}
     
    20142010void WebPageProxy::executeEditCommand(const String& commandName, const String& argument, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    20152011{
    2016     if (!isValid()) {
     2012    if (!hasRunningProcess()) {
    20172013        callbackFunction(CallbackBase::Error::Unknown);
    20182014        return;
     
    20272023    static NeverDestroyed<String> ignoreSpellingCommandName(MAKE_STATIC_STRING_IMPL("ignoreSpelling"));
    20282024
    2029     if (!isValid())
     2025    if (!hasRunningProcess())
    20302026        return;
    20312027
     
    20382034void WebPageProxy::requestFontAttributesAtSelectionStart(Function<void(const WebCore::FontAttributes&, CallbackBase::Error)>&& callback)
    20392035{
    2040     if (!isValid()) {
     2036    if (!hasRunningProcess()) {
    20412037        callback({ }, CallbackBase::Error::Unknown);
    20422038        return;
     
    20592055    if (editable == m_isEditable)
    20602056        return;
    2061     if (!isValid())
    2062         return;
    20632057
    20642058    m_isEditable = editable;
     2059
     2060    if (!hasRunningProcess())
     2061        return;
     2062
    20652063    m_process->send(Messages::WebPage::SetEditable(editable), m_pageID);
    20662064}
     
    21152113void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData& dragData, const String& dragStorageName, SandboxExtension::Handle&& sandboxExtensionHandle, SandboxExtension::HandleArray&& sandboxExtensionsForUpload)
    21162114{
    2117     if (!isValid())
     2115    if (!hasRunningProcess())
    21182116        return;
    21192117#if PLATFORM(GTK)
     
    21582156void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
    21592157{
    2160     if (!isValid())
     2158    if (!hasRunningProcess())
    21612159        return;
    21622160    m_process->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
     
    21712169void WebPageProxy::didStartDrag()
    21722170{
    2173     if (isValid())
     2171    if (hasRunningProcess())
    21742172        m_process->send(Messages::WebPage::DidStartDrag(), m_pageID);
    21752173}
     
    21772175void WebPageProxy::dragCancelled()
    21782176{
    2179     if (isValid())
     2177    if (hasRunningProcess())
    21802178        m_process->send(Messages::WebPage::DragCancelled(), m_pageID);
    21812179}
     
    22322230void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
    22332231{
    2234     if (!isValid())
     2232    if (!hasRunningProcess())
    22352233        return;
    22362234
     
    22582256void WebPageProxy::processNextQueuedMouseEvent()
    22592257{
    2260     if (!isValid())
     2258    if (!hasRunningProcess())
    22612259        return;
    22622260
     
    23512349#endif
    23522350
    2353     if (!isValid())
     2351    if (!hasRunningProcess())
    23542352        return;
    23552353
     
    24222420void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
    24232421{
    2424     if (!isValid())
     2422    if (!hasRunningProcess())
    24252423        return;
    24262424   
     
    25942592void WebPageProxy::handleGestureEvent(const NativeWebGestureEvent& event)
    25952593{
    2596     if (!isValid())
     2594    if (!hasRunningProcess())
    25972595        return;
    25982596
     
    26132611void WebPageProxy::handleTouchEventSynchronously(NativeWebTouchEvent& event)
    26142612{
    2615     if (!isValid())
     2613    if (!hasRunningProcess())
    26162614        return;
    26172615
     
    26532651void WebPageProxy::handleTouchEventAsynchronously(const NativeWebTouchEvent& event)
    26542652{
    2655     if (!isValid())
     2653    if (!hasRunningProcess())
    26562654        return;
    26572655
     
    26692667void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
    26702668{
    2671     if (!isValid())
     2669    if (!hasRunningProcess())
    26722670        return;
    26732671
     
    27102708void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
    27112709{
    2712     if (!isValid())
     2710    if (!hasRunningProcess())
    27132711        return;
    27142712
     
    27182716void WebPageProxy::centerSelectionInVisibleArea()
    27192717{
    2720     if (!isValid())
     2718    if (!hasRunningProcess())
    27212719        return;
    27222720
     
    28252823void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, Optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
    28262824{
    2827     if (!isValid()) {
     2825    if (!hasRunningProcess()) {
    28282826        sender->send(PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt);
    28292827        return;
     
    29602958#endif
    29612959
    2962     if (!isValid())
     2960    if (!hasRunningProcess())
    29632961        return;
    29642962    m_process->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
     
    29942992void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
    29952993{
    2996     if (!isValid() || !m_isPageSuspended)
     2994    if (!hasRunningProcess() || !m_isPageSuspended)
    29972995        return;
    29982996
     
    30043002void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
    30053003{
    3006     if (!isValid() || m_isPageSuspended)
     3004    if (!hasRunningProcess() || m_isPageSuspended)
    30073005        return;
    30083006
     
    30243022    m_customTextEncodingName = encodingName;
    30253023
    3026     if (!isValid())
     3024    if (!hasRunningProcess())
    30273025        return;
    30283026    m_process->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
     
    30973095void WebPageProxy::setTextZoomFactor(double zoomFactor)
    30983096{
    3099     if (!isValid())
    3100         return;
    3101 
    31023097    if (m_textZoomFactor == zoomFactor)
    31033098        return;
    31043099
    31053100    m_textZoomFactor = zoomFactor;
     3101
     3102    if (!hasRunningProcess())
     3103        return;
     3104
    31063105    m_process->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID);
    31073106}
     
    31093108void WebPageProxy::setPageZoomFactor(double zoomFactor)
    31103109{
    3111     if (!isValid())
    3112         return;
    3113 
    31143110    if (m_pageZoomFactor == zoomFactor)
    31153111        return;
     
    31183114
    31193115    m_pageZoomFactor = zoomFactor;
     3116
     3117    if (!hasRunningProcess())
     3118        return;
     3119
    31203120    m_process->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID);
    31213121}
     
    31233123void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
    31243124{
    3125     if (!isValid())
    3126         return;
    3127 
    31283125    if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
    31293126        return;
     
    31333130    m_pageZoomFactor = pageZoomFactor;
    31343131    m_textZoomFactor = textZoomFactor;
     3132
     3133    if (!hasRunningProcess())
     3134        return;
     3135
    31353136    m_process->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID);
    31363137}
     
    31583159    ASSERT(scale > 0);
    31593160
    3160     if (!isValid())
    3161         return;
    3162 
    31633161    m_pageScaleFactor = scale;
     3162
     3163    if (!hasRunningProcess())
     3164        return;
     3165
    31643166    m_process->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
    31653167}
     
    31693171    ASSERT(scale > 0);
    31703172
    3171     if (!isValid())
    3172         return;
    3173 
    31743173    m_pageScaleFactor = scale;
     3174
     3175    if (!hasRunningProcess())
     3176        return;
     3177
    31753178    m_process->send(Messages::WebPage::ScalePageInViewCoordinates(scale, centerInViewCoordinates), m_pageID);
    31763179}
     
    31803183    ASSERT(scale > 0);
    31813184
    3182     if (!isValid())
    3183         return;
    3184 
    31853185    m_viewScaleFactor = scale;
     3186
     3187    if (!hasRunningProcess())
     3188        return;
     3189
    31863190    m_process->send(Messages::WebPage::ScaleView(scale), m_pageID);
    31873191}
     
    32003204void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
    32013205{
    3202     if (!isValid())
     3206    if (!hasRunningProcess())
    32033207        return;
    32043208
     
    32133217void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
    32143218{
    3215     if (!isValid())
    3216         return;
    3217 
    32183219    // FIXME: Remove this once we bump cairo requirements to support HiDPI.
    32193220    // https://bugs.webkit.org/show_bug.cgi?id=133378
     
    32333234        m_customDeviceScaleFactor = WTF::nullopt;
    32343235
     3236    if (!hasRunningProcess())
     3237        return;
     3238
    32353239    if (deviceScaleFactor() != oldScaleFactor)
    32363240        m_drawingArea->deviceScaleFactorDidChange();
     
    32393243void WebPageProxy::accessibilitySettingsDidChange()
    32403244{
    3241     if (!isValid())
     3245    if (!hasRunningProcess())
    32423246        return;
    32433247
     
    32483252void WebPageProxy::updateAccessibilityEventsEnabled(bool enabled)
    32493253{
    3250     if (!isValid())
     3254    if (!hasRunningProcess())
    32513255        return;
    32523256
     
    32573261void WebPageProxy::setUseFixedLayout(bool fixed)
    32583262{
    3259     if (!isValid())
    3260         return;
    3261 
    32623263    // This check is fine as the value is initialized in the web
    32633264    // process as part of the creation parameters.
     
    32683269    if (!fixed)
    32693270        m_fixedLayoutSize = IntSize();
     3271
     3272    if (!hasRunningProcess())
     3273        return;
     3274
    32703275    m_process->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
    32713276}
     
    32733278void WebPageProxy::setFixedLayoutSize(const IntSize& size)
    32743279{
    3275     if (!isValid())
    3276         return;
    3277 
    32783280    if (size == m_fixedLayoutSize)
    32793281        return;
    32803282
    32813283    m_fixedLayoutSize = size;
     3284
     3285    if (!hasRunningProcess())
     3286        return;
     3287
    32823288    m_process->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
    32833289}
     
    32853291void WebPageProxy::setAlwaysShowsHorizontalScroller(bool alwaysShowsHorizontalScroller)
    32863292{
    3287     if (!isValid())
    3288         return;
    3289 
    32903293    if (alwaysShowsHorizontalScroller == m_alwaysShowsHorizontalScroller)
    32913294        return;
    32923295
    32933296    m_alwaysShowsHorizontalScroller = alwaysShowsHorizontalScroller;
     3297
     3298    if (!hasRunningProcess())
     3299        return;
     3300
    32943301    m_process->send(Messages::WebPage::SetAlwaysShowsHorizontalScroller(alwaysShowsHorizontalScroller), m_pageID);
    32953302}
     
    32973304void WebPageProxy::setAlwaysShowsVerticalScroller(bool alwaysShowsVerticalScroller)
    32983305{
    3299     if (!isValid())
    3300         return;
    3301 
    33023306    if (alwaysShowsVerticalScroller == m_alwaysShowsVerticalScroller)
    33033307        return;
    33043308
    33053309    m_alwaysShowsVerticalScroller = alwaysShowsVerticalScroller;
     3310
     3311    if (!hasRunningProcess())
     3312        return;
     3313
    33063314    m_process->send(Messages::WebPage::SetAlwaysShowsVerticalScroller(alwaysShowsVerticalScroller), m_pageID);
    33073315}
    33083316
    33093317void WebPageProxy::listenForLayoutMilestones(OptionSet<WebCore::LayoutMilestone> milestones)
    3310 {
    3311     if (!isValid())
    3312         return;
    3313    
     3318{   
    33143319    if (milestones == m_observedLayoutMilestones)
    33153320        return;
    33163321
    33173322    m_observedLayoutMilestones = milestones;
     3323
     3324    if (!hasRunningProcess())
     3325        return;
     3326
    33183327    m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
    33193328}
     
    33213330void WebPageProxy::setSuppressScrollbarAnimations(bool suppressAnimations)
    33223331{
    3323     if (!isValid())
    3324         return;
    3325 
    33263332    if (suppressAnimations == m_suppressScrollbarAnimations)
    33273333        return;
    33283334
    33293335    m_suppressScrollbarAnimations = suppressAnimations;
     3336
     3337    if (!hasRunningProcess())
     3338        return;
     3339
    33303340    m_process->send(Messages::WebPage::SetSuppressScrollbarAnimations(suppressAnimations), m_pageID);
    33313341}
     
    33783388    m_enableVerticalRubberBanding = enableVerticalRubberBanding;
    33793389
    3380     if (!isValid())
     3390    if (!hasRunningProcess())
    33813391        return;
    33823392    m_process->send(Messages::WebPage::SetEnableVerticalRubberBanding(enableVerticalRubberBanding), m_pageID);
     
    33953405    m_enableHorizontalRubberBanding = enableHorizontalRubberBanding;
    33963406
    3397     if (!isValid())
     3407    if (!hasRunningProcess())
    33983408        return;
    33993409    m_process->send(Messages::WebPage::SetEnableHorizontalRubberBanding(enableHorizontalRubberBanding), m_pageID);
     
    34123422    m_backgroundExtendsBeyondPage = backgroundExtendsBeyondPage;
    34133423
    3414     if (!isValid())
     3424    if (!hasRunningProcess())
    34153425        return;
    34163426    m_process->send(Messages::WebPage::SetBackgroundExtendsBeyondPage(backgroundExtendsBeyondPage), m_pageID);
     
    34293439    m_paginationMode = mode;
    34303440
    3431     if (!isValid())
     3441    if (!hasRunningProcess())
    34323442        return;
    34333443    m_process->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
     
    34413451    m_paginationBehavesLikeColumns = behavesLikeColumns;
    34423452
    3443     if (!isValid())
     3453    if (!hasRunningProcess())
    34443454        return;
    34453455    m_process->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
     
    34533463    m_pageLength = pageLength;
    34543464
    3455     if (!isValid())
     3465    if (!hasRunningProcess())
    34563466        return;
    34573467    m_process->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
     
    34653475    m_gapBetweenPages = gap;
    34663476
    3467     if (!isValid())
     3477    if (!hasRunningProcess())
    34683478        return;
    34693479    m_process->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
     
    34773487    m_paginationLineGridEnabled = lineGridEnabled;
    34783488   
    3479     if (!isValid())
     3489    if (!hasRunningProcess())
    34803490        return;
    34813491    m_process->send(Messages::WebPage::SetPaginationLineGridEnabled(lineGridEnabled), m_pageID);
     
    35293539void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
    35303540{
    3531     if (!isValid())
     3541    if (!hasRunningProcess())
    35323542        return;
    35333543
     
    35373547void WebPageProxy::replaceMatches(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly, Function<void(uint64_t, CallbackBase::Error)>&& callback)
    35383548{
    3539     if (!isValid()) {
     3549    if (!hasRunningProcess()) {
    35403550        callback(0, CallbackBase::Error::Unknown);
    35413551        return;
     
    35463556}
    35473557
     3558void WebPageProxy::launchInitialProcessIfNecessary()
     3559{
     3560    if (&process() == process().processPool().dummyProcessProxy())
     3561        launchProcess({ });
     3562}
     3563
    35483564void WebPageProxy::runJavaScriptInMainFrame(const String& script, bool forceUserGesture, WTF::Function<void (API::SerializedScriptValue*, bool hadException, const ExceptionDetails&, CallbackBase::Error)>&& callbackFunction)
    35493565{
    3550     if (!isValid()) {
     3566    // For backward-compatibility support running script in a WebView which has not done any loads yets.
     3567    launchInitialProcessIfNecessary();
     3568
     3569    if (!hasRunningProcess()) {
    35513570        callbackFunction(nullptr, false, { }, CallbackBase::Error::Unknown);
    35523571        return;
     
    35593578void WebPageProxy::runJavaScriptInMainFrameScriptWorld(const String& script, bool forceUserGesture, const String& worldName, WTF::Function<void(API::SerializedScriptValue*, bool hadException, const ExceptionDetails&, CallbackBase::Error)>&& callbackFunction)
    35603579{
    3561     if (!isValid()) {
     3580    // For backward-compatibility support running script in a WebView which has not done any loads yets.
     3581    launchInitialProcessIfNecessary();
     3582
     3583    if (!hasRunningProcess()) {
    35623584        callbackFunction(nullptr, false, { }, CallbackBase::Error::Unknown);
    35633585        return;
     
    35703592void WebPageProxy::getRenderTreeExternalRepresentation(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    35713593{
    3572     if (!isValid()) {
     3594    if (!hasRunningProcess()) {
    35733595        callbackFunction(String(), CallbackBase::Error::Unknown);
    35743596        return;
     
    35813603void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    35823604{
    3583     if (!isValid()) {
     3605    if (!hasRunningProcess()) {
    35843606        callbackFunction(String(), CallbackBase::Error::Unknown);
    35853607        return;
     
    35933615void WebPageProxy::getContentsAsString(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    35943616{
    3595     if (!isValid()) {
     3617    if (!hasRunningProcess()) {
    35963618        callbackFunction(String(), CallbackBase::Error::Unknown);
    35973619        return;
     
    36063628void WebPageProxy::getContentsAsAttributedString(CompletionHandler<void(const AttributedString&)>&& completionHandler)
    36073629{
    3608     if (!isValid()) {
     3630    if (!hasRunningProcess()) {
    36093631        completionHandler(AttributedString());
    36103632        return;
     
    36173639void WebPageProxy::getBytecodeProfile(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    36183640{
    3619     if (!isValid()) {
     3641    if (!hasRunningProcess()) {
    36203642        callbackFunction(String(), CallbackBase::Error::Unknown);
    36213643        return;
     
    36293651void WebPageProxy::getSamplingProfilerOutput(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    36303652{
    3631     if (!isValid()) {
     3653    if (!hasRunningProcess()) {
    36323654        callbackFunction(String(), CallbackBase::Error::Unknown);
    36333655        return;
     
    36423664void WebPageProxy::getContentsAsMHTMLData(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    36433665{
    3644     if (!isValid()) {
     3666    if (!hasRunningProcess()) {
    36453667        callbackFunction(nullptr, CallbackBase::Error::Unknown);
    36463668        return;
     
    36543676void WebPageProxy::getSelectionOrContentsAsString(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    36553677{
    3656     if (!isValid()) {
     3678    if (!hasRunningProcess()) {
    36573679        callbackFunction(String(), CallbackBase::Error::Unknown);
    36583680        return;
     
    36653687void WebPageProxy::getSelectionAsWebArchiveData(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    36663688{
    3667     if (!isValid()) {
     3689    if (!hasRunningProcess()) {
    36683690        callbackFunction(nullptr, CallbackBase::Error::Unknown);
    36693691        return;
     
    36763698void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    36773699{
    3678     if (!isValid() || !frame) {
     3700    if (!hasRunningProcess() || !frame) {
    36793701        callbackFunction(nullptr, CallbackBase::Error::Unknown);
    36803702        return;
     
    36873709void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, API::URL* resourceURL, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    36883710{
    3689     if (!isValid()) {
     3711    if (!hasRunningProcess()) {
    36903712        callbackFunction(nullptr, CallbackBase::Error::Unknown);
    36913713        return;
     
    36983720void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    36993721{
    3700     if (!isValid()) {
     3722    if (!hasRunningProcess()) {
    37013723        callbackFunction(nullptr, CallbackBase::Error::Unknown);
    37023724        return;
     
    37093731void WebPageProxy::forceRepaint(RefPtr<VoidCallback>&& callback)
    37103732{
    3711     if (!isValid()) {
     3733    if (!hasRunningProcess()) {
    37123734        // FIXME: If the page is invalid we should not call the callback. It'd be better to just return false from forceRepaint.
    37133735        callback->invalidate(CallbackBase::Error::OwnerWasInvalidated);
     
    37213743        }
    37223744
    3723         if (!isValid()) {
     3745        if (!hasRunningProcess()) {
    37243746            callback->invalidate(CallbackBase::Error::OwnerWasInvalidated);
    37253747            return;
     
    37513773void WebPageProxy::preferencesDidChange()
    37523774{
    3753     if (!isValid())
     3775    if (!hasRunningProcess())
    37543776        return;
    37553777
     
    53315353    m_mediaVolume = volume;
    53325354   
    5333     if (!isValid())
     5355    if (!hasRunningProcess())
    53345356        return;
    53355357   
     
    53415363    m_mutedState = state;
    53425364
    5343     if (!isValid())
     5365    if (!hasRunningProcess())
    53445366        return;
    53455367
     
    53585380    m_mediaCaptureEnabled = enabled;
    53595381
    5360     if (!isValid())
     5382    if (!hasRunningProcess())
    53615383        return;
    53625384
     
    53685390void WebPageProxy::stopMediaCapture()
    53695391{
    5370     if (!isValid())
     5392    if (!hasRunningProcess())
    53715393        return;
    53725394
     
    53785400void WebPageProxy::stopAllMediaPlayback()
    53795401{
    5380     if (!isValid())
     5402    if (!hasRunningProcess())
    53815403        return;
    53825404
     
    53865408void WebPageProxy::suspendAllMediaPlayback()
    53875409{
    5388     if (!isValid())
     5410    if (!hasRunningProcess())
    53895411        return;
    53905412
     
    53945416void WebPageProxy::resumeAllMediaPlayback()
    53955417{
    5396     if (!isValid())
     5418    if (!hasRunningProcess())
    53975419        return;
    53985420
     
    54035425void WebPageProxy::handleMediaEvent(MediaEventType eventType)
    54045426{
    5405     if (!isValid())
     5427    if (!hasRunningProcess())
    54065428        return;
    54075429   
     
    54115433void WebPageProxy::setVolumeOfMediaElement(double volume, uint64_t elementID)
    54125434{
    5413     if (!isValid())
     5435    if (!hasRunningProcess())
    54145436        return;
    54155437
     
    54255447    m_mayStartMediaWhenInWindow = mayStartMedia;
    54265448
    5427     if (!isValid())
     5449    if (!hasRunningProcess())
    54285450        return;
    54295451
     
    54655487void WebPageProxy::didChooseColor(const WebCore::Color& color)
    54665488{
    5467     if (!isValid())
     5489    if (!hasRunningProcess())
    54685490        return;
    54695491
     
    54735495void WebPageProxy::didEndColorPicker()
    54745496{
    5475     if (!isValid())
     5497    if (!hasRunningProcess())
    54765498        return;
    54775499
     
    55165538void WebPageProxy::didSelectOption(const String& selectedOption)
    55175539{
    5518     if (!isValid())
     5540    if (!hasRunningProcess())
    55195541        return;
    55205542
     
    55265548WebInspectorProxy* WebPageProxy::inspector() const
    55275549{
    5528     if (isClosed() || !isValid())
     5550    if (isClosed() || !hasRunningProcess())
    55295551        return nullptr;
    55305552    return m_inspector.get();
     
    59575979void WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>& fileURLs, const String& displayString, const API::Data* iconData)
    59585980{
    5959     if (!isValid())
     5981    if (!hasRunningProcess())
    59605982        return;
    59615983
     
    59786000void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
    59796001{
    5980     if (!isValid())
     6002    if (!hasRunningProcess())
    59816003        return;
    59826004
     
    60056027void WebPageProxy::didCancelForOpenPanel()
    60066028{
    6007     if (!isValid())
     6029    if (!hasRunningProcess())
    60086030        return;
    60096031
     
    60416063    m_editCommandSet.remove(&command);
    60426064
    6043     if (!isValid())
     6065    if (!hasRunningProcess())
    60446066        return;
    60456067    m_process->send(Messages::WebPage::DidRemoveEditCommand(command.commandID()), m_pageID);
     
    65886610    RELEASE_LOG_IF_ALLOWED(Process, "processDidBecomeUnresponsive: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    65896611
    6590     if (!isValid())
     6612    if (!hasRunningProcess())
    65916613        return;
    65926614
     
    66006622    RELEASE_LOG_IF_ALLOWED(Process, "processDidBecomeResponsive: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
    66016623
    6602     if (!isValid())
     6624    if (!hasRunningProcess())
    66036625        return;
    66046626   
     
    66316653        RELEASE_LOG_IF_ALLOWED(Process, "processDidTerminate: (pid %d), reason %d", processIdentifier(), reason);
    66326654
    6633     ASSERT(m_isValid);
     6655    ASSERT(m_hasRunningProcess);
    66346656
    66356657#if PLATFORM(IOS_FAMILY)
     
    67346756void WebPageProxy::processWillBecomeSuspended()
    67356757{
    6736     if (!isValid())
     6758    if (!hasRunningProcess())
    67376759        return;
    67386760
     
    67446766void WebPageProxy::processWillBecomeForeground()
    67456767{
    6746     if (!isValid())
     6768    if (!hasRunningProcess())
    67476769        return;
    67486770
     
    68806902void WebPageProxy::resetStateAfterProcessExited(ProcessTerminationReason terminationReason)
    68816903{
    6882     if (!isValid())
     6904    if (!hasRunningProcess())
    68836905        return;
    68846906
     
    69006922    m_visiblePageToken = nullptr;
    69016923
    6902     m_isValid = false;
     6924    m_hasRunningProcess = false;
    69036925    m_isPageSuspended = false;
    69046926
     
    74007422void WebPageProxy::setCanRunModal(bool canRunModal)
    74017423{
    7402     if (!isValid())
    7403         return;
    7404 
    74057424    // It's only possible to change the state for a WebPage which
    74067425    // already qualifies for running modal child web pages, otherwise
    74077426    // there's no other possibility than not allowing it.
    74087427    m_canRunModal = m_uiClient->canRunModal() && canRunModal;
     7428
     7429    if (!hasRunningProcess())
     7430        return;
     7431
    74097432    m_process->send(Messages::WebPage::SetCanRunModal(m_canRunModal), m_pageID);
    74107433}
     
    74127435bool WebPageProxy::canRunModal()
    74137436{
    7414     return isValid() ? m_canRunModal : false;
     7437    return hasRunningProcess() ? m_canRunModal : false;
    74157438}
    74167439
     
    74357458void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, Ref<ComputedPagesCallback>&& callback)
    74367459{
    7437     if (!isValid()) {
     7460    if (!hasRunningProcess()) {
    74387461        callback->invalidate();
    74397462        return;
     
    74497472void WebPageProxy::drawRectToImage(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, Ref<ImageCallback>&& callback)
    74507473{
    7451     if (!isValid()) {
     7474    if (!hasRunningProcess()) {
    74527475        callback->invalidate();
    74537476        return;
     
    74617484void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, Ref<DataCallback>&& callback)
    74627485{
    7463     if (!isValid()) {
     7486    if (!hasRunningProcess()) {
    74647487        callback->invalidate();
    74657488        return;
     
    74737496void WebPageProxy::drawPagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, Ref<PrintFinishedCallback>&& callback)
    74747497{
    7475     if (!isValid()) {
     7498    if (!hasRunningProcess()) {
    74767499        callback->invalidate();
    74777500        return;
     
    74877510void WebPageProxy::updateBackingStoreDiscardableState()
    74887511{
    7489     ASSERT(isValid());
     7512    ASSERT(hasRunningProcess());
    74907513
    74917514    if (!m_drawingArea)
     
    75237546    m_viewLayoutSize = viewLayoutSize;
    75247547
    7525     if (!isValid())
     7548    if (!hasRunningProcess())
    75267549        return;
    75277550
     
    75427565    m_autoSizingShouldExpandToViewHeight = shouldExpand;
    75437566
    7544     if (!isValid())
     7567    if (!hasRunningProcess())
    75457568        return;
    75467569
     
    75557578    m_viewportSizeForCSSViewportUnits = viewportSize;
    75567579
    7557     if (!isValid())
     7580    if (!hasRunningProcess())
    75587581        return;
    75597582
     
    76637686{
    76647687    // FIXME: We need to find out how to proper handle the crashes case.
    7665     if (!isValid())
     7688    if (!hasRunningProcess())
    76667689        return;
    76677690
     
    76717694void WebPageProxy::confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength)
    76727695{
    7673     if (!isValid())
     7696    if (!hasRunningProcess())
    76747697        return;
    76757698
     
    76797702void WebPageProxy::cancelComposition()
    76807703{
    7681     if (!isValid())
     7704    if (!hasRunningProcess())
    76827705        return;
    76837706
     
    76987721    m_scrollPinningBehavior = pinning;
    76997722
    7700     if (isValid())
     7723    if (hasRunningProcess())
    77017724        m_process->send(Messages::WebPage::SetScrollPinningBehavior(pinning), m_pageID);
    77027725}
     
    77167739        scrollbarStyleForMessage = static_cast<ScrollbarOverlayStyle>(scrollbarStyle.value());
    77177740
    7718     if (isValid())
     7741    if (hasRunningProcess())
    77197742        m_process->send(Messages::WebPage::SetScrollbarOverlayStyle(scrollbarStyleForMessage), m_pageID);
    77207743}
     
    77617784void WebPageProxy::changeFontAttributes(WebCore::FontAttributeChanges&& changes)
    77627785{
    7763     if (!isValid())
     7786    if (!hasRunningProcess())
    77647787        return;
    77657788
     
    77697792void WebPageProxy::changeFont(WebCore::FontChanges&& changes)
    77707793{
    7771     if (!isValid())
     7794    if (!hasRunningProcess())
    77727795        return;
    77737796
     
    77797802void WebPageProxy::setTextAsync(const String& text)
    77807803{
    7781     if (isValid())
     7804    if (hasRunningProcess())
    77827805        process().send(Messages::WebPage::SetTextAsync(text), m_pageID);
    77837806}
     
    77857808void WebPageProxy::insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup, EditingRangeIsRelativeTo editingRangeIsRelativeTo, bool suppressSelectionUpdate)
    77867809{
    7787     if (!isValid())
     7810    if (!hasRunningProcess())
    77887811        return;
    77897812
     
    77937816void WebPageProxy::getMarkedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&& callbackFunction)
    77947817{
    7795     if (!isValid()) {
     7818    if (!hasRunningProcess()) {
    77967819        callbackFunction(EditingRange(), CallbackBase::Error::Unknown);
    77977820        return;
     
    78047827void WebPageProxy::getSelectedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&& callbackFunction)
    78057828{
    7806     if (!isValid()) {
     7829    if (!hasRunningProcess()) {
    78077830        callbackFunction(EditingRange(), CallbackBase::Error::Unknown);
    78087831        return;
     
    78157838void WebPageProxy::characterIndexForPointAsync(const WebCore::IntPoint& point, WTF::Function<void (uint64_t, CallbackBase::Error)>&& callbackFunction)
    78167839{
    7817     if (!isValid()) {
     7840    if (!hasRunningProcess()) {
    78187841        callbackFunction(0, CallbackBase::Error::Unknown);
    78197842        return;
     
    78267849void WebPageProxy::firstRectForCharacterRangeAsync(const EditingRange& range, WTF::Function<void (const WebCore::IntRect&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
    78277850{
    7828     if (!isValid()) {
     7851    if (!hasRunningProcess()) {
    78297852        callbackFunction(WebCore::IntRect(), EditingRange(), CallbackBase::Error::Unknown);
    78307853        return;
     
    78377860void WebPageProxy::setCompositionAsync(const String& text, const Vector<CompositionUnderline>& underlines, const EditingRange& selectionRange, const EditingRange& replacementRange)
    78387861{
    7839     if (!isValid()) {
     7862    if (!hasRunningProcess()) {
    78407863        // If this fails, we should call -discardMarkedText on input context to notify the input method.
    78417864        // This will happen naturally later, as part of reloading the page.
     
    78487871void WebPageProxy::confirmCompositionAsync()
    78497872{
    7850     if (!isValid())
     7873    if (!hasRunningProcess())
    78517874        return;
    78527875
     
    78707893void WebPageProxy::takeSnapshot(IntRect rect, IntSize bitmapSize, SnapshotOptions options, WTF::Function<void (const ShareableBitmap::Handle&, CallbackBase::Error)>&& callbackFunction)
    78717894{
    7872     if (!isValid()) {
     7895    if (!hasRunningProcess()) {
    78737896        callbackFunction(ShareableBitmap::Handle(), CallbackBase::Error::Unknown);
    78747897        return;
     
    80238046void WebPageProxy::requestActiveNowPlayingSessionInfo(Ref<NowPlayingInfoCallback>&& callback)
    80248047{
    8025     if (!isValid()) {
     8048    if (!hasRunningProcess()) {
    80268049        callback->invalidate();
    80278050        return;
     
    81138136   
    81148137void WebPageProxy::setUseSystemAppearance(bool useSystemAppearance)
    8115 {
    8116     if (!isValid())
    8117         return;
    8118    
     8138{   
    81198139    if (useSystemAppearance == m_useSystemAppearance)
    81208140        return;
    81218141   
    81228142    m_useSystemAppearance = useSystemAppearance;
     8143
     8144    if (!hasRunningProcess())
     8145        return;
     8146
    81238147    m_process->send(Messages::WebPage::SetUseSystemAppearance(useSystemAppearance), m_pageID);
    81248148}
     
    81388162void WebPageProxy::installActivityStateChangeCompletionHandler(Function<void()>&& completionHandler)
    81398163{
    8140     if (!isValid()) {
     8164    if (!hasRunningProcess()) {
    81418165        completionHandler();
    81428166        return;
     
    82038227void WebPageProxy::setPlaybackTarget(uint64_t contextId, Ref<MediaPlaybackTarget>&& target)
    82048228{
    8205     if (!isValid())
     8229    if (!hasRunningProcess())
    82068230        return;
    82078231
     
    82118235void WebPageProxy::externalOutputDeviceAvailableDidChange(uint64_t contextId, bool available)
    82128236{
    8213     if (!isValid())
     8237    if (!hasRunningProcess())
    82148238        return;
    82158239
     
    82198243void WebPageProxy::setShouldPlayToPlaybackTarget(uint64_t contextId, bool shouldPlay)
    82208244{
    8221     if (!isValid())
     8245    if (!hasRunningProcess())
    82228246        return;
    82238247
     
    82458269void WebPageProxy::clearWheelEventTestTrigger()
    82468270{
    8247     if (!isValid())
     8271    if (!hasRunningProcess())
    82488272        return;
    82498273   
     
    82538277void WebPageProxy::callAfterNextPresentationUpdate(WTF::Function<void (CallbackBase::Error)>&& callback)
    82548278{
    8255     if (!isValid() || !m_drawingArea) {
     8279    if (!hasRunningProcess() || !m_drawingArea) {
    82568280        callback(CallbackBase::Error::OwnerWasInvalidated);
    82578281        return;
     
    82688292    m_shouldScaleViewToFitDocument = shouldScaleViewToFitDocument;
    82698293
    8270     if (!isValid())
     8294    if (!hasRunningProcess())
    82718295        return;
    82728296
     
    82828306{
    82838307    m_iconLoadingClient->getLoadDecisionForIcon(icon, [this, protectedThis = RefPtr<WebPageProxy>(this), loadIdentifier](WTF::Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction) {
    8284         if (!isValid()) {
     8308        if (!hasRunningProcess()) {
    82858309            if (callbackFunction)
    82868310                callbackFunction(nullptr, CallbackBase::Error::Unknown);
     
    83078331    m_isResourceCachingDisabled = disabled;
    83088332
    8309     if (!isValid())
     8333    if (!hasRunningProcess())
    83108334        return;
    83118335
     
    83208344void WebPageProxy::setUserInterfaceLayoutDirection(WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection)
    83218345{
    8322     if (!isValid())
     8346    if (!hasRunningProcess())
    83238347        return;
    83248348
     
    84658489void WebPageProxy::effectiveAppearanceDidChange()
    84668490{
    8467     if (!isValid())
     8491    if (!hasRunningProcess())
    84688492        return;
    84698493
     
    85008524void WebPageProxy::insertAttachment(Ref<API::Attachment>&& attachment, Function<void(CallbackBase::Error)>&& callback)
    85018525{
    8502     if (!isValid()) {
     8526    if (!hasRunningProcess()) {
    85038527        callback(CallbackBase::Error::OwnerWasInvalidated);
    85048528        return;
     
    85138537void WebPageProxy::updateAttachmentAttributes(const API::Attachment& attachment, Function<void(CallbackBase::Error)>&& callback)
    85148538{
    8515     if (!isValid()) {
     8539    if (!hasRunningProcess()) {
    85168540        callback(CallbackBase::Error::OwnerWasInvalidated);
    85178541        return;
     
    86748698void WebPageProxy::getApplicationManifest(Function<void(const Optional<WebCore::ApplicationManifest>&, CallbackBase::Error)>&& callbackFunction)
    86758699{
    8676     if (!isValid()) {
     8700    if (!hasRunningProcess()) {
    86778701        callbackFunction(WTF::nullopt, CallbackBase::Error::Unknown);
    86788702        return;
     
    89018925void WebPageProxy::textInputContextsInRect(WebCore::FloatRect rect, CompletionHandler<void(const Vector<WebKit::TextInputContext>&)>&& completionHandler)
    89028926{
    8903     if (!isValid()) {
     8927    if (!hasRunningProcess()) {
    89048928        completionHandler({ });
    89058929        return;
     
    89118935void WebPageProxy::focusTextInputContext(const TextInputContext& context, CompletionHandler<void(bool)>&& completionHandler)
    89128936{
    8913     if (!isValid()) {
     8937    if (!hasRunningProcess()) {
    89148938        completionHandler(false);
    89158939        return;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r243028 r243094  
    10721072    WebPageGroup& pageGroup() { return m_pageGroup; }
    10731073
    1074     bool isValid() const;
     1074    bool hasRunningProcess() const;
     1075    void launchInitialProcessIfNecessary();
    10751076
    10761077#if ENABLE(DRAG_SUPPORT)
     
    16751676    void setCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents) { m_canShortCircuitHorizontalWheelEvents = canShortCircuitHorizontalWheelEvents; }
    16761677
    1677     void reattachToWebProcess(const WebCore::RegistrableDomain&);
     1678    void launchProcess(const WebCore::RegistrableDomain&);
    16781679    void swapToWebProcess(Ref<WebProcessProxy>&&, std::unique_ptr<DrawingAreaProxy>&&, RefPtr<WebFrameProxy>&& mainFrame);
    16791680    void didFailToSuspendAfterProcessSwap();
     
    16831684    void finishAttachingToWebProcess(IsProcessSwap);
    16841685
    1685     RefPtr<API::Navigation> reattachToWebProcessForReload();
    1686     RefPtr<API::Navigation> reattachToWebProcessWithItem(WebBackForwardListItem&);
     1686    RefPtr<API::Navigation> launchProcessForReload();
     1687    RefPtr<API::Navigation> launchProcessWithItem(WebBackForwardListItem&);
    16871688
    16881689    void requestNotificationPermission(uint64_t notificationID, const String& originString);
     
    20102011    void updateFontAttributesAfterEditorStateChange();
    20112012
     2013    void didAttachToRunningProcess();
     2014
    20122015#if ENABLE(RESOURCE_LOAD_STATISTICS)
    20132016    void logFrameNavigation(const WebFrameProxy&, const URL& pageURL, const WebCore::ResourceRequest&, const URL& redirectURL);
     
    22152218       
    22162219    // If the process backing the web page is alive and kicking.
    2217     bool m_isValid { true };
     2220    bool m_hasRunningProcess { false };
    22182221
    22192222    // Whether WebPageProxy::close() has been called on this page.
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r243019 r243094  
    6464#include "WebCoreArgumentCoders.h"
    6565#include "WebGeolocationManagerProxy.h"
     66#include "WebInspectorUtilities.h"
    6667#include "WebKit2Initialize.h"
    6768#include "WebMemorySampler.h"
     
    739740{
    740741    if (privateBrowsingEnabled) {
    741         sendToNetworkingProcess(Messages::NetworkProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::legacyPrivateSessionParameters()));
     742        ensureNetworkProcess().send(Messages::NetworkProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::legacyPrivateSessionParameters()), 0);
    742743    } else {
    743         networkProcess()->removeSession(PAL::SessionID::legacyPrivateSessionID());
     744        if (auto* networkProcess = this->networkProcess())
     745            networkProcess->removeSession(PAL::SessionID::legacyPrivateSessionID());
    744746    }
    745747}
     
    899901
    900902    parameters.cacheModel = cacheModel();
    901     parameters.languages = userPreferredLanguages();
     903    parameters.languages = configuration().overrideLanguages().isEmpty() ? userPreferredLanguages() : configuration().overrideLanguages();
    902904
    903905    parameters.urlSchemesRegisteredAsEmptyDocument = copyToVector(m_schemesToRegisterAsEmptyDocument);
     
    11051107    }
    11061108
     1109    if (m_dummyProcessProxy == process)
     1110        m_dummyProcessProxy = nullptr;
     1111
    11071112    // FIXME (Multi-WebProcess): <rdar://problem/12239765> Some of the invalidation calls of the other supplements are still necessary in multi-process mode, but they should only affect data structures pertaining to the process being disconnected.
    11081113    // Clearing everything causes assertion failures, so it's less trouble to skip that for now.
     
    12111216        // Sharing processes, e.g. when creating the page via window.open().
    12121217        process = &pageConfiguration->relatedPage()->process();
     1218    } else if (WebKit::isInspectorProcessPool(*this)) {
     1219        // Do not delay process launch for inspector pages as inspector pages do not know how to transition from a terminated process.
     1220        process = &processForRegistrableDomain(pageConfiguration->websiteDataStore()->websiteDataStore(), nullptr, { });
    12131221    } else {
    1214         process = &processForRegistrableDomain(pageConfiguration->websiteDataStore()->websiteDataStore(), nullptr, { });
     1222        // In the common case, we delay process launch until something is actually loaded in the page.
     1223        if (!m_dummyProcessProxy) {
     1224            auto dummyProcessProxy = WebProcessProxy::create(*this, WebsiteDataStore::createNonPersistent().get(), WebProcessProxy::IsPrewarmed::No, WebProcessProxy::ShouldLaunchProcess::No);
     1225            m_dummyProcessProxy = dummyProcessProxy.ptr();
     1226            m_processes.append(WTFMove(dummyProcessProxy));
     1227        }
     1228        process = m_dummyProcessProxy;
    12151229    }
    12161230    ASSERT(process);
     
    12791293    if (sessionID.isEphemeral()) {
    12801294        ASSERT(dataStore.parameters().networkSessionParameters.sessionID == sessionID);
    1281         if (m_networkProcess)
     1295        if (m_networkProcess) {
    12821296            m_networkProcess->addSession(makeRef(dataStore));
    1283         dataStore.clearPendingCookies();
     1297            dataStore.clearPendingCookies();
     1298        }
    12841299    } else if (sessionID != PAL::SessionID::defaultSessionID()) {
    1285         if (m_networkProcess)
     1300        if (m_networkProcess) {
    12861301            m_networkProcess->addSession(makeRef(dataStore));
    1287         dataStore.clearPendingCookies();
     1302            dataStore.clearPendingCookies();
     1303        }
    12881304    }
    12891305}
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r243034 r243094  
    165165    const Vector<RefPtr<WebProcessProxy>>& processes() const { return m_processes; }
    166166
     167    // WebProcessProxy object which does not have a running process which is used for convenience, to avoid
     168    // null checks in WebPageProxy.
     169    WebProcessProxy* dummyProcessProxy() const { return m_dummyProcessProxy; }
     170
    167171    // WebProcess or NetworkProcess as approporiate for current process model. The connection must be non-null.
    168172    IPC::Connection* networkingProcessConnection();
     
    587591    Vector<RefPtr<WebProcessProxy>> m_processes;
    588592    WebProcessProxy* m_prewarmedProcess { nullptr };
     593    WebProcessProxy* m_dummyProcessProxy { nullptr }; // A lightweight WebProcessProxy without backing process.
    589594
    590595    WebProcessProxy* m_processWithPageCache { nullptr };
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r243034 r243094  
    123123}
    124124
    125 Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore& websiteDataStore, IsPrewarmed isPrewarmed)
     125Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore& websiteDataStore, IsPrewarmed isPrewarmed, ShouldLaunchProcess shouldLaunchProcess)
    126126{
    127127    auto proxy = adoptRef(*new WebProcessProxy(processPool, websiteDataStore, isPrewarmed));
    128     proxy->connect();
     128    if (shouldLaunchProcess == ShouldLaunchProcess::Yes)
     129        proxy->connect();
    129130    return proxy;
    130131}
     
    360361    ASSERT(!globalPageMap().contains(webPage.pageID()));
    361362    ASSERT(!m_isInProcessCache);
    362     ASSERT(m_websiteDataStore.ptr() == &webPage.websiteDataStore());
     363    ASSERT(m_websiteDataStore.ptr() == &webPage.websiteDataStore() || processPool().dummyProcessProxy() == this);
    363364
    364365    if (beginsUsingDataStore == BeginsUsingDataStore::Yes)
     
    848849void WebProcessProxy::maybeShutDown(AllowProcessCaching allowProcessCaching)
    849850{
     851    if (processPool().dummyProcessProxy() == this && m_pageMap.isEmpty()) {
     852        ASSERT(state() == State::Terminated);
     853        m_processPool->disconnectProcess(this);
     854        return;
     855    }
     856
    850857    if (state() == State::Terminated || !canTerminateAuxiliaryProcess())
    851858        return;
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r243034 r243094  
    105105    };
    106106
    107     static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore&, IsPrewarmed);
     107    enum class ShouldLaunchProcess : bool { No, Yes };
     108
     109    static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore&, IsPrewarmed, ShouldLaunchProcess = ShouldLaunchProcess::Yes);
    108110    ~WebProcessProxy();
    109111
  • trunk/Source/WebKit/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp

    r188121 r243094  
    4747void InstallMissingMediaPluginsPermissionRequest::allow(GUniquePtr<GstInstallPluginsContext>&& context)
    4848{
    49     if (!m_page->isValid())
     49    if (!m_page->hasRunningProcess())
    5050        return;
    5151
     
    7373void InstallMissingMediaPluginsPermissionRequest::didEndRequestInstallMissingMediaPlugins(uint32_t result)
    7474{
    75     if (!m_page->isValid())
     75    if (!m_page->hasRunningProcess())
    7676        return;
    7777
  • trunk/Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp

    r240437 r243094  
    400400void WebInspectorProxy::platformDetach()
    401401{
    402     if (!inspectedPage()->isValid())
     402    if (!inspectedPage()->hasRunningProcess())
    403403        return;
    404404
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r243082 r243094  
    672672- (void)setupInteraction
    673673{
     674    // If the page is not valid yet then delay interaction setup until the process is launched/relaunched.
     675    if (!_page->hasRunningProcess())
     676        return;
     677
    674678    if (_hasSetUpInteractions)
    675679        return;
     
    12181222- (void)_webTouchEventsRecognized:(UIWebTouchEventsGestureRecognizer *)gestureRecognizer
    12191223{
    1220     if (!_page->isValid())
     1224    if (!_page->hasRunningProcess())
    12211225        return;
    12221226
     
    67946798- (void)_hoverGestureRecognizerChanged:(UIGestureRecognizer *)gestureRecognizer
    67956799{
    6796     if (!_page->isValid())
     6800    if (!_page->hasRunningProcess())
    67976801        return;
    67986802
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r242833 r243094  
    206206void WebPageProxy::requestFocusedElementInformation(Function<void(const FocusedElementInformation&, CallbackBase::Error)>&& callback)
    207207{
    208     if (!isValid()) {
     208    if (!hasRunningProcess()) {
    209209        callback({ }, CallbackBase::Error::OwnerWasInvalidated);
    210210        return;
     
    217217void WebPageProxy::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdate)
    218218{
    219     if (!isValid())
    220         return;
    221 
    222219    if (visibleContentRectUpdate == m_lastVisibleContentRectUpdate)
    223220        return;
    224221
    225222    m_lastVisibleContentRectUpdate = visibleContentRectUpdate;
     223
     224    if (!hasRunningProcess())
     225        return;
     226
    226227    m_process->send(Messages::ViewUpdateDispatcher::VisibleContentRectUpdate(m_pageID, visibleContentRectUpdate), 0);
    227228}
     
    234235void WebPageProxy::updateStringForFind(const String& string)
    235236{
    236     if (!isValid())
     237    if (!hasRunningProcess())
    237238        return;
    238239
     
    310311void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, DynamicViewportSizeUpdateID dynamicViewportSizeUpdateID)
    311312{
    312     if (!isValid())
     313    if (!hasRunningProcess())
    313314        return;
    314315
     
    326327    m_viewportConfigurationLayoutSizeScaleFactor = scaleFactor;
    327328
    328     if (isValid())
     329    if (hasRunningProcess())
    329330        m_process->send(Messages::WebPage::SetViewportConfigurationViewLayoutSize(size, scaleFactor, minimumEffectiveDeviceWidth), m_pageID);
    330331}
     
    336337    m_forceAlwaysUserScalable = userScalable;
    337338
    338     if (isValid())
     339    if (hasRunningProcess())
    339340        m_process->send(Messages::WebPage::SetForceAlwaysUserScalable(userScalable), m_pageID);
    340341}
     
    344345    m_maximumUnobscuredSize = size;
    345346
    346     if (isValid())
     347    if (hasRunningProcess())
    347348        m_process->send(Messages::WebPage::SetMaximumUnobscuredSize(size), m_pageID);
    348349}
     
    352353    if (deviceOrientation != m_deviceOrientation) {
    353354        m_deviceOrientation = deviceOrientation;
    354         if (isValid())
     355        if (hasRunningProcess())
    355356            m_process->send(Messages::WebPage::SetDeviceOrientation(deviceOrientation), m_pageID);
    356357    }
     
    359360void WebPageProxy::setOverrideViewportArguments(const Optional<ViewportArguments>& viewportArguments)
    360361{
    361     if (isValid())
     362    if (hasRunningProcess())
    362363        m_process->send(Messages::WebPage::SetOverrideViewportArguments(viewportArguments), m_pageID);
    363364}
     
    416417void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, WebCore::TextGranularity granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
    417418{
    418     if (!isValid()) {
     419    if (!hasRunningProcess()) {
    419420        callbackFunction(WebCore::IntPoint(), 0, 0, 0, CallbackBase::Error::Unknown);
    420421        return;
     
    427428void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, uint32_t touches, bool baseIsStart, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
    428429{
    429     if (!isValid()) {
     430    if (!hasRunningProcess()) {
    430431        callbackFunction(WebCore::IntPoint(), 0, 0, CallbackBase::Error::Unknown);
    431432        return;
     
    448449void WebPageProxy::requestAutocorrectionData(const String& textForAutocorrection, WTF::Function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>&& callbackFunction)
    449450{
    450     if (!isValid()) {
     451    if (!hasRunningProcess()) {
    451452        callbackFunction(Vector<WebCore::FloatRect>(), String(), 0, 0, CallbackBase::Error::Unknown);
    452453        return;
     
    459460void WebPageProxy::applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
    460461{
    461     if (!isValid()) {
     462    if (!hasRunningProcess()) {
    462463        callbackFunction(String(), CallbackBase::Error::Unknown);
    463464        return;
     
    477478void WebPageProxy::selectTextWithGranularityAtPoint(const WebCore::IntPoint point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    478479{
    479     if (!isValid()) {
     480    if (!hasRunningProcess()) {
    480481        callbackFunction(CallbackBase::Error::Unknown);
    481482        return;
     
    488489void WebPageProxy::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint point, WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    489490{
    490     if (!isValid()) {
     491    if (!hasRunningProcess()) {
    491492        callbackFunction(CallbackBase::Error::Unknown);
    492493        return;
     
    499500void WebPageProxy::moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    500501{
    501     if (!isValid()) {
     502    if (!hasRunningProcess()) {
    502503        callbackFunction(CallbackBase::Error::Unknown);
    503504        return;
     
    510511void WebPageProxy::selectPositionAtPoint(const WebCore::IntPoint point, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    511512{
    512     if (!isValid()) {
     513    if (!hasRunningProcess()) {
    513514        callbackFunction(CallbackBase::Error::Unknown);
    514515        return;
     
    521522void WebPageProxy::beginSelectionInDirection(WebCore::SelectionDirection direction, WTF::Function<void (uint64_t, CallbackBase::Error)>&& callbackFunction)
    522523{
    523     if (!isValid()) {
     524    if (!hasRunningProcess()) {
    524525        callbackFunction(0, CallbackBase::Error::Unknown);
    525526        return;
     
    532533void WebPageProxy::updateSelectionWithExtentPoint(const WebCore::IntPoint point, bool isInteractingWithFocusedElement, WTF::Function<void(uint64_t, CallbackBase::Error)>&& callbackFunction)
    533534{
    534     if (!isValid()) {
     535    if (!hasRunningProcess()) {
    535536        callbackFunction(0, CallbackBase::Error::Unknown);
    536537        return;
     
    544545void WebPageProxy::updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, WTF::Function<void(uint64_t, CallbackBase::Error)>&& callbackFunction)
    545546{
    546     if (!isValid()) {
     547    if (!hasRunningProcess()) {
    547548        callbackFunction(0, CallbackBase::Error::Unknown);
    548549        return;
     
    556557void WebPageProxy::requestDictationContext(WTF::Function<void (const String&, const String&, const String&, CallbackBase::Error)>&& callbackFunction)
    557558{
    558     if (!isValid()) {
     559    if (!hasRunningProcess()) {
    559560        callbackFunction(String(), String(), String(), CallbackBase::Error::Unknown);
    560561        return;
     
    577578void WebPageProxy::getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&& callbackFunction)
    578579{
    579     if (!isValid()) {
     580    if (!hasRunningProcess()) {
    580581        callbackFunction(String(), String(), String(), CallbackBase::Error::Unknown);
    581582        return;
     
    598599void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
    599600{
    600     if (!isValid()) {
     601    if (!hasRunningProcess()) {
    601602        callbackFunction(WebCore::IntPoint(), 0, 0, 0, CallbackBase::Error::Unknown);
    602603        return;
     
    695696void WebPageProxy::requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
    696697{
    697     if (!isValid()) {
     698    if (!hasRunningProcess()) {
    698699        callbackFunction(Vector<WebCore::SelectionRect>(), CallbackBase::Error::Unknown);
    699700        return;
     
    706707void WebPageProxy::requestRectsAtSelectionOffsetWithText(int32_t offset, const String& text, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
    707708{
    708     if (!isValid()) {
     709    if (!hasRunningProcess()) {
    709710        callbackFunction(Vector<WebCore::SelectionRect>(), CallbackBase::Error::Unknown);
    710711        return;
     
    732733void WebPageProxy::moveSelectionByOffset(int32_t offset, WTF::Function<void (CallbackBase::Error)>&& callbackFunction)
    733734{
    734     if (!isValid()) {
     735    if (!hasRunningProcess()) {
    735736        callbackFunction(CallbackBase::Error::Unknown);
    736737        return;
     
    775776void WebPageProxy::registerUIProcessAccessibilityTokens(const IPC::DataReference& elementToken, const IPC::DataReference& windowToken)
    776777{
    777     if (!isValid())
     778    if (!hasRunningProcess())
    778779        return;
    779780   
     
    967968void WebPageProxy::focusNextFocusedElement(bool isForward, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
    968969{
    969     if (!isValid()) {
     970    if (!hasRunningProcess()) {
    970971        callbackFunction(CallbackBase::Error::Unknown);
    971972        return;
     
    10501051uint32_t WebPageProxy::computePagesForPrintingAndDrawToPDF(uint64_t frameID, const PrintInfo& printInfo, DrawToPDFCallback::CallbackFunction&& callback)
    10511052{
    1052     if (!isValid()) {
     1053    if (!hasRunningProcess()) {
    10531054        callback(IPC::DataReference(), CallbackBase::Error::OwnerWasInvalidated);
    10541055        return 0;
     
    11271128void WebPageProxy::requestEvasionRectsAboveSelection(CompletionHandler<void(const Vector<WebCore::FloatRect>&)>&& callback)
    11281129{
    1129     if (!isValid()) {
     1130    if (!hasRunningProcess()) {
    11301131        callback({ });
    11311132        return;
     
    11491150void WebPageProxy::requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition)
    11501151{
    1151     if (isValid())
     1152    if (hasRunningProcess())
    11521153        m_process->send(Messages::WebPage::RequestDragStart(clientPosition, globalPosition), m_pageID);
    11531154}
     
    11551156void WebPageProxy::requestAdditionalItemsForDragSession(const IntPoint& clientPosition, const IntPoint& globalPosition)
    11561157{
    1157     if (isValid())
     1158    if (hasRunningProcess())
    11581159        m_process->send(Messages::WebPage::RequestAdditionalItemsForDragSession(clientPosition, globalPosition), m_pageID);
    11591160}
  • trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm

    r241988 r243094  
    6161void TiledCoreAnimationDrawingAreaProxy::sizeDidChange()
    6262{
    63     if (!m_webPageProxy.isValid())
     63    if (!m_webPageProxy.hasRunningProcess())
    6464        return;
    6565
     
    7979void TiledCoreAnimationDrawingAreaProxy::viewLayoutSizeDidChange()
    8080{
    81     if (!m_webPageProxy.isValid())
     81    if (!m_webPageProxy.hasRunningProcess())
    8282        return;
    8383
     
    141141MachSendRight TiledCoreAnimationDrawingAreaProxy::createFence()
    142142{
    143     if (!m_webPageProxy.isValid())
     143    if (!m_webPageProxy.hasRunningProcess())
    144144        return MachSendRight();
    145145
     
    169169    RefPtr<WebPageProxy> retainedPage = &m_webPageProxy;
    170170    [CATransaction addCommitHandler:[callbackID, retainedPage] {
    171         if (!retainedPage->isValid())
     171        if (!retainedPage->hasRunningProcess())
    172172            return;
    173173        if (Connection* connection = retainedPage->process().connection())
     
    198198void TiledCoreAnimationDrawingAreaProxy::dispatchAfterEnsuringDrawing(WTF::Function<void (CallbackBase::Error)>&& callback)
    199199{
    200     if (!m_webPageProxy.isValid()) {
     200    if (!m_webPageProxy.hasRunningProcess()) {
    201201        callback(CallbackBase::Error::OwnerWasInvalidated);
    202202        return;
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r242339 r243094  
    166166void WebPageProxy::windowAndViewFramesChanged(const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
    167167{
    168     if (!isValid())
     168    if (!hasRunningProcess())
    169169        return;
    170170
     
    178178void WebPageProxy::setMainFrameIsScrollable(bool isScrollable)
    179179{
    180     if (!isValid())
     180    if (!hasRunningProcess())
    181181        return;
    182182
     
    187187{
    188188#if USE(DICTATION_ALTERNATIVES)
    189     if (!isValid())
     189    if (!hasRunningProcess())
    190190        return;
    191191
     
    211211void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
    212212{
    213     if (!isValid()) {
     213    if (!hasRunningProcess()) {
    214214        callbackFunction(AttributedString(), EditingRange(), CallbackBase::Error::Unknown);
    215215        return;
     
    237237void WebPageProxy::fontAtSelection(WTF::Function<void (const String&, double, bool, CallbackBase::Error)>&& callbackFunction)
    238238{
    239     if (!isValid()) {
     239    if (!hasRunningProcess()) {
    240240        callbackFunction(String(), 0, false, CallbackBase::Error::Unknown);
    241241        return;
     
    262262{
    263263    String value;
    264     if (!isValid())
     264    if (!hasRunningProcess())
    265265        return value;
    266266   
     
    272272RefPtr<WebCore::SharedBuffer> WebPageProxy::dataSelectionForPasteboard(const String& pasteboardType)
    273273{
    274     if (!isValid())
     274    if (!hasRunningProcess())
    275275        return nullptr;
    276276    SharedMemory::Handle handle;
     
    287287bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName)
    288288{
    289     if (!isValid())
     289    if (!hasRunningProcess())
    290290        return false;
    291291
     
    326326void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
    327327{
    328     if (!isValid())
     328    if (!hasRunningProcess())
    329329        return;
    330330   
     
    364364void WebPageProxy::registerWebProcessAccessibilityToken(const IPC::DataReference& data)
    365365{
    366     if (!isValid())
     366    if (!hasRunningProcess())
    367367        return;
    368368   
     
    387387void WebPageProxy::registerUIProcessAccessibilityTokens(const IPC::DataReference& elementToken, const IPC::DataReference& windowToken)
    388388{
    389     if (!isValid())
     389    if (!hasRunningProcess())
    390390        return;
    391391
     
    425425bool WebPageProxy::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& event)
    426426{
    427     if (!isValid())
     427    if (!hasRunningProcess())
    428428        return false;
    429429
  • trunk/Source/WebKit/UIProcess/win/WebInspectorProxyWin.cpp

    r239535 r243094  
    321321void WebInspectorProxy::platformDetach()
    322322{
    323     if (!inspectedPage()->isValid())
     323    if (!inspectedPage()->hasRunningProcess())
    324324        return;
    325325
  • trunk/Source/WebKit/UIProcess/win/WebView.cpp

    r242995 r243094  
    738738HCURSOR WebView::cursorToShow() const
    739739{
    740     if (!m_page->isValid())
     740    if (!m_page->hasRunningProcess())
    741741        return 0;
    742742
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r243044 r243094  
    482482
    483483    m_page = std::make_unique<Page>(WTFMove(pageConfiguration));
     484
     485    // Set the sessionID *before* updating the preferences as the privateBrowsingEnabled preferences may need to override it.
     486    if (parameters.sessionID.isValid())
     487        setSessionID(parameters.sessionID);
     488
    484489    updatePreferences(parameters.store);
    485490
     
    539544
    540545    setUseDarkAppearance(parameters.useDarkAppearance);
     546
     547    if (parameters.isEditable)
     548        setEditable(true);
    541549
    542550#if PLATFORM(MAC)
     
    567575    if (!parameters.itemStates.isEmpty())
    568576        restoreSessionInternal(parameters.itemStates, WasRestoredByAPIRequest::No, WebBackForwardListProxy::OverwriteExistingItem::Yes);
    569 
    570     if (parameters.sessionID.isValid())
    571         setSessionID(parameters.sessionID);
    572577
    573578    m_drawingArea->setPaintingEnabled(true);
  • trunk/Tools/ChangeLog

    r243083 r243094  
     12019-03-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Delay WebProcess launch until a load is triggered in a Web view
     4        https://bugs.webkit.org/show_bug.cgi?id=195758
     5        <rdar://problem/48126013>
     6
     7        Reviewed by Geoff Garen.
     8
     9        Add API test coverage. Also update some existing API tests to not expect
     10        constructing a WKWebView to launch both a WebProcess and a NetworkProcess.
     11
     12        * TestWebKitAPI/Tests/WebKit/NetworkProcessCrashWithPendingConnection.mm:
     13        (TestWebKitAPI::TEST):
     14        * TestWebKitAPI/Tests/WebKit/mac/GetBackingScaleFactor.mm:
     15        (TestWebKitAPI::TEST):
     16        * TestWebKitAPI/Tests/WebKitCocoa/ProcessPreWarming.mm:
     17        (TEST):
     18        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     19        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
     20        (TEST):
     21        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     22        (TEST):
     23        (testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript):
     24
    1252019-03-18  Xan Lopez  <xan@igalia.com>
    226
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/NetworkProcessCrashWithPendingConnection.mm

    r242339 r243094  
    4040static bool webProcessCrashed = false;
    4141static bool networkProcessCrashed = false;
    42 static pid_t pid;
    4342static WKWebView* testView;
    4443
     
    139138    memset(&client, 0, sizeof(client));
    140139    client.networkProcessDidCrash = [](WKContextRef context, const void* clientInfo) {
    141         pid = [testView _webProcessIdentifier];
    142         EXPECT_GT(pid, 0); // The WebProcess is already launched when the network process crashes.
    143140        networkProcessCrashed = true;
    144141    };
     
    162159    EXPECT_FALSE(webProcessCrashed);
    163160    EXPECT_GT([webView _webProcessIdentifier], 0);
    164     EXPECT_EQ(pid, [webView _webProcessIdentifier]);
    165161    EXPECT_GT([processPool.get() _networkProcessIdentifier], 0);
    166162}
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/mac/GetBackingScaleFactor.mm

    r221505 r243094  
    2929#import "SyntheticBackingScaleFactorWindow.h"
    3030#import "Test.h"
     31#import <WebKit/WKBrowsingContextController.h>
    3132#import <WebKit/WKViewPrivate.h>
    3233#import <wtf/RetainPtr.h>
     
    6970    setInjectedBundleClient(context.get());
    7071    RetainPtr<WKView> view = adoptNS([[WKView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) contextRef:context.get() pageGroupRef:0]);
     72    [[view browsingContextController] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
    7173
    7274    RetainPtr<SyntheticBackingScaleFactorWindow> window1 = createWindow();
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessPreWarming.mm

    r242371 r243094  
    6666    auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);
    6767
     68    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL]]];
     69
    6870    EXPECT_FALSE([pool _hasPrewarmedWebProcess]);
    6971    EXPECT_EQ(1U, [pool _webPageContentProcessCount]);
    7072
    71     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL]]];
    7273    [webView _test_waitForDidFinishNavigation];
    7374
     
    102103
    103104    auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);
     105    [webView2 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL]]];
     106
    104107    EXPECT_FALSE([pool _hasPrewarmedWebProcess]);
    105108    EXPECT_EQ(2U, [pool _webPageContentProcessCount]);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r243009 r243094  
    32733273}
    32743274
     3275TEST(ProcessSwap, UseWebProcessCacheForLoadInNewView)
     3276{
     3277    auto processPoolConfiguration = psonProcessPoolConfiguration();
     3278    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     3279
     3280    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     3281    [webViewConfiguration setProcessPool:processPool.get()];
     3282    auto handler = adoptNS([[PSONScheme alloc] init]);
     3283    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     3284
     3285    auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     3286
     3287    int webkitPID = 0;
     3288
     3289    @autoreleasepool {
     3290        auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     3291        [webView setNavigationDelegate:navigationDelegate.get()];
     3292
     3293        // Process launch should be delayed until a load actually happens.
     3294        EXPECT_EQ(0, [webView _webProcessIdentifier]);
     3295        TestWebKitAPI::Util::sleep(0.1);
     3296        EXPECT_EQ(0, [webView _webProcessIdentifier]);
     3297
     3298        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
     3299        [webView loadRequest:request];
     3300        TestWebKitAPI::Util::run(&done);
     3301        done = false;
     3302        webkitPID = [webView _webProcessIdentifier];
     3303        EXPECT_NE(0, webkitPID);
     3304    }
     3305
     3306    while ([processPool _processCacheSize] != 1)
     3307        TestWebKitAPI::Util::sleep(0.1);
     3308
     3309    EXPECT_EQ(1U, [processPool _webProcessCountIgnoringPrewarmed]);
     3310
     3311    @autoreleasepool {
     3312        auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     3313        [webView setNavigationDelegate:navigationDelegate.get()];
     3314
     3315        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main2.html"]];
     3316        [webView loadRequest:request];
     3317        TestWebKitAPI::Util::run(&done);
     3318        done = false;
     3319
     3320        EXPECT_EQ(webkitPID, [webView _webProcessIdentifier]);
     3321        EXPECT_EQ(1U, [processPool _webProcessCountIgnoringPrewarmed]);
     3322    }
     3323
     3324    while ([processPool _processCacheSize] != 1)
     3325        TestWebKitAPI::Util::sleep(0.1);
     3326
     3327    EXPECT_EQ(1U, [processPool _webProcessCountIgnoringPrewarmed]);
     3328
     3329    @autoreleasepool {
     3330        auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     3331        [webView setNavigationDelegate:navigationDelegate.get()];
     3332
     3333        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
     3334        [webView loadRequest:request];
     3335        TestWebKitAPI::Util::run(&done);
     3336        done = false;
     3337
     3338        EXPECT_NE(webkitPID, [webView _webProcessIdentifier]);
     3339    }
     3340
     3341    EXPECT_EQ(2U, [processPool _webProcessCountIgnoringPrewarmed]);
     3342}
     3343
    32753344#endif // PLATFORM(MAC)
    32763345
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm

    r242339 r243094  
    7575    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    7676    [dataStore _setResourceLoadStatisticsEnabled:YES];
     77    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
    7778
    7879    TestWebKitAPI::Util::run(&grandfatheredFlag);
     
    140141    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    141142    [dataStore _setResourceLoadStatisticsEnabled:YES];
     143    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
    142144
    143145    TestWebKitAPI::Util::run(&callbackFlag);
     
    171173    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    172174    [dataStore _setResourceLoadStatisticsEnabled:YES];
     175    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
    173176
    174177    TestWebKitAPI::Util::run(&doneFlag);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

    r242339 r243094  
    193193    auto delegate = adoptNS([[InjectedBundleNodeHandleIsSelectElementDelegate alloc] init]);
    194194    [webView setUIDelegate:delegate.get()];
     195    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
    195196    TestWebKitAPI::Util::run(&done);
    196197}
     
    595596    auto delegate = adoptNS([[AutoFillDelegate alloc] init]);
    596597    [webView setUIDelegate:delegate.get()];
     598    [webView evaluateJavaScript:@"" completionHandler: nil]; // Ensure the WebProcess and injected bundle are running.
    597599    TestWebKitAPI::Util::run(&readyForClick);
    598600    NSPoint buttonLocation = NSMakePoint(130, 575);
     
    634636    auto delegate = adoptNS([[DidResignInputElementStrongPasswordAppearanceDelegate alloc] init]);
    635637    [webView setUIDelegate:delegate.get()];
     638    [webView evaluateJavaScript:@"" completionHandler:nil]; // Make sure WebProcess and injected bundle are running.
    636639    TestWebKitAPI::Util::run(&readytoResign);
    637640    [webView evaluateJavaScript:script completionHandler:nil];
     
    675678    auto delegate = adoptNS([[AutoFillAvailableDelegate alloc] init]);
    676679    [webView setUIDelegate:delegate.get()];
     680    [webView evaluateJavaScript:@"" completionHandler: nil]; // Ensure the WebProcess and injected bundle are running.
    677681    TestWebKitAPI::Util::run(&done);
    678682}
     
    699703    auto delegate = adoptNS([[InjectedBundleNodeHandleIsTextFieldDelegate alloc] init]);
    700704    [webView setUIDelegate:delegate.get()];
     705    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
    701706    TestWebKitAPI::Util::run(&done);
    702707}
Note: See TracChangeset for help on using the changeset viewer.