Title: [261546] trunk/Source
Revision
261546
Author
[email protected]
Date
2020-05-11 22:46:28 -0700 (Mon, 11 May 2020)

Log Message

Fix problems caught by replacing WTF::Optional with std::optional
https://bugs.webkit.org/show_bug.cgi?id=211703

Reviewed by Chris Dumez.

Source/_javascript_Core:

* runtime/MachineContext.h:
(JSC::MachineContext::instructionPointer): Use explcit makeOptional here,
to work around the fact that MacroAssemblerCodePtr uses an unusual technique
to disable conversions to everything except bool.

Source/WebCore:

* editing/EditorCommand.cpp:
(WebCore::executeSelectToMark): Remove erroneous code that converts
a live range to a SimpleRange and then back again.

* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::willSendRequest): Pass a pointer to
a ResourceRequest.
(WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache): Ditto.
(WebCore::InspectorNetworkAgent::buildInitiatorObject): Take a const*
to a ResourceRequest instead of an Optional<const ResourceRequest&>
because std::optional does not work with reference types.
* inspector/agents/InspectorNetworkAgent.h: Update for the change above.

* layout/floats/FloatingContext.cpp:
(WebCore::Layout::Iterator::operator++): Fix code that was accidentally
comparing two optionals, after already checking them for null. Instead
we should compare their values.

* platform/PlatformScreen.cpp:
(WebCore::screenData): Return a const* instead of an Optional<const&>
because std::optonal does not work with reference types.
* platform/PlatformScreen.h: Updated for the above. Also removed both
the unneeded include of Optional.h (could have included Forward.h) and
of HashMap.h and put the Mac-specific type IORegistryGPUID inside a
PLATFORM(MAC) #if statement.

* platform/ScreenProperties.h: Moved the HashMap.h include here, since
this is the header that uses it. Changed the EncodedColorSpaceDataType
enum to an enum class and gave it much shorter names.
(WebCore::ScreenData::encode const): Updated for the enum class change.
Also fixed a mistake where the code would use operator<< instead of
encodeEnum for the color space type of Null. This would lead to some
kind of decoding error, rather than a null cgColorSpace.
(WebCore::ScreenData::decode): Ditto.

* platform/ios/PlatformScreenIOS.mm:
(WebCore::screenIsMonochrome): Updated since screenData returns a pointer.
(WebCore::screenHasInvertedColors): Ditto.
(WebCore::screenSupportsExtendedColor): Ditto.
(WebCore::screenSize): Ditto.
(WebCore::availableScreenSize): Ditto.

* platform/mac/PlatformScreenMac.mm: Moved declaration of
CGDisplayUsesForceToGray to CoreGraphicsSPI.h. Removed unused declaration
of CGDisplayUsesInvertedPolarity.
(WebCore::primaryOpenGLDisplayMask): Updated since screendData returns a pointer.
(WebCore::displayMaskForDisplay): Ditto.
(WebCore::gpuIDForDisplay): Ditto.
(WebCore::screenProperties): Ditto. Also renamed from getScreenProperties to
adhere to WebKit coding style.
(WebCore::screenIsMonochrome): Ditto.
(WebCore::screenHasInvertedColors): Ditto.
(WebCore::screenDepth): Ditto.
(WebCore::screenDepthPerComponent): Ditto.
(WebCore::screenRectForDisplay): Ditto.
(WebCore::screenRect): Ditto.
(WebCore::screenAvailableRect): Ditto.
(WebCore::screenColorSpace): Ditto.
(WebCore::screenSupportsExtendedColor): Ditto.
(WebCore::screenSupportsHighDynamicRange): Ditto.

* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::queueTaskToFireInstallEvent):
Removed capture of unused jobDataIdentifier.

Source/WebCore/PAL:

* pal/spi/cg/CoreGraphicsSPI.h: Moved definition of CGDisplayUsesForceToGray
here from PlatformScreenMac.mm and also added include of the private header
it's from when compiling with the Apple internal SDK for the additional
checking that we get from using both.

Source/WebKit:

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::plainTextForContext): Clarified ambiguous overload resolution by writing
the conversion from a live range to a SimpleRange out explicitly. Also fixed a typo
where there was a missing "&" in a "const&" argument.

Source/WTF:

* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Make URLDecodeFunction a function
pointer and use nullptr instead of trying to use Optional<> with
a function reference.
(WTF::URLHelpers::collectRangesThatNeedMapping): Ditto.
(WTF::URLHelpers::applyHostNameFunctionToMailToURLString): Ditto.
(WTF::URLHelpers::applyHostNameFunctionToURLString): Ditto.
(WTF::URLHelpers::mapHostNames): Ditto.
(WTF::URLHelpers::userVisibleURL): Ditto.
* wtf/URLHelpers.h: Ditto.

* wtf/cocoa/NSURLExtras.mm:
(WTF::decodeHostName): Pass nullptr for URLDecodeFunction.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (261545 => 261546)


--- trunk/Source/_javascript_Core/ChangeLog	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1,3 +1,15 @@
+2020-05-11  Darin Adler  <[email protected]>
+
+        Fix problems caught by replacing WTF::Optional with std::optional
+        https://bugs.webkit.org/show_bug.cgi?id=211703
+
+        Reviewed by Chris Dumez.
+
+        * runtime/MachineContext.h:
+        (JSC::MachineContext::instructionPointer): Use explcit makeOptional here,
+        to work around the fact that MacroAssemblerCodePtr uses an unusual technique
+        to disable conversions to everything except bool.
+
 2020-05-11  Yoshiaki JITSUKAWA  <[email protected]>
 
         Fix build errors after r260992

Modified: trunk/Source/_javascript_Core/runtime/MachineContext.h (261545 => 261546)


--- trunk/Source/_javascript_Core/runtime/MachineContext.h	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/_javascript_Core/runtime/MachineContext.h	2020-05-12 05:46:28 UTC (rev 261546)
@@ -454,11 +454,11 @@
     void* value = instructionPointerImpl(const_cast<PlatformRegisters&>(regs));
 #endif
     if (!value)
-        return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(nullptr);
+        return makeOptional(MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(nullptr));
     if (!usesPointerTagging())
-        return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
+        return makeOptional(MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value));
     if (isTaggedWith(value, PlatformRegistersPCPtrTag))
-        return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
+        return makeOptional(MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value));
     return WTF::nullopt;
 }
 

Modified: trunk/Source/WTF/ChangeLog (261545 => 261546)


--- trunk/Source/WTF/ChangeLog	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WTF/ChangeLog	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1,3 +1,24 @@
+2020-05-11  Darin Adler  <[email protected]>
+
+        Fix problems caught by replacing WTF::Optional with std::optional
+        https://bugs.webkit.org/show_bug.cgi?id=211703
+
+        Reviewed by Chris Dumez.
+
+        * wtf/URLHelpers.cpp:
+        (WTF::URLHelpers::mapHostName): Make URLDecodeFunction a function
+        pointer and use nullptr instead of trying to use Optional<> with
+        a function reference.
+        (WTF::URLHelpers::collectRangesThatNeedMapping): Ditto.
+        (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): Ditto.
+        (WTF::URLHelpers::applyHostNameFunctionToURLString): Ditto.
+        (WTF::URLHelpers::mapHostNames): Ditto.
+        (WTF::URLHelpers::userVisibleURL): Ditto.
+        * wtf/URLHelpers.h: Ditto.
+
+        * wtf/cocoa/NSURLExtras.mm:
+        (WTF::decodeHostName): Pass nullptr for URLDecodeFunction.
+
 2020-05-11  Yusuke Suzuki  <[email protected]>
 
         AtomString::init should temporarily disable checks via `isMainThread` due to WebThread's inconsistent state

Modified: trunk/Source/WTF/wtf/URLHelpers.cpp (261545 => 261546)


--- trunk/Source/WTF/wtf/URLHelpers.cpp	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WTF/wtf/URLHelpers.cpp	2020-05-12 05:46:28 UTC (rev 261546)
@@ -543,7 +543,7 @@
 }
 
 // Return value of null means no mapping is necessary.
-Optional<String> mapHostName(const String& hostName, const Optional<URLDecodeFunction>& decodeFunction)
+Optional<String> mapHostName(const String& hostName, URLDecodeFunction decodeFunction)
 {
     if (hostName.length() > hostNameBufferLength)
         return String();
@@ -580,7 +580,7 @@
 
 using MappingRangesVector = Optional<Vector<std::tuple<unsigned, unsigned, String>>>;
 
-static void collectRangesThatNeedMapping(const String& string, unsigned location, unsigned length, MappingRangesVector& array, const Optional<URLDecodeFunction>& decodeFunction)
+static void collectRangesThatNeedMapping(const String& string, unsigned location, unsigned length, MappingRangesVector& array, URLDecodeFunction decodeFunction)
 {
     // Generally, we want to optimize for the case where there is one host name that does not need mapping.
     // Therefore, we use null to indicate no mapping here and an empty array to indicate error.
@@ -598,7 +598,7 @@
         array->constructAndAppend(location, length, *host);
 }
 
-static void applyHostNameFunctionToMailToURLString(const String& string, const Optional<URLDecodeFunction>& decodeFunction, MappingRangesVector& array)
+static void applyHostNameFunctionToMailToURLString(const String& string, URLDecodeFunction decodeFunction, MappingRangesVector& array)
 {
     // In a mailto: URL, host names come after a '@' character and end with a '>' or ',' or '?' character.
     // Skip quoted strings so that characters in them don't confuse us.
@@ -670,7 +670,7 @@
     }
 }
 
-static void applyHostNameFunctionToURLString(const String& string, const Optional<URLDecodeFunction>& decodeFunction, MappingRangesVector& array)
+static void applyHostNameFunctionToURLString(const String& string, URLDecodeFunction decodeFunction, MappingRangesVector& array)
 {
     // Find hostnames. Too bad we can't use any real URL-parsing code to do this,
     // but we have to do it before doing all the %-escaping, and this is the only
@@ -713,7 +713,7 @@
     collectRangesThatNeedMapping(string, hostNameStart, hostNameEnd - hostNameStart, array, decodeFunction);
 }
 
-String mapHostNames(const String& string, const Optional<URLDecodeFunction>& decodeFunction)
+String mapHostNames(const String& string, URLDecodeFunction decodeFunction)
 {
     // Generally, we want to optimize for the case where there is one host name that does not need mapping.
     
@@ -869,7 +869,7 @@
 
     if (mayNeedHostNameDecoding) {
         // FIXME: Is it good to ignore the failure of mapHostNames and keep result intact?
-        auto mappedResult = mapHostNames(result, nullopt);
+        auto mappedResult = mapHostNames(result, nullptr);
         if (!!mappedResult)
             result = mappedResult;
     }

Modified: trunk/Source/WTF/wtf/URLHelpers.h (261545 => 261546)


--- trunk/Source/WTF/wtf/URLHelpers.h	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WTF/wtf/URLHelpers.h	2020-05-12 05:46:28 UTC (rev 261546)
@@ -34,14 +34,14 @@
 namespace WTF {
 namespace URLHelpers {
 
-using URLDecodeFunction = String(&)(const String&);
+using URLDecodeFunction = String(*)(const String&);
 
 WTF_EXPORT_PRIVATE String userVisibleURL(const CString& URL);
 void loadIDNScriptWhiteList();
 void whiteListIDNScript(const char* scriptName);
 void initializeDefaultIDNScriptWhiteList();
-Optional<String> mapHostName(const String&, const Optional<URLDecodeFunction>&);
-String mapHostNames(const String&, const Optional<URLDecodeFunction>&);
+Optional<String> mapHostName(const String&, URLDecodeFunction);
+String mapHostNames(const String&, URLDecodeFunction);
 
 } // namespace URLHelpers
 } // namespace WTF

Modified: trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm (261545 => 261546)


--- trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm	2020-05-12 05:46:28 UTC (rev 261546)
@@ -102,7 +102,7 @@
 
 NSString *decodeHostName(NSString *string)
 {
-    Optional<String> host = mapHostName(string, nullopt);
+    Optional<String> host = mapHostName(string, nullptr);
     if (!host)
         return nil;
     return !*host ? string : (NSString *)*host;

Modified: trunk/Source/WebCore/ChangeLog (261545 => 261546)


--- trunk/Source/WebCore/ChangeLog	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/ChangeLog	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1,3 +1,75 @@
+2020-05-11  Darin Adler  <[email protected]>
+
+        Fix problems caught by replacing WTF::Optional with std::optional
+        https://bugs.webkit.org/show_bug.cgi?id=211703
+
+        Reviewed by Chris Dumez.
+
+        * editing/EditorCommand.cpp:
+        (WebCore::executeSelectToMark): Remove erroneous code that converts
+        a live range to a SimpleRange and then back again.
+
+        * inspector/agents/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::willSendRequest): Pass a pointer to
+        a ResourceRequest.
+        (WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache): Ditto.
+        (WebCore::InspectorNetworkAgent::buildInitiatorObject): Take a const*
+        to a ResourceRequest instead of an Optional<const ResourceRequest&>
+        because std::optional does not work with reference types.
+        * inspector/agents/InspectorNetworkAgent.h: Update for the change above.
+
+        * layout/floats/FloatingContext.cpp:
+        (WebCore::Layout::Iterator::operator++): Fix code that was accidentally
+        comparing two optionals, after already checking them for null. Instead
+        we should compare their values.
+
+        * platform/PlatformScreen.cpp:
+        (WebCore::screenData): Return a const* instead of an Optional<const&>
+        because std::optonal does not work with reference types.
+        * platform/PlatformScreen.h: Updated for the above. Also removed both
+        the unneeded include of Optional.h (could have included Forward.h) and
+        of HashMap.h and put the Mac-specific type IORegistryGPUID inside a
+        PLATFORM(MAC) #if statement.
+
+        * platform/ScreenProperties.h: Moved the HashMap.h include here, since
+        this is the header that uses it. Changed the EncodedColorSpaceDataType
+        enum to an enum class and gave it much shorter names.
+        (WebCore::ScreenData::encode const): Updated for the enum class change.
+        Also fixed a mistake where the code would use operator<< instead of
+        encodeEnum for the color space type of Null. This would lead to some
+        kind of decoding error, rather than a null cgColorSpace.
+        (WebCore::ScreenData::decode): Ditto.
+
+        * platform/ios/PlatformScreenIOS.mm:
+        (WebCore::screenIsMonochrome): Updated since screenData returns a pointer.
+        (WebCore::screenHasInvertedColors): Ditto.
+        (WebCore::screenSupportsExtendedColor): Ditto.
+        (WebCore::screenSize): Ditto.
+        (WebCore::availableScreenSize): Ditto.
+
+        * platform/mac/PlatformScreenMac.mm: Moved declaration of
+        CGDisplayUsesForceToGray to CoreGraphicsSPI.h. Removed unused declaration
+        of CGDisplayUsesInvertedPolarity.
+        (WebCore::primaryOpenGLDisplayMask): Updated since screendData returns a pointer.
+        (WebCore::displayMaskForDisplay): Ditto.
+        (WebCore::gpuIDForDisplay): Ditto.
+        (WebCore::screenProperties): Ditto. Also renamed from getScreenProperties to
+        adhere to WebKit coding style.
+        (WebCore::screenIsMonochrome): Ditto.
+        (WebCore::screenHasInvertedColors): Ditto.
+        (WebCore::screenDepth): Ditto.
+        (WebCore::screenDepthPerComponent): Ditto.
+        (WebCore::screenRectForDisplay): Ditto.
+        (WebCore::screenRect): Ditto.
+        (WebCore::screenAvailableRect): Ditto.
+        (WebCore::screenColorSpace): Ditto.
+        (WebCore::screenSupportsExtendedColor): Ditto.
+        (WebCore::screenSupportsHighDynamicRange): Ditto.
+
+        * workers/service/context/ServiceWorkerThread.cpp:
+        (WebCore::ServiceWorkerThread::queueTaskToFireInstallEvent):
+        Removed capture of unused jobDataIdentifier.
+
 2020-05-11  James Darpinian  <[email protected]>
 
         WebGLLayer clobbers TEXTURE_2D binding on iOS

Modified: trunk/Source/WebCore/PAL/ChangeLog (261545 => 261546)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1,3 +1,15 @@
+2020-05-11  Darin Adler  <[email protected]>
+
+        Fix problems caught by replacing WTF::Optional with std::optional
+        https://bugs.webkit.org/show_bug.cgi?id=211703
+
+        Reviewed by Chris Dumez.
+
+        * pal/spi/cg/CoreGraphicsSPI.h: Moved definition of CGDisplayUsesForceToGray
+        here from PlatformScreenMac.mm and also added include of the private header
+        it's from when compiling with the Apple internal SDK for the additional
+        checking that we get from using both.
+
 2020-05-11  Andres Gonzalez  <[email protected]>
 
         Add mechanism to turn on accessibility isolated tree mode from WebKitTestRunner.

Modified: trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (261545 => 261546)


--- trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2020-05-12 05:46:28 UTC (rev 261546)
@@ -38,13 +38,15 @@
 
 #if USE(APPLE_INTERNAL_SDK)
 
-#if PLATFORM(MAC)
-#include <ColorSync/ColorSyncPriv.h>
-#endif
 #include <CoreGraphics/CGFontCache.h>
 #include <CoreGraphics/CGPathPrivate.h>
 #include <CoreGraphics/CoreGraphicsPrivate.h>
 
+#if PLATFORM(MAC)
+#include <ColorSync/ColorSyncPriv.h>
+#include <CoreGraphics/CGAccessibility.h>
+#endif
+
 #else
 
 struct CGFontHMetrics {
@@ -309,6 +311,9 @@
 #endif // PLATFORM(WIN)
 
 #if PLATFORM(MAC)
+
+bool CGDisplayUsesForceToGray(void);
+
 void CGSShutdownServerConnections(void);
 
 CGSConnectionID CGSMainConnectionID(void);
@@ -324,6 +329,7 @@
 size_t CGDisplayModeGetPixelsHigh(CGDisplayModeRef);
 
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+
 CGError CGSSetDenyWindowServerConnections(bool);
 
 typedef int32_t CGSDisplayID;

Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (261545 => 261546)


--- trunk/Source/WebCore/editing/EditorCommand.cpp	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1056,7 +1056,7 @@
         PAL::systemBeep();
         return false;
     }
-    frame.selection().setSelectedRange(unionDOMRanges(createLiveRange(*mark), createLiveRange(*selection)).get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes);
+    frame.selection().setSelectedRange(unionDOMRanges(createLiveRange(*mark), *selection).get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes);
     return true;
 }
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp (261545 => 261546)


--- trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp	2020-05-12 05:46:28 UTC (rev 261546)
@@ -456,7 +456,7 @@
     auto protocolResourceType = InspectorPageAgent::resourceTypeJSON(type);
 
     Document* document = loader && loader->frame() ? loader->frame()->document() : nullptr;
-    auto initiatorObject = buildInitiatorObject(document, request);
+    auto initiatorObject = buildInitiatorObject(document, &request);
 
     String url = "" ? loader->url().string() : request.url().string();
     m_frontendDispatcher->requestWillBeSent(requestId, frameId, loaderId, url, buildObjectForResourceRequest(request), sendTimestamp, walltime.secondsSinceEpoch().seconds(), initiatorObject, buildObjectForResourceResponse(redirectResponse, nullptr), type != InspectorPageAgent::OtherResource ? &protocolResourceType : nullptr, targetId.isEmpty() ? nullptr : &targetId);
@@ -636,7 +636,7 @@
 
     m_resourcesData->resourceCreated(requestId, loaderId, resource);
 
-    auto initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : nullptr, resource.resourceRequest());
+    auto initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : nullptr, &resource.resourceRequest());
 
     // FIXME: It would be ideal to generate the Network.Response with the MemoryCache source
     // instead of whatever ResourceResponse::Source the CachedResources's response has.
@@ -706,7 +706,7 @@
         m_styleRecalculationInitiator = buildInitiatorObject(&document);
 }
 
-RefPtr<Inspector::Protocol::Network::Initiator> InspectorNetworkAgent::buildInitiatorObject(Document* document, Optional<const ResourceRequest&> resourceRequest)
+RefPtr<Inspector::Protocol::Network::Initiator> InspectorNetworkAgent::buildInitiatorObject(Document* document, const ResourceRequest* resourceRequest)
 {
     // FIXME: Worker support.
     if (!isMainThread()) {

Modified: trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h (261545 => 261546)


--- trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h	2020-05-12 05:46:28 UTC (rev 261546)
@@ -145,7 +145,7 @@
 
     WebSocket* webSocketForRequestId(const String& requestId);
 
-    RefPtr<Inspector::Protocol::Network::Initiator> buildInitiatorObject(Document*, Optional<const ResourceRequest&> = WTF::nullopt);
+    RefPtr<Inspector::Protocol::Network::Initiator> buildInitiatorObject(Document*, const ResourceRequest* = nullptr);
     Ref<Inspector::Protocol::Network::ResourceTiming> buildObjectForTiming(const NetworkLoadMetrics*, ResourceLoader&);
     Ref<Inspector::Protocol::Network::Metrics> buildObjectForMetrics(const NetworkLoadMetrics&);
     RefPtr<Inspector::Protocol::Network::Response> buildObjectForResourceResponse(const ResourceResponse&, ResourceLoader*);

Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (261545 => 261546)


--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp	2020-05-12 05:46:28 UTC (rev 261546)
@@ -595,8 +595,8 @@
     auto leftBottom = m_current.left() ? Optional<PositionInContextRoot>(m_current.left()->bottom()) : WTF::nullopt;
     auto rightBottom = m_current.right() ? Optional<PositionInContextRoot>(m_current.right()->bottom()) : WTF::nullopt;
 
-    auto updateLeft = (leftBottom == rightBottom) || (!rightBottom || (leftBottom && leftBottom < rightBottom)); 
-    auto updateRight = (leftBottom == rightBottom) || (!leftBottom || (rightBottom && leftBottom > rightBottom)); 
+    auto updateLeft = (leftBottom == rightBottom) || (!rightBottom || (leftBottom && *leftBottom < *rightBottom));
+    auto updateRight = (leftBottom == rightBottom) || (!leftBottom || (rightBottom && *leftBottom > *rightBottom));
 
     if (updateLeft) {
         ASSERT(m_current.m_floatPair.left);

Modified: trunk/Source/WebCore/platform/PlatformScreen.cpp (261545 => 261546)


--- trunk/Source/WebCore/platform/PlatformScreen.cpp	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/platform/PlatformScreen.cpp	2020-05-12 05:46:28 UTC (rev 261546)
@@ -48,21 +48,20 @@
     screenProperties() = properties;
 }
 
-Optional<const ScreenData&> screenData(PlatformDisplayID screendisplayID)
+const ScreenData* screenData(PlatformDisplayID screenDisplayID)
 {
     if (screenProperties().screenDataMap.isEmpty())
-        return WTF::nullopt;
+        return nullptr;
 
     // Return property of the first screen if the screen is not found in the map.
-    auto displayID = screendisplayID ? screendisplayID : primaryScreenDisplayID();
-    if (displayID) {
-        auto screenPropertiesForDisplay = screenProperties().screenDataMap.find(displayID);
-        if (screenPropertiesForDisplay != screenProperties().screenDataMap.end())
-            return screenPropertiesForDisplay->value;
+    if (auto displayID = screenDisplayID ? screenDisplayID : primaryScreenDisplayID()) {
+        auto properties = screenProperties().screenDataMap.find(displayID);
+        if (properties != screenProperties().screenDataMap.end())
+            return &properties->value;
     }
 
     // Last resort: use the first item in the screen list.
-    return screenProperties().screenDataMap.begin()->value;
+    return &screenProperties().screenDataMap.begin()->value;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformScreen.h (261545 => 261546)


--- trunk/Source/WebCore/platform/PlatformScreen.h	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/platform/PlatformScreen.h	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2018 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,15 +25,11 @@
 
 #pragma once
 
-#include <wtf/Optional.h>
-
 #if USE(GLIB)
 #include <wtf/Function.h>
 #endif
 
 #if PLATFORM(MAC)
-#include <wtf/HashMap.h>
-
 OBJC_CLASS NSScreen;
 OBJC_CLASS NSWindow;
 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
@@ -60,13 +56,19 @@
 class Widget;
 
 using PlatformDisplayID = uint32_t;
+
+#if PLATFORM(MAC)
+
 using IORegistryGPUID = int64_t; // Global IOKit I/O registryID that can match a GPU across process boundaries.
 
+#endif
+
 int screenDepth(Widget*);
 int screenDepthPerComponent(Widget*);
 bool screenIsMonochrome(Widget*);
 
 bool screenHasInvertedColors();
+
 #if USE(GLIB)
 double screenDPI();
 void setScreenDPIObserverHandler(Function<void()>&&, void*);
@@ -92,10 +94,11 @@
     
 WEBCORE_EXPORT ScreenProperties collectScreenProperties();
 WEBCORE_EXPORT void setScreenProperties(const ScreenProperties&);
-Optional<const ScreenData&> screenData(PlatformDisplayID screendisplayID);
+const ScreenData* screenData(PlatformDisplayID screendisplayID);
 WEBCORE_EXPORT PlatformDisplayID primaryScreenDisplayID();
     
 #if PLATFORM(MAC)
+
 WEBCORE_EXPORT PlatformDisplayID displayID(NSScreen *);
 
 WEBCORE_EXPORT NSScreen *screen(NSWindow *);

Modified: trunk/Source/WebCore/platform/ScreenProperties.h (261545 => 261546)


--- trunk/Source/WebCore/platform/ScreenProperties.h	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/platform/ScreenProperties.h	2020-05-12 05:46:28 UTC (rev 261546)
@@ -27,6 +27,7 @@
 
 #include "FloatRect.h"
 #include "PlatformScreen.h"
+#include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -48,12 +49,8 @@
     uint32_t displayMask { 0 };
     IORegistryGPUID gpuID { 0 };
 #endif
-    enum EncodedColorSpaceDataType {
-        Null,
-        ColorSpaceName,
-        ColorSpaceData,
-    };
 
+    enum class ColorSpaceType : uint8_t { None, Name, Data };
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static Optional<ScreenData> decode(Decoder&);
 };
@@ -103,7 +100,7 @@
     if (colorSpace) {
         // Try to encode the name.
         if (auto name = adoptCF(CGColorSpaceCopyName(colorSpace.get()))) {
-            encoder.encodeEnum(ColorSpaceName);
+            encoder.encodeEnum(ColorSpaceType::Name);
             encoder << String(name.get());
             return;
         }
@@ -110,11 +107,10 @@
 
         // Failing that, just encode the ICC data.
         if (auto profileData = adoptCF(CGColorSpaceCopyICCData(colorSpace.get()))) {
-            encoder.encodeEnum(ColorSpaceData);
-
             Vector<uint8_t> iccData;
             iccData.append(CFDataGetBytePtr(profileData.get()), CFDataGetLength(profileData.get()));
 
+            encoder.encodeEnum(ColorSpaceType::Data);
             encoder << iccData;
             return;
         }
@@ -121,7 +117,7 @@
     }
 
     // The color space was null or failed to be encoded.
-    encoder << Null;
+    encoder.encodeEnum(ColorSpaceType::None);
 }
 
 template<class Decoder>
@@ -179,15 +175,15 @@
         return WTF::nullopt;
 #endif
 
-    EncodedColorSpaceDataType dataType;
+    ColorSpaceType dataType;
     if (!decoder.decodeEnum(dataType))
         return WTF::nullopt;
 
     RetainPtr<CGColorSpaceRef> cgColorSpace;
     switch (dataType) {
-    case Null:
+    case ColorSpaceType::None:
         break;
-    case ColorSpaceName: {
+    case ColorSpaceType::Name: {
         Optional<String> colorSpaceName;
         decoder >> colorSpaceName;
         ASSERT(colorSpaceName);
@@ -197,7 +193,7 @@
         cgColorSpace = adoptCF(CGColorSpaceCreateWithName(colorSpaceName->createCFString().get()));
         break;
     }
-    case ColorSpaceData: {
+    case ColorSpaceType::Data: {
         Optional<Vector<uint8_t>> iccData;
         decoder >> iccData;
         ASSERT(iccData);

Modified: trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm (261545 => 261546)


--- trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm	2020-05-12 05:46:28 UTC (rev 261546)
@@ -60,9 +60,8 @@
 
 bool screenIsMonochrome(Widget*)
 {
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->screenIsMonochrome;
+    if (auto data = ""
+        return data->screenIsMonochrome;
     
     return PAL::softLinkUIKitUIAccessibilityIsGrayscaleEnabled();
 }
@@ -69,9 +68,8 @@
 
 bool screenHasInvertedColors()
 {
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->screenHasInvertedColors;
+    if (auto data = ""
+        return data->screenHasInvertedColors;
     
     return PAL::softLinkUIKitUIAccessibilityIsInvertColorsEnabled();
 }
@@ -78,9 +76,8 @@
 
 bool screenSupportsExtendedColor(Widget*)
 {
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->screenSupportsExtendedColor;
+    if (auto data = ""
+        return data->screenSupportsExtendedColor;
 
     return MGGetBoolAnswer(kMGQHasExtendedColorDisplay);
 }
@@ -155,9 +152,8 @@
     if (deviceHasIPadCapability() && [[PAL::getUIApplicationClass() sharedApplication] _isClassic])
         return { 320, 480 };
 
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->screenRect.size();
+    if (auto data = ""
+        return data->screenRect.size();
 
     return FloatSize([[PAL::getUIScreenClass() mainScreen] _referenceBounds].size);
 }
@@ -167,9 +163,8 @@
     if (deviceHasIPadCapability() && [[PAL::getUIApplicationClass() sharedApplication] _isClassic])
         return { 320, 480 };
 
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->screenAvailableRect.size();
+    if (auto data = ""
+        return data->screenAvailableRect.size();
 
     return FloatSize([PAL::getUIScreenClass() mainScreen].bounds.size);
 }

Modified: trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm (261545 => 261546)


--- trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm	2020-05-12 05:46:28 UTC (rev 261546)
@@ -40,11 +40,6 @@
 #import <pal/cocoa/MediaToolboxSoftLink.h>
 #endif
 
-extern "C" {
-bool CGDisplayUsesInvertedPolarity(void);
-bool CGDisplayUsesForceToGray(void);
-}
-
 namespace WebCore {
 
 // These functions scale between screen and page coordinates because _javascript_/DOM operations
@@ -148,9 +143,8 @@
 
 uint32_t primaryOpenGLDisplayMask()
 {
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->displayMask;
+    if (auto data = ""
+        return data->displayMask;
 
     return 0;
 }
@@ -157,9 +151,8 @@
 
 uint32_t displayMaskForDisplay(PlatformDisplayID displayID)
 {
-    auto v = screenData(displayID);
-    if (v.hasValue())
-        return v->displayMask;
+    if (auto data = ""
+        return data->displayMask;
 
     ASSERT_NOT_REACHED();
     return 0;
@@ -173,13 +166,12 @@
 IORegistryGPUID gpuIDForDisplay(PlatformDisplayID displayID)
 {
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    auto v = screenData(displayID);
-    if (v.hasValue())
-        return v->gpuID;
+    if (auto data = ""
+        return data->gpuID;
+    return 0;
 #else
     return gpuIDForDisplayMask(CGDisplayIDToOpenGLDisplayMask(displayID));
 #endif
-    return 0;
 }
 
 IORegistryGPUID gpuIDForDisplayMask(GLuint displayMask)
@@ -217,7 +209,7 @@
     return (IORegistryGPUID) gpuIDHigh << 32 | gpuIDLow;
 }
 
-static Optional<const ScreenData&> getScreenProperties(Widget* widget)
+static const ScreenData* screenProperties(Widget* widget)
 {
     return screenData(displayID(widget));
 }
@@ -224,9 +216,8 @@
 
 bool screenIsMonochrome(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue())
-        return v->screenIsMonochrome;
+    if (auto data = ""
+        return data->screenIsMonochrome;
 
     // This is a system-wide accessibility setting, same on all screens.
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
@@ -235,9 +226,8 @@
 
 bool screenHasInvertedColors()
 {
-    auto v = screenData(primaryScreenDisplayID());
-    if (v.hasValue())
-        return v->screenHasInvertedColors;
+    if (auto data = ""
+        return data->screenHasInvertedColors;
 
     // This is a system-wide accessibility setting, same on all screens.
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
@@ -246,11 +236,9 @@
 
 int screenDepth(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue()) {
-        auto screenDepth = v->screenDepth;
-        ASSERT(screenDepth);
-        return screenDepth;
+    if (auto data = "" {
+        ASSERT(data->screenDepth);
+        return data->screenDepth;
     }
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
@@ -259,11 +247,9 @@
 
 int screenDepthPerComponent(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue()) {
-        auto depthPerComponent = v->screenDepthPerComponent;
-        ASSERT(depthPerComponent);
-        return depthPerComponent;
+    if (auto data = "" {
+        ASSERT(data->screenDepthPerComponent);
+        return data->screenDepthPerComponent;
     }
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
@@ -272,11 +258,9 @@
 
 FloatRect screenRectForDisplay(PlatformDisplayID displayID)
 {
-    auto v = screenData(displayID);
-    if (v.hasValue()) {
-        auto screenRect = v->screenRect;
-        ASSERT(!screenRect.isEmpty());
-        return screenRect;
+    if (auto data = "" {
+        ASSERT(!data->screenRect.isEmpty());
+        return data->screenRect;
     }
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
@@ -290,9 +274,8 @@
 
 FloatRect screenRect(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue())
-        return v->screenRect;
+    if (auto data = ""
+        return data->screenRect;
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return toUserSpace([screen(widget) frame], window(widget));
@@ -300,9 +283,8 @@
 
 FloatRect screenAvailableRect(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue())
-        return v->screenAvailableRect;
+    if (auto data = ""
+        return data->screenAvailableRect;
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return toUserSpace([screen(widget) visibleFrame], window(widget));
@@ -326,9 +308,8 @@
 
 CGColorSpaceRef screenColorSpace(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue())
-        return v->colorSpace.get();
+    if (auto data = ""
+        return data->colorSpace.get();
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return screen(widget).colorSpace.CGColorSpace;
@@ -336,9 +317,8 @@
 
 bool screenSupportsExtendedColor(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue())
-        return v->screenSupportsExtendedColor;
+    if (auto data = ""
+        return data->screenSupportsExtendedColor;
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return [screen(widget) canRepresentDisplayGamut:NSDisplayGamutP3];
@@ -346,9 +326,8 @@
 
 bool screenSupportsHighDynamicRange(Widget* widget)
 {
-    auto v = getScreenProperties(widget);
-    if (v.hasValue())
-        return v->screenSupportsHighDynamicRange;
+    if (auto data = ""
+        return data->screenSupportsHighDynamicRange;
 
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
 #if USE(MEDIATOOLBOX)

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (261545 => 261546)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2020-05-12 05:46:28 UTC (rev 261546)
@@ -144,11 +144,11 @@
 void ServiceWorkerThread::queueTaskToFireInstallEvent()
 {
     auto serviceWorkerGlobalScope = makeRef(downcast<ServiceWorkerGlobalScope>(*workerGlobalScope()));
-    serviceWorkerGlobalScope->eventLoop().queueTask(TaskSource::DOMManipulation, [serviceWorkerGlobalScope = serviceWorkerGlobalScope.copyRef(), jobDataIdentifier = m_data.jobDataIdentifier, serviceWorkerIdentifier = this->identifier()] {
+    serviceWorkerGlobalScope->eventLoop().queueTask(TaskSource::DOMManipulation, [serviceWorkerGlobalScope = serviceWorkerGlobalScope.copyRef(), serviceWorkerIdentifier = this->identifier()] {
         auto installEvent = ExtendableEvent::create(eventNames().installEvent, { }, ExtendableEvent::IsTrusted::Yes);
         serviceWorkerGlobalScope->dispatchEvent(installEvent);
 
-        installEvent->whenAllExtendLifetimePromisesAreSettled([jobDataIdentifier, serviceWorkerIdentifier](HashSet<Ref<DOMPromise>>&& extendLifetimePromises) {
+        installEvent->whenAllExtendLifetimePromisesAreSettled([serviceWorkerIdentifier](HashSet<Ref<DOMPromise>>&& extendLifetimePromises) {
             bool hasRejectedAnyPromise = false;
             for (auto& promise : extendLifetimePromises) {
                 if (promise->status() == DOMPromise::Status::Rejected) {

Modified: trunk/Source/WebKit/ChangeLog (261545 => 261546)


--- trunk/Source/WebKit/ChangeLog	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebKit/ChangeLog	2020-05-12 05:46:28 UTC (rev 261546)
@@ -1,3 +1,15 @@
+2020-05-11  Darin Adler  <[email protected]>
+
+        Fix problems caught by replacing WTF::Optional with std::optional
+        https://bugs.webkit.org/show_bug.cgi?id=211703
+
+        Reviewed by Chris Dumez.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::plainTextForContext): Clarified ambiguous overload resolution by writing
+        the conversion from a live range to a SimpleRange out explicitly. Also fixed a typo
+        where there was a missing "&" in a "const&" argument.
+
 2020-05-11  Simon Fraser  <[email protected]>
 
         [ macOS ] scrollingcoordinator/mac/latching/scrolling-select-should-not-latch-mainframe.html is a flaky failure

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (261545 => 261546)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-05-12 05:21:28 UTC (rev 261545)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-05-12 05:46:28 UTC (rev 261546)
@@ -150,7 +150,7 @@
     return WebCore::plainTextReplacingNoBreakSpace(range);
 }
 
-static String plainTextForContext(const Optional<SimpleRange> range)
+static String plainTextForContext(const Optional<SimpleRange>& range)
 {
     return range ? plainTextForContext(*range) : emptyString();
 }
@@ -157,7 +157,7 @@
 
 static String plainTextForContext(const Range* range)
 {
-    return range ? plainTextForContext(*range) : emptyString();
+    return range ? plainTextForContext(SimpleRange { *range }) : emptyString();
 }
 
 static String plainTextForDisplay(const SimpleRange& range)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to