Title: [287731] trunk/Source
Revision
287731
Author
[email protected]
Date
2022-01-06 16:18:59 -0800 (Thu, 06 Jan 2022)

Log Message

Add a helper function that returns the value of a std::optional<T> or constructs T if needed
https://bugs.webkit.org/show_bug.cgi?id=234865

Reviewed by Darin Adler.

Source/WebCore:

Use `valueOrDefault` where appropriate. See WTF/ChangeLog for more details.

* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::convert):
(WebCore::ApplePayPaymentHandler::didAuthorizePayment):
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::applyConstraints):
* Modules/mediastream/RTCIceCandidate.cpp:
(WebCore::RTCIceCandidate::create):
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::executeSql):
* Modules/webxr/WebXRBoundedReferenceSpace.cpp:
(WebCore::WebXRBoundedReferenceSpace::updateIfNeeded):
* dom/Document.cpp:
* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::setupDateTimeChooserParameters):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::handleClick):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::isPointInPathInternal):
(WebCore::CanvasRenderingContext2DBase::isPointInStrokeInternal):
* layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::build):
* layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp:
(WebCore::Layout::LineBoxVerticalAligner::computeLineBoxLogicalHeight const):
* layout/formattingContexts/table/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
* loader/DocumentLoader.cpp:
* loader/FrameLoader.cpp:
* loader/PolicyChecker.cpp:
* loader/ResourceLoader.cpp:
* loader/SubresourceLoader.cpp:
* loader/cache/CachedResource.cpp:
* loader/cache/CachedResourceLoader.cpp:
* page/EventHandler.cpp:
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::lastKnownMousePosition const):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::targetPositionInWindowForSelectionAutoscroll const):
(WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad):
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
(WebCore::EventHandler::hoverTimerFired):
* page/FrameView.cpp:
(WebCore::FrameView::setLayoutViewportOverrideRect):
* page/Page.cpp:
(WebCore::Page::sampledPageTopColor const):
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::targetPositionInWindowForSelectionAutoscroll const):
* page/scrolling/ScrollingTreeLatchingController.cpp:
(WebCore::ScrollingTreeLatchingController::nodeDidHandleEvent):
* platform/graphics/ShadowBlur.cpp:
(WebCore::ShadowBlur::calculateLayerBoundingRect):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::naturalSize):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setVisibleAndCoverageRects):
* platform/graphics/transforms/TransformState.cpp:
(WebCore::TransformState::mappedPoint const):
(WebCore::TransformState::mapQuad const):
(WebCore::TransformState::flattenWithTransform):
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::systemPreviewInfo const):
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::filter):
(WebCore::ResourceResponseBase::sanitizeHTTPHeaderFieldsAccordingToTainting):
* rendering/PaintInfo.h:
(WebCore::PaintInfo::applyTransform):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::relativePositionOffset const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeAutoRepeatTracksCount const):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPositions):
(WebCore::RenderLayer::paintLayerByApplyingTransform):
* rendering/RenderView.cpp:
(WebCore::RenderView::layout):
* rendering/svg/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::nodeAtPoint):
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::nodeAtFloatPoint):
* rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::nodeAtFloatPoint):
* rendering/svg/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::nodeAtFloatPoint):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::hitTestClipContent):
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::clippedOverflowRect const):
(WebCore::RenderSVGRoot::absoluteRects const):
(WebCore::RenderSVGRoot::absoluteQuads const):
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::nodeAtFloatPoint):
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::nodeAtFloatPoint):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::clipContextToCSSClippingArea):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::clipToImageBuffer):
* svg/SVGAnimateMotionElement.cpp:
(WebCore::SVGAnimateMotionElement::calculateToAtEndOfDurationValue):
(WebCore::SVGAnimateMotionElement::calculateFromAndToValues):
(WebCore::SVGAnimateMotionElement::calculateFromAndByValues):
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::processGlyphElement):
(WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter):
* svg/properties/SVGPropertyTraits.h:
(WebCore::SVGPropertyTraits<FloatPoint>::fromString):
(WebCore::SVGPropertyTraits<FloatRect>::fromString):
* testing/Internals.cpp:
(WebCore::Internals::frameIdentifier const):
(WebCore::Internals::pageIdentifier const):
* workers/service/server/SWScriptStorage.cpp:
(WebCore::SWScriptStorage::SWScriptStorage):

Source/WebCore/PAL:

Use `valueOrDefault` where appropriate. See WTF/ChangeLog for more details.

* pal/graphics/WebGPU/Impl/WebGPUComputePassEncoderImpl.cpp:
(PAL::WebGPU::ComputePassEncoderImpl::setBindGroup):
* pal/graphics/WebGPU/Impl/WebGPURenderBundleEncoderImpl.cpp:
(PAL::WebGPU::RenderBundleEncoderImpl::setBindGroup):
* pal/graphics/WebGPU/Impl/WebGPURenderPassEncoderImpl.cpp:
(PAL::WebGPU::RenderPassEncoderImpl::setBindGroup):

Source/WebKit:

Use `valueOrDefault` where appropriate. See WTF/ChangeLog for more details.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad):
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::ensureSWServer):
* NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::fileTimes):
* NetworkProcess/storage/NetworkStorageManager.cpp:
(WebKit::NetworkStorageManager::NetworkStorageManager):
* UIProcess/Automation/SimulatedInputDispatcher.cpp:
(WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
* UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::loadRequest):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::registrableDomain const):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::parameters):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::loadResource):
(WebKit::WebLoaderStrategy::scheduleLoad):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::convertFromPDFViewToRootView const):
(WebKit::PDFPlugin::boundsOnScreen const):
(WebKit::PDFPlugin::geometryDidChange):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runJavaScriptInFrameInScriptWorld):
* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::didEnterFullscreen):

Source/WTF:

Add a new helper function that returns the value of a given `std::optional<Type>` if it exists, and otherwise
constructs and returns `Type { }`. Currently, the alternative to this is writing out the `Type { }` in full when
passing in an argument to `value_or`; using this avoids some redundancy and makes the _expression_ a bit easier to
read.

* wtf/StdLibExtras.h:
(WTF::valueOrDefault):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (287730 => 287731)


--- trunk/Source/WTF/ChangeLog	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WTF/ChangeLog	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1,3 +1,18 @@
+2022-01-06  Wenson Hsieh  <[email protected]>
+
+        Add a helper function that returns the value of a std::optional<T> or constructs T if needed
+        https://bugs.webkit.org/show_bug.cgi?id=234865
+
+        Reviewed by Darin Adler.
+
+        Add a new helper function that returns the value of a given `std::optional<Type>` if it exists, and otherwise
+        constructs and returns `Type { }`. Currently, the alternative to this is writing out the `Type { }` in full when
+        passing in an argument to `value_or`; using this avoids some redundancy and makes the _expression_ a bit easier to
+        read.
+
+        * wtf/StdLibExtras.h:
+        (WTF::valueOrDefault):
+
 2022-01-06  Tim Horton  <[email protected]>
 
         Separate "linked-on-or-{before, after}-everything" override from the SDK version

Modified: trunk/Source/WTF/wtf/StdLibExtras.h (287730 => 287731)


--- trunk/Source/WTF/wtf/StdLibExtras.h	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WTF/wtf/StdLibExtras.h	2022-01-07 00:18:59 UTC (rev 287731)
@@ -596,6 +596,11 @@
     return optional ? *optional : callback();
 }
 
+template<typename OptionalType> auto valueOrDefault(OptionalType&& optionalValue)
+{
+    return optionalValue ? *std::forward<OptionalType>(optionalValue) : std::remove_reference_t<decltype(*optionalValue)> { };
+}
+
 } // namespace WTF
 
 #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value)
@@ -622,3 +627,4 @@
 using WTF::safeCast;
 using WTF::tryBinarySearch;
 using WTF::valueOrCompute;
+using WTF::valueOrDefault;

Modified: trunk/Source/WebCore/ChangeLog (287730 => 287731)


--- trunk/Source/WebCore/ChangeLog	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/ChangeLog	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1,3 +1,127 @@
+2022-01-06  Wenson Hsieh  <[email protected]>
+
+        Add a helper function that returns the value of a std::optional<T> or constructs T if needed
+        https://bugs.webkit.org/show_bug.cgi?id=234865
+
+        Reviewed by Darin Adler.
+
+        Use `valueOrDefault` where appropriate. See WTF/ChangeLog for more details.
+
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::convert):
+        (WebCore::ApplePayPaymentHandler::didAuthorizePayment):
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::applyConstraints):
+        * Modules/mediastream/RTCIceCandidate.cpp:
+        (WebCore::RTCIceCandidate::create):
+        * Modules/webdatabase/SQLTransaction.cpp:
+        (WebCore::SQLTransaction::executeSql):
+        * Modules/webxr/WebXRBoundedReferenceSpace.cpp:
+        (WebCore::WebXRBoundedReferenceSpace::updateIfNeeded):
+        * dom/Document.cpp:
+        * html/BaseDateAndTimeInputType.cpp:
+        (WebCore::BaseDateAndTimeInputType::setupDateTimeChooserParameters):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::handleClick):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::isPointInPathInternal):
+        (WebCore::CanvasRenderingContext2DBase::isPointInStrokeInternal):
+        * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+        (WebCore::Layout::LineBoxBuilder::build):
+        * layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp:
+        (WebCore::Layout::LineBoxVerticalAligner::computeLineBoxLogicalHeight const):
+        * layout/formattingContexts/table/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
+        * loader/DocumentLoader.cpp:
+        * loader/FrameLoader.cpp:
+        * loader/PolicyChecker.cpp:
+        * loader/ResourceLoader.cpp:
+        * loader/SubresourceLoader.cpp:
+        * loader/cache/CachedResource.cpp:
+        * loader/cache/CachedResourceLoader.cpp:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::updateSelectionForMouseDrag):
+        (WebCore::EventHandler::lastKnownMousePosition const):
+        (WebCore::EventHandler::handleMouseMoveEvent):
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+        (WebCore::EventHandler::targetPositionInWindowForSelectionAutoscroll const):
+        (WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad):
+        (WebCore::EventHandler::fakeMouseMoveEventTimerFired):
+        (WebCore::EventHandler::hoverTimerFired):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setLayoutViewportOverrideRect):
+        * page/Page.cpp:
+        (WebCore::Page::sampledPageTopColor const):
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::targetPositionInWindowForSelectionAutoscroll const):
+        * page/scrolling/ScrollingTreeLatchingController.cpp:
+        (WebCore::ScrollingTreeLatchingController::nodeDidHandleEvent):
+        * platform/graphics/ShadowBlur.cpp:
+        (WebCore::ShadowBlur::calculateLayerBoundingRect):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext):
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::naturalSize):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setVisibleAndCoverageRects):
+        * platform/graphics/transforms/TransformState.cpp:
+        (WebCore::TransformState::mappedPoint const):
+        (WebCore::TransformState::mapQuad const):
+        (WebCore::TransformState::flattenWithTransform):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::systemPreviewInfo const):
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::filter):
+        (WebCore::ResourceResponseBase::sanitizeHTTPHeaderFieldsAccordingToTainting):
+        * rendering/PaintInfo.h:
+        (WebCore::PaintInfo::applyTransform):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::relativePositionOffset const):
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeAutoRepeatTracksCount const):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPositions):
+        (WebCore::RenderLayer::paintLayerByApplyingTransform):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout):
+        * rendering/svg/LegacyRenderSVGRoot.cpp:
+        (WebCore::LegacyRenderSVGRoot::nodeAtPoint):
+        * rendering/svg/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::nodeAtFloatPoint):
+        * rendering/svg/RenderSVGForeignObject.cpp:
+        (WebCore::RenderSVGForeignObject::nodeAtFloatPoint):
+        * rendering/svg/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::nodeAtFloatPoint):
+        * rendering/svg/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::hitTestClipContent):
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::clippedOverflowRect const):
+        (WebCore::RenderSVGRoot::absoluteRects const):
+        (WebCore::RenderSVGRoot::absoluteQuads const):
+        * rendering/svg/RenderSVGShape.cpp:
+        (WebCore::RenderSVGShape::nodeAtFloatPoint):
+        * rendering/svg/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::nodeAtFloatPoint):
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::clipContextToCSSClippingArea):
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::clipToImageBuffer):
+        * svg/SVGAnimateMotionElement.cpp:
+        (WebCore::SVGAnimateMotionElement::calculateToAtEndOfDurationValue):
+        (WebCore::SVGAnimateMotionElement::calculateFromAndToValues):
+        (WebCore::SVGAnimateMotionElement::calculateFromAndByValues):
+        * svg/SVGToOTFFontConversion.cpp:
+        (WebCore::SVGToOTFFontConverter::processGlyphElement):
+        (WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter):
+        * svg/properties/SVGPropertyTraits.h:
+        (WebCore::SVGPropertyTraits<FloatPoint>::fromString):
+        (WebCore::SVGPropertyTraits<FloatRect>::fromString):
+        * testing/Internals.cpp:
+        (WebCore::Internals::frameIdentifier const):
+        (WebCore::Internals::pageIdentifier const):
+        * workers/service/server/SWScriptStorage.cpp:
+        (WebCore::SWScriptStorage::SWScriptStorage):
+
 2022-01-06  Myles C. Maxfield  <[email protected]>
 
         REGRESSION(r281389): Text wraps unnecessarily within intrinsically-sized elements when using certain fonts and the inner HTML of the element contains a new line that is not preceded by a space

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (287730 => 287731)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -742,7 +742,7 @@
 
 static Ref<PaymentAddress> convert(const ApplePayPaymentContact& contact)
 {
-    return PaymentAddress::create(contact.countryCode, contact.addressLines.value_or(Vector<String>()), contact.administrativeArea, contact.locality, contact.subLocality, contact.postalCode, String(), String(), contact.localizedName, contact.phoneNumber);
+    return PaymentAddress::create(contact.countryCode, valueOrDefault(contact.addressLines), contact.administrativeArea, contact.locality, contact.subLocality, contact.postalCode, String(), String(), contact.localizedName, contact.phoneNumber);
 }
 
 template<typename T>
@@ -757,7 +757,7 @@
     ASSERT(m_updateState == UpdateState::None);
 
     auto applePayPayment = payment.toApplePayPayment(version());
-    auto shippingContact = applePayPayment.shippingContact.value_or(ApplePayPaymentContact());
+    auto shippingContact = valueOrDefault(applePayPayment.shippingContact);
     auto detailsFunction = [applePayPayment = WTFMove(applePayPayment)](JSC::JSGlobalObject& lexicalGlobalObject) {
         return toJSDictionary(lexicalGlobalObject, applePayPayment);
     };

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (287730 => 287731)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -386,7 +386,7 @@
             return;
         }
         m_promise->resolve();
-        m_constraints = constraints.value_or(MediaTrackConstraints { });
+        m_constraints = valueOrDefault(constraints);
     };
     m_private->applyConstraints(createMediaConstraints(constraints), WTFMove(completionHandler));
 }

Modified: trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp (287730 => 287731)


--- trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -56,7 +56,7 @@
     if (dictionary.sdpMid.isNull() && !dictionary.sdpMLineIndex)
         return Exception { TypeError, "Candidate must not have both null sdpMid and sdpMLineIndex" };
 
-    auto fields = parseIceCandidateSDP(dictionary.candidate).value_or(RTCIceCandidate::Fields { });
+    auto fields = valueOrDefault(parseIceCandidateSDP(dictionary.candidate));
     fields.usernameFragment = dictionary.usernameFragment;
     return adoptRef(*new RTCIceCandidate(dictionary.candidate, dictionary.sdpMid, dictionary.sdpMLineIndex, WTFMove(fields)));
 }

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp (287730 => 287731)


--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -83,7 +83,7 @@
     else if (m_readOnly)
         permissions |= DatabaseAuthorizer::ReadOnlyMask;
 
-    auto statement = makeUnique<SQLStatement>(m_database, sqlStatement, arguments.value_or(Vector<SQLValue> { }), WTFMove(callback), WTFMove(callbackError), permissions);
+    auto statement = makeUnique<SQLStatement>(m_database, sqlStatement, valueOrDefault(arguments), WTFMove(callback), WTFMove(callbackError), permissions);
 
     if (m_database->deleted())
         statement->setDatabaseDeletedError();

Modified: trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp (287730 => 287731)


--- trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -105,7 +105,7 @@
 
     if (frameData.stageParameters.bounds.size() >= MinimumBoundsVertices) {
         // Each point has to multiplied by the inverse of originOffset.
-        auto transform = originOffset().rawTransform().inverse().value_or(TransformationMatrix());
+        auto transform = valueOrDefault(originOffset().rawTransform().inverse());
         for (auto& point : frameData.stageParameters.bounds) {
             auto mappedPoint = transform.mapPoint(FloatPoint3D(point.x(), 0.0, point.y()));
             m_boundsGeometry.append(DOMPointReadOnly::create(quantize(mappedPoint.x()), quantize(mappedPoint.y()), quantize(mappedPoint.z()), 1.0));

Modified: trunk/Source/WebCore/PAL/ChangeLog (287730 => 287731)


--- trunk/Source/WebCore/PAL/ChangeLog	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/PAL/ChangeLog	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1,3 +1,19 @@
+2022-01-06  Wenson Hsieh  <[email protected]>
+
+        Add a helper function that returns the value of a std::optional<T> or constructs T if needed
+        https://bugs.webkit.org/show_bug.cgi?id=234865
+
+        Reviewed by Darin Adler.
+
+        Use `valueOrDefault` where appropriate. See WTF/ChangeLog for more details.
+
+        * pal/graphics/WebGPU/Impl/WebGPUComputePassEncoderImpl.cpp:
+        (PAL::WebGPU::ComputePassEncoderImpl::setBindGroup):
+        * pal/graphics/WebGPU/Impl/WebGPURenderBundleEncoderImpl.cpp:
+        (PAL::WebGPU::RenderBundleEncoderImpl::setBindGroup):
+        * pal/graphics/WebGPU/Impl/WebGPURenderPassEncoderImpl.cpp:
+        (PAL::WebGPU::RenderPassEncoderImpl::setBindGroup):
+
 2022-01-06  Alex Christensen  <[email protected]>
 
         Start using C++20

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUComputePassEncoderImpl.cpp (287730 => 287731)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUComputePassEncoderImpl.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUComputePassEncoderImpl.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -81,7 +81,7 @@
 void ComputePassEncoderImpl::setBindGroup(Index32 index, const BindGroup& bindGroup,
     std::optional<Vector<BufferDynamicOffset>>&& offsets)
 {
-    auto backingOffsets = offsets.value_or(Vector<BufferDynamicOffset> { });
+    auto backingOffsets = valueOrDefault(offsets);
     wgpuComputePassEncoderSetBindGroup(m_backing, index, m_convertToBackingContext->convertToBacking(bindGroup), static_cast<uint32_t>(backingOffsets.size()), backingOffsets.data());
 }
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderBundleEncoderImpl.cpp (287730 => 287731)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderBundleEncoderImpl.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderBundleEncoderImpl.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -90,7 +90,7 @@
 void RenderBundleEncoderImpl::setBindGroup(Index32 index, const BindGroup& bindGroup,
     std::optional<Vector<BufferDynamicOffset>>&& dynamicOffsets)
 {
-    auto backingOffsets = dynamicOffsets.value_or(Vector<BufferDynamicOffset> { });
+    auto backingOffsets = valueOrDefault(dynamicOffsets);
     wgpuRenderBundleEncoderSetBindGroup(m_backing, index, m_convertToBackingContext->convertToBacking(bindGroup), backingOffsets.size(), backingOffsets.data());
 }
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderPassEncoderImpl.cpp (287730 => 287731)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderPassEncoderImpl.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPURenderPassEncoderImpl.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -91,7 +91,7 @@
 void RenderPassEncoderImpl::setBindGroup(Index32 index, const BindGroup& bindGroup,
     std::optional<Vector<BufferDynamicOffset>>&& dynamicOffsets)
 {
-    auto backingOffsets = dynamicOffsets.value_or(Vector<BufferDynamicOffset> { });
+    auto backingOffsets = valueOrDefault(dynamicOffsets);
     wgpuRenderPassEncoderSetBindGroup(m_backing, index, m_convertToBackingContext->convertToBacking(bindGroup), backingOffsets.size(), backingOffsets.data());
 }
 

Modified: trunk/Source/WebCore/dom/Document.cpp (287730 => 287731)


--- trunk/Source/WebCore/dom/Document.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -353,8 +353,8 @@
 #include "HTMLVideoElement.h"
 #endif
 
-#define DOCUMENT_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] Document::" fmt, this, pageID().value_or(PageIdentifier { }).toUInt64(), frameID().value_or(FrameIdentifier { }).toUInt64(), this == &topDocument(), ##__VA_ARGS__)
-#define DOCUMENT_RELEASE_LOG_ERROR(channel, fmt, ...) RELEASE_LOG_ERROR(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] Document::" fmt, this, pageID().value_or(PageIdentifier { }).toUInt64(), frameID().value_or(FrameIdentifier { }).toUInt64(), this == &topDocument(), ##__VA_ARGS__)
+#define DOCUMENT_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] Document::" fmt, this, valueOrDefault(pageID()).toUInt64(), valueOrDefault(frameID()).toUInt64(), this == &topDocument(), ##__VA_ARGS__)
+#define DOCUMENT_RELEASE_LOG_ERROR(channel, fmt, ...) RELEASE_LOG_ERROR(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] Document::" fmt, this, valueOrDefault(pageID()).toUInt64(), valueOrDefault(frameID()).toUInt64(), this == &topDocument(), ##__VA_ARGS__)
 
 namespace WebCore {
 

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp (287730 => 287731)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -547,7 +547,7 @@
     parameters.isAnchorElementRTL = computedStyle->direction() == TextDirection::RTL;
     parameters.useDarkAppearance = document.useDarkAppearance(computedStyle);
 
-    auto date = parseToDateComponents(element.value()).value_or(DateComponents());
+    auto date = valueOrDefault(parseToDateComponents(element.value()));
     parameters.hasSecondField = shouldHaveSecondField(date);
     parameters.hasMillisecondField = shouldHaveMillisecondField(date);
 

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (287730 => 287731)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -513,7 +513,7 @@
     if (systemPreviewInfo.isPreview) {
         systemPreviewInfo.element.elementIdentifier = document().identifierForElement(*this);
         systemPreviewInfo.element.documentIdentifier = document().identifier();
-        systemPreviewInfo.element.webPageIdentifier = document().frame()->loader().pageID().value_or(PageIdentifier { });
+        systemPreviewInfo.element.webPageIdentifier = valueOrDefault(document().frame()->loader().pageID());
         if (auto* child = firstElementChild())
             systemPreviewInfo.previewRect = child->boundsInRootViewSpace();
     }

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (287730 => 287731)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1158,7 +1158,7 @@
     if (!state.hasInvertibleTransform)
         return false;
 
-    auto transformedPoint = state.transform.inverse().value_or(AffineTransform()).mapPoint(FloatPoint(x, y));
+    auto transformedPoint = valueOrDefault(state.transform.inverse()).mapPoint(FloatPoint(x, y));
     if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.y()))
         return false;
 
@@ -1173,7 +1173,7 @@
     if (!state.hasInvertibleTransform)
         return false;
 
-    auto transformedPoint = state.transform.inverse().value_or(AffineTransform()).mapPoint(FloatPoint(x, y));
+    auto transformedPoint = valueOrDefault(state.transform.inverse()).mapPoint(FloatPoint(x, y));
     if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.y()))
         return false;
 

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (287730 => 287731)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -106,7 +106,7 @@
 LineBoxBuilder::LineBoxAndHeight LineBoxBuilder::build(const LineBuilder::LineContent& lineContent, size_t lineIndex)
 {
     auto& rootStyle = lineIndex ? rootBox().firstLineStyle() : rootBox().style();
-    auto rootInlineBoxAlignmentOffset = Layout::horizontalAlignmentOffset(rootStyle.textAlign(), lineContent, rootStyle.isLeftToRightDirection()).value_or(InlineLayoutUnit { });
+    auto rootInlineBoxAlignmentOffset = valueOrDefault(Layout::horizontalAlignmentOffset(rootStyle.textAlign(), lineContent, rootStyle.isLeftToRightDirection()));
     // FIXME: The overflowing hanging content should be part of the ink overflow.  
     auto lineBox = LineBox { rootBox(), rootInlineBoxAlignmentOffset, lineContent.contentLogicalWidth - lineContent.hangingContentWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };
     auto lineBoxLogicalHeight = constructAndAlignInlineLevelBoxes(lineBox, lineContent, lineIndex);

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp (287730 => 287731)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -177,7 +177,7 @@
         case VerticalAlign::TextBottom: {
             // Note that text-bottom aligns with the inline box's font metrics bottom (descent) and not the layout bounds bottom.
             auto parentInlineBoxLayoutBounds = parentInlineBox.layoutBounds();
-            auto parentInlineBoxLogicalBottom = parentInlineBoxLayoutBounds.height() - parentInlineBoxLayoutBounds.descent + parentInlineBox.descent().value_or(InlineLayoutUnit());
+            auto parentInlineBoxLogicalBottom = parentInlineBoxLayoutBounds.height() - parentInlineBoxLayoutBounds.descent + valueOrDefault(parentInlineBox.descent());
             logicalTop = parentInlineBoxLogicalBottom - inlineLevelBox.layoutBounds().height();
             break;
         }
@@ -208,7 +208,7 @@
     // The line box height computation is as follows:
     // 1. Stretch the line box with the non-line-box relative aligned inline box absolute top and bottom values.
     // 2. Check if the line box relative aligned inline boxes (top, bottom etc) have enough room and stretch the line box further if needed.
-    auto lineBoxLogicalHeight = maximumLogicalBottom.value_or(InlineLayoutUnit()) - minimumLogicalTop.value_or(InlineLayoutUnit());
+    auto lineBoxLogicalHeight = valueOrDefault(maximumLogicalBottom) - valueOrDefault(minimumLogicalTop);
     for (auto* lineBoxRelativeInlineLevelBox : lineBoxRelativeInlineLevelBoxes) {
         if (!formattingGeometry.inlineLevelBoxAffectsLineBox(*lineBoxRelativeInlineLevelBox, lineBox))
             continue;

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp (287730 => 287731)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -123,8 +123,8 @@
 
             // FIXME: Find out if it is ok to use the regular padding here to align the content box inside a tall cell or we need to
             // use some kind of intrinsic padding similar to RenderTableCell.
-            auto paddingTop = cellBoxGeometry.paddingBefore().value_or(LayoutUnit { });
-            auto paddingBottom = cellBoxGeometry.paddingAfter().value_or(LayoutUnit { });
+            auto paddingTop = valueOrDefault(cellBoxGeometry.paddingBefore());
+            auto paddingBottom = valueOrDefault(cellBoxGeometry.paddingAfter());
             auto intrinsicPaddingTop = LayoutUnit { };
             auto intrinsicPaddingBottom = LayoutUnit { };
 

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -127,8 +127,8 @@
 #include "NetworkStorageSession.h"
 #endif
 
-#define PAGE_ID ((m_frame ? m_frame->pageID().value_or(PageIdentifier()) : PageIdentifier()).toUInt64())
-#define FRAME_ID ((m_frame ? m_frame->frameID().value_or(FrameIdentifier()) : FrameIdentifier()).toUInt64())
+#define PAGE_ID ((m_frame ? valueOrDefault(m_frame->pageID()) : PageIdentifier()).toUInt64())
+#define FRAME_ID ((m_frame ? valueOrDefault(m_frame->frameID()) : FrameIdentifier()).toUInt64())
 #define IS_MAIN_FRAME (m_frame ? m_frame->isMainFrame() : false)
 #define DOCUMENTLOADER_RELEASE_LOG(fmt, ...) RELEASE_LOG(Network, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] DocumentLoader::" fmt, this, PAGE_ID, FRAME_ID, IS_MAIN_FRAME, ##__VA_ARGS__)
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -153,8 +153,8 @@
 #include "RuntimeApplicationChecks.h"
 #endif
 
-#define PAGE_ID ((pageID().value_or(PageIdentifier())).toUInt64())
-#define FRAME_ID ((frameID().value_or(FrameIdentifier())).toUInt64())
+#define PAGE_ID (valueOrDefault(pageID()).toUInt64())
+#define FRAME_ID (valueOrDefault(frameID()).toUInt64())
 #define FRAMELOADER_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] FrameLoader::" fmt, this, PAGE_ID, FRAME_ID, m_frame.isMainFrame(), ##__VA_ARGS__)
 #define FRAMELOADER_RELEASE_LOG_ERROR(channel, fmt, ...) RELEASE_LOG_ERROR(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] FrameLoader::" fmt, this, PAGE_ID, FRAME_ID, m_frame.isMainFrame(), ##__VA_ARGS__)
 

Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/PolicyChecker.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -54,8 +54,8 @@
 #include "QuickLook.h"
 #endif
 
-#define PAGE_ID (m_frame.loader().pageID().value_or(PageIdentifier()).toUInt64())
-#define FRAME_ID (m_frame.loader().frameID().value_or(FrameIdentifier()).toUInt64())
+#define PAGE_ID (valueOrDefault(m_frame.loader().pageID()).toUInt64())
+#define FRAME_ID (valueOrDefault(m_frame.loader().frameID()).toUInt64())
 #define POLICYCHECKER_RELEASE_LOG(fmt, ...) RELEASE_LOG(Loading, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 "] PolicyChecker::" fmt, this, PAGE_ID, FRAME_ID, ##__VA_ARGS__)
 
 namespace WebCore {

Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/ResourceLoader.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -64,8 +64,8 @@
 #endif
 
 #undef RESOURCELOADER_RELEASE_LOG
-#define PAGE_ID ((frame() ? frame()->pageID().value_or(PageIdentifier()) : PageIdentifier()).toUInt64())
-#define FRAME_ID ((frame() ? frame()->frameID().value_or(FrameIdentifier()) : FrameIdentifier()).toUInt64())
+#define PAGE_ID ((frame() ? valueOrDefault(frame()->pageID()) : PageIdentifier()).toUInt64())
+#define FRAME_ID ((frame() ? valueOrDefault(frame()->frameID()) : FrameIdentifier()).toUInt64())
 #define RESOURCELOADER_RELEASE_LOG(fmt, ...) RELEASE_LOG(Network, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", frameLoader=%p, resourceID=%" PRIu64 "] ResourceLoader::" fmt, this, PAGE_ID, FRAME_ID, frameLoader(), identifier().toUInt64(), ##__VA_ARGS__)
 
 namespace WebCore {

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -69,8 +69,8 @@
 
 #undef SUBRESOURCELOADER_RELEASE_LOG
 #undef SUBRESOURCELOADER_RELEASE_LOG_ERROR
-#define PAGE_ID ((frame() ? frame()->pageID().value_or(PageIdentifier()) : PageIdentifier()).toUInt64())
-#define FRAME_ID ((frame() ? frame()->frameID().value_or(FrameIdentifier()) : FrameIdentifier()).toUInt64())
+#define PAGE_ID ((frame() ? valueOrDefault(frame()->pageID()) : PageIdentifier()).toUInt64())
+#define FRAME_ID ((frame() ? valueOrDefault(frame()->frameID()) : FrameIdentifier()).toUInt64())
 #if RELEASE_LOG_DISABLED
 #define SUBRESOURCELOADER_RELEASE_LOG(fmt, ...) UNUSED_VARIABLE(this)
 #define SUBRESOURCELOADER_RELEASE_LOG_ERROR(fmt, ...) UNUSED_VARIABLE(this)

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -64,8 +64,8 @@
 #endif
 
 #undef CACHEDRESOURCE_RELEASE_LOG
-#define PAGE_ID(frame) (frame.pageID().value_or(PageIdentifier()).toUInt64())
-#define FRAME_ID(frame) (frame.frameID().value_or(FrameIdentifier()).toUInt64())
+#define PAGE_ID(frame) (valueOrDefault(frame.pageID()).toUInt64())
+#define FRAME_ID(frame) (valueOrDefault(frame.frameID()).toUInt64())
 #define CACHEDRESOURCE_RELEASE_LOG(fmt, ...) RELEASE_LOG(Network, "%p - CachedResource::" fmt, this, ##__VA_ARGS__)
 #define CACHEDRESOURCE_RELEASE_LOG_WITH_FRAME(fmt, frame, ...) RELEASE_LOG(Network, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 "] CachedResource::" fmt, this, PAGE_ID(frame), FRAME_ID(frame), ##__VA_ARGS__)
 

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (287730 => 287731)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -96,8 +96,8 @@
 #endif
 
 #undef CACHEDRESOURCELOADER_RELEASE_LOG
-#define PAGE_ID(frame) (frame.pageID().value_or(PageIdentifier()).toUInt64())
-#define FRAME_ID(frame) (frame.frameID().value_or(FrameIdentifier()).toUInt64())
+#define PAGE_ID(frame) (valueOrDefault(frame.pageID()).toUInt64())
+#define FRAME_ID(frame) (valueOrDefault(frame.frameID()).toUInt64())
 #define CACHEDRESOURCELOADER_RELEASE_LOG(fmt, ...) RELEASE_LOG(Network, "%p - CachedResourceLoader::" fmt, this, ##__VA_ARGS__)
 #define CACHEDRESOURCELOADER_RELEASE_LOG_WITH_FRAME(fmt, frame, ...) RELEASE_LOG(Network, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 "] CachedResourceLoader::" fmt, this, PAGE_ID(frame), FRAME_ID(frame), ##__VA_ARGS__)
 

Modified: trunk/Source/WebCore/page/EventHandler.cpp (287730 => 287731)


--- trunk/Source/WebCore/page/EventHandler.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -947,7 +947,7 @@
         return;
 
     constexpr OptionSet<HitTestRequest::Type> hitType {  HitTestRequest::Type::ReadOnly, HitTestRequest::Type::Active, HitTestRequest::Type::Move, HitTestRequest::Type::DisallowUserAgentShadowContent };
-    HitTestResult result(view->windowToContents(m_lastKnownMousePosition.value_or(IntPoint())));
+    HitTestResult result(view->windowToContents(valueOrDefault(m_lastKnownMousePosition)));
     document->hitTest(hitType, result);
     updateSelectionForMouseDrag(result);
 }
@@ -1307,7 +1307,7 @@
 
 IntPoint EventHandler::lastKnownMousePosition() const
 {
-    return m_lastKnownMousePosition.value_or(IntPoint());
+    return valueOrDefault(m_lastKnownMousePosition);
 }
 
 RefPtr<Frame> EventHandler::subframeForHitTestResult(const MouseEventWithHitTestResults& hitTestResult)
@@ -1960,7 +1960,7 @@
 #endif
 
     if (m_svgPan) {
-        downcast<SVGDocument>(*m_frame.document()).updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition.value_or(IntPoint())));
+        downcast<SVGDocument>(*m_frame.document()).updatePan(m_frame.view()->windowToContents(valueOrDefault(m_lastKnownMousePosition)));
         return true;
     }
 
@@ -2126,7 +2126,7 @@
 
     if (m_svgPan) {
         m_svgPan = false;
-        downcast<SVGDocument>(*m_frame.document()).updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition.value_or(IntPoint())));
+        downcast<SVGDocument>(*m_frame.document()).updatePan(m_frame.view()->windowToContents(valueOrDefault(m_lastKnownMousePosition)));
         return true;
     }
 
@@ -2864,7 +2864,7 @@
     
 IntPoint EventHandler::targetPositionInWindowForSelectionAutoscroll() const
 {
-    return m_lastKnownMousePosition.value_or(IntPoint());
+    return valueOrDefault(m_lastKnownMousePosition);
 }
     
 #endif // !PLATFORM(IOS_FAMILY)
@@ -3391,7 +3391,7 @@
     if (!view)
         return;
 
-    if (!quad.containsPoint(view->windowToContents(m_lastKnownMousePosition.value_or(IntPoint()))))
+    if (!quad.containsPoint(view->windowToContents(valueOrDefault(m_lastKnownMousePosition))))
         return;
 
     dispatchFakeMouseMoveEventSoon();
@@ -3420,7 +3420,7 @@
     bool altKey;
     bool metaKey;
     PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
-    PlatformMouseEvent fakeMouseMoveEvent(m_lastKnownMousePosition.value_or(IntPoint()), m_lastKnownMouseGlobalPosition, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), 0, NoTap);
+    PlatformMouseEvent fakeMouseMoveEvent(valueOrDefault(m_lastKnownMousePosition), m_lastKnownMouseGlobalPosition, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), 0, NoTap);
     mouseMoved(fakeMouseMoveEvent);
 }
 #endif // !ENABLE(IOS_TOUCH_EVENTS)
@@ -3446,7 +3446,7 @@
 
     if (RefPtr document = m_frame.document()) {
         if (RefPtr view = m_frame.view()) {
-            HitTestResult result(view->windowToContents(m_lastKnownMousePosition.value_or(IntPoint())));
+            HitTestResult result(view->windowToContents(valueOrDefault(m_lastKnownMousePosition)));
             constexpr OptionSet<HitTestRequest::Type> hitType { HitTestRequest::Type::Move, HitTestRequest::Type::DisallowUserAgentShadowContent };
             document->hitTest(hitType, result);
             document->updateHoverActiveState(hitType, result.targetElement());

Modified: trunk/Source/WebCore/page/FrameView.cpp (287730 => 287731)


--- trunk/Source/WebCore/page/FrameView.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/page/FrameView.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -140,8 +140,8 @@
 #include "LayoutContext.h"
 #endif
 
-#define PAGE_ID frame().pageID().value_or(PageIdentifier()).toUInt64()
-#define FRAME_ID frame().frameID().value_or(FrameIdentifier()).toUInt64()
+#define PAGE_ID valueOrDefault(frame().pageID()).toUInt64()
+#define FRAME_ID valueOrDefault(frame().frameID()).toUInt64()
 #define FRAMEVIEW_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, "%p - [pageID=%" PRIu64 ", frameID=%" PRIu64 ", main=%d] FrameView::" fmt, this, PAGE_ID, FRAME_ID, frame().isMainFrame(), ##__VA_ARGS__)
 
 namespace WebCore {
@@ -1716,7 +1716,7 @@
     if (oldRect.height() != layoutViewportRect().height())
         layoutTriggering = TriggerLayoutOrNot::Yes;
 
-    LOG_WITH_STREAM(Scrolling, stream << "\nFrameView " << this << " setLayoutViewportOverrideRect() - changing override layout viewport from " << oldRect << " to " << m_layoutViewportOverrideRect.value_or(LayoutRect()) << " layoutTriggering " << (layoutTriggering == TriggerLayoutOrNot::Yes ? "yes" : "no"));
+    LOG_WITH_STREAM(Scrolling, stream << "\nFrameView " << this << " setLayoutViewportOverrideRect() - changing override layout viewport from " << oldRect << " to " << valueOrDefault(m_layoutViewportOverrideRect) << " layoutTriggering " << (layoutTriggering == TriggerLayoutOrNot::Yes ? "yes" : "no"));
 
     if (oldRect != layoutViewportRect() && layoutTriggering == TriggerLayoutOrNot::Yes)
         setViewportConstrainedObjectsNeedLayout();

Modified: trunk/Source/WebCore/page/Page.cpp (287730 => 287731)


--- trunk/Source/WebCore/page/Page.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/page/Page.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -2666,7 +2666,7 @@
 
 Color Page::sampledPageTopColor() const
 {
-    return m_sampledPageTopColor.value_or(Color());
+    return valueOrDefault(m_sampledPageTopColor);
 }
 
 void Page::setUnderPageBackgroundColorOverride(Color&& underPageBackgroundColorOverride)

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (287730 => 287731)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1049,10 +1049,10 @@
 {
     Page* page = m_frame.page();
     if (!page)
-        return m_lastKnownMousePosition.value_or(IntPoint());
+        return valueOrDefault(m_lastKnownMousePosition);
 
     auto frame = toUserSpaceForPrimaryScreen(screenRectForDisplay(page->chrome().displayID()));
-    return m_lastKnownMousePosition.value_or(IntPoint()) + autoscrollAdjustmentFactorForScreenBoundaries(m_lastKnownMouseGlobalPosition, frame);
+    return valueOrDefault(m_lastKnownMousePosition) + autoscrollAdjustmentFactorForScreenBoundaries(m_lastKnownMouseGlobalPosition, frame);
 }
 
 }

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeLatchingController.cpp (287730 => 287731)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeLatchingController.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeLatchingController.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -112,7 +112,7 @@
         if (!wheelEvent.isGestureContinuation())
             return false;
 
-        if (m_processingStepsForCurrentGesture.value_or(OptionSet<WheelEventProcessingSteps> { }).contains(WheelEventProcessingSteps::MainThreadForScrolling) && processingSteps.contains(WheelEventProcessingSteps::ScrollingThread))
+        if (valueOrDefault(m_processingStepsForCurrentGesture).contains(WheelEventProcessingSteps::MainThreadForScrolling) && processingSteps.contains(WheelEventProcessingSteps::ScrollingThread))
             return true;
 
         return false;

Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp (287730 => 287731)


--- trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -404,7 +404,7 @@
     if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {
         FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
         transformedPolygon.move(m_offset);
-        layerRect = transform.inverse().value_or(AffineTransform()).mapQuad(transformedPolygon).boundingBox();
+        layerRect = valueOrDefault(transform.inverse()).mapQuad(transformedPolygon).boundingBox();
     } else {
         layerRect = shadowedRect;
         layerRect.move(m_offset);

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (287730 => 287731)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1007,7 +1007,7 @@
     if (!m_videoTransform)
         m_videoTransform = videoTransformationMatrix(*m_imagePainter.mediaSample);
     AffineTransform videoTransform = *m_videoTransform;
-    FloatRect transformedDestRect = videoTransform.inverse().value_or(AffineTransform()).mapRect(destRect);
+    FloatRect transformedDestRect = valueOrDefault(videoTransform.inverse()).mapRect(destRect);
     context.concatCTM(videoTransform);
     context.drawNativeImage(*image, imageRect.size(), transformedDestRect, imageRect);
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (287730 => 287731)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1268,7 +1268,7 @@
 
 FloatSize SourceBufferPrivateAVFObjC::naturalSize()
 {
-    return m_cachedSize.value_or(FloatSize());
+    return valueOrDefault(m_cachedSize);
 }
 
 void SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples(uint64_t trackID)

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (287730 => 287731)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1666,7 +1666,7 @@
     if (auto extent = animationExtent()) {
         // Adjust the animation extent to match the current animation position.
         auto animatingTransformWithAnchorPoint = transformByApplyingAnchorPoint(rects.animatingTransform);
-        bounds = animatingTransformWithAnchorPoint.inverse().value_or(TransformationMatrix()).mapRect(*extent);
+        bounds = valueOrDefault(animatingTransformWithAnchorPoint.inverse()).mapRect(*extent);
     }
 
     // FIXME: we need to take reflections into account when determining whether this layer intersects the coverage rect.

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp (287730 => 287731)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -169,7 +169,7 @@
     if (m_direction == ApplyTransformDirection)
         return m_accumulatedTransform->mapPoint(point);
 
-    return m_accumulatedTransform->inverse().value_or(TransformationMatrix()).projectPoint(point, wasClamped);
+    return valueOrDefault(m_accumulatedTransform->inverse()).projectPoint(point, wasClamped);
 }
 
 FloatQuad TransformState::mappedQuad(bool* wasClamped) const
@@ -219,7 +219,7 @@
         return;
     }
 
-    quad = m_accumulatedTransform->inverse().value_or(TransformationMatrix()).projectQuad(quad, wasClamped);
+    quad = valueOrDefault(m_accumulatedTransform->inverse()).projectQuad(quad, wasClamped);
 }
 
 void TransformState::flattenWithTransform(const TransformationMatrix& t, bool* wasClamped)
@@ -233,7 +233,7 @@
                 m_lastPlanarSecondaryQuad = t.mapQuad(*m_lastPlanarSecondaryQuad);
         }
     } else {
-        TransformationMatrix inverseTransform = t.inverse().value_or(TransformationMatrix());
+        TransformationMatrix inverseTransform = valueOrDefault(t.inverse());
         if (m_mapPoint)
             m_lastPlanarPoint = inverseTransform.projectPoint(m_lastPlanarPoint);
         if (m_mapQuad) {

Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp (287730 => 287731)


--- trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -628,7 +628,7 @@
 
 SystemPreviewInfo ResourceRequestBase::systemPreviewInfo() const
 {
-    return m_systemPreviewInfo.value_or(SystemPreviewInfo { });
+    return valueOrDefault(m_systemPreviewInfo);
 }
 
 void ResourceRequestBase::setSystemPreviewInfo(const SystemPreviewInfo& info)

Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (287730 => 287731)


--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -192,7 +192,7 @@
     ASSERT(response.tainting() == Tainting::Cors);
     filteredResponse.setType(Type::Cors);
 
-    auto accessControlExposeHeaderSet = parseAccessControlAllowList<ASCIICaseInsensitiveHash>(response.httpHeaderField(HTTPHeaderName::AccessControlExposeHeaders)).value_or(HashSet<String, ASCIICaseInsensitiveHash> { });
+    auto accessControlExposeHeaderSet = valueOrDefault(parseAccessControlAllowList<ASCIICaseInsensitiveHash>(response.httpHeaderField(HTTPHeaderName::AccessControlExposeHeaders)));
     if (performCheck == PerformExposeAllHeadersCheck::Yes && accessControlExposeHeaderSet.contains("*"))
         return filteredResponse;
 
@@ -458,7 +458,7 @@
     case ResourceResponse::Tainting::Basic:
         break;
     case ResourceResponse::Tainting::Cors: {
-        auto corsSafeHeaderSet = parseAccessControlAllowList<ASCIICaseInsensitiveHash>(httpHeaderField(HTTPHeaderName::AccessControlExposeHeaders)).value_or(HashSet<String, ASCIICaseInsensitiveHash> { });
+        auto corsSafeHeaderSet = valueOrDefault(parseAccessControlAllowList<ASCIICaseInsensitiveHash>(httpHeaderField(HTTPHeaderName::AccessControlExposeHeaders)));
         if (corsSafeHeaderSet.contains("*"_str))
             return;
 

Modified: trunk/Source/WebCore/rendering/PaintInfo.h (287730 => 287731)


--- trunk/Source/WebCore/rendering/PaintInfo.h	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/PaintInfo.h	2022-01-07 00:18:59 UTC (rev 287731)
@@ -116,7 +116,7 @@
         if (rect.isInfinite())
             return;
 
-        FloatRect tranformedRect(localToAncestorTransform.inverse().value_or(AffineTransform()).mapRect(rect));
+        FloatRect tranformedRect(valueOrDefault(localToAncestorTransform.inverse()).mapRect(rect));
         rect.setLocation(LayoutPoint(tranformedRect.location()));
         rect.setSize(LayoutSize(tranformedRect.size()));
     }

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -349,7 +349,7 @@
     // https://drafts.csswg.org/css-grid/#grid-item-sizing
     if (!style().left().isAuto() || !style().right().isAuto()) {
         LayoutUnit availableWidth = hasOverridingContainingBlockContentWidth()
-            ? overridingContainingBlockContentWidth().value_or(LayoutUnit()) : containingBlock()->availableWidth();
+            ? valueOrDefault(overridingContainingBlockContentWidth()) : containingBlock()->availableWidth();
         if (!style().left().isAuto()) {
             if (!style().right().isAuto() && !containingBlock()->style().isLeftToRightDirection())
                 offset.setWidth(-valueForLength(style().right(), !style().right().isFixed() ? availableWidth : 0_lu));

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -494,7 +494,7 @@
         if (maxSize.isSpecified()) {
             if (maxSize.isPercentOrCalculated())
                 containingBlockAvailableSize = isRowAxis ? containingBlockLogicalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
-            LayoutUnit maxSizeValue = valueForLength(maxSize, containingBlockAvailableSize.value_or(LayoutUnit()));
+            LayoutUnit maxSizeValue = valueForLength(maxSize, valueOrDefault(containingBlockAvailableSize));
             availableMaxSize = isRowAxis ? adjustContentBoxLogicalWidthForBoxSizing(maxSizeValue, maxSize.type()) : adjustContentBoxLogicalHeightForBoxSizing(maxSizeValue);
         }
 
@@ -509,7 +509,7 @@
         if (minSize.isSpecified()) {
             if (!containingBlockAvailableSize && minSize.isPercentOrCalculated())
                 containingBlockAvailableSize = isRowAxis ? containingBlockLogicalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
-            LayoutUnit minSizeValue = valueForLength(minSize, containingBlockAvailableSize.value_or(LayoutUnit()));
+            LayoutUnit minSizeValue = valueForLength(minSize, valueOrDefault(containingBlockAvailableSize));
             availableMinSize = isRowAxis ? adjustContentBoxLogicalWidthForBoxSizing(minSizeValue, minSize.type()) : adjustContentBoxLogicalHeightForBoxSizing(minSizeValue);
         } else if (shouldComputeMinSizeFromAspectRatio) {
             auto [logicalMinWidth, logicalMaxWidth] = computeMinMaxLogicalWidthFromAspectRatio();
@@ -518,7 +518,7 @@
         if (!maxSize.isSpecified())
             needsToFulfillMinimumSize = true;
 
-        availableSize = std::max(availableMinSize.value_or(LayoutUnit()), availableMaxSize.value_or(LayoutUnit()));
+        availableSize = std::max(valueOrDefault(availableMinSize), valueOrDefault(availableMaxSize));
     }
 
     LayoutUnit autoRepeatTracksSize;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1010,7 +1010,7 @@
                 } else if (shouldRepaintAfterLayout()) {
                     // FIXME: We will convert this to just take the old and new RepaintLayoutRects once
                     // we change other callers to use RepaintLayoutRects.
-                    auto resolvedOldRects = oldRects.value_or(LayerRepaintRects { });
+                    auto resolvedOldRects = valueOrDefault(oldRects);
                     renderer().repaintAfterLayoutIfNeeded(repaintContainer, resolvedOldRects.clippedOverflowRect, resolvedOldRects.outlineBoundsRect,
                         &newRects->clippedOverflowRect, &newRects->outlineBoundsRect);
                 }
@@ -3493,7 +3493,7 @@
     LayoutSize adjustedSubpixelOffset = offsetForThisLayer - LayoutSize(devicePixelSnappedOffsetForThisLayer);
     LayerPaintingInfo transformedPaintingInfo(paintingInfo);
     transformedPaintingInfo.rootLayer = this;
-    transformedPaintingInfo.paintDirtyRect = LayoutRect(encloseRectToDevicePixels(transform.inverse().value_or(AffineTransform()).mapRect(paintingInfo.paintDirtyRect), deviceScaleFactor));
+    transformedPaintingInfo.paintDirtyRect = LayoutRect(encloseRectToDevicePixels(valueOrDefault(transform.inverse()).mapRect(paintingInfo.paintDirtyRect), deviceScaleFactor));
     transformedPaintingInfo.subpixelOffset = adjustedSubpixelOffset;
     paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags);
 

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -179,7 +179,7 @@
     if (!needsLayout())
         return;
 
-    LayoutStateMaintainer statePusher(*this, { }, false, m_pageLogicalSize.value_or(LayoutSize()).height(), m_pageLogicalHeightChanged);
+    LayoutStateMaintainer statePusher(*this, { }, false, valueOrDefault(m_pageLogicalSize).height(), m_pageLogicalHeightChanged);
 
     m_pageLogicalHeightChanged = false;
 

Modified: trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -429,7 +429,7 @@
     // Test SVG content if the point is in our content box or it is inside the visualOverflowRect and the overflow is visible.
     // FIXME: This should be an intersection when rect-based hit tests are supported by nodeAtFloatPoint.
     if (contentBoxRect().contains(pointInBorderBox) || (!shouldApplyViewportClip() && visualOverflowRect().contains(pointInParent))) {
-        FloatPoint localPoint = localToParentTransform().inverse().value_or(AffineTransform()).mapPoint(FloatPoint(pointInParent));
+        FloatPoint localPoint = valueOrDefault(localToParentTransform().inverse()).mapPoint(FloatPoint(pointInParent));
 
         for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
             // FIXME: nodeAtFloatPoint() doesn't handle rect-based hit tests yet.

Modified: trunk/Source/WebCore/rendering/svg/LegacyRenderSVGShape.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/LegacyRenderSVGShape.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/LegacyRenderSVGShape.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -347,7 +347,7 @@
     if (hitTestAction != HitTestForeground)
         return false;
 
-    FloatPoint localPoint = m_localTransform.inverse().value_or(AffineTransform()).mapPoint(pointInParent);
+    FloatPoint localPoint = valueOrDefault(m_localTransform.inverse()).mapPoint(pointInParent);
 
     if (!SVGRenderSupport::pointInClippingArea(*this, localPoint))
         return false;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -161,7 +161,7 @@
     if (!pointIsInsideViewportClip(pointInParent))
         return false;
 
-    FloatPoint localPoint = localToParentTransform().inverse().value_or(AffineTransform()).mapPoint(pointInParent);
+    FloatPoint localPoint = valueOrDefault(localToParentTransform().inverse()).mapPoint(pointInParent);
 
     if (!SVGRenderSupport::pointInClippingArea(*this, localPoint))
         return false;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -169,7 +169,7 @@
     if (hitTestAction != HitTestForeground)
         return false;
 
-    FloatPoint localPoint = localTransform().inverse().value_or(AffineTransform()).mapPoint(pointInParent);
+    FloatPoint localPoint = valueOrDefault(localTransform().inverse()).mapPoint(pointInParent);
 
     // Early exit if local point is not contained in clipped viewport area
     if (SVGRenderSupport::isOverflowHidden(*this) && !m_viewport.contains(localPoint))

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -219,7 +219,7 @@
     PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_IMAGE_HITTESTING, request, style().pointerEvents());
     bool isVisible = (style().visibility() == Visibility::Visible);
     if (isVisible || !hitRules.requireVisible) {
-        FloatPoint localPoint = localToParentTransform().inverse().value_or(AffineTransform()).mapPoint(pointInParent);
+        FloatPoint localPoint = valueOrDefault(localToParentTransform().inverse()).mapPoint(pointInParent);
             
         if (!SVGRenderSupport::pointInClippingArea(*this, localPoint))
             return false;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -285,10 +285,10 @@
         AffineTransform transform;
         transform.translate(objectBoundingBox.location());
         transform.scale(objectBoundingBox.size());
-        point = transform.inverse().value_or(AffineTransform()).mapPoint(point);
+        point = valueOrDefault(transform.inverse()).mapPoint(point);
     }
 
-    point = clipPathElement().animatedLocalTransform().inverse().value_or(AffineTransform()).mapPoint(point);
+    point = valueOrDefault(clipPathElement().animatedLocalTransform().inverse()).mapPoint(point);
 
     for (Node* childNode = clipPathElement().firstChild(); childNode; childNode = childNode->nextSibling()) {
         RenderObject* renderer = childNode->renderer();

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -418,7 +418,7 @@
     if (style().visibility() != Visibility::Visible && !enclosingLayer()->hasVisibleContent())
         return LayoutRect();
 
-    auto repaintRect = LayoutRect(m_viewBoxTransform.inverse().value_or(AffineTransform()).mapRect(borderBoxRect()));
+    auto repaintRect = LayoutRect(valueOrDefault(m_viewBoxTransform.inverse()).mapRect(borderBoxRect()));
     return computeRect(repaintRect, repaintContainer, context);
 }
 
@@ -628,7 +628,7 @@
 
 void RenderSVGRoot::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
 {
-    auto localRect = LayoutRect(m_supplementalLocalToParentTransform.inverse().value_or(AffineTransform()).mapRect(borderBoxRect()));
+    auto localRect = LayoutRect(valueOrDefault(m_supplementalLocalToParentTransform.inverse()).mapRect(borderBoxRect()));
     rects.append(snappedIntRect(accumulatedOffset, localRect.size()));
 }
 
@@ -638,7 +638,7 @@
     if (fragmentedFlow && fragmentedFlow->absoluteQuadsForBox(quads, wasFixed, this))
         return;
 
-    auto localRect = FloatRect(m_supplementalLocalToParentTransform.inverse().value_or(AffineTransform()).mapRect(borderBoxRect()));
+    auto localRect = FloatRect(valueOrDefault(m_supplementalLocalToParentTransform.inverse()).mapRect(borderBoxRect()));
     quads.append(localToAbsoluteQuad(localRect, UseTransforms, wasFixed));
 }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -409,7 +409,7 @@
     if (isVisible || !hitRules.requireVisible) {
         if ((hitRules.canHitStroke && (style().svgStyle().hasStroke() || !hitRules.requireStroke))
             || (hitRules.canHitFill && (style().svgStyle().hasFill() || !hitRules.requireFill))) {
-            FloatPoint localPoint = localToParentTransform().inverse().value_or(AffineTransform()).mapPoint(pointInParent);
+            FloatPoint localPoint = valueOrDefault(localToParentTransform().inverse()).mapPoint(pointInParent);
 
             if (!SVGRenderSupport::pointInClippingArea(*this, localPoint))
                 return false;       

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -421,7 +421,7 @@
         referenceBox = localToParentTransform.mapRect(referenceBox);
 
         auto path = clipPath.pathForReferenceRect(referenceBox);
-        path.transform(localToParentTransform.inverse().value_or(AffineTransform()));
+        path.transform(valueOrDefault(localToParentTransform.inverse()));
 
         context.clipPath(path, clipPath.windRule());
     }

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (287730 => 287731)


--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -307,7 +307,7 @@
 
     // The mask image has been created in the absolute coordinate space, as the image should not be scaled.
     // So the actual masking process has to be done in the absolute coordinate space as well.
-    context.concatCTM(absoluteTransform.inverse().value_or(AffineTransform()));
+    context.concatCTM(valueOrDefault(absoluteTransform.inverse()));
     context.clipToImageBuffer(*imageBuffer, absoluteTargetRect);
     context.concatCTM(absoluteTransform);
 

Modified: trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp (287730 => 287731)


--- trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -161,7 +161,7 @@
 
 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
 {
-    m_toPointAtEndOfDuration = parsePoint(toAtEndOfDurationString).value_or(FloatPoint { });
+    m_toPointAtEndOfDuration = valueOrDefault(parsePoint(toAtEndOfDurationString));
     return true;
 }
 
@@ -168,8 +168,8 @@
 bool SVGAnimateMotionElement::calculateFromAndToValues(const String& fromString, const String& toString)
 {
     m_toPointAtEndOfDuration = std::nullopt;
-    m_fromPoint = parsePoint(fromString).value_or(FloatPoint { });
-    m_toPoint = parsePoint(toString).value_or(FloatPoint { });
+    m_fromPoint = valueOrDefault(parsePoint(fromString));
+    m_toPoint = valueOrDefault(parsePoint(toString));
     return true;
 }
     
@@ -178,8 +178,8 @@
     m_toPointAtEndOfDuration = std::nullopt;
     if (animationMode() == AnimationMode::By && !isAdditive())
         return false;
-    m_fromPoint = parsePoint(fromString).value_or(FloatPoint { });
-    auto byPoint = parsePoint(byString).value_or(FloatPoint { });
+    m_fromPoint = valueOrDefault(parsePoint(fromString));
+    auto byPoint = valueOrDefault(parsePoint(byString));
     m_toPoint = FloatPoint(m_fromPoint.x() + byPoint.x(), m_fromPoint.y() + byPoint.y());
     return true;
 }

Modified: trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp (287730 => 287731)


--- trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1292,7 +1292,7 @@
     if (glyphBoundingBox)
         m_minRightSideBearing = std::min(m_minRightSideBearing, horizontalAdvance - glyphBoundingBox.value().maxX());
 
-    m_glyphs.append(GlyphData(WTFMove(path), glyphElement, horizontalAdvance, verticalAdvance, glyphBoundingBox.value_or(FloatRect()), codepoints));
+    m_glyphs.append(GlyphData(WTFMove(path), glyphElement, horizontalAdvance, verticalAdvance, valueOrDefault(glyphBoundingBox), codepoints));
 }
 
 void SVGToOTFFontConverter::appendLigatureGlyphs()
@@ -1416,7 +1416,7 @@
             processGlyphElement(glyphElement, &glyphElement, defaultHorizontalAdvance, defaultVerticalAdvance, unicodeAttribute, boundingBox);
     }
 
-    m_boundingBox = boundingBox.value_or(FloatRect());
+    m_boundingBox = valueOrDefault(boundingBox);
 
     appendLigatureGlyphs();
 

Modified: trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h (287730 => 287731)


--- trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h	2022-01-07 00:18:59 UTC (rev 287731)
@@ -104,7 +104,7 @@
     static std::pair<float, float> initialValue() { return { }; }
     static std::pair<float, float> fromString(const String& string)
     {
-        return parseNumberOptionalNumber(string).value_or(std::pair<float, float> { });
+        return valueOrDefault(parseNumberOptionalNumber(string));
     }
     static std::optional<std::pair<float, float>> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); }
     static String toString(std::pair<float, float>) { ASSERT_NOT_REACHED(); return emptyString(); }
@@ -115,7 +115,7 @@
     static FloatPoint initialValue() { return FloatPoint(); }
     static FloatPoint fromString(const String& string)
     {
-        return parsePoint(string).value_or(FloatPoint { });
+        return valueOrDefault(parsePoint(string));
     }
     static std::optional<FloatPoint> parse(const QualifiedName&, const String& string)
     {
@@ -132,7 +132,7 @@
     static FloatRect initialValue() { return FloatRect(); }
     static FloatRect fromString(const String& string)
     {
-        return parseRect(string).value_or(FloatRect { });
+        return valueOrDefault(parseRect(string));
     }
     static std::optional<FloatRect> parse(const QualifiedName&, const String& string)
     {

Modified: trunk/Source/WebCore/testing/Internals.cpp (287730 => 287731)


--- trunk/Source/WebCore/testing/Internals.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/testing/Internals.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -2794,13 +2794,13 @@
 uint64_t Internals::frameIdentifier(const Document& document) const
 {
     if (auto* page = document.page())
-        return page->mainFrame().loader().frameID().value_or(FrameIdentifier { }).toUInt64();
+        return valueOrDefault(page->mainFrame().loader().frameID()).toUInt64();
     return 0;
 }
 
 uint64_t Internals::pageIdentifier(const Document& document) const
 {
-    return document.pageID().value_or(PageIdentifier { }).toUInt64();
+    return valueOrDefault(document.pageID()).toUInt64();
 }
 
 bool Internals::isAnyWorkletGlobalScopeAlive() const

Modified: trunk/Source/WebCore/workers/service/server/SWScriptStorage.cpp (287730 => 287731)


--- trunk/Source/WebCore/workers/service/server/SWScriptStorage.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebCore/workers/service/server/SWScriptStorage.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -44,7 +44,7 @@
 
 SWScriptStorage::SWScriptStorage(const String& directory)
     : m_directory(directory)
-    , m_salt(FileSystem::readOrMakeSalt(saltPath()).value_or(FileSystem::Salt()))
+    , m_salt(valueOrDefault(FileSystem::readOrMakeSalt(saltPath())))
 {
     ASSERT(!isMainThread());
 }

Modified: trunk/Source/WebKit/ChangeLog (287730 => 287731)


--- trunk/Source/WebKit/ChangeLog	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/ChangeLog	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1,3 +1,44 @@
+2022-01-06  Wenson Hsieh  <[email protected]>
+
+        Add a helper function that returns the value of a std::optional<T> or constructs T if needed
+        https://bugs.webkit.org/show_bug.cgi?id=234865
+
+        Reviewed by Darin Adler.
+
+        Use `valueOrDefault` where appropriate. See WTF/ChangeLog for more details.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad):
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::ensureSWServer):
+        * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
+        (WebKit::NetworkCache::fileTimes):
+        * NetworkProcess/storage/NetworkStorageManager.cpp:
+        (WebKit::NetworkStorageManager::NetworkStorageManager):
+        * UIProcess/Automation/SimulatedInputDispatcher.cpp:
+        (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
+        * UIProcess/ProvisionalPageProxy.cpp:
+        (WebKit::ProvisionalPageProxy::loadRequest):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessProxy.h:
+        (WebKit::WebProcessProxy::registrableDomain const):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::parameters):
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::loadResource):
+        (WebKit::WebLoaderStrategy::scheduleLoad):
+        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::convertFromPDFViewToRootView const):
+        (WebKit::PDFPlugin::boundsOnScreen const):
+        (WebKit::PDFPlugin::geometryDidChange):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::runJavaScriptInFrameInScriptWorld):
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::VideoFullscreenManager::didEnterFullscreen):
+
 2022-01-06  Tim Horton  <[email protected]>
 
         Separate "linked-on-or-{before, after}-everything" override from the SDK version

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (287730 => 287731)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -497,7 +497,7 @@
 
 void NetworkConnectionToWebProcess::scheduleResourceLoad(NetworkResourceLoadParameters&& loadParameters, std::optional<NetworkResourceLoadIdentifier> existingLoaderToResume)
 {
-    CONNECTION_RELEASE_LOG(Loading, "scheduleResourceLoad: (parentPID=%d, pageProxyID=%" PRIu64 ", webPageID=%" PRIu64 ", frameID=%" PRIu64 ", resourceID=%" PRIu64 ", existingLoaderToResume=%" PRIu64 ")", loadParameters.parentPID, loadParameters.webPageProxyID.toUInt64(), loadParameters.webPageID.toUInt64(), loadParameters.webFrameID.toUInt64(), loadParameters.identifier.toUInt64(), existingLoaderToResume.value_or(NetworkResourceLoadIdentifier { }).toUInt64());
+    CONNECTION_RELEASE_LOG(Loading, "scheduleResourceLoad: (parentPID=%d, pageProxyID=%" PRIu64 ", webPageID=%" PRIu64 ", frameID=%" PRIu64 ", resourceID=%" PRIu64 ", existingLoaderToResume=%" PRIu64 ")", loadParameters.parentPID, loadParameters.webPageProxyID.toUInt64(), loadParameters.webPageID.toUInt64(), loadParameters.webFrameID.toUInt64(), loadParameters.identifier.toUInt64(), valueOrDefault(existingLoaderToResume).toUInt64());
 
 #if ENABLE(SERVICE_WORKER)
     if (auto* session = networkSession()) {

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (287730 => 287731)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -607,7 +607,7 @@
 SWServer& NetworkSession::ensureSWServer()
 {
     if (!m_swServer) {
-        auto info = m_serviceWorkerInfo.value_or(ServiceWorkerInfo { });
+        auto info = valueOrDefault(m_serviceWorkerInfo);
         auto path = info.databasePath;
         // There should already be a registered path for this PAL::SessionID.
         // If there's not, then where did this PAL::SessionID come from?

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp (287730 => 287731)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -84,7 +84,7 @@
 #elif OS(WINDOWS)
     auto createTime = FileSystem::fileCreationTime(path);
     auto modifyTime = FileSystem::fileModificationTime(path);
-    return { createTime.value_or(WallTime()), modifyTime.value_or(WallTime()) };
+    return { valueOrDefault(createTime), valueOrDefault(modifyTime) };
 #endif
 }
 

Modified: trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp (287730 => 287731)


--- trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -118,7 +118,7 @@
         m_customLocalStoragePath = customLocalStoragePath;
         if (!m_path.isEmpty()) {
             auto saltPath = FileSystem::pathByAppendingComponent(m_path, "salt");
-            m_salt = FileSystem::readOrMakeSalt(saltPath).value_or(FileSystem::Salt());
+            m_salt = valueOrDefault(FileSystem::readOrMakeSalt(saltPath));
         }
     });
 }

Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp (287730 => 287731)


--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -275,7 +275,7 @@
 #if !ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
         RELEASE_ASSERT_NOT_REACHED();
 #else
-        resolveLocation(a.location.value_or(WebCore::IntPoint()), b.location, b.origin.value_or(MouseMoveOrigin::Viewport), b.nodeHandle, [this, &a, &b, inputSource = inputSource.type, eventDispatchFinished = WTFMove(eventDispatchFinished)](std::optional<WebCore::IntPoint> location, std::optional<AutomationCommandError> error) mutable {
+        resolveLocation(valueOrDefault(a.location), b.location, b.origin.value_or(MouseMoveOrigin::Viewport), b.nodeHandle, [this, &a, &b, inputSource = inputSource.type, eventDispatchFinished = WTFMove(eventDispatchFinished)](std::optional<WebCore::IntPoint> location, std::optional<AutomationCommandError> error) mutable {
             if (error) {
                 eventDispatchFinished(error);
                 return;
@@ -316,7 +316,7 @@
 #if !ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
         RELEASE_ASSERT_NOT_REACHED();
 #else
-        resolveLocation(a.location.value_or(WebCore::IntPoint()), b.location, b.origin.value_or(MouseMoveOrigin::Viewport), b.nodeHandle, [this, &a, &b, eventDispatchFinished = WTFMove(eventDispatchFinished)](std::optional<WebCore::IntPoint> location, std::optional<AutomationCommandError> error) mutable {
+        resolveLocation(valueOrDefault(a.location), b.location, b.origin.value_or(MouseMoveOrigin::Viewport), b.nodeHandle, [this, &a, &b, eventDispatchFinished = WTFMove(eventDispatchFinished)](std::optional<WebCore::IntPoint> location, std::optional<AutomationCommandError> error) mutable {
             if (error) {
                 eventDispatchFinished(error);
                 return;
@@ -422,7 +422,7 @@
 #if !ENABLE(WEBDRIVER_WHEEL_INTERACTIONS)
         RELEASE_ASSERT_NOT_REACHED();
 #else
-        resolveLocation(a.location.value_or(WebCore::IntPoint()), b.location, b.origin.value_or(MouseMoveOrigin::Viewport), b.nodeHandle, [this, &a, &b, eventDispatchFinished = WTFMove(eventDispatchFinished)](std::optional<WebCore::IntPoint> location, std::optional<AutomationCommandError> error) mutable {
+        resolveLocation(valueOrDefault(a.location), b.location, b.origin.value_or(MouseMoveOrigin::Viewport), b.nodeHandle, [this, &a, &b, eventDispatchFinished = WTFMove(eventDispatchFinished)](std::optional<WebCore::IntPoint> location, std::optional<AutomationCommandError> error) mutable {
             if (error) {
                 eventDispatchFinished(error);
                 return;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (287730 => 287731)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2022-01-07 00:18:59 UTC (rev 287731)
@@ -177,7 +177,7 @@
                 if (![[NSFileManager defaultManager] fileExistsAtPath:filename])
                     return SandboxExtension::Handle { };
 
-                return SandboxExtension::createHandle(filename, SandboxExtension::Type::ReadOnly).value_or(SandboxExtension::Handle { });
+                return valueOrDefault(SandboxExtension::createHandle(filename, SandboxExtension::Type::ReadOnly));
             });
 #endif
         }

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (287730 => 287731)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -186,7 +186,7 @@
 
 void ProvisionalPageProxy::loadRequest(API::Navigation& navigation, WebCore::ResourceRequest&& request, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, std::optional<WebsitePoliciesData>&& websitePolicies, std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume)
 {
-    PROVISIONALPAGEPROXY_RELEASE_LOG(ProcessSwapping, "loadRequest: existingNetworkResourceLoadIdentifierToResume=%" PRIu64, existingNetworkResourceLoadIdentifierToResume.value_or(NetworkResourceLoadIdentifier { }).toUInt64());
+    PROVISIONALPAGEPROXY_RELEASE_LOG(ProcessSwapping, "loadRequest: existingNetworkResourceLoadIdentifierToResume=%" PRIu64, valueOrDefault(existingNetworkResourceLoadIdentifierToResume).toUInt64());
     ASSERT(shouldTreatAsContinuingLoad != WebCore::ShouldTreatAsContinuingLoad::No);
 
     // If this is a client-side redirect continuing in a new process, then the new process will overwrite the fromItem's URL. In this case,

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (287730 => 287731)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1492,7 +1492,7 @@
     void setAutoSizingShouldExpandToViewHeight(bool);
 
     void setViewportSizeForCSSViewportUnits(const WebCore::FloatSize&);
-    WebCore::FloatSize viewportSizeForCSSViewportUnits() const { return m_viewportSizeForCSSViewportUnits.value_or(WebCore::FloatSize()); }
+    WebCore::FloatSize viewportSizeForCSSViewportUnits() const { return valueOrDefault(m_viewportSizeForCSSViewportUnits); }
 
     void didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&&, NegotiatedLegacyTLS);
     void negotiatedLegacyTLS();

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (287730 => 287731)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2022-01-07 00:18:59 UTC (rev 287731)
@@ -154,7 +154,7 @@
     WebProcessPool& processPool() const;
 
     bool isMatchingRegistrableDomain(const WebCore::RegistrableDomain& domain) const { return m_registrableDomain ? *m_registrableDomain == domain : false; }
-    WebCore::RegistrableDomain registrableDomain() const { return m_registrableDomain.value_or(WebCore::RegistrableDomain { }); }
+    WebCore::RegistrableDomain registrableDomain() const { return valueOrDefault(m_registrableDomain); }
     const std::optional<WebCore::RegistrableDomain>& optionalRegistrableDomain() const { return m_registrableDomain; }
 
     enum class WillShutDown : bool { No, Yes };

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (287730 => 287731)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -1837,7 +1837,7 @@
     HashSet<WebCore::RegistrableDomain> appBoundDomains;
 #if ENABLE(APP_BOUND_DOMAINS)
     if (isAppBoundITPRelaxationEnabled)
-        appBoundDomains = appBoundDomainsIfInitialized().value_or(HashSet<WebCore::RegistrableDomain> { });
+        appBoundDomains = valueOrDefault(appBoundDomainsIfInitialized());
 #endif
     WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource;
     ResourceLoadStatisticsParameters resourceLoadStatisticsParameters = {

Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (287730 => 287731)


--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -116,7 +116,7 @@
         if (loader)
             scheduleLoad(*loader, resource.get(), referrerPolicy == ReferrerPolicy::NoReferrerWhenDowngrade);
         else
-            RELEASE_LOG(Network, "%p - [webPageID=%" PRIu64 ", frameID=%" PRIu64 "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader", this, frame->pageID().value_or(PageIdentifier()).toUInt64(), frame->frameID().value_or(FrameIdentifier()).toUInt64());
+            RELEASE_LOG(Network, "%p - [webPageID=%" PRIu64 ", frameID=%" PRIu64 "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader", this, valueOrDefault(frame->pageID()).toUInt64(), valueOrDefault(frame->frameID()).toUInt64());
         completionHandler(WTFMove(loader));
     });
 }
@@ -178,13 +178,13 @@
 
     WebResourceLoader::TrackingParameters trackingParameters;
     if (auto* webFrameLoaderClient = toWebFrameLoaderClient(frameLoaderClient))
-        trackingParameters.webPageProxyID = webFrameLoaderClient->webPageProxyID().value_or(WebPageProxyIdentifier { });
+        trackingParameters.webPageProxyID = valueOrDefault(webFrameLoaderClient->webPageProxyID());
 #if ENABLE(SERVICE_WORKER)
     else if (is<ServiceWorkerFrameLoaderClient>(frameLoaderClient))
         trackingParameters.webPageProxyID = downcast<ServiceWorkerFrameLoaderClient>(frameLoaderClient).webPageProxyID();
 #endif
-    trackingParameters.pageID = frameLoaderClient.pageID().value_or(PageIdentifier { });
-    trackingParameters.frameID = frameLoaderClient.frameID().value_or(FrameIdentifier { });
+    trackingParameters.pageID = valueOrDefault(frameLoaderClient.pageID());
+    trackingParameters.frameID = valueOrDefault(frameLoaderClient.frameID());
     trackingParameters.resourceID = identifier;
 
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
@@ -448,7 +448,7 @@
     std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume;
     if (loadParameters.isMainFrameNavigation)
         existingNetworkResourceLoadIdentifierToResume = std::exchange(m_existingNetworkResourceLoadIdentifierToResume, std::nullopt);
-    WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: Resource is being scheduled with the NetworkProcess (priority=%d, existingNetworkResourceLoadIdentifierToResume=%" PRIu64 ")", static_cast<int>(resourceLoader.request().priority()), existingNetworkResourceLoadIdentifierToResume.value_or(NetworkResourceLoadIdentifier { }).toUInt64());
+    WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: Resource is being scheduled with the NetworkProcess (priority=%d, existingNetworkResourceLoadIdentifierToResume=%" PRIu64 ")", static_cast<int>(resourceLoader.request().priority()), valueOrDefault(existingNetworkResourceLoadIdentifierToResume).toUInt64());
     if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ScheduleResourceLoad(loadParameters, existingNetworkResourceLoadIdentifierToResume), 0)) {
         WEBLOADERSTRATEGY_RELEASE_LOG_ERROR("scheduleLoad: Unable to schedule resource with the NetworkProcess (priority=%d)", static_cast<int>(resourceLoader.request().priority()));
         // We probably failed to schedule this load with the NetworkProcess because it had crashed.

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (287730 => 287731)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2022-01-07 00:18:59 UTC (rev 287731)
@@ -2048,13 +2048,13 @@
 IntPoint PDFPlugin::convertFromPDFViewToRootView(const IntPoint& point) const
 {
     IntPoint pointInPluginCoordinates(point.x(), size().height() - point.y());
-    return m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).mapPoint(pointInPluginCoordinates);
+    return valueOrDefault(m_rootViewToPluginTransform.inverse()).mapPoint(pointInPluginCoordinates);
 }
 
 IntRect PDFPlugin::convertFromPDFViewToRootView(const IntRect& rect) const
 {
     IntRect rectInPluginCoordinates(rect.x(), rect.y(), rect.width(), rect.height());
-    return m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).mapRect(rectInPluginCoordinates);
+    return valueOrDefault(m_rootViewToPluginTransform.inverse()).mapRect(rectInPluginCoordinates);
 }
 
 IntPoint PDFPlugin::convertFromRootViewToPDFView(const IntPoint& point) const
@@ -2087,7 +2087,7 @@
         return { };
 
     FloatRect bounds = FloatRect(FloatPoint(), size());
-    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).mapRect(bounds);
+    FloatRect rectInRootViewCoordinates = valueOrDefault(m_rootViewToPluginTransform.inverse()).mapRect(bounds);
     auto* page = m_frame->coreFrame()->page();
     if (!page)
         return { };
@@ -2114,7 +2114,7 @@
         return;
 
     m_size = pluginSize;
-    m_rootViewToPluginTransform = pluginToRootViewTransform.inverse().value_or(AffineTransform());
+    m_rootViewToPluginTransform = valueOrDefault(pluginToRootViewTransform.inverse());
     [m_pdfLayerController setFrameSize:pluginSize];
 
     [CATransaction begin];

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (287730 => 287731)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-01-07 00:18:59 UTC (rev 287731)
@@ -3767,7 +3767,7 @@
 
 void WebPage::runJavaScriptInFrameInScriptWorld(RunJavaScriptParameters&& parameters, std::optional<WebCore::FrameIdentifier> frameID, const std::pair<ContentWorldIdentifier, String>& worldData, CompletionHandler<void(const IPC::DataReference&, const std::optional<WebCore::ExceptionDetails>&)>&& completionHandler)
 {
-    WEBPAGE_RELEASE_LOG(Process, "runJavaScriptInFrameInScriptWorld: frameID=%" PRIu64, frameID.value_or(WebCore::FrameIdentifier { }).toUInt64());
+    WEBPAGE_RELEASE_LOG(Process, "runJavaScriptInFrameInScriptWorld: frameID=%" PRIu64, valueOrDefault(frameID).toUInt64());
     RefPtr webFrame = frameID ? WebProcess::singleton().webFrame(*frameID) : &mainWebFrame();
 
     if (auto* newWorld = m_userContentController->addContentWorld(worldData)) {

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (287730 => 287731)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2022-01-07 00:06:58 UTC (rev 287730)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2022-01-07 00:18:59 UTC (rev 287731)
@@ -481,7 +481,7 @@
     if (!videoElement)
         return;
 
-    videoElement->didEnterFullscreenOrPictureInPicture(size.value_or(WebCore::FloatSize()));
+    videoElement->didEnterFullscreenOrPictureInPicture(valueOrDefault(size));
 
     if (interface->targetIsFullscreen() || interface->fullscreenStandby())
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to