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

Changeset 278244 in webkit


Ignore:
Timestamp:
May 29, 2021, 3:08:56 PM (5 years ago)
Author:
Darin Adler
Message:

Clients of optional should use has_value instead of relying on hasValue macro
https://bugs.webkit.org/show_bug.cgi?id=226395

Reviewed by Chris Dumez.

Source/JavaScriptCore:

  • bytecompiler/NodesCodegen.cpp:

(JSC::RegExpNode::emitBytecode): Don't use hasValue.

Source/WebCore:

In some files we are touching, moved from Optional to std::optional, but doing
that consistently in files we are not otherwise modifying is out of scope here.

In some places, use has_value instead of hasValue. In others, improved further
by not using has_value explicitly when it's clearer to do so. Wasn't 100%
consistent about that, but did aim to cover 100% of the hasValue call sites.

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::create): Don't use hasValue.

  • Modules/webxr/WebXRFrame.cpp:

(WebCore::WebXRFrame::getViewerPose): Ditto.
(WebCore::WebXRFrame::getPose): Ditto.

  • Modules/webxr/WebXRGamepad.cpp:

(WebCore::WebXRGamepad::WebXRGamepad): Ditto.

  • Modules/webxr/WebXRInputSource.cpp:

(WebCore::WebXRInputSource::requiresInputSourceChange): Use has_value.

  • bindings/js/DOMPromiseProxy.h:

(WebCore::DOMPromiseProxy<IDLType>::isFulfilled const): Ditto.
(WebCore::DOMPromiseProxy<IDLUndefined>::isFulfilled const): Ditto.
(WebCore::DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled const): Ditto.

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneDeserializer::readTerminal): Ditto.

  • css/CSSFontFaceSet.cpp:

(WebCore::CSSFontFaceSet::addToFacesLookupTable): Removed unneeded double check
of optional value. !x and !x.has_value() check the same thing.
(WebCore::CSSFontFaceSet::remove): Ditto.
(WebCore::CSSFontFaceSet::fontFace): Simplified code with extra local variables
to use an idiom that does not use hasValue. Since using *, ->, or value() on an
optional already asserts, there is no need to explicitly assert in the caller.

  • css/CSSGradientValue.cpp:

(WebCore::GradientStop::isSpecified const): Use has_value.

  • css/CSSSegmentedFontFace.cpp:

(WebCore::CSSSegmentedFontFace::fontRanges): Removed unneeded calls to hasValue.

  • css/FontFace.cpp:

(WebCore::FontFace::family const): Use has_value.
(WebCore::FontFace::style const): Ditto.
(WebCore::FontFace::weight const): Ditto.
(WebCore::FontFace::stretch const): Ditto.
(WebCore::FontFace::unicodeRange const): Ditto.
(WebCore::FontFace::featureSettings const): Ditto.
(WebCore::FontFace::display const): Ditto.

  • css/parser/CSSSelectorParser.cpp:

(WebCore::consumeANPlusB): Ditto.

  • display/css/DisplayStyle.h: Ditto.
  • dom/DataTransferItemList.h: Ditto.
  • dom/Document.cpp:

(WebCore::Document::updateHighlightPositions): Ditto.

  • dom/EventTarget.cpp:

(WebCore::EventTarget::addEventListener): Ditto.

  • editing/AlternativeTextController.cpp:

(WebCore::AlternativeTextController::hasPendingCorrection const): Ditto.

  • editing/ApplyStyleCommand.cpp:

(WebCore::ApplyStyleCommand::applyInlineStyle): Don't call hasValue.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::captionDisplayMode): Ditto.

  • html/ImageBitmap.h: Ditto.
  • inspector/agents/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::setScreenSizeOverride): Use has_value.

  • layout/LayoutPhase.cpp:

(WebCore::Layout::PhaseScope::PhaseScope): Ditto.

  • layout/formattingContexts/inline/InlineContentBreaker.cpp:

(WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const): Ditto.

  • layout/formattingContexts/inline/InlineLine.h: Ditto.
  • loader/CrossOriginPreflightResultCache.cpp:

(WebCore::parseAccessControlMaxAge): Ditto.

  • page/EventHandler.cpp:

(WebCore::EventHandler::defaultWheelEventHandler): Ditto.

  • page/ios/ContentChangeObserver.cpp:

(WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope): Ditto.

  • page/scrolling/ScrollSnapOffsetsInfo.cpp:

(WebCore::closestSnapOffsetWithInfoAndAxis): Ditto.

  • platform/ScrollController.cpp:

(WebCore::ScrollController::adjustScrollDestination): Don't use hasValue.

  • platform/cocoa/SystemBattery.mm:

(WebCore::systemHasBattery): Use has_value.
(WebCore::systemHasAC): Use has_value.

  • platform/graphics/Gradient.h: Ditto.
  • platform/graphics/ImageSource.h: Ditto.
  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::wouldTaintOrigin const): Changed idiom to not use hasValue.

  • platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp:

(setGLContext): Do not use hasValue.

  • platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:

(WebCore::GStreamerRegistryScanner::ElementFactories::hasElementForMediaType const): Ditto.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::playbackPosition const): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::performTaskAtMediaTime): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::triggerRepaint): Ditto.

  • platform/graphics/gstreamer/eme/CDMProxyThunder.cpp:

(WebCore::CDMProxyThunder::getDecryptionSession const): Use has_value.

  • platform/graphics/gstreamer/eme/CDMThunder.cpp:

(WebCore::ParsedResponseMessage::hasType const): Use has_value.
(WebCore::CDMInstanceSessionThunder::cdmInstanceThunder const): Use
a pointer for the erturn value instead of Optional<&>. This hasn't
compiled since we switched to std::optional so I suspect this code is
not compiled by EWS or the buildbot.

  • platform/graphics/gstreamer/eme/CDMThunder.h: Updated to match above.
  • platform/graphics/gstreamer/mse/AppendPipeline.cpp:

(WebCore::AppendPipeline::parseDemuxerSrcPadCaps): Use value_or.
(WebCore::AppendPipeline::appsinkCapsChanged): Do not use has_value.

  • platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:

(WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected): Ditto.

  • platform/graphics/transforms/TransformState.h: Use has_value.
  • platform/ios/VideoFullscreenInterfaceAVKit.mm:

(WebCore::supportsPictureInPicture): Ditto.

  • platform/mac/NSScrollerImpDetails.mm:

(WebCore::ScrollerStyle::recommendedScrollerStyle): Ditto.

  • platform/network/ResourceRequestBase.cpp:

(WebCore::ResourceRequestBase::isSystemPreview const): Ditto.

  • platform/xr/openxr/OpenXRInputSource.cpp:

(PlatformXR::OpenXRInputSource::getInputSource const): Ditto.

  • rendering/EventRegion.h: Ditto.
  • rendering/GridTrackSizingAlgorithm.h: Remove unnecessary assertion, since

the * operator already does the assertion.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::canComputePercentageFlexBasis): Use has_value.

  • rendering/RenderListItem.cpp:

(WebCore::RenderListItem::setExplicitValue): Ditto.

  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::systemFocusRingColor): Ditto.

  • rendering/updating/RenderTreeBuilder.cpp:

(WebCore::RenderTreeBuilder::removeAnonymousWrappersForInlineChildrenIfNeeded): Ditto.

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::createSVGTransformFromMatrix): Changed idiom to not
call hasValue.

  • svg/SVGTransform.h: Ditto.
  • testing/WebFakeXRDevice.cpp:

(WebCore::WebFakeXRDevice::setViews): Ditto.

Source/WebDriver:

  • socket/SessionHostSocket.cpp:

(WebDriver::SessionHost::isConnected const): Use has_value.

Source/WebKit:

  • Platform/IPC/ArgumentCoders.h: Use std::optional; there was no hasValue

in here and I edited it by mistake, but we want to do this eventually.

  • Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: Removed using namespace WebCore.

(IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData): Use has_value.

  • Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm:

(WebKit::XPCServiceInitializerDelegate::getClientSDKVersion): Ditto.

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::decodeImage): Changed idiom to not call hasValue.
(IPC::ArgumentCoder<Ref<Font>>::decode): Ditto.

  • Shared/mac/MediaFormatReader/MediaFormatReader.cpp:

(WebKit::MediaFormatReader::finishParsing): Use has_value.
(WebKit::MediaFormatReader::copyProperty): Ditto.
(WebKit::MediaFormatReader::copyTrackArray): Ditto.

  • Shared/win/WebCoreArgumentCodersWin.cpp:

(IPC::ArgumentCoder<Ref<Font>>::decodePlatformData): Do not call hasValue.

  • UIProcess/API/Cocoa/WKWebViewConfiguration.mm:

(-[WKWebViewConfiguration encodeWithCoder:]): Changed idiom to not use hasValue.

  • UIProcess/API/glib/InputMethodFilter.cpp:

(WebKit::InputMethodFilter::setState): Use has_value.

  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::AutomationCommandError::toProtocolString): Changed idiom to not use hasValue.

  • UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:

(WebKit::WebPasteboardProxy::determineDataOwner const): Use has_value.

  • UIProcess/Inspector/socket/RemoteInspectorClient.cpp:

(WebKit::RemoteInspectorClient::sendWebInspectorEvent): Changed idiom to not use hasValue.

  • UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp:

(WebKit::UserMediaPermissionRequestManagerProxy::platformValidateUserMediaRequestConstraints): Ditto.

  • WebProcess/GPU/media/MediaSourcePrivateRemote.cpp:

(WebKit::MediaSourcePrivateRemote::addSourceBuffer): Use has_value.

  • WebProcess/WebPage/Cocoa/WebPageCocoa.mm:

(WebKit::WebPage::platformDidReceiveLoadParameters): Ditto.

  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::notifyPreferencesChanged): Changed idiom to not
call hasValue.

Source/WTF:

  • wtf/Hasher.h: Use has_value.
  • wtf/Optional.h: Remove hasValue macro. Not needed any more, but also a bit

dangerous because of how widespread the use of hasValue is for things other
than WTF::Optional.

Tools:

  • TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp: Use has_value.
  • TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp: Ditto.
  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp: Ditto.
  • TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:

(AudioRenderingWebViewTest::handleStart): Ditto.

  • WebKitTestRunner/GeolocationProviderMock.cpp:

(WTR::GeolocationProviderMock::setPosition): Ditto.

  • WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:

(-[TestRunnerWKWebView canPerformAction:withSender:]): Ditto.

Location:
trunk
Files:
85 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r278243 r278244  
     12021-05-28  Darin Adler  <darin@apple.com>
     2
     3        Clients of optional should use has_value instead of relying on hasValue macro
     4        https://bugs.webkit.org/show_bug.cgi?id=226395
     5
     6        Reviewed by Chris Dumez.
     7
     8        * bytecompiler/NodesCodegen.cpp:
     9        (JSC::RegExpNode::emitBytecode): Don't use hasValue.
     10
    1112021-05-29  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r278185 r278244  
    159159
    160160    auto flags = Yarr::parseFlags(m_flags.string());
    161     ASSERT(flags.hasValue());
     161    ASSERT(flags);
    162162    RegExp* regExp = RegExp::create(generator.vm(), m_pattern.string(), flags.value());
    163163    if (regExp->isValid())
  • trunk/Source/WTF/ChangeLog

    r278236 r278244  
     12021-05-28  Darin Adler  <darin@apple.com>
     2
     3        Clients of optional should use has_value instead of relying on hasValue macro
     4        https://bugs.webkit.org/show_bug.cgi?id=226395
     5
     6        Reviewed by Chris Dumez.
     7
     8        * wtf/Hasher.h: Use has_value.
     9
     10        * wtf/Optional.h: Remove hasValue macro. Not needed any more, but also a bit
     11        dangerous because of how widespread the use of hasValue is for things other
     12        than WTF::Optional.
     13
    1142021-05-28  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WTF/wtf/Hasher.h

    r275650 r278244  
    2121#pragma once
    2222
    23 #include <wtf/Optional.h>
     23#include <optional>
    2424#include <wtf/StdLibExtras.h>
    2525#include <wtf/URL.h>
     
    160160}
    161161
    162 template<typename T> void add(Hasher& hasher, const Optional<T>& optional)
     162template<typename T> void add(Hasher& hasher, const std::optional<T>& optional)
    163163{
    164     add(hasher, optional.hasValue());
    165     if (optional.hasValue())
     164    add(hasher, optional.has_value());
     165    if (optional.has_value())
    166166        add(hasher, optional.value());
    167167}
  • trunk/Source/WTF/wtf/Optional.h

    r278185 r278244  
    2727template<typename T> using Optional = std::optional<T>;
    2828
    29 // FIXME: We probably don't need this; it's only used in 5 places.
    3029template<typename OptionalType, class Callback> auto valueOrCompute(OptionalType optional, Callback callback) -> typename OptionalType::value_type
    3130{
     
    3736using WTF::Optional;
    3837using WTF::valueOrCompute;
    39 
    40 // FIXME: This macro is a workaround to allow us to use std::optional without a global replace; it can be removed after the global replace.
    41 #define hasValue has_value
  • trunk/Source/WebCore/ChangeLog

    r278239 r278244  
     12021-05-28  Darin Adler  <darin@apple.com>
     2
     3        Clients of optional should use has_value instead of relying on hasValue macro
     4        https://bugs.webkit.org/show_bug.cgi?id=226395
     5
     6        Reviewed by Chris Dumez.
     7
     8        In some files we are touching, moved from Optional to std::optional, but doing
     9        that consistently in files we are not otherwise modifying is out of scope here.
     10
     11        In some places, use has_value instead of hasValue. In others, improved further
     12        by not using has_value explicitly when it's clearer to do so. Wasn't 100%
     13        consistent about that, but did aim to cover 100% of the hasValue call sites.
     14
     15        * Modules/webaudio/AudioContext.cpp:
     16        (WebCore::AudioContext::create): Don't use hasValue.
     17        * Modules/webxr/WebXRFrame.cpp:
     18        (WebCore::WebXRFrame::getViewerPose): Ditto.
     19        (WebCore::WebXRFrame::getPose): Ditto.
     20        * Modules/webxr/WebXRGamepad.cpp:
     21        (WebCore::WebXRGamepad::WebXRGamepad): Ditto.
     22
     23        * Modules/webxr/WebXRInputSource.cpp:
     24        (WebCore::WebXRInputSource::requiresInputSourceChange): Use has_value.
     25        * bindings/js/DOMPromiseProxy.h:
     26        (WebCore::DOMPromiseProxy<IDLType>::isFulfilled const): Ditto.
     27        (WebCore::DOMPromiseProxy<IDLUndefined>::isFulfilled const): Ditto.
     28        (WebCore::DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled const): Ditto.
     29        * bindings/js/SerializedScriptValue.cpp:
     30        (WebCore::CloneDeserializer::readTerminal): Ditto.
     31
     32        * css/CSSFontFaceSet.cpp:
     33        (WebCore::CSSFontFaceSet::addToFacesLookupTable): Removed unneeded double check
     34        of optional value. !x and !x.has_value() check the same thing.
     35        (WebCore::CSSFontFaceSet::remove): Ditto.
     36        (WebCore::CSSFontFaceSet::fontFace): Simplified code with extra local variables
     37        to use an idiom that does not use hasValue. Since using *, ->, or value() on an
     38        optional already asserts, there is no need to explicitly assert in the caller.
     39
     40        * css/CSSGradientValue.cpp:
     41        (WebCore::GradientStop::isSpecified const): Use has_value.
     42
     43        * css/CSSSegmentedFontFace.cpp:
     44        (WebCore::CSSSegmentedFontFace::fontRanges): Removed unneeded calls to hasValue.
     45
     46        * css/FontFace.cpp:
     47        (WebCore::FontFace::family const): Use has_value.
     48        (WebCore::FontFace::style const): Ditto.
     49        (WebCore::FontFace::weight const): Ditto.
     50        (WebCore::FontFace::stretch const): Ditto.
     51        (WebCore::FontFace::unicodeRange const): Ditto.
     52        (WebCore::FontFace::featureSettings const): Ditto.
     53        (WebCore::FontFace::display const): Ditto.
     54        * css/parser/CSSSelectorParser.cpp:
     55        (WebCore::consumeANPlusB): Ditto.
     56        * display/css/DisplayStyle.h: Ditto.
     57        * dom/DataTransferItemList.h: Ditto.
     58        * dom/Document.cpp:
     59        (WebCore::Document::updateHighlightPositions): Ditto.
     60        * dom/EventTarget.cpp:
     61        (WebCore::EventTarget::addEventListener): Ditto.
     62        * editing/AlternativeTextController.cpp:
     63        (WebCore::AlternativeTextController::hasPendingCorrection const): Ditto.
     64
     65        * editing/ApplyStyleCommand.cpp:
     66        (WebCore::ApplyStyleCommand::applyInlineStyle): Don't call hasValue.
     67        * html/HTMLMediaElement.cpp:
     68        (WebCore::HTMLMediaElement::captionDisplayMode): Ditto.
     69        * html/ImageBitmap.h: Ditto.
     70
     71        * inspector/agents/InspectorPageAgent.cpp:
     72        (WebCore::InspectorPageAgent::setScreenSizeOverride): Use has_value.
     73        * layout/LayoutPhase.cpp:
     74        (WebCore::Layout::PhaseScope::PhaseScope): Ditto.
     75        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
     76        (WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const): Ditto.
     77        * layout/formattingContexts/inline/InlineLine.h: Ditto.
     78        * loader/CrossOriginPreflightResultCache.cpp:
     79        (WebCore::parseAccessControlMaxAge): Ditto.
     80        * page/EventHandler.cpp:
     81        (WebCore::EventHandler::defaultWheelEventHandler): Ditto.
     82        * page/ios/ContentChangeObserver.cpp:
     83        (WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope): Ditto.
     84        * page/scrolling/ScrollSnapOffsetsInfo.cpp:
     85        (WebCore::closestSnapOffsetWithInfoAndAxis): Ditto.
     86
     87        * platform/ScrollController.cpp:
     88        (WebCore::ScrollController::adjustScrollDestination): Don't use hasValue.
     89
     90        * platform/cocoa/SystemBattery.mm:
     91        (WebCore::systemHasBattery): Use has_value.
     92        (WebCore::systemHasAC): Use has_value.
     93        * platform/graphics/Gradient.h: Ditto.
     94        * platform/graphics/ImageSource.h: Ditto.
     95
     96        * platform/graphics/MediaPlayer.cpp:
     97        (WebCore::MediaPlayer::wouldTaintOrigin const): Changed idiom to not use hasValue.
     98
     99        * platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp:
     100        (setGLContext): Do not use hasValue.
     101        * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
     102        (WebCore::GStreamerRegistryScanner::ElementFactories::hasElementForMediaType const): Ditto.
     103        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     104        (WebCore::MediaPlayerPrivateGStreamer::playbackPosition const): Ditto.
     105        (WebCore::MediaPlayerPrivateGStreamer::performTaskAtMediaTime): Ditto.
     106        (WebCore::MediaPlayerPrivateGStreamer::triggerRepaint): Ditto.
     107
     108        * platform/graphics/gstreamer/eme/CDMProxyThunder.cpp:
     109        (WebCore::CDMProxyThunder::getDecryptionSession const): Use has_value.
     110        * platform/graphics/gstreamer/eme/CDMThunder.cpp:
     111        (WebCore::ParsedResponseMessage::hasType const): Use has_value.
     112        (WebCore::CDMInstanceSessionThunder::cdmInstanceThunder const): Use
     113        a pointer for the erturn value instead of Optional<&>. This hasn't
     114        compiled since we switched to std::optional so I suspect this code is
     115        not compiled by EWS or the buildbot.
     116        * platform/graphics/gstreamer/eme/CDMThunder.h: Updated to match above.
     117
     118        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
     119        (WebCore::AppendPipeline::parseDemuxerSrcPadCaps): Use value_or.
     120        (WebCore::AppendPipeline::appsinkCapsChanged): Do not use has_value.
     121        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
     122        (WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected): Ditto.
     123
     124        * platform/graphics/transforms/TransformState.h: Use has_value.
     125        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
     126        (WebCore::supportsPictureInPicture): Ditto.
     127        * platform/mac/NSScrollerImpDetails.mm:
     128        (WebCore::ScrollerStyle::recommendedScrollerStyle): Ditto.
     129        * platform/network/ResourceRequestBase.cpp:
     130        (WebCore::ResourceRequestBase::isSystemPreview const): Ditto.
     131        * platform/xr/openxr/OpenXRInputSource.cpp:
     132        (PlatformXR::OpenXRInputSource::getInputSource const): Ditto.
     133        * rendering/EventRegion.h: Ditto.
     134
     135        * rendering/GridTrackSizingAlgorithm.h: Remove unnecessary assertion, since
     136        the * operator already does the assertion.
     137
     138        * rendering/RenderFlexibleBox.cpp:
     139        (WebCore::RenderFlexibleBox::canComputePercentageFlexBasis): Use has_value.
     140        * rendering/RenderListItem.cpp:
     141        (WebCore::RenderListItem::setExplicitValue): Ditto.
     142        * rendering/RenderThemeIOS.mm:
     143        (WebCore::RenderThemeIOS::systemFocusRingColor): Ditto.
     144        * rendering/updating/RenderTreeBuilder.cpp:
     145        (WebCore::RenderTreeBuilder::removeAnonymousWrappersForInlineChildrenIfNeeded): Ditto.
     146
     147        * svg/SVGSVGElement.cpp:
     148        (WebCore::SVGSVGElement::createSVGTransformFromMatrix): Changed idiom to not
     149        call hasValue.
     150        * svg/SVGTransform.h: Ditto.
     151        * testing/WebFakeXRDevice.cpp:
     152        (WebCore::WebFakeXRDevice::setViews): Ditto.
     153
    11542021-05-29  Alan Bujtas  <zalan@apple.com>
    2155
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r277586 r278244  
    103103        contextOptions.sampleRate = *defaultSampleRateForTesting();
    104104
    105     if (contextOptions.sampleRate.hasValue() && !isSupportedSampleRate(contextOptions.sampleRate.value()))
     105    if (contextOptions.sampleRate && !isSupportedSampleRate(*contextOptions.sampleRate))
    106106        return Exception { SyntaxError, "sampleRate is not in range"_s };
    107107   
  • trunk/Source/WebCore/Modules/webxr/WebXRFrame.cpp

    r278185 r278244  
    9797
    9898// https://immersive-web.github.io/webxr/#populate-the-pose
    99 ExceptionOr<Optional<WebXRFrame::PopulatedPose>> WebXRFrame::populatePose(const Document& document, const WebXRSpace& space, const WebXRSpace& baseSpace)
     99ExceptionOr<std::optional<WebXRFrame::PopulatedPose>> WebXRFrame::populatePose(const Document& document, const WebXRSpace& space, const WebXRSpace& baseSpace)
    100100{
    101101    // 1. If frame’s active boolean is false, throw an InvalidStateError and abort these steps.
     
    160160    // 6. If pose is null return null.
    161161    auto populateValue = populatePoseResult.releaseReturnValue();
    162     if (!populateValue.hasValue())
     162    if (!populateValue)
    163163        return nullptr;
    164164
     
    228228
    229229    auto populateValue = populatePoseResult.releaseReturnValue();
    230     if (!populateValue.hasValue())
     230    if (!populateValue)
    231231        return nullptr;
    232232
  • trunk/Source/WebCore/Modules/webxr/WebXRGamepad.cpp

    r276433 r278244  
    4747    // In order to report a mapping of "xr-standard" the device MUST report a targetRayMode of "tracked-pointer" and MUST have a non-null gripSpace.
    4848    // It MUST have at least one primary trigger, separate from any touchpads or thumbsticks
    49     if (source.targetRayMode == XRTargetRayMode::TrackedPointer && !source.buttons.isEmpty() && source.gripOrigin.hasValue())
     49    if (source.targetRayMode == XRTargetRayMode::TrackedPointer && !source.buttons.isEmpty() && source.gripOrigin)
    5050        m_mapping = xrStandardGamepadMappingString();
    5151    m_axes = source.axes.map([](auto value) {
  • trunk/Source/WebCore/Modules/webxr/WebXRInputSource.cpp

    r277251 r278244  
    9494        || m_source.targetRayMode != source.targetRayMode
    9595        || m_source.profiles != source.profiles
    96         || static_cast<bool>(m_gripSpace) != source.gripOrigin.hasValue();
     96        || static_cast<bool>(m_gripSpace) != source.gripOrigin.has_value();
    9797}
    9898
  • trunk/Source/WebCore/bindings/js/DOMPromiseProxy.h

    r278185 r278244  
    150150inline bool DOMPromiseProxy<IDLType>::isFulfilled() const
    151151{
    152     return m_valueOrException.hasValue();
     152    return m_valueOrException.has_value();
    153153}
    154154
     
    219219inline bool DOMPromiseProxy<IDLUndefined>::isFulfilled() const
    220220{
    221     return m_valueOrException.hasValue();
     221    return m_valueOrException.has_value();
    222222}
    223223
     
    289289inline bool DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled() const
    290290{
    291     return m_valueOrException.hasValue();
     291    return m_valueOrException.has_value();
    292292}
    293293
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r278185 r278244  
    34833483                return JSValue();
    34843484            auto reFlags = Yarr::parseFlags(flags->string());
    3485             ASSERT(reFlags.hasValue());
     3485            ASSERT(reFlags.has_value());
    34863486            VM& vm = m_lexicalGlobalObject->vm();
    34873487            RegExp* regExp = RegExp::create(vm, pattern->string(), reFlags.value());
  • trunk/Source/WebCore/css/CSSFontFaceSet.cpp

    r278185 r278244  
    163163void CSSFontFaceSet::addToFacesLookupTable(CSSFontFace& face)
    164164{
    165     if (!face.families() || !face.families().hasValue())
     165    if (!face.families())
    166166        return;
    167167    auto families = face.families().value();
     
    246246    });
    247247   
    248     if (face.families() && face.families().hasValue())
     248    if (face.families())
    249249        removeFromFacesLookupTable(face, *face.families().value());
    250250
     
    452452    for (int i = familyFontFaces.size() - 1; i >= 0; --i) {
    453453        CSSFontFace& candidate = familyFontFaces[i];
    454         auto capabilitiesWrapped = candidate.fontSelectionCapabilities();
    455         if (!capabilitiesWrapped.hasValue())
    456             continue;
    457         auto capabilities = capabilitiesWrapped.value();
    458         if (!isItalic(request.slope) && isItalic(capabilities.slope.minimum))
    459             continue;
    460         candidateFontFaces.append(candidate);
     454        if (auto capabilities = candidate.fontSelectionCapabilities()) {
     455            if (!isItalic(request.slope) && isItalic(capabilities->slope.minimum))
     456                continue;
     457            candidateFontFaces.append(candidate);
     458        }
    461459    }
    462460
     
    464462    if (localIterator != m_locallyInstalledFacesLookupTable.end()) {
    465463        for (auto& candidate : localIterator->value) {
    466             auto capabilitiesWrapped = candidate->fontSelectionCapabilities();
    467             if (!capabilitiesWrapped.hasValue())
    468                 continue;
    469             auto capabilities = capabilitiesWrapped.value();
    470             if (!isItalic(request.slope) && isItalic(capabilities.slope.minimum))
    471                 continue;
    472             candidateFontFaces.append(candidate);
     464            if (auto capabilities = candidate->fontSelectionCapabilities()) {
     465                if (!isItalic(request.slope) && isItalic(capabilities->slope.minimum))
     466                    continue;
     467                candidateFontFaces.append(candidate);
     468            }
    473469        }
    474470    }
     
    478474        capabilities.reserveInitialCapacity(candidateFontFaces.size());
    479475        for (auto& face : candidateFontFaces) {
    480             auto fontSelectionCapabilitiesWrapped = face.get().fontSelectionCapabilities();
    481             ASSERT(fontSelectionCapabilitiesWrapped.hasValue());
    482             auto fontSelectionCapabilities = fontSelectionCapabilitiesWrapped.value();
    483             capabilities.uncheckedAppend(fontSelectionCapabilities);
     476            auto fontSelectionCapabilities = face.get().fontSelectionCapabilities();
     477            capabilities.uncheckedAppend(*fontSelectionCapabilities);
    484478        }
    485479        FontSelectionAlgorithm fontSelectionAlgorithm(request, capabilities);
    486480        std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), [&fontSelectionAlgorithm](const CSSFontFace& first, const CSSFontFace& second) {
    487             auto firstCapabilitiesWrapped = first.fontSelectionCapabilities();
    488             auto secondCapabilitiesWrapped = second.fontSelectionCapabilities();
    489             ASSERT(firstCapabilitiesWrapped.hasValue() && secondCapabilitiesWrapped.hasValue());
     481            auto firstCapabilities = first.fontSelectionCapabilities();
     482            auto secondCapabilities = second.fontSelectionCapabilities();
    490483           
    491             auto firstCapabilities = firstCapabilitiesWrapped.value();
    492             auto secondCapabilities = secondCapabilitiesWrapped.value();
    493             auto stretchDistanceFirst = fontSelectionAlgorithm.stretchDistance(firstCapabilities).distance;
    494             auto stretchDistanceSecond = fontSelectionAlgorithm.stretchDistance(secondCapabilities).distance;
     484            auto stretchDistanceFirst = fontSelectionAlgorithm.stretchDistance(*firstCapabilities).distance;
     485            auto stretchDistanceSecond = fontSelectionAlgorithm.stretchDistance(*secondCapabilities).distance;
    495486            if (stretchDistanceFirst < stretchDistanceSecond)
    496487                return true;
     
    498489                return false;
    499490
    500             auto styleDistanceFirst = fontSelectionAlgorithm.styleDistance(firstCapabilities).distance;
    501             auto styleDistanceSecond = fontSelectionAlgorithm.styleDistance(secondCapabilities).distance;
     491            auto styleDistanceFirst = fontSelectionAlgorithm.styleDistance(*firstCapabilities).distance;
     492            auto styleDistanceSecond = fontSelectionAlgorithm.styleDistance(*secondCapabilities).distance;
    502493            if (styleDistanceFirst < styleDistanceSecond)
    503494                return true;
     
    505496                return false;
    506497
    507             auto weightDistanceFirst = fontSelectionAlgorithm.weightDistance(firstCapabilities).distance;
    508             auto weightDistanceSecond = fontSelectionAlgorithm.weightDistance(secondCapabilities).distance;
     498            auto weightDistanceFirst = fontSelectionAlgorithm.weightDistance(*firstCapabilities).distance;
     499            auto weightDistanceSecond = fontSelectionAlgorithm.weightDistance(*secondCapabilities).distance;
    509500            if (weightDistanceFirst < weightDistanceSecond)
    510501                return true;
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r277967 r278244  
    7070struct GradientStop {
    7171    Color color;
    72     Optional<float> offset;
    73 
    74     bool isSpecified() const { return offset.hasValue(); }
     72    std::optional<float> offset;
     73
     74    bool isSpecified() const { return offset.has_value(); }
    7575    bool isMidpoint() const { return !color.isValid(); }
    7676};
     
    242242        size_t lastStopIndex = numStops - 1;
    243243
    244         Optional<size_t> firstZeroOrGreaterIndex;
     244        std::optional<size_t> firstZeroOrGreaterIndex;
    245245        for (size_t i = 0; i < numStops; ++i) {
    246246            if (*stops[i].offset >= 0) {
     
    272272        }
    273273
    274         Optional<size_t> lastOneOrLessIndex;
     274        std::optional<size_t> lastOneOrLessIndex;
    275275        for (int i = lastStopIndex; i >= 0; --i) {
    276276            if (*stops[i].offset <= 1) {
  • trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp

    r275488 r278244  
    121121            continue;
    122122
    123         auto selectionCapabilitiesWrapped = face->fontSelectionCapabilities();
    124         ASSERT(selectionCapabilitiesWrapped.hasValue());
    125         auto selectionCapabilities = selectionCapabilitiesWrapped.value();
     123        auto selectionCapabilities = *face->fontSelectionCapabilities();
    126124
    127125        bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && !isFontWeightBold(selectionCapabilities.weight.maximum) && isFontWeightBold(desiredRequest.weight);
     
    133131            continue;
    134132       
    135         auto faceRangesWrapped = face->ranges();
    136         ASSERT(faceRangesWrapped.hasValue());
    137         auto faceRanges = faceRangesWrapped.value();
    138         appendFont(ranges, WTFMove(fontAccessor), faceRanges);
     133        appendFont(ranges, WTFMove(fontAccessor), *face->ranges());
    139134    }
    140135   
  • trunk/Source/WebCore/css/FontFace.cpp

    r276450 r278244  
    271271
    272272    const auto& families = m_backing->families();
    273     if (!families.hasValue())
     273    if (!families)
    274274        return "normal"_s;
    275275    auto familiesUnrwapped = families.value();
     
    296296    const auto& styleWrapped = m_backing->italic();
    297297   
    298     if (!styleWrapped.hasValue())
     298    if (!styleWrapped)
    299299        return "normal"_s;
    300300    auto style = styleWrapped.value();
     
    329329    m_backing->updateStyleIfNeeded();
    330330    const auto& weightWrapped = m_backing->weight();
    331     if (!weightWrapped.hasValue())
     331    if (!weightWrapped)
    332332        return "normal"_s;
    333333    auto weight = weightWrapped.value();
     
    352352    m_backing->updateStyleIfNeeded();
    353353    const auto& stretchWrapped = m_backing->stretch();
    354     if (!stretchWrapped.hasValue())
     354    if (!stretchWrapped)
    355355        return "normal"_s;
    356356    auto stretch = stretchWrapped.value();
     
    375375    m_backing->updateStyleIfNeeded();
    376376    const auto& rangesWrapped = m_backing->ranges();
    377     if (!rangesWrapped.hasValue())
     377    if (!rangesWrapped)
    378378        return "U+0-10FFFF";
    379379    auto ranges = rangesWrapped.value();
     
    390390    m_backing->updateStyleIfNeeded();
    391391    const auto& featureSettingsWrapped = m_backing->featureSettings();
    392     if (!featureSettingsWrapped.hasValue())
     392    if (!featureSettingsWrapped)
    393393        return "normal"_s;
    394394    auto featureSettings = featureSettingsWrapped.value();
     
    405405    m_backing->updateStyleIfNeeded();
    406406    const auto& loadingBehaviorWrapped = m_backing->loadingBehavior();
    407     if (!loadingBehaviorWrapped.hasValue())
     407    if (!loadingBehaviorWrapped)
    408408        return "auto"_s;
    409409    return context.cssValuePool().createValue(loadingBehaviorWrapped.value())->cssText();
  • trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp

    r278185 r278244  
    888888        auto parsedNumber = parseInteger<int>(StringView { nString }.substring(1));
    889889        result.second = parsedNumber.value_or(0);
    890         return parsedNumber.hasValue();
     890        return parsedNumber.has_value();
    891891    }
    892892
  • trunk/Source/WebCore/display/css/DisplayStyle.h

    r271921 r278244  
    7777    const ShadowData* boxShadow() const { return m_boxShadow.get(); }
    7878
    79     Optional<int> zIndex() const { return m_zIndex; }
    80     bool isStackingContext() const { return m_zIndex.hasValue(); }
     79    std::optional<int> zIndex() const { return m_zIndex; }
     80    bool isStackingContext() const { return m_zIndex.has_value(); }
    8181   
    8282    bool isPositioned() const { return m_flags.contains(Flags::Positioned); }
     
    126126    float m_opacity;
    127127
    128     Optional<int> m_zIndex;
     128    std::optional<int> m_zIndex;
    129129    OptionSet<Flags> m_flags;
    130130};
  • trunk/Source/WebCore/dom/DataTransferItemList.h

    r266168 r278244  
    6868    void didClearStringData(const String& type);
    6969    void didSetStringData(const String& type);
    70     bool hasItems() const { return m_items.hasValue(); }
     70    bool hasItems() const { return m_items.has_value(); }
    7171    const Vector<Ref<DataTransferItem>>& items() const
    7272    {
  • trunk/Source/WebCore/dom/Document.cpp

    r278185 r278244  
    28642864            Position startPosition;
    28652865            Position endPosition;
    2866             if (!rangeData->startPosition.hasValue())
     2866            if (!rangeData->startPosition.has_value())
    28672867                startPosition = visibleSelection.visibleStart().deepEquivalent();
    2868             if (!rangeData->endPosition.hasValue())
     2868            if (!rangeData->endPosition.has_value())
    28692869                endPosition = visibleSelection.visibleEnd().deepEquivalent();
    28702870            if (!weakRangeData.get())
  • trunk/Source/WebCore/dom/EventTarget.cpp

    r278185 r278244  
    9090    auto passive = options.passive;
    9191
    92     if (!passive.hasValue() && Quirks::shouldMakeEventListenerPassive(*this, eventType, listener.get()))
     92    if (!passive.has_value() && Quirks::shouldMakeEventListenerPassive(*this, eventType, listener.get()))
    9393        passive = true;
    9494
  • trunk/Source/WebCore/editing/AlternativeTextController.cpp

    r278185 r278244  
    147147bool AlternativeTextController::hasPendingCorrection() const
    148148{
    149     return m_rangeWithAlternative.hasValue();
     149    return m_rangeWithAlternative.has_value();
    150150}
    151151
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r277174 r278244  
    601601    RefPtr<EditingStyle> styleWithoutEmbedding;
    602602    RefPtr<EditingStyle> embeddingStyle;
    603     if (textDirection.hasValue()) {
     603    if (textDirection) {
    604604        // Leave alone an ancestor that provides the desired single level embedding, if there is one.
    605605        auto startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.deprecatedNode(), true, *textDirection);
     
    652652
    653653    RefPtr<EditingStyle> styleToApply = &style;
    654     if (textDirection.hasValue()) {
     654    if (textDirection) {
    655655        // Avoid applying the unicode-bidi and direction properties beneath ancestors that already have them.
    656656        auto embeddingStartNode = highestEmbeddingAncestor(start.deprecatedNode(), enclosingBlock(start.deprecatedNode()));
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r278185 r278244  
    65846584CaptionUserPreferences::CaptionDisplayMode HTMLMediaElement::captionDisplayMode()
    65856585{
    6586     if (!m_captionDisplayMode.hasValue()) {
     6586    if (!m_captionDisplayMode) {
    65876587        if (document().page())
    65886588            m_captionDisplayMode = document().page()->group().captionPreferences().captionDisplayMode();
  • trunk/Source/WebCore/html/ImageBitmap.h

    r269381 r278244  
    104104
    105105    Optional<ImageBitmapBacking> takeImageBitmapBacking();
    106     bool isDetached() const { return !m_backingStore.hasValue(); }
     106    bool isDetached() const { return !m_backingStore; }
    107107    void close() { takeImageBitmapBacking(); }
    108108
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp

    r278185 r278244  
    11101110Protocol::ErrorStringOr<void> InspectorPageAgent::setScreenSizeOverride(Optional<int>&& width, Optional<int>&& height)
    11111111{
    1112     if (width.hasValue() != height.hasValue())
     1112    if (width.has_value() != height.has_value())
    11131113        return makeUnexpected("Screen width and height override should be both specified or omitted"_s);
    11141114
  • trunk/Source/WebCore/layout/LayoutPhase.cpp

    r254666 r278244  
    5858{
    5959    // Should never nest states like calling TreeBuilding from Layout.
    60     ASSERT(!(*phase()).hasValue());
     60    ASSERT(!(*phase()).has_value());
    6161    phase().set(type);
    6262}
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp

    r278185 r278244  
    429429    auto& inlineTextItem = downcast<InlineTextItem>(overflowingRun.inlineItem);
    430430    auto& style = inlineTextItem.style();
    431     auto availableSpaceIsInfinite = !availableWidth.hasValue();
     431    auto availableSpaceIsInfinite = !availableWidth.has_value();
    432432
    433433    auto breakRules = wordBreakBehavior(style, hasWrapOpportunityAtPreviousPosition);
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h

    r276886 r278244  
    5454    bool isTrailingRunFullyTrimmable() const { return m_trimmableTrailingContent.isTrailingRunFullyTrimmable(); }
    5555
    56     Optional<InlineLayoutUnit> trailingSoftHyphenWidth() const { return m_trailingSoftHyphenWidth; }
     56    std::optional<InlineLayoutUnit> trailingSoftHyphenWidth() const { return m_trailingSoftHyphenWidth; }
    5757    void addTrailingHyphen(InlineLayoutUnit hyphenLogicalWidth);
    5858
     
    7272        const Box& layoutBox() const { return *m_layoutBox; }
    7373        const RenderStyle& style() const { return m_layoutBox->style(); }
    74         const Optional<LineRun::Text>& textContent() const { return m_textContent; }
     74        const std::optional<LineRun::Text>& textContent() const { return m_textContent; }
    7575
    7676        InlineLayoutUnit logicalWidth() const { return m_logicalWidth; }
     
    123123        TrailingWhitespace m_trailingWhitespaceType { TrailingWhitespace::None };
    124124        InlineLayoutUnit m_trailingWhitespaceWidth { 0 };
    125         Optional<LineRun::Text> m_textContent;
     125        std::optional<LineRun::Text> m_textContent;
    126126        LineRun::Expansion m_expansion;
    127127        unsigned m_expansionOpportunityCount { 0 };
     
    154154
    155155        InlineLayoutUnit width() const { return m_fullyTrimmableWidth + m_partiallyTrimmableWidth; }
    156         bool isEmpty() const { return !m_firstTrimmableRunIndex.hasValue(); }
     156        bool isEmpty() const { return !m_firstTrimmableRunIndex.has_value(); }
    157157        bool isTrailingRunFullyTrimmable() const { return m_hasFullyTrimmableContent; }
    158158        bool isTrailingRunPartiallyTrimmable() const { return m_partiallyTrimmableWidth; }
     
    162162    private:
    163163        RunList& m_runs;
    164         Optional<size_t> m_firstTrimmableRunIndex;
     164        std::optional<size_t> m_firstTrimmableRunIndex;
    165165        bool m_hasFullyTrimmableContent { false };
    166166        InlineLayoutUnit m_fullyTrimmableWidth { 0 };
     
    173173    InlineLayoutUnit m_contentLogicalWidth { 0 };
    174174    size_t m_nonSpanningInlineLevelBoxCount { 0 };
    175     Optional<InlineLayoutUnit> m_trailingSoftHyphenWidth { 0 };
     175    std::optional<InlineLayoutUnit> m_trailingSoftHyphenWidth { 0 };
    176176};
    177177
  • trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp

    r278185 r278244  
    5151    auto parsedInteger = parseInteger<uint64_t>(string);
    5252    expiryDelta = Seconds(static_cast<double>(parsedInteger.value_or(0)));
    53     return parsedInteger.hasValue();
     53    return parsedInteger.has_value();
    5454}
    5555
  • trunk/Source/WebCore/page/EventHandler.cpp

    r278185 r278244  
    30973097
    30983098    auto platformEvent = wheelEvent.underlyingPlatformEvent();
    3099     bool isUserEvent = platformEvent.hasValue();
     3099    bool isUserEvent = platformEvent.has_value();
    31003100
    31013101    if (isUserEvent && !m_currentWheelEventAllowsScrolling)
  • trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp

    r274864 r278244  
    660660{
    661661    // Do we track this element?
    662     if (!m_wasHidden.hasValue())
     662    if (!m_wasHidden.has_value())
    663663        return;
    664664
  • trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp

    r278185 r278244  
    108108
    109109template <typename InfoType, typename SizeType, typename LayoutType>
    110 static std::pair<LayoutType, unsigned> closestSnapOffsetWithInfoAndAxis(const InfoType& info, ScrollEventAxis axis, const SizeType& viewportSize, LayoutType scrollDestinationOffset, float velocity, Optional<LayoutType> originalOffsetForDirectionalSnapping)
     110static std::pair<LayoutType, unsigned> closestSnapOffsetWithInfoAndAxis(const InfoType& info, ScrollEventAxis axis, const SizeType& viewportSize, LayoutType scrollDestinationOffset, float velocity, std::optional<LayoutType> originalOffsetForDirectionalSnapping)
    111111{
    112112    const auto& snapOffsets = info.offsetsForAxis(axis);
     
    114114        return std::make_pair(scrollDestinationOffset, invalidSnapOffsetIndex);
    115115
    116     if (originalOffsetForDirectionalSnapping.hasValue()) {
    117         auto firstSnapStopOffsetIndex = findFirstSnapStopOffsetBetweenOriginAndDestination(snapOffsets, *originalOffsetForDirectionalSnapping, scrollDestinationOffset);
    118         if (firstSnapStopOffsetIndex.hasValue())
     116    if (originalOffsetForDirectionalSnapping) {
     117        if (auto firstSnapStopOffsetIndex = findFirstSnapStopOffsetBetweenOriginAndDestination(snapOffsets, *originalOffsetForDirectionalSnapping, scrollDestinationOffset))
    119118            return std::make_pair(snapOffsets[*firstSnapStopOffsetIndex].offset, *firstSnapStopOffsetIndex);
    120119    }
     
    357356
    358357template <> template <>
    359 std::pair<LayoutUnit, unsigned> LayoutScrollSnapOffsetsInfo::closestSnapOffset(ScrollEventAxis axis, const LayoutSize& viewportSize, LayoutUnit scrollDestinationOffset, float velocity, Optional<LayoutUnit> originalPositionForDirectionalSnapping) const
     358std::pair<LayoutUnit, unsigned> LayoutScrollSnapOffsetsInfo::closestSnapOffset(ScrollEventAxis axis, const LayoutSize& viewportSize, LayoutUnit scrollDestinationOffset, float velocity, std::optional<LayoutUnit> originalPositionForDirectionalSnapping) const
    360359{
    361360    return closestSnapOffsetWithInfoAndAxis(*this, axis, viewportSize, scrollDestinationOffset, velocity, originalPositionForDirectionalSnapping);
     
    363362
    364363template <> template<>
    365 std::pair<float, unsigned> FloatScrollSnapOffsetsInfo::closestSnapOffset(ScrollEventAxis axis, const FloatSize& viewportSize, float scrollDestinationOffset, float velocity, Optional<float> originalPositionForDirectionalSnapping) const
     364std::pair<float, unsigned> FloatScrollSnapOffsetsInfo::closestSnapOffset(ScrollEventAxis axis, const FloatSize& viewportSize, float scrollDestinationOffset, float velocity, std::optional<float> originalPositionForDirectionalSnapping) const
    366365{
    367366    return closestSnapOffsetWithInfoAndAxis(*this, axis, viewportSize, scrollDestinationOffset, velocity, originalPositionForDirectionalSnapping);
  • trunk/Source/WebCore/platform/ScrollController.cpp

    r277350 r278244  
    169169}
    170170
    171 float ScrollController::adjustScrollDestination(ScrollEventAxis axis, float destinationOffset, float velocity, Optional<float> originalOffset)
     171float ScrollController::adjustScrollDestination(ScrollEventAxis axis, float destinationOffset, float velocity, std::optional<float> originalOffset)
    172172{
    173173    if (!usesScrollSnap())
     
    179179        return destinationOffset;
    180180
    181     Optional<LayoutUnit> originalOffsetInLayoutUnits;
    182     if (originalOffset.hasValue())
     181    std::optional<LayoutUnit> originalOffsetInLayoutUnits;
     182    if (originalOffset)
    183183        originalOffsetInLayoutUnits = LayoutUnit(*originalOffset / m_client.pageScaleFactor());
    184184    LayoutSize viewportSize(m_client.viewportSize().width(), m_client.viewportSize().height());
  • trunk/Source/WebCore/platform/cocoa/SystemBattery.mm

    r273504 r278244  
    4545        return *overrideForTesting;
    4646
    47     if (!hasBattery.hasValue()) {
     47    if (!hasBattery.has_value()) {
    4848        hasBattery = [] {
    4949#if PLATFORM(IOS) || PLATFORM(WATCHOS)
     
    8888        return *overrideForTesting;
    8989
    90     if (!hasAC.hasValue()) {
     90    if (!hasAC.has_value()) {
    9191        hasAC = [] {
    9292#if PLATFORM(APPLETV)
  • trunk/Source/WebCore/platform/graphics/Gradient.h

    r278185 r278244  
    6969
    7070        template<typename Encoder> void encode(Encoder&) const;
    71         template<typename Decoder> static Optional<ColorStop> decode(Decoder&);
     71        template<typename Decoder> static std::optional<ColorStop> decode(Decoder&);
    7272    };
    7373
     
    7979
    8080        template<typename Encoder> void encode(Encoder&) const;
    81         template<typename Decoder> static Optional<LinearData> decode(Decoder&);
     81        template<typename Decoder> static std::optional<LinearData> decode(Decoder&);
    8282    };
    8383
     
    9090
    9191        template<typename Encoder> void encode(Encoder&) const;
    92         template<typename Decoder> static Optional<RadialData> decode(Decoder&);
     92        template<typename Decoder> static std::optional<RadialData> decode(Decoder&);
    9393    };
    9494
     
    9898
    9999        template<typename Encoder> void encode(Encoder&) const;
    100         template<typename Decoder> static Optional<ConicData> decode(Decoder&);
     100        template<typename Decoder> static std::optional<ConicData> decode(Decoder&);
    101101    };
    102102
     
    136136
    137137    template<typename Encoder> void encode(Encoder&) const;
    138     template<typename Decoder> static Optional<Ref<Gradient>> decode(Decoder&);
     138    template<typename Decoder> static std::optional<Ref<Gradient>> decode(Decoder&);
    139139
    140140private:
     
    169169}
    170170
    171 template<typename Decoder> Optional<Gradient::ColorStop> Gradient::ColorStop::decode(Decoder& decoder)
    172 {
    173     Optional<float> offset;
     171template<typename Decoder> std::optional<Gradient::ColorStop> Gradient::ColorStop::decode(Decoder& decoder)
     172{
     173    std::optional<float> offset;
    174174    decoder >> offset;
    175175    if (!offset)
    176176        return std::nullopt;
    177177
    178     Optional<Color> color;
     178    std::optional<Color> color;
    179179    decoder >> color;
    180180    if (!color)
     
    190190}
    191191
    192 template<typename Decoder> Optional<Gradient::LinearData> Gradient::LinearData::decode(Decoder& decoder)
    193 {
    194     Optional<FloatPoint> point0;
     192template<typename Decoder> std::optional<Gradient::LinearData> Gradient::LinearData::decode(Decoder& decoder)
     193{
     194    std::optional<FloatPoint> point0;
    195195    decoder >> point0;
    196196    if (!point0)
    197197        return std::nullopt;
    198198
    199     Optional<FloatPoint> point1;
     199    std::optional<FloatPoint> point1;
    200200    decoder >> point1;
    201201    if (!point1)
     
    214214}
    215215
    216 template<typename Decoder> Optional<Gradient::RadialData> Gradient::RadialData::decode(Decoder& decoder)
    217 {
    218     Optional<FloatPoint> point0;
     216template<typename Decoder> std::optional<Gradient::RadialData> Gradient::RadialData::decode(Decoder& decoder)
     217{
     218    std::optional<FloatPoint> point0;
    219219    decoder >> point0;
    220220    if (!point0)
    221221        return std::nullopt;
    222222
    223     Optional<FloatPoint> point1;
     223    std::optional<FloatPoint> point1;
    224224    decoder >> point1;
    225225    if (!point1)
    226226        return std::nullopt;
    227227
    228     Optional<float> startRadius;
     228    std::optional<float> startRadius;
    229229    decoder >> startRadius;
    230230    if (!startRadius)
    231231        return std::nullopt;
    232232
    233     Optional<float> endRadius;
     233    std::optional<float> endRadius;
    234234    decoder >> endRadius;
    235235    if (!endRadius)
    236236        return std::nullopt;
    237237
    238     Optional<float> aspectRatio;
     238    std::optional<float> aspectRatio;
    239239    decoder >> aspectRatio;
    240240    if (!aspectRatio)
     
    250250}
    251251
    252 template<typename Decoder> Optional<Gradient::ConicData> Gradient::ConicData::decode(Decoder& decoder)
    253 {
    254     Optional<FloatPoint> point0;
     252template<typename Decoder> std::optional<Gradient::ConicData> Gradient::ConicData::decode(Decoder& decoder)
     253{
     254    std::optional<FloatPoint> point0;
    255255    decoder >> point0;
    256256    if (!point0)
    257257        return std::nullopt;
    258258
    259     Optional<float> angleRadians;
     259    std::optional<float> angleRadians;
    260260    decoder >> angleRadians;
    261261    if (!angleRadians)
     
    273273}
    274274
    275 template<typename Decoder> Optional<Ref<Gradient>> Gradient::decode(Decoder& decoder)
    276 {
    277     Optional<Data> data;
     275template<typename Decoder> std::optional<Ref<Gradient>> Gradient::decode(Decoder& decoder)
     276{
     277    std::optional<Data> data;
    278278    decoder >> data;
    279279    if (!data)
     
    281281    auto gradient = Gradient::create(WTFMove(*data));
    282282
    283     Optional<ColorStopVector> stops;
     283    std::optional<ColorStopVector> stops;
    284284    decoder >> stops;
    285285    if (!stops)
    286286        return std::nullopt;
    287     Optional<bool> stopsSorted;
     287    std::optional<bool> stopsSorted;
    288288    decoder >> stopsSorted;
    289     if (!stopsSorted.hasValue())
     289    if (!stopsSorted.has_value())
    290290        return std::nullopt;
    291291    if (*stopsSorted)
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r275570 r278244  
    8080    bool canUseAsyncDecoding();
    8181    void startAsyncDecodingQueue();
    82     void requestFrameAsyncDecodingAtIndex(size_t, SubsamplingLevel, const Optional<IntSize>& = { });
     82    void requestFrameAsyncDecodingAtIndex(size_t, SubsamplingLevel, const std::optional<IntSize>& = { });
    8383    void stopAsyncDecodingQueue();
    8484    bool hasAsyncDecodingQueue() const { return m_decodingQueue; }
     
    9696    String filenameExtension();
    9797    String accessibilityDescription();
    98     Optional<IntPoint> hotSpot();
    99     Optional<IntSize> densityCorrectedSize(ImageOrientation = ImageOrientation::FromImage);
    100     bool hasDensityCorrectedSize() { return densityCorrectedSize().hasValue(); }
     98    std::optional<IntPoint> hotSpot();
     99    std::optional<IntSize> densityCorrectedSize(ImageOrientation = ImageOrientation::FromImage);
     100    bool hasDensityCorrectedSize() { return densityCorrectedSize().has_value(); }
    101101
    102102    ImageOrientation orientation();
     
    114114    bool frameHasAlphaAtIndex(size_t);
    115115    bool frameHasImageAtIndex(size_t);
    116     bool frameHasFullSizeNativeImageAtIndex(size_t, const Optional<SubsamplingLevel>&);
    117     bool frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(size_t, const Optional<SubsamplingLevel>&, const DecodingOptions&);
     116    bool frameHasFullSizeNativeImageAtIndex(size_t, const std::optional<SubsamplingLevel>&);
     117    bool frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(size_t, const std::optional<SubsamplingLevel>&, const DecodingOptions&);
    118118    SubsamplingLevel frameSubsamplingLevelAtIndex(size_t);
    119119
     
    154154
    155155    template<typename T>
    156     T firstFrameMetadataCacheIfNeeded(T& cachedValue, MetadataType, T (ImageFrame::*functor)() const, ImageFrame::Caching, const Optional<SubsamplingLevel>& = { });
     156    T firstFrameMetadataCacheIfNeeded(T& cachedValue, MetadataType, T (ImageFrame::*functor)() const, ImageFrame::Caching, const std::optional<SubsamplingLevel>& = { });
    157157
    158158    bool ensureDecoderAvailable(SharedBuffer* data);
     
    177177
    178178    const ImageFrame& frameAtIndex(size_t index) { return index < m_frames.size() ? m_frames[index] : ImageFrame::defaultFrame(); }
    179     const ImageFrame& frameAtIndexCacheIfNeeded(size_t, ImageFrame::Caching, const Optional<SubsamplingLevel>& = { });
     179    const ImageFrame& frameAtIndexCacheIfNeeded(size_t, ImageFrame::Caching, const std::optional<SubsamplingLevel>& = { });
    180180
    181181    void dump(TextStream&);
     
    215215    String m_filenameExtension;
    216216    String m_accessibilityDescription;
    217     Optional<IntPoint> m_hotSpot;
     217    std::optional<IntPoint> m_hotSpot;
    218218
    219219    // Image metadata which is calculated from the first ImageFrame.
    220220    IntSize m_size;
    221     Optional<IntSize> m_densityCorrectedSize;
     221    std::optional<IntSize> m_densityCorrectedSize;
    222222    ImageOrientation m_orientation;
    223223    Color m_singlePixelSolidColor;
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r278185 r278244  
    11661166bool MediaPlayer::wouldTaintOrigin(const SecurityOrigin& origin) const
    11671167{
    1168     auto wouldTaint = m_private->wouldTaintOrigin(origin);
    1169     if (wouldTaint.hasValue())
    1170         return wouldTaint.value();
     1168    if (auto wouldTaint = m_private->wouldTaintOrigin(origin))
     1169        return *wouldTaint;
    11711170
    11721171    if (m_url.protocolIsData())
  • trunk/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp

    r278185 r278244  
    183183    if (!oldContext) {
    184184        auto newContext = requestGLContext(contextType);
    185         if (!newContext.hasValue())
     185        if (!newContext)
    186186            return false;
    187187        gst_element_set_context(elementSink, newContext->get());
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp

    r278185 r278244  
    148148    bool isUsingHardware = false;
    149149
    150     if (disallowedList.hasValue() && !disallowedList->isEmpty()) {
     150    if (disallowedList && !disallowedList->isEmpty()) {
    151151        bool hasValidCandidate = false;
    152152        for (GList* factories = candidates; factories; factories = g_list_next(factories)) {
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r278185 r278244  
    13441344        return m_playbackRate > 0 ? durationMediaTime() : MediaTime::zeroTime();
    13451345
    1346     if (m_cachedPosition.hasValue()) {
     1346    if (m_cachedPosition) {
    13471347        GST_TRACE_OBJECT(pipeline(), "Returning cached position: %s", m_cachedPosition.value().toString().utf8().data());
    13481348        return m_cachedPosition.value();
     
    28722872    // Dispatch the task if the time is already reached. Dispatching instead of directly running the
    28732873    // task prevents infinite recursion in case the task calls performTaskAtMediaTime() internally.
    2874     if (taskToSchedule.hasValue())
     2874    if (taskToSchedule)
    28752875        RunLoop::main().dispatch(WTFMove(taskToSchedule.value()));
    28762876
     
    31253125        // Heuristic to avoid asking for playbackPosition() from a non-main thread.
    31263126        MediaTime currentTime = MediaTime(gst_segment_to_stream_time(gst_sample_get_segment(sample), GST_FORMAT_TIME, GST_BUFFER_PTS(buffer)), GST_SECOND);
    3127         auto task = holdLock(m_TaskAtMediaTimeSchedulerDataMutex)->checkTaskForScheduling(currentTime);
    3128         if (task.hasValue())
     3127        if (auto task = holdLock(m_TaskAtMediaTimeSchedulerDataMutex)->checkTaskForScheduling(currentTime))
    31293128            RunLoop::main().dispatch(WTFMove(task.value()));
    31303129    }
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMProxyThunder.cpp

    r275599 r278244  
    5656
    5757    auto keyHandle = getOrWaitForKeyHandle(keyID, WTFMove(in.cdmProxyDecryptionClient));
    58     if (!keyHandle.hasValue() || !keyHandle.value()->isStatusCurrentlyValid())
     58    if (!keyHandle.has_value() || !keyHandle.value()->isStatusCurrentlyValid())
    5959        return nullptr;
    6060
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp

    r278185 r278244  
    251251}
    252252
    253 Optional<String> CDMPrivateThunder::sanitizeSessionId(const String& sessionId) const
     253std::optional<String> CDMPrivateThunder::sanitizeSessionId(const String& sessionId) const
    254254{
    255255    return sessionId;
     
    365365    const Ref<SharedBuffer>& payload() const& { ASSERT(m_payload); return m_payload.value(); }
    366366    Ref<SharedBuffer>& payload() & { ASSERT(m_payload); return m_payload.value(); }
    367     bool hasType() const { return m_type.hasValue(); }
     367    bool hasType() const { return m_type.has_value(); }
    368368    WebCore::MediaKeyMessageType type() const { ASSERT(m_type); return m_type.value(); }
    369369    WebCore::MediaKeyMessageType typeOr(WebCore::MediaKeyMessageType alternate) const { return m_type ? m_type.value() : alternate; }
     
    373373private:
    374374    bool m_isValid { false };
    375     Optional<Ref<SharedBuffer>> m_payload;
    376     Optional<WebCore::MediaKeyMessageType> m_type;
     375    std::optional<Ref<SharedBuffer>> m_payload;
     376    std::optional<WebCore::MediaKeyMessageType> m_type;
    377377};
    378378
     
    470470    if (m_doesKeyStoreNeedMerging) {
    471471        m_doesKeyStoreNeedMerging = false;
    472         auto instance = cdmInstanceThunder();
    473         if (instance)
     472        if (auto instance = cdmInstanceThunder())
    474473            instance->mergeKeysFrom(m_keyStore);
    475474    }
     
    675674}
    676675
    677 Optional<CDMInstanceThunder&> CDMInstanceSessionThunder::cdmInstanceThunder() const
    678 {
    679     auto instance = cdmInstanceProxy();
    680     if (!instance)
    681         return std::nullopt;
    682     return static_cast<CDMInstanceThunder&>(*instance);
     676CDMInstanceThunder* CDMInstanceSessionThunder::cdmInstanceThunder() const
     677{
     678    return static_cast<CDMInstanceThunder*>(cdmInstanceProxy());
    683679}
    684680
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.h

    r274719 r278244  
    9999    RefPtr<SharedBuffer> sanitizeInitData(const AtomString& initDataType, const SharedBuffer& initData) const final;
    100100    RefPtr<SharedBuffer> sanitizeResponse(const SharedBuffer&) const final;
    101     Optional<String> sanitizeSessionId(const String&) const final;
     101    std::optional<String> sanitizeSessionId(const String&) const final;
    102102
    103103private:
     
    143143
    144144private:
    145     Optional<CDMInstanceThunder&> cdmInstanceThunder() const;
     145    CDMInstanceThunder* cdmInstanceThunder() const;
    146146
    147147    using Notification = void (CDMInstanceSessionThunder::*)(RefPtr<WebCore::SharedBuffer>&&);
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp

    r277947 r278244  
    395395    auto& gstRegistryScanner = GStreamerRegistryScannerMSE::singleton();
    396396    if (!gstRegistryScanner.isCodecSupported(GStreamerRegistryScanner::Configuration::Decoding, originalMediaType)) {
    397             m_presentationSize = WebCore::FloatSize();
    398             m_streamType = MediaSourceStreamTypeGStreamer::Invalid;
     397        m_presentationSize = FloatSize();
     398        m_streamType = MediaSourceStreamTypeGStreamer::Invalid;
    399399    } else if (doCapsHaveType(m_demuxerSrcPadCaps.get(), GST_VIDEO_CAPS_TYPE_PREFIX)) {
    400         Optional<FloatSize> size = getVideoResolutionFromCaps(m_demuxerSrcPadCaps.get());
    401         if (size.hasValue())
    402             m_presentationSize = size.value();
    403         else
    404             m_presentationSize = WebCore::FloatSize();
    405 
     400        m_presentationSize = getVideoResolutionFromCaps(m_demuxerSrcPadCaps.get()).value_or(FloatSize());
    406401        m_streamType = MediaSourceStreamTypeGStreamer::Video;
    407402    } else {
    408         m_presentationSize = WebCore::FloatSize();
     403        m_presentationSize = FloatSize();
    409404        if (doCapsHaveType(m_demuxerSrcPadCaps.get(), GST_AUDIO_CAPS_TYPE_PREFIX))
    410405            m_streamType = MediaSourceStreamTypeGStreamer::Audio;
     
    437432
    438433    if (doCapsHaveType(caps.get(), GST_VIDEO_CAPS_TYPE_PREFIX)) {
    439         Optional<FloatSize> size = getVideoResolutionFromCaps(caps.get());
    440         if (size.hasValue())
    441             m_presentationSize = size.value();
     434        if (auto size = getVideoResolutionFromCaps(caps.get()))
     435            m_presentationSize = *size;
    442436    }
    443437
     
    471465    }
    472466
    473     auto mediaSample = WebCore::MediaSampleGStreamer::create(WTFMove(sample), m_presentationSize, trackId());
     467    auto mediaSample = MediaSampleGStreamer::create(WTFMove(sample), m_presentationSize, trackId());
    474468
    475469    GST_TRACE("append: trackId=%s PTS=%s DTS=%s DUR=%s presentationSize=%.0fx%.0f",
     
    506500    ASSERT(isMainThread());
    507501
    508     WebCore::SourceBufferPrivateClient::InitializationSegment initializationSegment;
     502    SourceBufferPrivateClient::InitializationSegment initializationSegment;
    509503
    510504    GST_DEBUG("Notifying SourceBuffer for track %s", (m_track) ? m_track->id().string().utf8().data() : nullptr);
     
    513507    switch (m_streamType) {
    514508    case Audio: {
    515         WebCore::SourceBufferPrivateClient::InitializationSegment::AudioTrackInformation info;
     509        SourceBufferPrivateClient::InitializationSegment::AudioTrackInformation info;
    516510        info.track = static_cast<AudioTrackPrivateGStreamer*>(m_track.get());
    517         info.description = WebCore::GStreamerMediaDescription::create(m_demuxerSrcPadCaps.get());
     511        info.description = GStreamerMediaDescription::create(m_demuxerSrcPadCaps.get());
    518512        initializationSegment.audioTracks.append(info);
    519513        break;
    520514    }
    521515    case Video: {
    522         WebCore::SourceBufferPrivateClient::InitializationSegment::VideoTrackInformation info;
     516        SourceBufferPrivateClient::InitializationSegment::VideoTrackInformation info;
    523517        info.track = static_cast<VideoTrackPrivateGStreamer*>(m_track.get());
    524         info.description = WebCore::GStreamerMediaDescription::create(m_demuxerSrcPadCaps.get());
     518        info.description = GStreamerMediaDescription::create(m_demuxerSrcPadCaps.get());
    525519        initializationSegment.videoTracks.append(info);
    526520        break;
     
    777771    switch (m_streamType) {
    778772    case MediaSourceStreamTypeGStreamer::Audio: {
    779         auto specificTrack = WebCore::AudioTrackPrivateGStreamer::create(makeWeakPtr(*m_playerPrivate), id(), sinkSinkPad.get());
     773        auto specificTrack = AudioTrackPrivateGStreamer::create(makeWeakPtr(*m_playerPrivate), id(), sinkSinkPad.get());
    780774        gstreamerTrack = specificTrack.ptr();
    781775        m_track = makeRefPtr(static_cast<TrackPrivateBase*>(specificTrack.ptr()));
     
    783777    }
    784778    case MediaSourceStreamTypeGStreamer::Video: {
    785         auto specificTrack = WebCore::VideoTrackPrivateGStreamer::create(makeWeakPtr(*m_playerPrivate), id(), sinkSinkPad.get());
     779        auto specificTrack = VideoTrackPrivateGStreamer::create(makeWeakPtr(*m_playerPrivate), id(), sinkSinkPad.get());
    786780        gstreamerTrack = specificTrack.ptr();
    787781        m_track = makeRefPtr(static_cast<TrackPrivateBase*>(specificTrack.ptr()));
     
    789783    }
    790784    case MediaSourceStreamTypeGStreamer::Text: {
    791         auto specificTrack = WebCore::InbandTextTrackPrivateGStreamer::create(id(), sinkSinkPad.get());
     785        auto specificTrack = InbandTextTrackPrivateGStreamer::create(id(), sinkSinkPad.get());
    792786        gstreamerTrack = specificTrack.ptr();
    793787        m_track = makeRefPtr(static_cast<TrackPrivateBase*>(specificTrack.ptr()));
     
    907901    GstEvent* event = gst_pad_probe_info_get_event(info);
    908902    GST_DEBUG("Handling event %s on append pipeline appsinkPad", GST_EVENT_TYPE_NAME(event));
    909     WebCore::AppendPipeline* appendPipeline = padProbeInformation->appendPipeline;
     903    AppendPipeline* appendPipeline = padProbeInformation->appendPipeline;
    910904
    911905    switch (GST_EVENT_TYPE(event)) {
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

    r277031 r278244  
    346346    // want to report an initial size for HAVE_METADATA (first initialization segment).
    347347    if (m_videoSize.isEmpty() && doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
    348         Optional<FloatSize> size = getVideoResolutionFromCaps(caps);
    349         if (size.hasValue()) {
    350             m_videoSize = size.value();
     348        if (auto size = getVideoResolutionFromCaps(caps)) {
     349            m_videoSize = *size;
    351350            GST_DEBUG("Setting initial video size: %gx%g", m_videoSize.width(), m_videoSize.height());
    352351        }
  • trunk/Source/WebCore/platform/graphics/transforms/TransformState.h

    r260353 r278244  
    3131#include "LayoutSize.h"
    3232#include "TransformationMatrix.h"
    33 #include <wtf/Optional.h>
     33#include <optional>
    3434
    3535namespace WTF {
     
    8383    }
    8484
    85     void setSecondaryQuad(const Optional<FloatQuad>& quad)
     85    void setSecondaryQuad(const std::optional<FloatQuad>& quad)
    8686    {
    8787        // We must be in a flattened state (no accumulated offset) when setting this secondary quad.
     
    9090    }
    9191
    92     void setLastPlanarSecondaryQuad(const Optional<FloatQuad>&);
     92    void setLastPlanarSecondaryQuad(const std::optional<FloatQuad>&);
    9393
    9494    void move(LayoutUnit x, LayoutUnit y, TransformAccumulation accumulate = FlattenTransform)
     
    105105    FloatPoint lastPlanarPoint() const { return m_lastPlanarPoint; }
    106106    FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; }
    107     Optional<FloatQuad> lastPlanarSecondaryQuad() const { return m_lastPlanarSecondaryQuad; }
    108     bool isMappingSecondaryQuad() const { return m_lastPlanarSecondaryQuad.hasValue(); }
     107    std::optional<FloatQuad> lastPlanarSecondaryQuad() const { return m_lastPlanarSecondaryQuad; }
     108    bool isMappingSecondaryQuad() const { return m_lastPlanarSecondaryQuad.has_value(); }
    109109
    110110    // Return the point or quad mapped through the current transform
    111111    FloatPoint mappedPoint(bool* wasClamped = nullptr) const;
    112112    FloatQuad mappedQuad(bool* wasClamped = nullptr) const;
    113     Optional<FloatQuad> mappedSecondaryQuad(bool* wasClamped = nullptr) const;
     113    std::optional<FloatQuad> mappedSecondaryQuad(bool* wasClamped = nullptr) const;
    114114
    115115    TransformationMatrix* accumulatedTransform() const { return m_accumulatedTransform.get(); }
     
    128128    FloatPoint m_lastPlanarPoint;
    129129    FloatQuad m_lastPlanarQuad;
    130     Optional<FloatQuad> m_lastPlanarSecondaryQuad;
     130    std::optional<FloatQuad> m_lastPlanarSecondaryQuad;
    131131
    132132    // We only allocate the transform if we need to
  • trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm

    r277242 r278244  
    16451645{
    16461646#if ENABLE(VIDEO_PRESENTATION_MODE) && !PLATFORM(WATCHOS)
    1647     if (isPictureInPictureSupported.hasValue())
     1647    if (isPictureInPictureSupported.has_value())
    16481648        return *isPictureInPictureSupported;
    16491649    return [getAVPictureInPictureControllerClass() isPictureInPictureSupported];
  • trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.mm

    r239477 r278244  
    3939NSScrollerStyle ScrollerStyle::recommendedScrollerStyle()
    4040{
    41     if (m_useOverlayScrollbars.hasValue())
     41    if (m_useOverlayScrollbars.has_value())
    4242        return *m_useOverlayScrollbars ? NSScrollerStyleOverlay : NSScrollerStyleLegacy;
    43    
    4443    if (DeprecatedGlobalSettings::usesOverlayScrollbars())
    4544        return NSScrollerStyleOverlay;
  • trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp

    r278185 r278244  
    603603
    604604#if USE(SYSTEM_PREVIEW)
     605
    605606bool ResourceRequestBase::isSystemPreview() const
    606607{
    607     return m_systemPreviewInfo.hasValue();
     608    return m_systemPreviewInfo.has_value();
    608609}
    609610
     
    617618    m_systemPreviewInfo = info;
    618619}
     620
    619621#endif
    620622
  • trunk/Source/WebCore/platform/xr/openxr/OpenXRInputSource.cpp

    r278185 r278244  
    163163
    164164    // Trigger is mandatory in xr-standard mapping.
    165     if (buttons.isEmpty() || !buttons.first().hasValue())
     165    if (buttons.isEmpty() || !buttons.first().has_value())
    166166        return std::nullopt;
    167167
  • trunk/Source/WebCore/rendering/EventRegion.h

    r278185 r278244  
    8989#if ENABLE(EDITABLE_REGION)
    9090    void ensureEditableRegion();
    91     bool hasEditableRegion() const { return m_editableRegion.hasValue(); }
     91    bool hasEditableRegion() const { return m_editableRegion.has_value(); }
    9292    WEBCORE_EXPORT bool containsEditableElementsInRect(const IntRect&) const;
    9393    Vector<IntRect, 1> rectsForEditableElements() const { return m_editableRegion ? m_editableRegion->rects() : Vector<IntRect, 1> { }; }
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.h

    r278185 r278244  
    7474    Optional<LayoutUnit> growthLimitCap() const { return m_growthLimitCap; }
    7575
    76     const GridTrackSize& cachedTrackSize() const
    77     {
    78         ASSERT(m_cachedTrackSize.hasValue());
    79         return m_cachedTrackSize.value();
    80     }
     76    const GridTrackSize& cachedTrackSize() const { return *m_cachedTrackSize; }
    8177    void setCachedTrackSize(const GridTrackSize&);
    8278
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r278185 r278244  
    863863    if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite)
    864864        return false;
    865     bool definite = child.computePercentageLogicalHeight(flexBasis, updateDescendants).hasValue();
     865    bool definite = child.computePercentageLogicalHeight(flexBasis, updateDescendants).has_value();
    866866    if (m_inLayout && (isHorizontalWritingMode() == child.isHorizontalWritingMode())) {
    867867        // We can reach this code even while we're not laying ourselves out, such
  • trunk/Source/WebCore/rendering/RenderListItem.cpp

    r278185 r278244  
    320320            return;
    321321    }
    322     m_valueWasSetExplicitly = value.hasValue();
     322    m_valueWasSetExplicitly = value.has_value();
    323323    m_value = value;
    324324    explicitValueChanged();
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r278185 r278244  
    12381238Color RenderThemeIOS::systemFocusRingColor()
    12391239{
    1240     if (!cachedFocusRingColor().hasValue()) {
     1240    if (!cachedFocusRingColor().has_value()) {
    12411241        // FIXME: Should be using -keyboardFocusIndicatorColor. For now, work around <rdar://problem/50838886>.
    12421242        cachedFocusRingColor() = colorFromUIColor([PAL::getUIColorClass() systemBlueColor]);
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp

    r278219 r278244  
    792792            continue;
    793793        auto isInlineLevelBox = firstChild->isInline();
    794         if (!shouldAllChildrenBeInline.hasValue()) {
     794        if (!shouldAllChildrenBeInline.has_value()) {
    795795            shouldAllChildrenBeInline = isInlineLevelBox;
    796796            continue;
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r272805 r278244  
    314314{
    315315    AffineTransform transform;
    316     if (matrixInit.a.hasValue())
    317         transform.setA(matrixInit.a.value());
    318     if (matrixInit.b.hasValue())
    319         transform.setB(matrixInit.b.value());
    320     if (matrixInit.c.hasValue())
    321         transform.setC(matrixInit.c.value());
    322     if (matrixInit.d.hasValue())
    323         transform.setD(matrixInit.d.value());
    324     if (matrixInit.e.hasValue())
    325         transform.setE(matrixInit.e.value());
    326     if (matrixInit.f.hasValue())
    327         transform.setF(matrixInit.f.value());
     316    if (matrixInit.a)
     317        transform.setA(*matrixInit.a);
     318    if (matrixInit.b)
     319        transform.setB(*matrixInit.b);
     320    if (matrixInit.c)
     321        transform.setC(*matrixInit.c);
     322    if (matrixInit.d)
     323        transform.setD(*matrixInit.d);
     324    if (matrixInit.e)
     325        transform.setE(*matrixInit.e);
     326    if (matrixInit.f)
     327        transform.setF(*matrixInit.f);
    328328    return SVGTransform::create(transform);
    329329}
  • trunk/Source/WebCore/svg/SVGTransform.h

    r258459 r278244  
    7878
    7979        AffineTransform transform;
    80         if (matrixInit.a.hasValue())
     80        if (matrixInit.a)
    8181            transform.setA(matrixInit.a.value());
    82         if (matrixInit.b.hasValue())
     82        if (matrixInit.b)
    8383            transform.setB(matrixInit.b.value());
    84         if (matrixInit.c.hasValue())
     84        if (matrixInit.c)
    8585            transform.setC(matrixInit.c.value());
    86         if (matrixInit.d.hasValue())
     86        if (matrixInit.d)
    8787            transform.setD(matrixInit.d.value());
    88         if (matrixInit.e.hasValue())
     88        if (matrixInit.e)
    8989            transform.setE(matrixInit.e.value());
    90         if (matrixInit.f.hasValue())
     90        if (matrixInit.f)
    9191            transform.setF(matrixInit.f.value());
    9292        m_value.setMatrix(transform);
  • trunk/Source/WebCore/testing/WebFakeXRDevice.cpp

    r278185 r278244  
    214214            PlatformXR::Device::FrameData::View view;
    215215            view.offset = fakeView->offset();
    216             if (fakeView->fieldOfView().hasValue())
     216            if (fakeView->fieldOfView())
    217217                view.projection = { *fakeView->fieldOfView() };
    218218            else
  • trunk/Source/WebDriver/ChangeLog

    r278185 r278244  
     12021-05-28  Darin Adler  <darin@apple.com>
     2
     3        Clients of optional should use has_value instead of relying on hasValue macro
     4        https://bugs.webkit.org/show_bug.cgi?id=226395
     5
     6        Reviewed by Chris Dumez.
     7
     8        * socket/SessionHostSocket.cpp:
     9        (WebDriver::SessionHost::isConnected const): Use has_value.
     10
    1112021-05-27  Darin Adler  <darin@apple.com>
    212
  • trunk/Source/WebDriver/socket/SessionHostSocket.cpp

    r278185 r278244  
    8181bool SessionHost::isConnected() const
    8282{
    83     return m_clientID.hasValue();
     83    return m_clientID.has_value();
    8484}
    8585
  • trunk/Source/WebKit/ChangeLog

    r278235 r278244  
     12021-05-28  Darin Adler  <darin@apple.com>
     2
     3        Clients of optional should use has_value instead of relying on hasValue macro
     4        https://bugs.webkit.org/show_bug.cgi?id=226395
     5
     6        Reviewed by Chris Dumez.
     7
     8        * Platform/IPC/ArgumentCoders.h: Use std::optional; there was no hasValue
     9        in here and I edited it by mistake, but we want to do this eventually.
     10
     11        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: Removed using namespace WebCore.
     12        (IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData): Use has_value.
     13        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm:
     14        (WebKit::XPCServiceInitializerDelegate::getClientSDKVersion): Ditto.
     15
     16        * Shared/WebCoreArgumentCoders.cpp:
     17        (IPC::decodeImage): Changed idiom to not call hasValue.
     18        (IPC::ArgumentCoder<Ref<Font>>::decode): Ditto.
     19
     20        * Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
     21        (WebKit::MediaFormatReader::finishParsing): Use has_value.
     22        (WebKit::MediaFormatReader::copyProperty): Ditto.
     23        (WebKit::MediaFormatReader::copyTrackArray): Ditto.
     24
     25        * Shared/win/WebCoreArgumentCodersWin.cpp:
     26        (IPC::ArgumentCoder<Ref<Font>>::decodePlatformData): Do not call hasValue.
     27
     28        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     29        (-[WKWebViewConfiguration encodeWithCoder:]): Changed idiom to not use hasValue.
     30
     31        * UIProcess/API/glib/InputMethodFilter.cpp:
     32        (WebKit::InputMethodFilter::setState): Use has_value.
     33
     34        * UIProcess/Automation/WebAutomationSession.cpp:
     35        (WebKit::AutomationCommandError::toProtocolString): Changed idiom to not use hasValue.
     36
     37        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
     38        (WebKit::WebPasteboardProxy::determineDataOwner const): Use has_value.
     39
     40        * UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
     41        (WebKit::RemoteInspectorClient::sendWebInspectorEvent): Changed idiom to not use hasValue.
     42        * UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp:
     43        (WebKit::UserMediaPermissionRequestManagerProxy::platformValidateUserMediaRequestConstraints): Ditto.
     44
     45        * WebProcess/GPU/media/MediaSourcePrivateRemote.cpp:
     46        (WebKit::MediaSourcePrivateRemote::addSourceBuffer): Use has_value.
     47        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
     48        (WebKit::WebPage::platformDidReceiveLoadParameters): Ditto.
     49
     50        * WebProcess/cocoa/WebProcessCocoa.mm:
     51        (WebKit::WebProcess::notifyPreferencesChanged): Changed idiom to not
     52        call hasValue.
     53
    1542021-05-28  Wenson Hsieh  <wenson_hsieh@apple.com>
    255
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h

    r278185 r278244  
    6464        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(arrayReference.data()), arrayReference.size() * sizeof(T), alignof(T));
    6565    }
    66     static Optional<ArrayReferenceType> decode(Decoder& decoder)
     66    static std::optional<ArrayReferenceType> decode(Decoder& decoder)
    6767    {
    6868        if (!Extent)
     
    8585        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(arrayReference.data()), arrayReference.size() * sizeof(T), alignof(T));
    8686    }
    87     static Optional<ArrayReferenceType> decode(Decoder& decoder)
     87    static std::optional<ArrayReferenceType> decode(Decoder& decoder)
    8888    {
    8989        uint64_t size;
     
    122122    }
    123123
    124     static Optional<OptionSet<T>> decode(Decoder& decoder)
    125     {
    126         Optional<typename OptionSet<T>::StorageType> value;
     124    static std::optional<OptionSet<T>> decode(Decoder& decoder)
     125    {
     126        std::optional<typename OptionSet<T>::StorageType> value;
    127127        decoder >> value;
    128128        if (!value)
     
    135135};
    136136
    137 template<typename T> struct ArgumentCoder<Optional<T>> {
    138    
    139     template<typename Encoder> static void encode(Encoder& encoder, const Optional<T>& optional)
     137template<typename T> struct ArgumentCoder<std::optional<T>> {
     138   
     139    template<typename Encoder> static void encode(Encoder& encoder, const std::optional<T>& optional)
    140140    {
    141141        if (!optional) {
     
    148148    }
    149149
    150     template<typename Decoder> static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Optional<T>& optional)
     150    template<typename Decoder> static WARN_UNUSED_RETURN bool decode(Decoder& decoder, std::optional<T>& optional)
    151151    {
    152152        bool isEngaged;
     
    167167    }
    168168   
    169     template<typename Decoder> static Optional<Optional<T>> decode(Decoder& decoder)
    170     {
    171         Optional<bool> isEngaged;
     169    template<typename Decoder> static std::optional<std::optional<T>> decode(Decoder& decoder)
     170    {
     171        std::optional<bool> isEngaged;
    172172        decoder >> isEngaged;
    173173        if (!isEngaged)
    174174            return std::nullopt;
    175175        if (*isEngaged) {
    176             Optional<T> value;
     176            std::optional<T> value;
    177177            decoder >> value;
    178178            if (!value)
    179179                return std::nullopt;
    180             return Optional<Optional<T>>(WTFMove(*value));
    181         }
    182         return Optional<Optional<T>>(Optional<T>(std::nullopt));
     180            return std::optional<std::optional<T>>(WTFMove(*value));
     181        }
     182        return std::optional<std::optional<T>>(std::optional<T>(std::nullopt));
    183183    }
    184184};
     
    215215    }
    216216
    217     static Optional<Box<T>> decode(Decoder& decoder)
    218     {
    219         Optional<bool> isEngaged;
     217    static std::optional<Box<T>> decode(Decoder& decoder)
     218    {
     219        std::optional<bool> isEngaged;
    220220        decoder >> isEngaged;
    221221        if (!isEngaged)
    222222            return std::nullopt;
    223223        if (*isEngaged) {
    224             Optional<T> value;
     224            std::optional<T> value;
    225225            decoder >> value;
    226226            if (!value)
    227227                return std::nullopt;
    228             return Optional<Box<T>>(Box<T>::create(WTFMove(*value)));
    229         }
    230         return Optional<Box<T>>(Box<T>(nullptr));
     228            return std::optional<Box<T>>(Box<T>::create(WTFMove(*value)));
     229        }
     230        return std::optional<Box<T>>(Box<T>(nullptr));
    231231    }
    232232};
     
    253253    }
    254254
    255     static Optional<std::pair<T, U>> decode(Decoder& decoder)
    256     {
    257         Optional<T> first;
     255    static std::optional<std::pair<T, U>> decode(Decoder& decoder)
     256    {
     257        std::optional<T> first;
    258258        decoder >> first;
    259259        if (!first)
    260260            return std::nullopt;
    261261       
    262         Optional<U> second;
     262        std::optional<U> second;
    263263        decoder >> second;
    264264        if (!second)
     
    301301template<typename Type, typename... Types>
    302302struct TupleDecoderImpl {
    303     static Optional<std::tuple<Type, Types...>> decode(Decoder& decoder)
    304     {
    305         Optional<Type> optional;
     303    static std::optional<std::tuple<Type, Types...>> decode(Decoder& decoder)
     304    {
     305        std::optional<Type> optional;
    306306        decoder >> optional;
    307307        if (!optional)
    308308            return std::nullopt;
    309309
    310         Optional<std::tuple<Types...>> subTuple = TupleDecoderImpl<Types...>::decode(decoder);
     310        std::optional<std::tuple<Types...>> subTuple = TupleDecoderImpl<Types...>::decode(decoder);
    311311        if (!subTuple)
    312312            return std::nullopt;
     
    318318template<typename Type>
    319319struct TupleDecoderImpl<Type> {
    320     static Optional<std::tuple<Type>> decode(Decoder& decoder)
    321     {
    322         Optional<Type> optional;
     320    static std::optional<std::tuple<Type>> decode(Decoder& decoder)
     321    {
     322        std::optional<Type> optional;
    323323        decoder >> optional;
    324324        if (!optional)
     
    330330template<size_t size, typename... Elements>
    331331struct TupleDecoder {
    332     static Optional<std::tuple<Elements...>> decode(Decoder& decoder)
     332    static std::optional<std::tuple<Elements...>> decode(Decoder& decoder)
    333333    {
    334334        return TupleDecoderImpl<Elements...>::decode(decoder);
     
    338338template<>
    339339struct TupleDecoder<0> {
    340     static Optional<std::tuple<>> decode(Decoder&)
     340    static std::optional<std::tuple<>> decode(Decoder&)
    341341    {
    342342        return std::make_tuple();
     
    351351    }
    352352
    353     static Optional<std::tuple<Elements...>> decode(Decoder& decoder)
     353    static std::optional<std::tuple<Elements...>> decode(Decoder& decoder)
    354354    {
    355355        return TupleDecoder<sizeof...(Elements), Elements...>::decode(decoder);
     
    392392    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector)
    393393    {
    394         Optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> optional;
     394        std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> optional;
    395395        decoder >> optional;
    396396        if (!optional)
     
    400400    }
    401401
    402     static Optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)
     402    static std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)
    403403    {
    404404        uint64_t size;
     
    408408        Vector<T, inlineCapacity, OverflowHandler, minCapacity> vector;
    409409        for (size_t i = 0; i < size; ++i) {
    410             Optional<T> element;
     410            std::optional<T> element;
    411411            decoder >> element;
    412412            if (!element)
     
    454454    }
    455455   
    456     static Optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)
     456    static std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)
    457457    {
    458458        uint64_t decodedSize;
     
    493493    }
    494494
    495     static Optional<HashMapType> decode(Decoder& decoder)
     495    static std::optional<HashMapType> decode(Decoder& decoder)
    496496    {
    497497        uint32_t hashMapSize;
     
    501501        HashMapType hashMap;
    502502        for (uint32_t i = 0; i < hashMapSize; ++i) {
    503             Optional<KeyArg> key;
     503            std::optional<KeyArg> key;
    504504            decoder >> key;
    505505            if (UNLIKELY(!key))
    506506                return std::nullopt;
    507507
    508             Optional<MappedArg> value;
     508            std::optional<MappedArg> value;
    509509            decoder >> value;
    510510            if (UNLIKELY(!value))
     
    525525    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashMapType& hashMap)
    526526    {
    527         Optional<HashMapType> tempHashMap;
     527        std::optional<HashMapType> tempHashMap;
    528528        decoder >> tempHashMap;
    529529        if (!tempHashMap)
     
    546546    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashSetType& hashSet)
    547547    {
    548         Optional<HashSetType> tempHashSet;
     548        std::optional<HashSetType> tempHashSet;
    549549        decoder >> tempHashSet;
    550550        if (!tempHashSet)
     
    555555    }
    556556
    557     static Optional<HashSetType> decode(Decoder& decoder)
     557    static std::optional<HashSetType> decode(Decoder& decoder)
    558558    {
    559559        uint64_t hashSetSize;
     
    563563        HashSetType hashSet;
    564564        for (uint64_t i = 0; i < hashSetSize; ++i) {
    565             Optional<KeyArg> key;
     565            std::optional<KeyArg> key;
    566566            decoder >> key;
    567567            if (!key)
     
    636636    }
    637637
    638     static Optional<Expected<ValueType, ErrorType>> decode(Decoder& decoder)
    639     {
    640         Optional<bool> hasValue;
     638    static std::optional<Expected<ValueType, ErrorType>> decode(Decoder& decoder)
     639    {
     640        std::optional<bool> hasValue;
    641641        decoder >> hasValue;
    642642        if (!hasValue)
     
    644644       
    645645        if (*hasValue) {
    646             Optional<ValueType> value;
     646            std::optional<ValueType> value;
    647647            decoder >> value;
    648648            if (!value)
     
    652652            return expected;
    653653        }
    654         Optional<ErrorType> error;
     654        std::optional<ErrorType> error;
    655655        decoder >> error;
    656656        if (!error)
     
    671671    }
    672672   
    673     static Optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
     673    static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
    674674    {
    675675        if (i == index) {
    676             Optional<typename WTF::variant_alternative<index, WTF::Variant<Types...>>::type> optional;
     676            std::optional<typename WTF::variant_alternative<index, WTF::Variant<Types...>>::type> optional;
    677677            decoder >> optional;
    678678            if (!optional)
     
    692692    }
    693693   
    694     static Optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
     694    static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
    695695    {
    696696        ASSERT_UNUSED(i, !i);
    697         Optional<typename WTF::variant_alternative<0, WTF::Variant<Types...>>::type> optional;
     697        std::optional<typename WTF::variant_alternative<0, WTF::Variant<Types...>>::type> optional;
    698698        decoder >> optional;
    699699        if (!optional)
     
    711711    }
    712712   
    713     static Optional<WTF::Variant<Types...>> decode(Decoder& decoder)
    714     {
    715         Optional<unsigned> i;
     713    static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder)
     714    {
     715        std::optional<unsigned> i;
    716716        decoder >> i;
    717717        if (!i)
     
    724724    static void encode(Encoder&, const WallTime&);
    725725    static WARN_UNUSED_RETURN bool decode(Decoder&, WallTime&);
    726     static Optional<WallTime> decode(Decoder&);
     726    static std::optional<WallTime> decode(Decoder&);
    727727};
    728728
     
    741741    static void encode(Encoder&, const String&);
    742742    static WARN_UNUSED_RETURN bool decode(Decoder&, String&);
    743     static Optional<String> decode(Decoder&);
     743    static std::optional<String> decode(Decoder&);
    744744};
    745745
     
    758758template<> struct ArgumentCoder<Monostate> {
    759759    static void encode(Encoder&, const Monostate&);
    760     static Optional<Monostate> decode(Decoder&);
     760    static std::optional<Monostate> decode(Decoder&);
    761761};
    762762
  • trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm

    r278190 r278244  
    7171
    7272namespace IPC {
    73 using namespace WebCore;
    7473
    7574void ArgumentCoder<WebCore::AttributedString>::encode(Encoder& encoder, const WebCore::AttributedString& attributedString)
     
    7877}
    7978
    80 Optional<WebCore::AttributedString> ArgumentCoder<WebCore::AttributedString>::decode(Decoder& decoder)
     79std::optional<WebCore::AttributedString> ArgumentCoder<WebCore::AttributedString>::decode(Decoder& decoder)
    8180{
    8281    RetainPtr<NSAttributedString> attributedString;
     
    9897}
    9998
    100 Optional<WebCore::PaymentInstallmentConfiguration> ArgumentCoder<WebCore::PaymentInstallmentConfiguration>::decode(Decoder& decoder)
     99std::optional<WebCore::PaymentInstallmentConfiguration> ArgumentCoder<WebCore::PaymentInstallmentConfiguration>::decode(Decoder& decoder)
    101100{
    102101    auto configuration = IPC::decode<PKPaymentInstallmentConfiguration>(decoder, PAL::getPKPaymentInstallmentConfigurationClass());
     
    114113}
    115114
    116 Optional<WebCore::Payment> ArgumentCoder<WebCore::Payment>::decode(Decoder& decoder)
     115std::optional<WebCore::Payment> ArgumentCoder<WebCore::Payment>::decode(Decoder& decoder)
    117116{
    118117    auto payment = IPC::decode<PKPayment>(decoder, PAL::getPKPaymentClass());
     
    120119        return std::nullopt;
    121120
    122     return Payment { WTFMove(*payment) };
     121    return WebCore::Payment { WTFMove(*payment) };
    123122}
    124123
     
    129128}
    130129
    131 Optional<WebCore::PaymentAuthorizationResult> ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode(Decoder& decoder)
    132 {
    133     Optional<PaymentAuthorizationStatus> status;
     130std::optional<WebCore::PaymentAuthorizationResult> ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode(Decoder& decoder)
     131{
     132    std::optional<WebCore::PaymentAuthorizationStatus> status;
    134133    decoder >> status;
    135134    if (!status)
    136135        return std::nullopt;
    137136
    138     Optional<Vector<RefPtr<ApplePayError>>> errors;
     137    std::optional<Vector<RefPtr<WebCore::ApplePayError>>> errors;
    139138    decoder >> errors;
    140139    if (!errors)
     
    149148}
    150149
    151 Optional<WebCore::PaymentContact> ArgumentCoder<WebCore::PaymentContact>::decode(Decoder& decoder)
     150std::optional<WebCore::PaymentContact> ArgumentCoder<WebCore::PaymentContact>::decode(Decoder& decoder)
    152151{
    153152    auto contact = IPC::decode<PKContact>(decoder, PAL::getPKContactClass());
     
    163162}
    164163
    165 Optional<WebCore::PaymentMerchantSession> ArgumentCoder<WebCore::PaymentMerchantSession>::decode(Decoder& decoder)
     164std::optional<WebCore::PaymentMerchantSession> ArgumentCoder<WebCore::PaymentMerchantSession>::decode(Decoder& decoder)
    166165{
    167166    auto paymentMerchantSession = IPC::decode<PKPaymentMerchantSession>(decoder, PAL::getPKPaymentMerchantSessionClass());
     
    177176}
    178177
    179 Optional<WebCore::PaymentMethod> ArgumentCoder<WebCore::PaymentMethod>::decode(Decoder& decoder)
     178std::optional<WebCore::PaymentMethod> ArgumentCoder<WebCore::PaymentMethod>::decode(Decoder& decoder)
    180179{
    181180    auto paymentMethod = IPC::decode<PKPaymentMethod>(decoder, PAL::getPKPaymentMethodClass());
     
    183182        return std::nullopt;
    184183
    185     return PaymentMethod { WTFMove(*paymentMethod) };
    186 }
    187 
    188 void ArgumentCoder<ApplePaySessionPaymentRequest>::encode(Encoder& encoder, const ApplePaySessionPaymentRequest& request)
     184    return WebCore::PaymentMethod { WTFMove(*paymentMethod) };
     185}
     186
     187void ArgumentCoder<WebCore::ApplePaySessionPaymentRequest>::encode(Encoder& encoder, const WebCore::ApplePaySessionPaymentRequest& request)
    189188{
    190189    encoder << request.countryCode();
     
    211210}
    212211
    213 bool ArgumentCoder<ApplePaySessionPaymentRequest>::decode(Decoder& decoder, ApplePaySessionPaymentRequest& request)
     212bool ArgumentCoder<WebCore::ApplePaySessionPaymentRequest>::decode(Decoder& decoder, WebCore::ApplePaySessionPaymentRequest& request)
    214213{
    215214    String countryCode;
     
    223222    request.setCurrencyCode(currencyCode);
    224223
    225     ApplePaySessionPaymentRequest::ContactFields requiredBillingContactFields;
     224    WebCore::ApplePaySessionPaymentRequest::ContactFields requiredBillingContactFields;
    226225    if (!decoder.decode((requiredBillingContactFields)))
    227226        return false;
    228227    request.setRequiredBillingContactFields(requiredBillingContactFields);
    229228
    230     Optional<PaymentContact> billingContact;
     229    std::optional<WebCore::PaymentContact> billingContact;
    231230    decoder >> billingContact;
    232231    if (!billingContact)
     
    234233    request.setBillingContact(*billingContact);
    235234
    236     ApplePaySessionPaymentRequest::ContactFields requiredShippingContactFields;
     235    WebCore::ApplePaySessionPaymentRequest::ContactFields requiredShippingContactFields;
    237236    if (!decoder.decode((requiredShippingContactFields)))
    238237        return false;
    239238    request.setRequiredShippingContactFields(requiredShippingContactFields);
    240239
    241     Optional<PaymentContact> shippingContact;
     240    std::optional<WebCore::PaymentContact> shippingContact;
    242241    decoder >> shippingContact;
    243242    if (!shippingContact)
     
    245244    request.setShippingContact(*shippingContact);
    246245
    247     ApplePaySessionPaymentRequest::MerchantCapabilities merchantCapabilities;
     246    WebCore::ApplePaySessionPaymentRequest::MerchantCapabilities merchantCapabilities;
    248247    if (!decoder.decode(merchantCapabilities))
    249248        return false;
     
    255254    request.setSupportedNetworks(supportedNetworks);
    256255
    257     ApplePaySessionPaymentRequest::ShippingType shippingType;
     256    WebCore::ApplePaySessionPaymentRequest::ShippingType shippingType;
    258257    if (!decoder.decode(shippingType))
    259258        return false;
    260259    request.setShippingType(shippingType);
    261260
    262     Vector<ApplePayShippingMethod> shippingMethods;
     261    Vector<WebCore::ApplePayShippingMethod> shippingMethods;
    263262    if (!decoder.decode(shippingMethods))
    264263        return false;
    265264    request.setShippingMethods(shippingMethods);
    266265
    267     Vector<ApplePayLineItem> lineItems;
     266    Vector<WebCore::ApplePayLineItem> lineItems;
    268267    if (!decoder.decode(lineItems))
    269268        return false;
    270269    request.setLineItems(lineItems);
    271270
    272     Optional<ApplePayLineItem> total;
     271    std::optional<WebCore::ApplePayLineItem> total;
    273272    decoder >> total;
    274273    if (!total)
     
    286285    request.setSupportedCountries(WTFMove(supportedCountries));
    287286
    288     ApplePaySessionPaymentRequest::Requester requester;
     287    WebCore::ApplePaySessionPaymentRequest::Requester requester;
    289288    if (!decoder.decode(requester))
    290289        return false;
     
    292291   
    293292#if ENABLE(APPLE_PAY_INSTALLMENTS)
    294     Optional<WebCore::PaymentInstallmentConfiguration> installmentConfiguration;
     293    std::optional<WebCore::PaymentInstallmentConfiguration> installmentConfiguration;
    295294    decoder >> installmentConfiguration;
    296295    if (!installmentConfiguration)
     
    307306}
    308307
    309 void ArgumentCoder<ApplePaySessionPaymentRequest::ContactFields>::encode(Encoder& encoder, const ApplePaySessionPaymentRequest::ContactFields& contactFields)
     308void ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::ContactFields>::encode(Encoder& encoder, const WebCore::ApplePaySessionPaymentRequest::ContactFields& contactFields)
    310309{
    311310    encoder << contactFields.postalAddress;
     
    316315}
    317316
    318 bool ArgumentCoder<ApplePaySessionPaymentRequest::ContactFields>::decode(Decoder& decoder, ApplePaySessionPaymentRequest::ContactFields& contactFields)
     317bool ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::ContactFields>::decode(Decoder& decoder, WebCore::ApplePaySessionPaymentRequest::ContactFields& contactFields)
    319318{
    320319    if (!decoder.decode(contactFields.postalAddress))
     
    332331}
    333332
    334 void ArgumentCoder<ApplePaySessionPaymentRequest::MerchantCapabilities>::encode(Encoder& encoder, const ApplePaySessionPaymentRequest::MerchantCapabilities& merchantCapabilities)
     333void ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::MerchantCapabilities>::encode(Encoder& encoder, const WebCore::ApplePaySessionPaymentRequest::MerchantCapabilities& merchantCapabilities)
    335334{
    336335    encoder << merchantCapabilities.supports3DS;
     
    340339}
    341340
    342 bool ArgumentCoder<ApplePaySessionPaymentRequest::MerchantCapabilities>::decode(Decoder& decoder, ApplePaySessionPaymentRequest::MerchantCapabilities& merchantCapabilities)
     341bool ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::MerchantCapabilities>::decode(Decoder& decoder, WebCore::ApplePaySessionPaymentRequest::MerchantCapabilities& merchantCapabilities)
    343342{
    344343    if (!decoder.decode(merchantCapabilities.supports3DS))
     
    354353}
    355354
    356 void ArgumentCoder<RefPtr<ApplePayError>>::encode(Encoder& encoder, const RefPtr<ApplePayError>& error)
     355void ArgumentCoder<RefPtr<WebCore::ApplePayError>>::encode(Encoder& encoder, const RefPtr<WebCore::ApplePayError>& error)
    357356{
    358357    encoder << !!error;
     
    361360}
    362361
    363 Optional<RefPtr<ApplePayError>> ArgumentCoder<RefPtr<ApplePayError>>::decode(Decoder& decoder)
    364 {
    365     Optional<bool> isValid;
     362std::optional<RefPtr<WebCore::ApplePayError>> ArgumentCoder<RefPtr<WebCore::ApplePayError>>::decode(Decoder& decoder)
     363{
     364    std::optional<bool> isValid;
    366365    decoder >> isValid;
    367366    if (!isValid)
    368367        return std::nullopt;
    369368
    370     RefPtr<ApplePayError> error;
     369    RefPtr<WebCore::ApplePayError> error;
    371370    if (!*isValid)
    372371        return { nullptr };
    373372
    374     error = ApplePayError::decode(decoder);
     373    error = WebCore::ApplePayError::decode(decoder);
    375374    if (!error)
    376375        return std::nullopt;
     
    383382}
    384383
    385 Optional<WebCore::PaymentSessionError> ArgumentCoder<WebCore::PaymentSessionError>::decode(Decoder& decoder)
     384std::optional<WebCore::PaymentSessionError> ArgumentCoder<WebCore::PaymentSessionError>::decode(Decoder& decoder)
    386385{
    387386    auto platformError = IPC::decode<NSError>(decoder);
     
    413412}
    414413
    415 Optional<FontAttributes> ArgumentCoder<WebCore::FontAttributes>::decodePlatformData(Decoder& decoder, WebCore::FontAttributes& attributes)
     414std::optional<WebCore::FontAttributes> ArgumentCoder<WebCore::FontAttributes>::decodePlatformData(Decoder& decoder, WebCore::FontAttributes& attributes)
    416415{
    417416    if (!IPC::decode(decoder, attributes.font))
     
    420419}
    421420
    422 void ArgumentCoder<Ref<Font>>::encodePlatformData(Encoder& encoder, const Ref<WebCore::Font>& font)
     421void ArgumentCoder<Ref<WebCore::Font>>::encodePlatformData(Encoder& encoder, const Ref<WebCore::Font>& font)
    423422{
    424423    const auto& platformData = font->platformData();
     
    469468}
    470469
    471 Optional<FontPlatformData> ArgumentCoder<Ref<Font>>::decodePlatformData(Decoder& decoder)
    472 {
    473     Optional<FontOrientation> orientation;
     470std::optional<WebCore::FontPlatformData> ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData(Decoder& decoder)
     471{
     472    std::optional<WebCore::FontOrientation> orientation;
    474473    decoder >> orientation;
    475     if (!orientation.hasValue())
    476         return std::nullopt;
    477 
    478     Optional<FontWidthVariant> widthVariant;
     474    if (!orientation)
     475        return std::nullopt;
     476
     477    std::optional<WebCore::FontWidthVariant> widthVariant;
    479478    decoder >> widthVariant;
    480     if (!widthVariant.hasValue())
    481         return std::nullopt;
    482 
    483     Optional<TextRenderingMode> textRenderingMode;
     479    if (!widthVariant)
     480        return std::nullopt;
     481
     482    std::optional<WebCore::TextRenderingMode> textRenderingMode;
    484483    decoder >> textRenderingMode;
    485     if (!textRenderingMode.hasValue())
    486         return std::nullopt;
    487 
    488     Optional<float> size;
     484    if (!textRenderingMode)
     485        return std::nullopt;
     486
     487    std::optional<float> size;
    489488    decoder >> size;
    490     if (!size.hasValue())
    491         return std::nullopt;
    492 
    493     Optional<bool> syntheticBold;
     489    if (!size)
     490        return std::nullopt;
     491
     492    std::optional<bool> syntheticBold;
    494493    decoder >> syntheticBold;
    495     if (!syntheticBold.hasValue())
    496         return std::nullopt;
    497 
    498     Optional<bool> syntheticOblique;
     494    if (!syntheticBold)
     495        return std::nullopt;
     496
     497    std::optional<bool> syntheticOblique;
    499498    decoder >> syntheticOblique;
    500     if (!syntheticOblique.hasValue())
    501         return std::nullopt;
    502 
    503     Optional<RetainPtr<CFDictionaryRef>> attributes;
     499    if (!syntheticOblique)
     500        return std::nullopt;
     501
     502    std::optional<RetainPtr<CFDictionaryRef>> attributes;
    504503    decoder >> attributes;
    505504    if (!attributes)
    506505        return std::nullopt;
    507506
    508     Optional<bool> includesCreationData;
     507    std::optional<bool> includesCreationData;
    509508    decoder >> includesCreationData;
    510     if (!includesCreationData.hasValue())
    511         return std::nullopt;
    512 
    513     if (includesCreationData.value()) {
    514         Optional<Ref<SharedBuffer>> fontFaceData;
     509    if (!includesCreationData)
     510        return std::nullopt;
     511
     512    if (*includesCreationData) {
     513        std::optional<Ref<WebCore::SharedBuffer>> fontFaceData;
    515514        decoder >> fontFaceData;
    516         if (!fontFaceData.hasValue())
     515        if (!fontFaceData)
    517516            return std::nullopt;
    518517
    519         Optional<String> itemInCollection;
     518        std::optional<String> itemInCollection;
    520519        decoder >> itemInCollection;
    521         if (!itemInCollection.hasValue())
     520        if (!itemInCollection)
    522521            return std::nullopt;
    523522
    524         auto fontCustomPlatformData = createFontCustomPlatformData(fontFaceData.value(), itemInCollection.value());
     523        auto fontCustomPlatformData = createFontCustomPlatformData(*fontFaceData, *itemInCollection);
    525524        if (!fontCustomPlatformData)
    526525            return std::nullopt;
     
    529528            return std::nullopt;
    530529        auto fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithAttributes(baseFontDescriptor, attributes->get()));
    531         auto ctFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size.value(), nullptr));
    532 
    533         auto creationData = FontPlatformData::CreationData { fontFaceData.value(), itemInCollection.value() };
    534         return FontPlatformData(ctFont.get(), size.value(), syntheticBold.value(), syntheticOblique.value(), orientation.value(), widthVariant.value(), textRenderingMode.value(), &creationData);
     530        auto ctFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), *size, nullptr));
     531
     532        auto creationData = WebCore::FontPlatformData::CreationData { *fontFaceData, *itemInCollection };
     533        return WebCore::FontPlatformData(ctFont.get(), *size, *syntheticBold, *syntheticOblique, *orientation, *widthVariant, *textRenderingMode, &creationData);
    535534    }
    536535
    537     Optional<String> referenceURL;
     536    std::optional<String> referenceURL;
    538537    decoder >> referenceURL;
    539     if (!referenceURL.hasValue())
    540         return std::nullopt;
    541 
    542     Optional<String> postScriptName;
     538    if (!referenceURL)
     539        return std::nullopt;
     540
     541    std::optional<String> postScriptName;
    543542    decoder >> postScriptName;
    544     if (!postScriptName.hasValue())
    545         return std::nullopt;
    546 
    547     RetainPtr<CTFontDescriptorRef> fontDescriptor = findFontDescriptor(referenceURL.value(), postScriptName.value());
     543    if (!postScriptName)
     544        return std::nullopt;
     545
     546    auto fontDescriptor = findFontDescriptor(*referenceURL, *postScriptName);
    548547    if (!fontDescriptor)
    549548        return std::nullopt;
    550549    fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithAttributes(fontDescriptor.get(), attributes->get()));
    551     auto ctFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size.value(), nullptr));
    552 
    553     return FontPlatformData(ctFont.get(), size.value(), syntheticBold.value(), syntheticOblique.value(), orientation.value(), widthVariant.value(), textRenderingMode.value());
     550    auto ctFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), *size, nullptr));
     551
     552    return WebCore::FontPlatformData(ctFont.get(), *size, *syntheticBold, *syntheticOblique, *orientation, *widthVariant, *textRenderingMode);
    554553}
    555554
     
    618617#if ENABLE(DATA_DETECTION)
    619618
    620 void ArgumentCoder<DataDetectorElementInfo>::encode(Encoder& encoder, const DataDetectorElementInfo& info)
     619void ArgumentCoder<WebCore::DataDetectorElementInfo>::encode(Encoder& encoder, const WebCore::DataDetectorElementInfo& info)
    621620{
    622621    encoder << info.result.get();
     
    624623}
    625624
    626 Optional<DataDetectorElementInfo> ArgumentCoder<DataDetectorElementInfo>::decode(Decoder& decoder)
     625std::optional<WebCore::DataDetectorElementInfo> ArgumentCoder<WebCore::DataDetectorElementInfo>::decode(Decoder& decoder)
    627626{
    628627    auto result = IPC::decode<DDScannerResult>(decoder, PAL::getDDScannerResultClass());
     
    630629        return std::nullopt;
    631630
    632     Optional<IntRect> elementBounds;
     631    std::optional<WebCore::IntRect> elementBounds;
    633632    decoder >> elementBounds;
    634633    if (!elementBounds)
    635634        return std::nullopt;
    636635
    637     return std::make_optional<DataDetectorElementInfo>({ WTFMove(*result), WTFMove(*elementBounds) });
     636    return std::make_optional<WebCore::DataDetectorElementInfo>({ WTFMove(*result), WTFMove(*elementBounds) });
    638637}
    639638
     
    641640
    642641#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    643 void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const MediaPlaybackTargetContext& target)
    644 {
    645     if (target.type() == MediaPlaybackTargetContext::Type::AVOutputContext) {
     642void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const WebCore::MediaPlaybackTargetContext& target)
     643{
     644    if (target.type() == WebCore::MediaPlaybackTargetContext::Type::AVOutputContext) {
    646645        if ([PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
    647646            encoder << target.outputContext();
    648     } else if (target.type() == MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
     647    } else if (target.type() == WebCore::MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
    649648        encoder << target.serializedOutputContext();
    650649        encoder << target.hasActiveRoute();
     
    653652}
    654653
    655 bool ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData(Decoder& decoder, MediaPlaybackTargetContext::Type contextType, MediaPlaybackTargetContext& target)
    656 {
    657     ASSERT(contextType != MediaPlaybackTargetContext::Type::Mock);
    658 
    659     if (contextType == MediaPlaybackTargetContext::Type::AVOutputContext) {
     654bool ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData(Decoder& decoder, WebCore::MediaPlaybackTargetContext::Type contextType, WebCore::MediaPlaybackTargetContext& target)
     655{
     656    ASSERT(contextType != WebCore::MediaPlaybackTargetContext::Type::Mock);
     657
     658    if (contextType == WebCore::MediaPlaybackTargetContext::Type::AVOutputContext) {
    660659        if (![PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
    661660            return false;
     
    669668    }
    670669
    671     if (contextType == MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
     670    if (contextType == WebCore::MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
    672671        RetainPtr<NSData> serializedOutputContext;
    673672        if (!IPC::decode(decoder, serializedOutputContext) || !serializedOutputContext)
     
    688687#if ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION)
    689688
    690 void ArgumentCoder<ImageExtractionDataDetectorInfo>::encodePlatformData(Encoder& encoder, const ImageExtractionDataDetectorInfo& info)
     689void ArgumentCoder<WebCore::ImageExtractionDataDetectorInfo>::encodePlatformData(Encoder& encoder, const WebCore::ImageExtractionDataDetectorInfo& info)
    691690{
    692691    encoder << info.result.get();
    693692}
    694693
    695 bool ArgumentCoder<ImageExtractionDataDetectorInfo>::decodePlatformData(Decoder& decoder, ImageExtractionDataDetectorInfo& result)
     694bool ArgumentCoder<WebCore::ImageExtractionDataDetectorInfo>::decodePlatformData(Decoder& decoder, WebCore::ImageExtractionDataDetectorInfo& result)
    696695{
    697696    auto scannerResult = IPC::decode<DDScannerResult>(decoder, @[ PAL::getDDScannerResultClass() ]);
  • trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm

    r278185 r278244  
    8686    auto version = parseInteger<uint32_t>(xpc_dictionary_get_string(m_initializerMessage, "client-sdk-version"));
    8787    clientSDKVersion = version.value_or(0);
    88     return version.hasValue();
     88    return version.has_value();
    8989}
    9090
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r278185 r278244  
    10671067    Optional<bool> didCreateGraphicsContext;
    10681068    decoder >> didCreateGraphicsContext;
    1069     if (!didCreateGraphicsContext.hasValue() || !didCreateGraphicsContext.value())
     1069    if (!didCreateGraphicsContext || !*didCreateGraphicsContext)
    10701070        return false;
    10711071
     
    11221122    Optional<Font::Origin> origin;
    11231123    decoder >> origin;
    1124     if (!origin.hasValue())
     1124    if (!origin)
    11251125        return std::nullopt;
    11261126
    11271127    Optional<Font::Interstitial> isInterstitial;
    11281128    decoder >> isInterstitial;
    1129     if (!isInterstitial.hasValue())
     1129    if (!isInterstitial)
    11301130        return std::nullopt;
    11311131
    11321132    Optional<Font::Visibility> visibility;
    11331133    decoder >> visibility;
    1134     if (!visibility.hasValue())
     1134    if (!visibility)
    11351135        return std::nullopt;
    11361136
    11371137    Optional<Font::OrientationFallback> isTextOrientationFallback;
    11381138    decoder >> isTextOrientationFallback;
    1139     if (!isTextOrientationFallback.hasValue())
     1139    if (!isTextOrientationFallback)
    11401140        return std::nullopt;
    11411141
    11421142    Optional<RenderingResourceIdentifier> renderingRersouceIdentifier;
    11431143    decoder >> renderingRersouceIdentifier;
    1144     if (!renderingRersouceIdentifier.hasValue())
     1144    if (!renderingRersouceIdentifier)
    11451145        return std::nullopt;
    11461146
    11471147    auto platformData = decodePlatformData(decoder);
    1148     if (!platformData.hasValue())
     1148    if (!platformData)
    11491149        return std::nullopt;
    11501150
  • trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp

    r278223 r278244  
    209209
    210210    Locker locker { m_parseTracksLock };
    211     ASSERT(m_parseTracksStatus.hasValue());
     211    ASSERT(m_parseTracksStatus.has_value());
    212212
    213213    for (auto& trackReader : m_trackReaders)
     
    240240    m_parseTracksCondition.wait(m_parseTracksLock, [&] {
    241241        assertIsHeld(m_parseTracksLock);
    242         return m_parseTracksStatus.hasValue();
     242        return m_parseTracksStatus.has_value();
    243243    });
    244244
     
    260260    m_parseTracksCondition.wait(m_parseTracksLock, [&] {
    261261        assertIsHeld(m_parseTracksLock);
    262         return m_parseTracksStatus.hasValue();
     262        return m_parseTracksStatus.has_value();
    263263    });
    264264
  • trunk/Source/WebKit/Shared/win/WebCoreArgumentCodersWin.cpp

    r278185 r278244  
    4343}
    4444
    45 Optional<FontAttributes> ArgumentCoder<FontAttributes>::decodePlatformData(Decoder&, FontAttributes&)
     45std::optional<FontAttributes> ArgumentCoder<FontAttributes>::decodePlatformData(Decoder&, FontAttributes&)
    4646{
    4747    ASSERT_NOT_REACHED();
     
    5454        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(&logFont), sizeof logFont, 1);
    5555    }
    56     static Optional<LOGFONT> decode(Decoder& decoder)
     56    static std::optional<LOGFONT> decode(Decoder& decoder)
    5757    {
    5858        LOGFONT logFont;
     
    8282}
    8383
    84 Optional<FontPlatformData> ArgumentCoder<Ref<Font>>::decodePlatformData(Decoder& decoder)
     84std::optional<FontPlatformData> ArgumentCoder<Ref<Font>>::decodePlatformData(Decoder& decoder)
    8585{
    86     Optional<float> size;
     86    std::optional<float> size;
    8787    decoder >> size;
    88     if (!size.hasValue())
     88    if (!size)
    8989        return std::nullopt;
    9090
    91     Optional<bool> syntheticBold;
     91    std::optional<bool> syntheticBold;
    9292    decoder >> syntheticBold;
    93     if (!syntheticBold.hasValue())
     93    if (!syntheticBold)
    9494        return std::nullopt;
    9595
    96     Optional<bool> syntheticOblique;
     96    std::optional<bool> syntheticOblique;
    9797    decoder >> syntheticOblique;
    98     if (!syntheticOblique.hasValue())
     98    if (!syntheticOblique)
    9999        return std::nullopt;
    100100
    101     Optional<bool> includesCreationData;
     101    std::optional<bool> includesCreationData;
    102102    decoder >> includesCreationData;
    103     if (!includesCreationData.hasValue())
     103    if (!includesCreationData)
    104104        return std::nullopt;
    105105
     
    108108
    109109    if (includesCreationData.value()) {
    110         Optional<Ref<SharedBuffer>> fontFaceData;
     110        std::optional<Ref<SharedBuffer>> fontFaceData;
    111111        decoder >> fontFaceData;
    112         if (!fontFaceData.hasValue())
     112        if (!fontFaceData)
    113113            return std::nullopt;
    114114
    115         Optional<String> itemInCollection;
     115        std::optional<String> itemInCollection;
    116116        decoder >> itemInCollection;
    117         if (!itemInCollection.hasValue())
     117        if (!itemInCollection)
    118118            return std::nullopt;
    119119
     
    124124    }
    125125
    126     Optional<LOGFONT> logFont;
     126    std::optional<LOGFONT> logFont;
    127127    decoder >> logFont;
    128     if (!logFont.hasValue())
     128    if (!logFont)
    129129        return std::nullopt;
    130130
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r278185 r278244  
    303303    [coder encodeBool:self.suppressesIncrementalRendering forKey:@"suppressesIncrementalRendering"];
    304304
    305     if (_applicationNameForUserAgent.hasValue())
     305    if (_applicationNameForUserAgent)
    306306        [coder encodeObject:self.applicationNameForUserAgent forKey:@"applicationNameForUserAgent"];
    307307
  • trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp

    r260752 r278244  
    8484}
    8585
    86 void InputMethodFilter::setState(Optional<InputMethodState>&& state)
    87 {
    88     bool focusChanged = state.hasValue() != m_state.hasValue();
     86void InputMethodFilter::setState(std::optional<InputMethodState>&& state)
     87{
     88    bool focusChanged = state.has_value() != m_state.has_value();
    8989    if (focusChanged && !state)
    9090        notifyFocusedOut();
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r278185 r278244  
    6363{
    6464    String protocolErrorName = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(type);
    65     if (!message.hasValue())
     65    if (!message)
    6666        return protocolErrorName;
    67 
    68     return makeString(protocolErrorName, errorNameAndDetailsSeparator, message.value());
     67    return makeString(protocolErrorName, errorNameAndDetailsSeparator, *message);
    6968}
    7069   
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm

    r278185 r278244  
    9696}
    9797
    98 Optional<WebPasteboardProxy::PasteboardAccessType> WebPasteboardProxy::accessType(IPC::Connection& connection, const String& pasteboardName) const
     98std::optional<WebPasteboardProxy::PasteboardAccessType> WebPasteboardProxy::accessType(IPC::Connection& connection, const String& pasteboardName) const
    9999{
    100100    MESSAGE_CHECK_WITH_RETURN_VALUE(!pasteboardName.isEmpty(), std::nullopt);
     
    140140}
    141141
    142 void WebPasteboardProxy::getPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
     142void WebPasteboardProxy::getPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
    143143{
    144144    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    155155}
    156156
    157 void WebPasteboardProxy::getPasteboardPathnamesForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, Optional<PageIdentifier> pageID,
     157void WebPasteboardProxy::getPasteboardPathnamesForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, std::optional<PageIdentifier> pageID,
    158158    CompletionHandler<void(Vector<String>&& pathnames, SandboxExtension::HandleArray&& sandboxExtensions)>&& completionHandler)
    159159{
     
    187187}
    188188
    189 void WebPasteboardProxy::getPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, Optional<PageIdentifier> pageID, CompletionHandler<void(String&&)>&& completionHandler)
     189void WebPasteboardProxy::getPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, std::optional<PageIdentifier> pageID, CompletionHandler<void(String&&)>&& completionHandler)
    190190{
    191191    MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ }));
     
    202202}
    203203
    204 void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, Optional<PageIdentifier> pageID, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
     204void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, std::optional<PageIdentifier> pageID, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
    205205{
    206206    MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ }));
     
    217217}
    218218
    219 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, Optional<PageIdentifier> pageID, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
     219void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, std::optional<PageIdentifier> pageID, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
    220220{
    221221    MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ }));
     
    245245}
    246246
    247 void WebPasteboardProxy::getPasteboardChangeCount(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     247void WebPasteboardProxy::getPasteboardChangeCount(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    248248{
    249249    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    257257}
    258258
    259 void WebPasteboardProxy::getPasteboardColor(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(WebCore::Color&&)>&& completionHandler)
     259void WebPasteboardProxy::getPasteboardColor(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(WebCore::Color&&)>&& completionHandler)
    260260{
    261261    if (!canAccessPasteboardData(connection, pasteboardName))
     
    270270}
    271271
    272 void WebPasteboardProxy::getPasteboardURL(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(const String&)>&& completionHandler)
     272void WebPasteboardProxy::getPasteboardURL(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(const String&)>&& completionHandler)
    273273{
    274274    if (!canAccessPasteboardData(connection, pasteboardName))
     
    283283}
    284284
    285 void WebPasteboardProxy::addPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     285void WebPasteboardProxy::addPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    286286{
    287287    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    301301}
    302302
    303 void WebPasteboardProxy::setPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     303void WebPasteboardProxy::setPasteboardTypes(IPC::Connection& connection, const String& pasteboardName, const Vector<String>& pasteboardTypes, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    304304{
    305305    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    319319}
    320320
    321 void WebPasteboardProxy::setPasteboardURL(IPC::Connection& connection, const PasteboardURL& pasteboardURL, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     321void WebPasteboardProxy::setPasteboardURL(IPC::Connection& connection, const PasteboardURL& pasteboardURL, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    322322{
    323323    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    343343}
    344344
    345 void WebPasteboardProxy::setPasteboardColor(IPC::Connection& connection, const String& pasteboardName, const WebCore::Color& color, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     345void WebPasteboardProxy::setPasteboardColor(IPC::Connection& connection, const String& pasteboardName, const WebCore::Color& color, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    346346{
    347347    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    358358}
    359359
    360 void WebPasteboardProxy::setPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const String& string, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     360void WebPasteboardProxy::setPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const String& string, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    361361{
    362362    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    374374}
    375375
    376 void WebPasteboardProxy::containsURLStringSuitableForLoading(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(bool)>&& completionHandler)
     376void WebPasteboardProxy::containsURLStringSuitableForLoading(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(bool)>&& completionHandler)
    377377{
    378378    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    387387}
    388388
    389 void WebPasteboardProxy::urlStringSuitableForLoading(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
     389void WebPasteboardProxy::urlStringSuitableForLoading(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
    390390{
    391391    if (!canAccessPasteboardData(connection, pasteboardName))
     
    402402}
    403403
    404 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::IPCHandle& ipcHandle, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     404void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::IPCHandle& ipcHandle, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    405405{
    406406    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    428428}
    429429
    430 void WebPasteboardProxy::getNumberOfFiles(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(uint64_t)>&& completionHandler)
     430void WebPasteboardProxy::getNumberOfFiles(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(uint64_t)>&& completionHandler)
    431431{
    432432    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    441441}
    442442
    443 void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection& connection, const String& pasteboardName, const String& origin, Optional<PageIdentifier> pageID, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
     443void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection& connection, const String& pasteboardName, const String& origin, std::optional<PageIdentifier> pageID, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
    444444{
    445445    MESSAGE_CHECK_COMPLETION(!origin.isNull(), completionHandler({ }));
     
    456456}
    457457
    458 void WebPasteboardProxy::writeCustomData(IPC::Connection& connection, const Vector<PasteboardCustomData>& data, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
     458void WebPasteboardProxy::writeCustomData(IPC::Connection& connection, const Vector<PasteboardCustomData>& data, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(int64_t)>&& completionHandler)
    459459{
    460460    MESSAGE_CHECK_COMPLETION(!pasteboardName.isEmpty(), completionHandler(0));
     
    471471}
    472472
    473 void WebPasteboardProxy::allPasteboardItemInfo(IPC::Connection& connection, const String& pasteboardName, int64_t changeCount, Optional<PageIdentifier> pageID, CompletionHandler<void(Optional<Vector<PasteboardItemInfo>>&&)>&& completionHandler)
     473void WebPasteboardProxy::allPasteboardItemInfo(IPC::Connection& connection, const String& pasteboardName, int64_t changeCount, std::optional<PageIdentifier> pageID, CompletionHandler<void(std::optional<Vector<PasteboardItemInfo>>&&)>&& completionHandler)
    474474{
    475475    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    484484}
    485485
    486 void WebPasteboardProxy::informationForItemAtIndex(IPC::Connection& connection, size_t index, const String& pasteboardName, int64_t changeCount, Optional<PageIdentifier> pageID, CompletionHandler<void(Optional<PasteboardItemInfo>&&)>&& completionHandler)
     486void WebPasteboardProxy::informationForItemAtIndex(IPC::Connection& connection, size_t index, const String& pasteboardName, int64_t changeCount, std::optional<PageIdentifier> pageID, CompletionHandler<void(std::optional<PasteboardItemInfo>&&)>&& completionHandler)
    487487{
    488488    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    497497}
    498498
    499 void WebPasteboardProxy::getPasteboardItemsCount(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(uint64_t)>&& completionHandler)
     499void WebPasteboardProxy::getPasteboardItemsCount(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(uint64_t)>&& completionHandler)
    500500{
    501501    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    510510}
    511511
    512 void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(String&&)>&& completionHandler)
     512void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(String&&)>&& completionHandler)
    513513{
    514514    MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ }));
     
    525525}
    526526
    527 void WebPasteboardProxy::readURLFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
     527void WebPasteboardProxy::readURLFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(String&& url, String&& title)>&& completionHandler)
    528528{
    529529    if (!canAccessPasteboardData(connection, pasteboardName))
     
    540540}
    541541
    542 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
     542void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
    543543{
    544544    MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ }));
     
    568568}
    569569
    570 void WebPasteboardProxy::containsStringSafeForDOMToReadForType(IPC::Connection& connection, const String& type, const String& pasteboardName, Optional<PageIdentifier> pageID, CompletionHandler<void(bool)>&& completionHandler)
     570void WebPasteboardProxy::containsStringSafeForDOMToReadForType(IPC::Connection& connection, const String& type, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(bool)>&& completionHandler)
    571571{
    572572    if (!canAccessPasteboardTypes(connection, pasteboardName))
     
    583583#if PLATFORM(IOS_FAMILY)
    584584
    585 void WebPasteboardProxy::writeURLToPasteboard(IPC::Connection& connection, const PasteboardURL& url, const String& pasteboardName, Optional<PageIdentifier> pageID)
     585void WebPasteboardProxy::writeURLToPasteboard(IPC::Connection& connection, const PasteboardURL& url, const String& pasteboardName, std::optional<PageIdentifier> pageID)
    586586{
    587587    MESSAGE_CHECK(!pasteboardName.isEmpty());
     
    599599}
    600600
    601 void WebPasteboardProxy::writeWebContentToPasteboard(IPC::Connection& connection, const WebCore::PasteboardWebContent& content, const String& pasteboardName, Optional<PageIdentifier> pageID)
     601void WebPasteboardProxy::writeWebContentToPasteboard(IPC::Connection& connection, const WebCore::PasteboardWebContent& content, const String& pasteboardName, std::optional<PageIdentifier> pageID)
    602602{
    603603    MESSAGE_CHECK(!pasteboardName.isEmpty());
     
    615615}
    616616
    617 void WebPasteboardProxy::writeImageToPasteboard(IPC::Connection& connection, const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName, Optional<PageIdentifier> pageID)
     617void WebPasteboardProxy::writeImageToPasteboard(IPC::Connection& connection, const WebCore::PasteboardImage& pasteboardImage, const String& pasteboardName, std::optional<PageIdentifier> pageID)
    618618{
    619619    MESSAGE_CHECK(!pasteboardName.isEmpty());
     
    631631}
    632632
    633 void WebPasteboardProxy::writeStringToPasteboard(IPC::Connection& connection, const String& pasteboardType, const String& text, const String& pasteboardName, Optional<PageIdentifier> pageID)
     633void WebPasteboardProxy::writeStringToPasteboard(IPC::Connection& connection, const String& pasteboardType, const String& text, const String& pasteboardName, std::optional<PageIdentifier> pageID)
    634634{
    635635    MESSAGE_CHECK(!pasteboardName.isEmpty());
     
    648648}
    649649
    650 void WebPasteboardProxy::updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName, Optional<PageIdentifier>)
     650void WebPasteboardProxy::updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName, std::optional<PageIdentifier>)
    651651{
    652652    PlatformPasteboard(pasteboardName).updateSupportedTypeIdentifiers(identifiers);
     
    655655#endif // PLATFORM(IOS_FAMILY)
    656656
    657 Optional<DataOwnerType> WebPasteboardProxy::determineDataOwner(IPC::Connection& connection, const String& pasteboardName, Optional<PageIdentifier> pageID, PasteboardAccessIntent intent) const
     657std::optional<DataOwnerType> WebPasteboardProxy::determineDataOwner(IPC::Connection& connection, const String& pasteboardName, std::optional<PageIdentifier> pageID, PasteboardAccessIntent intent) const
    658658{
    659659    MESSAGE_CHECK_WITH_RETURN_VALUE(!pasteboardName.isEmpty(), std::nullopt);
     
    666666
    667667#if HAVE(PASTEBOARD_DATA_OWNER)
    668     Optional<DataOwnerType> result;
     668    std::optional<DataOwnerType> result;
    669669    for (auto* page : process->pages()) {
    670670        if (page->webPageID() == *pageID) {
     
    675675    // If this message check is hit, then the incoming web page ID doesn't correspond to any page
    676676    // currently known to the UI process.
    677     MESSAGE_CHECK_WITH_RETURN_VALUE(result.hasValue(), std::nullopt);
     677    MESSAGE_CHECK_WITH_RETURN_VALUE(result.has_value(), std::nullopt);
    678678    return result;
    679679#else
     
    709709}
    710710
    711 Optional<WebPasteboardProxy::PasteboardAccessType> WebPasteboardProxy::PasteboardAccessInformation::accessType(WebProcessProxy& process) const
     711std::optional<WebPasteboardProxy::PasteboardAccessType> WebPasteboardProxy::PasteboardAccessInformation::accessType(WebProcessProxy& process) const
    712712{
    713713    auto matchIndex = processes.findMatching([&](auto& processAndType) {
  • trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp

    r277740 r278244  
    123123{
    124124    ASSERT(isMainRunLoop());
    125     ASSERT(m_connectionID.hasValue());
     125    ASSERT(m_connectionID);
    126126    auto message = event.utf8();
    127127    send(m_connectionID.value(), reinterpret_cast<const uint8_t*>(message.data()), message.length());
  • trunk/Source/WebKit/UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp

    r271513 r278244  
    3030void UserMediaPermissionRequestManagerProxy::platformValidateUserMediaRequestConstraints(RealtimeMediaSourceCenter::ValidConstraintsHandler&& validHandler, RealtimeMediaSourceCenter::InvalidConstraintsHandler&& invalidHandler, String&& deviceIDHashSalt)
    3131{
    32     m_page.process().connection()->sendWithAsyncReply(Messages::UserMediaCaptureManager::ValidateUserMediaRequestConstraints(m_currentUserMediaRequest->userRequest(), deviceIDHashSalt), [validHandler = WTFMove(validHandler), invalidHandler = WTFMove(invalidHandler)](Optional<String> invalidConstraint, Vector<WebCore::CaptureDevice> audioDevices, Vector<WebCore::CaptureDevice> videoDevices, Optional<String> deviceIdentifierHashSalt) mutable {
    33         if (invalidConstraint.hasValue())
     32    m_page.process().connection()->sendWithAsyncReply(Messages::UserMediaCaptureManager::ValidateUserMediaRequestConstraints(m_currentUserMediaRequest->userRequest(), deviceIDHashSalt), [validHandler = WTFMove(validHandler), invalidHandler = WTFMove(invalidHandler)](std::optional<String> invalidConstraint, Vector<WebCore::CaptureDevice> audioDevices, Vector<WebCore::CaptureDevice> videoDevices, Optional<String> deviceIdentifierHashSalt) mutable {
     33        if (invalidConstraint)
    3434            invalidHandler(*invalidConstraint);
    3535        else
  • trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.cpp

    r276367 r278244  
    9999        return status;
    100100
    101     Optional<RemoteSourceBufferIdentifier> remoteSourceBufferIdentifier;
     101    std::optional<RemoteSourceBufferIdentifier> remoteSourceBufferIdentifier;
    102102    m_gpuProcessConnection->connection().sendSync(Messages::RemoteMediaSourceProxy::AddSourceBuffer(contentType), Messages::RemoteMediaSourceProxy::AddSourceBuffer::Reply(status, remoteSourceBufferIdentifier), m_identifier);
    103103
    104104    if (status == AddStatus::Ok) {
    105         ASSERT(remoteSourceBufferIdentifier.hasValue());
     105        ASSERT(remoteSourceBufferIdentifier.has_value());
    106106        auto newSourceBuffer = SourceBufferPrivateRemote::create(*m_gpuProcessConnection, *remoteSourceBufferIdentifier, *this, *m_mediaPlayerPrivate);
    107107        outPrivate = newSourceBuffer.copyRef();
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

    r278190 r278244  
    8888    if (parameters.contentFilterExtensionHandle)
    8989        SandboxExtension::consumePermanently(*parameters.contentFilterExtensionHandle);
    90     ParentalControlsContentFilter::setHasConsumedSandboxExtension(parameters.contentFilterExtensionHandle.hasValue());
     90    ParentalControlsContentFilter::setHasConsumedSandboxExtension(parameters.contentFilterExtensionHandle.has_value());
    9191
    9292    if (parameters.frontboardServiceExtensionHandle)
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r278185 r278244  
    11431143void WebProcess::notifyPreferencesChanged(const String& domain, const String& key, const Optional<String>& encodedValue)
    11441144{
    1145     if (!encodedValue.hasValue()) {
     1145    if (!encodedValue) {
    11461146        setPreferenceValue(domain, key, nil);
    11471147        dispatchSimulatedNotificationsForPreferenceChange(key);
  • trunk/Tools/ChangeLog

    r278236 r278244  
     12021-05-28  Darin Adler  <darin@apple.com>
     2
     3        Clients of optional should use has_value instead of relying on hasValue macro
     4        https://bugs.webkit.org/show_bug.cgi?id=226395
     5
     6        Reviewed by Chris Dumez.
     7
     8        * TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp: Use has_value.
     9        * TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp: Ditto.
     10        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp: Ditto.
     11        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
     12        (AudioRenderingWebViewTest::handleStart): Ditto.
     13        * WebKitTestRunner/GeolocationProviderMock.cpp:
     14        (WTR::GeolocationProviderMock::setPosition): Ditto.
     15        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
     16        (-[TestRunnerWKWebView canPerformAction:withSender:]): Ditto.
     17
    1182021-05-28  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp

    r239477 r278244  
    6464
    6565    for (const UintTestCase& testCase : kUintTestCases) {
    66         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
    67         ASSERT_TRUE(cbor.hasValue());
     66        std::optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
     67        ASSERT_TRUE(cbor.has_value());
    6868        ASSERT_TRUE(cbor.value().type() == CBORValue::Type::Unsigned);
    6969        EXPECT_EQ(cbor.value().getInteger(), testCase.value);
     
    109109    CBORReader::DecoderError errorCode;
    110110    for (const auto& nonMinimalUint : nonMinimalUintEncodings) {
    111         Optional<CBORValue> cbor = CBORReader::read(nonMinimalUint, &errorCode);
    112         EXPECT_FALSE(cbor.hasValue());
     111        std::optional<CBORValue> cbor = CBORReader::read(nonMinimalUint, &errorCode);
     112        EXPECT_FALSE(cbor.has_value());
    113113        EXPECT_TRUE(errorCode == CBORReader::DecoderError::NonMinimalCBOREncoding);
    114114    }
     
    135135
    136136    for (const NegativeIntTestCase& testCase : kNegativeIntTestCases) {
    137         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
    138         ASSERT_TRUE(cbor.hasValue());
     137        std::optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
     138        ASSERT_TRUE(cbor.has_value());
    139139        ASSERT_TRUE(cbor.value().type() == CBORValue::Type::Negative);
    140140        EXPECT_EQ(cbor.value().getInteger(), testCase.negativeInt);
     
    155155
    156156    for (const ByteTestCase& testCase : kByteStringTestCases) {
    157         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
    158         ASSERT_TRUE(cbor.hasValue());
     157        std::optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
     158        ASSERT_TRUE(cbor.has_value());
    159159        ASSERT_TRUE(cbor.value().type() == CBORValue::Type::ByteString);
    160160        EXPECT_TRUE(cbor.value().getByteString() == testCase.value);
     
    180180
    181181    for (const StringTestCase& testCase : kStringTestCases) {
    182         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
    183         ASSERT_TRUE(cbor.hasValue());
     182        std::optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
     183        ASSERT_TRUE(cbor.has_value());
    184184        ASSERT_TRUE(cbor.value().type() == CBORValue::Type::String);
    185185        EXPECT_TRUE(cbor.value().getString() == testCase.value);
     
    208208
    209209    for (const auto& testCase : kStringTestCases) {
    210         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
    211         ASSERT_TRUE(cbor.hasValue());
     210        std::optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
     211        ASSERT_TRUE(cbor.has_value());
    212212        ASSERT_TRUE(cbor.value().type() == CBORValue::Type::String);
    213213        EXPECT_TRUE(cbor.value().getString() == testCase.value);
     
    225225    };
    226226    CBORReader::DecoderError errorCode;
    227     Optional<CBORValue> cbor = CBORReader::read(stringWithInvalidContinuationByte, &errorCode);
    228     EXPECT_FALSE(cbor.hasValue());
     227    std::optional<CBORValue> cbor = CBORReader::read(stringWithInvalidContinuationByte, &errorCode);
     228    EXPECT_FALSE(cbor.has_value());
    229229    EXPECT_TRUE(errorCode == CBORReader::DecoderError::InvalidUTF8);
    230230}
     
    239239    };
    240240
    241     Optional<CBORValue> cbor = CBORReader::read(kArrayTestCaseCBOR);
    242     ASSERT_TRUE(cbor.hasValue());
     241    std::optional<CBORValue> cbor = CBORReader::read(kArrayTestCaseCBOR);
     242    ASSERT_TRUE(cbor.has_value());
    243243    const CBORValue cborArray = WTFMove(cbor.value());
    244244    ASSERT_TRUE(cborArray.type() == CBORValue::Type::Array);
     
    269269    };
    270270
    271     Optional<CBORValue> cbor = CBORReader::read(kMapTestCaseCBOR);
    272     ASSERT_TRUE(cbor.hasValue());
     271    std::optional<CBORValue> cbor = CBORReader::read(kMapTestCaseCBOR);
     272    ASSERT_TRUE(cbor.has_value());
    273273    const CBORValue cborVal = WTFMove(cbor.value());
    274274    ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     
    313313    };
    314314
    315     Optional<CBORValue> cbor = CBORReader::read(kMapWithIntegerKeyCBOR);
    316     ASSERT_TRUE(cbor.hasValue());
     315    std::optional<CBORValue> cbor = CBORReader::read(kMapWithIntegerKeyCBOR);
     316    ASSERT_TRUE(cbor.has_value());
    317317    const CBORValue cborVal = WTFMove(cbor.value());
    318318    ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     
    353353    };
    354354
    355     Optional<CBORValue> cbor = CBORReader::read(kMapArrayTestCaseCBOR);
    356     ASSERT_TRUE(cbor.hasValue());
     355    std::optional<CBORValue> cbor = CBORReader::read(kMapArrayTestCaseCBOR);
     356    ASSERT_TRUE(cbor.has_value());
    357357    const CBORValue cborVal = WTFMove(cbor.value());
    358358    ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     
    392392    };
    393393
    394     Optional<CBORValue> cbor = CBORReader::read(kNestedMapTestCase);
    395     ASSERT_TRUE(cbor.hasValue());
     394    std::optional<CBORValue> cbor = CBORReader::read(kNestedMapTestCase);
     395    ASSERT_TRUE(cbor.has_value());
    396396    const CBORValue cborVal = WTFMove(cbor.value());
    397397    ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     
    429429    };
    430430
    431     Optional<CBORValue> maxPositiveInt = CBORReader::read(kMaxPositiveInt);
    432     ASSERT_TRUE(maxPositiveInt.hasValue());
     431    std::optional<CBORValue> maxPositiveInt = CBORReader::read(kMaxPositiveInt);
     432    ASSERT_TRUE(maxPositiveInt.has_value());
    433433    EXPECT_EQ(maxPositiveInt.value().getInteger(), INT64_MAX);
    434434
    435     Optional<CBORValue> minNegativeInt = CBORReader::read(kMinNegativeInt);
    436     ASSERT_TRUE(minNegativeInt.hasValue());
     435    std::optional<CBORValue> minNegativeInt = CBORReader::read(kMinNegativeInt);
     436    ASSERT_TRUE(minNegativeInt.has_value());
    437437    EXPECT_EQ(minNegativeInt.value().getInteger(), INT64_MIN);
    438438}
     
    449449
    450450    CBORReader::DecoderError errorCode;
    451     Optional<CBORValue> positiveIntOutOfRangeCBOR = CBORReader::read(kOutOfRangePositiveInt, &errorCode);
     451    std::optional<CBORValue> positiveIntOutOfRangeCBOR = CBORReader::read(kOutOfRangePositiveInt, &errorCode);
    452452    EXPECT_FALSE(positiveIntOutOfRangeCBOR);
    453453    EXPECT_TRUE(errorCode == CBORReader::DecoderError::OutOfRangeIntegerValue);
    454454
    455     Optional<CBORValue> negativeIntOutOfRangeCBOR = CBORReader::read(kOutOfRangeNegativeInt, &errorCode);
     455    std::optional<CBORValue> negativeIntOutOfRangeCBOR = CBORReader::read(kOutOfRangeNegativeInt, &errorCode);
    456456    EXPECT_FALSE(negativeIntOutOfRangeCBOR);
    457457    EXPECT_TRUE(errorCode == CBORReader::DecoderError::OutOfRangeIntegerValue);
     
    471471
    472472    for (const auto& testCase : kSimpleValueTestCases) {
    473         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
    474         ASSERT_TRUE(cbor.hasValue());
     473        std::optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
     474        ASSERT_TRUE(cbor.has_value());
    475475        ASSERT_TRUE(cbor.value().type() == CBORValue::Type::SimpleValue);
    476476        ASSERT_TRUE(cbor.value().getSimpleValue() == testCase.value);
     
    491491    for (const auto& unsupported_floating_point : floatingPointCbors) {
    492492        CBORReader::DecoderError errorCode;
    493         Optional<CBORValue> cbor = CBORReader::read(unsupported_floating_point, &errorCode);
    494         EXPECT_FALSE(cbor.hasValue());
     493        std::optional<CBORValue> cbor = CBORReader::read(unsupported_floating_point, &errorCode);
     494        EXPECT_FALSE(cbor.has_value());
    495495        EXPECT_TRUE(errorCode == CBORReader::DecoderError::UnsupportedFloatingPointValue);
    496496    }
     
    517517    for (const auto& incomplete_data : incompleteCborList) {
    518518        CBORReader::DecoderError errorCode;
    519         Optional<CBORValue> cbor = CBORReader::read(incomplete_data, &errorCode);
    520         EXPECT_FALSE(cbor.hasValue());
     519        std::optional<CBORValue> cbor = CBORReader::read(incomplete_data, &errorCode);
     520        EXPECT_FALSE(cbor.has_value());
    521521        EXPECT_TRUE(errorCode == CBORReader::DecoderError::IncompleteCBORData);
    522522    }
     
    538538
    539539    CBORReader::DecoderError errorCode;
    540     Optional<CBORValue> cbor = CBORReader::read(kMapWithUintKey, &errorCode);
    541     EXPECT_FALSE(cbor.hasValue());
     540    std::optional<CBORValue> cbor = CBORReader::read(kMapWithUintKey, &errorCode);
     541    EXPECT_FALSE(cbor.has_value());
    542542    EXPECT_TRUE(errorCode == CBORReader::DecoderError::IncorrectMapKeyType);
    543543}
     
    567567    for (const auto& incorrect_cbor : kUnknownAdditionalInfoList) {
    568568        CBORReader::DecoderError errorCode;
    569         Optional<CBORValue> cbor = CBORReader::read(incorrect_cbor, &errorCode);
    570         EXPECT_FALSE(cbor.hasValue());
     569        std::optional<CBORValue> cbor = CBORReader::read(incorrect_cbor, &errorCode);
     570        EXPECT_FALSE(cbor.has_value());
    571571        EXPECT_TRUE(errorCode == CBORReader::DecoderError::UnknownAdditionalInfo);
    572572    }
     
    590590    for (const auto& zeroDepthData : kZeroDepthCBORList) {
    591591        CBORReader::DecoderError errorCode;
    592         Optional<CBORValue> cbor = CBORReader::read(zeroDepthData, &errorCode, 0);
    593         EXPECT_TRUE(cbor.hasValue());
     592        std::optional<CBORValue> cbor = CBORReader::read(zeroDepthData, &errorCode, 0);
     593        EXPECT_TRUE(cbor.has_value());
    594594        EXPECT_TRUE(errorCode == CBORReader::DecoderError::CBORNoError);
    595595    }
     
    610610
    611611    CBORReader::DecoderError errorCode;
    612     Optional<CBORValue> cborSingleLayerMax = CBORReader::read(kNestedCBORData, &errorCode, 1);
    613     EXPECT_FALSE(cborSingleLayerMax.hasValue());
     612    std::optional<CBORValue> cborSingleLayerMax = CBORReader::read(kNestedCBORData, &errorCode, 1);
     613    EXPECT_FALSE(cborSingleLayerMax.has_value());
    614614    EXPECT_TRUE(errorCode == CBORReader::DecoderError::TooMuchNesting);
    615615
    616     Optional<CBORValue> cborDoubleLayerMax = CBORReader::read(kNestedCBORData, &errorCode, 2);
    617     EXPECT_TRUE(cborDoubleLayerMax.hasValue());
     616    std::optional<CBORValue> cborDoubleLayerMax = CBORReader::read(kNestedCBORData, &errorCode, 2);
     617    EXPECT_TRUE(cborDoubleLayerMax.has_value());
    618618    EXPECT_TRUE(errorCode == CBORReader::DecoderError::CBORNoError);
    619619}
     
    647647    CBORReader::DecoderError errorCode;
    648648    for (const auto& unsortedMap : kMapsWithUnsortedKeys) {
    649         Optional<CBORValue> cbor =
     649        std::optional<CBORValue> cbor =
    650650        CBORReader::read(unsortedMap, &errorCode);
    651         EXPECT_FALSE(cbor.hasValue());
     651        EXPECT_FALSE(cbor.has_value());
    652652        EXPECT_TRUE(errorCode == CBORReader::DecoderError::OutOfOrderKey);
    653653    }
     
    679679    CBORReader::DecoderError errorCode;
    680680
    681     Optional<CBORValue> cbor = CBORReader::read(kMapWithDuplicateKey, &errorCode);
    682     EXPECT_FALSE(cbor.hasValue());
     681    std::optional<CBORValue> cbor = CBORReader::read(kMapWithDuplicateKey, &errorCode);
     682    EXPECT_FALSE(cbor.has_value());
    683683    EXPECT_TRUE(errorCode == CBORReader::DecoderError::DuplicateKey);
    684684}
     
    699699    CBORReader::DecoderError errorCode;
    700700    for (const auto& cbor_byte : utf8CharacterEncodings) {
    701         Optional<CBORValue> correctlyEncodedCbor = CBORReader::read(cbor_byte, &errorCode);
    702         EXPECT_TRUE(correctlyEncodedCbor.hasValue());
     701        std::optional<CBORValue> correctlyEncodedCbor = CBORReader::read(cbor_byte, &errorCode);
     702        EXPECT_TRUE(correctlyEncodedCbor.has_value());
    703703        EXPECT_TRUE(errorCode == CBORReader::DecoderError::CBORNoError);
    704704    }
     
    706706    // Incorrect UTF8 encoding referenced by section 3.5.3 of the stress test.
    707707    Vector<uint8_t> impossible_utf_byte { 0x64, 0xfe, 0xfe, 0xff, 0xff };
    708     Optional<CBORValue> incorrectlyEncodedCbor = CBORReader::read(impossible_utf_byte, &errorCode);
     708    std::optional<CBORValue> incorrectlyEncodedCbor = CBORReader::read(impossible_utf_byte, &errorCode);
    709709    EXPECT_FALSE(incorrectlyEncodedCbor);
    710710    EXPECT_TRUE(errorCode == CBORReader::DecoderError::InvalidUTF8);
     
    728728    for (const auto& extraneous_cborData : zeroPaddedCborList) {
    729729        CBORReader::DecoderError errorCode;
    730         Optional<CBORValue> cbor = CBORReader::read(extraneous_cborData, &errorCode);
    731         EXPECT_FALSE(cbor.hasValue());
     730        std::optional<CBORValue> cbor = CBORReader::read(extraneous_cborData, &errorCode);
     731        EXPECT_FALSE(cbor.has_value());
    732732        EXPECT_TRUE(errorCode == CBORReader::DecoderError::ExtraneousData);
    733733    }
     
    759759    for (const auto& unsupportedSimpleVal : unsupportedSimpleValues) {
    760760        CBORReader::DecoderError errorCode;
    761         Optional<CBORValue> cbor = CBORReader::read(unsupportedSimpleVal, &errorCode);
    762         EXPECT_FALSE(cbor.hasValue());
     761        std::optional<CBORValue> cbor = CBORReader::read(unsupportedSimpleVal, &errorCode);
     762        EXPECT_FALSE(cbor.has_value());
    763763        EXPECT_TRUE(errorCode == CBORReader::DecoderError::UnsupportedSimpleValue);
    764764    }
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp

    r239477 r278244  
    8282    for (const UintTestCase& testCase : kUintTestCases) {
    8383        auto cbor = CBORWriter::write(CBORValue(testCase.value));
    84         ASSERT_TRUE(cbor.hasValue());
     84        ASSERT_TRUE(cbor.has_value());
    8585        EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
    8686    }
     
    109109    for (const auto& testCase : kNegativeIntTestCases) {
    110110        auto cbor = CBORWriter::write(CBORValue(testCase.negativeInt));
    111         ASSERT_TRUE(cbor.hasValue());
     111        ASSERT_TRUE(cbor.has_value());
    112112        EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
    113113    }
     
    128128    for (const BytesTestCase& testCase : kBytesTestCases) {
    129129        auto cbor = CBORWriter::write(CBORValue(testCase.bytes));
    130         ASSERT_TRUE(cbor.hasValue());
     130        ASSERT_TRUE(cbor.has_value());
    131131        EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
    132132    }
     
    152152    for (const StringTestCase& testCase : kStringTestCases) {
    153153        auto cbor = CBORWriter::write(CBORValue(testCase.string));
    154         ASSERT_TRUE(cbor.hasValue());
     154        ASSERT_TRUE(cbor.has_value());
    155155        EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
    156156    }
     
    169169        array.append(CBORValue(i));
    170170    auto cbor = CBORWriter::write(CBORValue(array));
    171     ASSERT_TRUE(cbor.hasValue());
     171    ASSERT_TRUE(cbor.has_value());
    172172    EXPECT_TRUE(eq(cbor.value(), kArrayTestCaseCbor, sizeof(kArrayTestCaseCbor)));
    173173}
     
    279279    map[CBORValue(std::numeric_limits<int64_t>::max())] = CBORValue("j");
    280280    auto cbor = CBORWriter::write(CBORValue(map));
    281     ASSERT_TRUE(cbor.hasValue());
     281    ASSERT_TRUE(cbor.has_value());
    282282    EXPECT_TRUE(eq(cbor.value(), kMapTestCaseCbor, sizeof(kMapTestCaseCbor)));
    283283}
     
    302302    map[CBORValue("b")] = CBORValue(array);
    303303    auto cbor = CBORWriter::write(CBORValue(map));
    304     ASSERT_TRUE(cbor.hasValue());
     304    ASSERT_TRUE(cbor.has_value());
    305305    EXPECT_TRUE(eq(cbor.value(), kMapArrayTestCaseCbor, sizeof(kMapArrayTestCaseCbor)));
    306306}
     
    328328    map[CBORValue("b")] = CBORValue(nestedMap);
    329329    auto cbor = CBORWriter::write(CBORValue(map));
    330     ASSERT_TRUE(cbor.hasValue());
     330    ASSERT_TRUE(cbor.has_value());
    331331    EXPECT_TRUE(eq(cbor.value(), kNestedMapTestCase, sizeof(kNestedMapTestCase)));
    332332}
     
    346346    for (const auto& testCase : kSimpleTestCase) {
    347347        auto cbor = CBORWriter::write(CBORValue(testCase.simpleValue));
    348         ASSERT_TRUE(cbor.hasValue());
     348        ASSERT_TRUE(cbor.has_value());
    349349        EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
    350350    }
     
    371371    const CBORValue singleLayerCborArray = CBORValue(simpleArray);
    372372
    373     EXPECT_TRUE(CBORWriter::write(simpleUint, 0).hasValue());
    374     EXPECT_TRUE(CBORWriter::write(simpleString, 0).hasValue());
    375     EXPECT_TRUE(CBORWriter::write(simpleBytestring, 0).hasValue());
    376 
    377     EXPECT_TRUE(CBORWriter::write(emptyArrayValue, 0).hasValue());
    378     EXPECT_TRUE(CBORWriter::write(emptyMapValue, 0).hasValue());
    379 
    380     EXPECT_FALSE(CBORWriter::write(singleLayerCborArray, 0).hasValue());
    381     EXPECT_TRUE(CBORWriter::write(singleLayerCborArray, 1).hasValue());
    382 
    383     EXPECT_FALSE(CBORWriter::write(singleLayerCborMap, 0).hasValue());
    384     EXPECT_TRUE(CBORWriter::write(singleLayerCborMap, 1).hasValue());
     373    EXPECT_TRUE(CBORWriter::write(simpleUint, 0).has_value());
     374    EXPECT_TRUE(CBORWriter::write(simpleString, 0).has_value());
     375    EXPECT_TRUE(CBORWriter::write(simpleBytestring, 0).has_value());
     376
     377    EXPECT_TRUE(CBORWriter::write(emptyArrayValue, 0).has_value());
     378    EXPECT_TRUE(CBORWriter::write(emptyMapValue, 0).has_value());
     379
     380    EXPECT_FALSE(CBORWriter::write(singleLayerCborArray, 0).has_value());
     381    EXPECT_TRUE(CBORWriter::write(singleLayerCborArray, 1).has_value());
     382
     383    EXPECT_FALSE(CBORWriter::write(singleLayerCborMap, 0).has_value());
     384    EXPECT_TRUE(CBORWriter::write(singleLayerCborMap, 1).has_value());
    385385}
    386386
     
    397397    nestedMap[CBORValue("d")] = CBORValue(3);
    398398    cborMap[CBORValue("b")] = CBORValue(nestedMap);
    399     EXPECT_TRUE(CBORWriter::write(CBORValue(cborMap), 2).hasValue());
    400     EXPECT_FALSE(CBORWriter::write(CBORValue(cborMap), 1).hasValue());
     399    EXPECT_TRUE(CBORWriter::write(CBORValue(cborMap), 2).has_value());
     400    EXPECT_FALSE(CBORWriter::write(CBORValue(cborMap), 1).has_value());
    401401}
    402402
     
    423423    cborArray.append(CBORValue(cborMap));
    424424
    425     EXPECT_TRUE(CBORWriter::write(CBORValue(cborArray), 3).hasValue());
    426     EXPECT_FALSE(CBORWriter::write(CBORValue(cborArray), 2).hasValue());
     425    EXPECT_TRUE(CBORWriter::write(CBORValue(cborArray), 3).has_value());
     426    EXPECT_FALSE(CBORWriter::write(CBORValue(cborArray), 2).has_value());
    427427}
    428428
     
    457457    map[CBORValue("b")] = CBORValue(nestedMap);
    458458
    459     EXPECT_TRUE(CBORWriter::write(CBORValue(map), 5).hasValue());
    460     EXPECT_FALSE(CBORWriter::write(CBORValue(map), 4).hasValue());
     459    EXPECT_TRUE(CBORWriter::write(CBORValue(map), 5).has_value());
     460    EXPECT_FALSE(CBORWriter::write(CBORValue(map), 4).has_value());
    461461}
    462462
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp

    r278185 r278244  
    132132        // Spin until autoplay status is reported, the run JS API can
    133133        // complete its main loop before the promises in autoplay-check fire.
    134         while (!m_autoplayed.hasValue())
     134        while (!m_autoplayed.has_value())
    135135            g_main_loop_run(m_mainLoop);
    136136
     
    142142    bool m_respondToPolicyDecisionAsynchronously { false };
    143143    bool m_haltMainLoopAfterMakingDecision { false };
    144     Optional<bool> m_autoplayed;
     144    std::optional<bool> m_autoplayed;
    145145    GRefPtr<WebKitPolicyDecision> m_previousPolicyDecision;
    146146    GRefPtr<WebKitWebsitePolicies> m_websitePolicies;
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp

    r276848 r278244  
    14381438    {
    14391439        g_assert(m_state == RenderingState::Unknown);
    1440         g_assert_false(m_streamId.hasValue());
     1440        g_assert_false(m_streamId.has_value());
    14411441        g_assert_cmpuint(id, ==, 0);
    14421442        m_streamId = id;
     
    15141514    static const struct wpe_audio_receiver m_audioReceiver;
    15151515    RenderingState m_state { RenderingState::Unknown };
    1516     Optional<uint32_t> m_streamId;
     1516    std::optional<uint32_t> m_streamId;
    15171517};
    15181518
  • trunk/Tools/WebKitTestRunner/GeolocationProviderMock.cpp

    r278185 r278244  
    6464}
    6565
    66 void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy, Optional<double> altitude, Optional<double> altitudeAccuracy, Optional<double> heading, Optional<double> speed, Optional<double> floorLevel)
     66void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy, std::optional<double> altitude, std::optional<double> altitudeAccuracy, std::optional<double> heading, std::optional<double> speed, std::optional<double> floorLevel)
    6767{
    68     m_position.adopt(WKGeolocationPositionCreate_c(WallTime::now().secondsSinceEpoch().seconds(), latitude, longitude, accuracy, altitude.hasValue(), altitude.value_or(0), altitudeAccuracy.hasValue(), altitudeAccuracy.value_or(0), heading.hasValue(), heading.value_or(0), speed.hasValue(), speed.value_or(0), floorLevel.hasValue(), floorLevel.value_or(0)));
     68    m_position.adopt(WKGeolocationPositionCreate_c(WallTime::now().secondsSinceEpoch().seconds(), latitude, longitude, accuracy, altitude.has_value(), altitude.value_or(0), altitudeAccuracy.has_value(), altitudeAccuracy.value_or(0), heading.has_value(), heading.value_or(0), speed.has_value(), speed.value_or(0), floorLevel.has_value(), floorLevel.value_or(0)));
    6969
    7070    m_hasError = false;
  • trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm

    r277301 r278244  
    6969    BOOL _isInteractingWithFormControl;
    7070    BOOL _scrollingUpdatesDisabled;
    71     Optional<CustomMenuActionInfo> _customMenuActionInfo;
     71    std::optional<CustomMenuActionInfo> _customMenuActionInfo;
    7272    RetainPtr<NSArray<NSString *>> _allowedMenuActions;
    7373#if PLATFORM(IOS_FAMILY)
     
    316316    BOOL canPerformActionByDefault = [super canPerformAction:action withSender:sender];
    317317    if (isCustomAction)
    318         canPerformActionByDefault = _customMenuActionInfo.hasValue();
     318        canPerformActionByDefault = _customMenuActionInfo.has_value();
    319319
    320320    if (canPerformActionByDefault && _allowedMenuActions && sender == UIMenuController.sharedMenuController) {
Note: See TracChangeset for help on using the changeset viewer.