Title: [263208] trunk/Source
Revision
263208
Author
ddkil...@apple.com
Date
2020-06-18 08:53:25 -0700 (Thu, 18 Jun 2020)

Log Message

[IPC hardening] OptionSet<> values should be validated
<https://webkit.org/b/213199>
<rdar://problem/64369963>

Reviewed by Anders Carlsson.

Source/WebCore:

Summary:
- Add WTF::EnumTraits<> for all OptionSet<> enums.
- Specify unsigned backing types for enum classes.

* loader/CrossOriginAccessControl.h:
* page/ActivityState.h:
* page/AutoplayEvent.h:
* page/CrossSiteNavigationDataTransfer.h:
* page/LayoutMilestone.h:
* page/TextIndicator.h:
* platform/PlatformEvent.h:
* platform/graphics/GraphicsContext.h:

Source/WebKit:

Summary:
- Add WTF::EnumTraits<> for all OptionSet<> enums.
- Specify unsigned backing types for enum classes.

* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkSession.h:
* Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<OptionSet<T>>::encode):
(IPC::ArgumentCoder<OptionSet<T>>::decode):
- Add WTF::isValidOptionSet() checks.
* Platform/IPC/Decoder.h:
* Platform/IPC/Encoder.h:
- Replace <wtf/EnumTraits.h> with <wtf/OptionSet.h> since the
  latter now includes the former.
* Platform/IPC/MessageFlags.h:
* Shared/DocumentEditingContext.h:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
* Shared/WebEvent.h:
* Shared/WebsiteAutoplayQuirk.h:
* Shared/WebsiteData/WebsiteData.h:
* Shared/WebsiteData/WebsiteDataFetchOption.h:
* Shared/WebsiteData/WebsiteDataType.h:
* Shared/ios/GestureTypes.h:
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Plugins/PluginProcessManager.h:
* UIProcess/WebProcessProxy.h:
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/WebProcess.h:

Source/WTF:

* wtf/OptionSet.h:
(WTF::isValidOptionSet): Add.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (263207 => 263208)


--- trunk/Source/WTF/ChangeLog	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WTF/ChangeLog	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,3 +1,14 @@
+2020-06-18  David Kilzer  <ddkil...@apple.com>
+
+        [IPC hardening] OptionSet<> values should be validated
+        <https://webkit.org/b/213199>
+        <rdar://problem/64369963>
+
+        Reviewed by Anders Carlsson.
+
+        * wtf/OptionSet.h:
+        (WTF::isValidOptionSet): Add.
+
 2020-06-17  Mark Lam  <mark....@apple.com>
 
         Replace JSC::FreeList linked list with a Bitmap.

Modified: trunk/Source/WTF/wtf/OptionSet.h (263207 => 263208)


--- trunk/Source/WTF/wtf/OptionSet.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WTF/wtf/OptionSet.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -250,6 +250,13 @@
     StorageType m_storage { 0 };
 };
 
+template<typename E>
+WARN_UNUSED_RETURN constexpr bool isValidOptionSet(OptionSet<E> optionSet)
+{
+    auto allValidBitsValue = OptionSetValueChecker<std::underlying_type_t<E>, typename EnumTraits<E>::values>::allValidBits();
+    return (optionSet.toRaw() | allValidBitsValue) == allValidBitsValue;
+}
+
 } // namespace WTF
 
 using WTF::OptionSet;

Modified: trunk/Source/WebCore/ChangeLog (263207 => 263208)


--- trunk/Source/WebCore/ChangeLog	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/ChangeLog	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,3 +1,24 @@
+2020-06-18  David Kilzer  <ddkil...@apple.com>
+
+        [IPC hardening] OptionSet<> values should be validated
+        <https://webkit.org/b/213199>
+        <rdar://problem/64369963>
+
+        Reviewed by Anders Carlsson.
+
+        Summary:
+        - Add WTF::EnumTraits<> for all OptionSet<> enums.
+        - Specify unsigned backing types for enum classes.
+
+        * loader/CrossOriginAccessControl.h:
+        * page/ActivityState.h:
+        * page/AutoplayEvent.h:
+        * page/CrossSiteNavigationDataTransfer.h:
+        * page/LayoutMilestone.h:
+        * page/TextIndicator.h:
+        * platform/PlatformEvent.h:
+        * platform/graphics/GraphicsContext.h:
+
 2020-06-17  Clark Wang  <clark_w...@apple.com>
 
         Added missing orientation attributes to PannerNode

Modified: trunk/Source/WebCore/loader/CrossOriginAccessControl.h (263207 => 263208)


--- trunk/Source/WebCore/loader/CrossOriginAccessControl.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/loader/CrossOriginAccessControl.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2020 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -56,7 +56,7 @@
 enum class SameOriginFlag { No, Yes };
 CachedResourceRequest createPotentialAccessControlRequest(ResourceRequest&&, ResourceLoaderOptions&&, Document&, const String& crossOriginAttribute, SameOriginFlag = SameOriginFlag::No);
 
-enum class HTTPHeadersToKeepFromCleaning {
+enum class HTTPHeadersToKeepFromCleaning : uint8_t {
     ContentType = 1 << 0,
     Referer = 1 << 1,
     Origin = 1 << 2,
@@ -85,3 +85,18 @@
 String validateCrossOriginRedirectionURL(const URL&);
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::HTTPHeadersToKeepFromCleaning> {
+    using values = EnumValues<
+        WebCore::HTTPHeadersToKeepFromCleaning,
+        WebCore::HTTPHeadersToKeepFromCleaning::ContentType,
+        WebCore::HTTPHeadersToKeepFromCleaning::Referer,
+        WebCore::HTTPHeadersToKeepFromCleaning::Origin,
+        WebCore::HTTPHeadersToKeepFromCleaning::UserAgent,
+        WebCore::HTTPHeadersToKeepFromCleaning::AcceptEncoding
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebCore/page/ActivityState.h (263207 => 263208)


--- trunk/Source/WebCore/page/ActivityState.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/page/ActivityState.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -58,3 +58,22 @@
 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, OptionSet<ActivityState::Flag>);
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::ActivityState::Flag> {
+    using values = EnumValues<
+        WebCore::ActivityState::Flag,
+        WebCore::ActivityState::Flag::WindowIsActive,
+        WebCore::ActivityState::Flag::IsFocused,
+        WebCore::ActivityState::Flag::IsVisible,
+        WebCore::ActivityState::Flag::IsVisibleOrOccluded,
+        WebCore::ActivityState::Flag::IsInWindow,
+        WebCore::ActivityState::Flag::IsVisuallyIdle,
+        WebCore::ActivityState::Flag::IsAudible,
+        WebCore::ActivityState::Flag::IsLoading,
+        WebCore::ActivityState::Flag::IsCapturingMedia
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebCore/page/AutoplayEvent.h (263207 => 263208)


--- trunk/Source/WebCore/page/AutoplayEvent.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/page/AutoplayEvent.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,7 +34,7 @@
     UserDidInterfereWithPlayback,
 };
 
-enum class AutoplayEventFlags {
+enum class AutoplayEventFlags : uint8_t {
     HasAudio = 1 << 0,
     PlaybackWasPrevented = 1 << 1,
     MediaIsMainContent = 1 << 2,
@@ -41,3 +41,16 @@
 };
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::AutoplayEventFlags> {
+    using values = EnumValues<
+        WebCore::AutoplayEventFlags,
+        WebCore::AutoplayEventFlags::HasAudio,
+        WebCore::AutoplayEventFlags::PlaybackWasPrevented,
+        WebCore::AutoplayEventFlags::MediaIsMainContent
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebCore/page/CrossSiteNavigationDataTransfer.h (263207 => 263208)


--- trunk/Source/WebCore/page/CrossSiteNavigationDataTransfer.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/page/CrossSiteNavigationDataTransfer.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,4 +38,16 @@
 };
 
 } // namespace WebCore
-#endif
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::CrossSiteNavigationDataTransfer::Flag> {
+    using values = EnumValues<
+        WebCore::CrossSiteNavigationDataTransfer::Flag,
+        WebCore::CrossSiteNavigationDataTransfer::Flag::DestinationLinkDecoration,
+        WebCore::CrossSiteNavigationDataTransfer::Flag::ReferrerLinkDecoration
+    >;
+};
+
+} // namespace WTF
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)

Modified: trunk/Source/WebCore/page/LayoutMilestone.h (263207 => 263208)


--- trunk/Source/WebCore/page/LayoutMilestone.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/page/LayoutMilestone.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,3 +45,22 @@
 };
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::LayoutMilestone> {
+    using values = EnumValues<
+        WebCore::LayoutMilestone,
+        WebCore::LayoutMilestone::DidFirstLayout,
+        WebCore::LayoutMilestone::DidFirstVisuallyNonEmptyLayout,
+        WebCore::LayoutMilestone::DidHitRelevantRepaintedObjectsAreaThreshold,
+        WebCore::LayoutMilestone::DidFirstFlushForHeaderLayer,
+        WebCore::LayoutMilestone::DidFirstLayoutAfterSuppressedIncrementalRendering,
+        WebCore::LayoutMilestone::DidFirstPaintAfterSuppressedIncrementalRendering,
+        WebCore::LayoutMilestone::ReachedSessionRestorationRenderTreeSizeThreshold,
+        WebCore::LayoutMilestone::DidRenderSignificantAmountOfText,
+        WebCore::LayoutMilestone::DidFirstMeaningfulPaint
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebCore/page/TextIndicator.h (263207 => 263208)


--- trunk/Source/WebCore/page/TextIndicator.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/page/TextIndicator.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -149,6 +149,24 @@
 
 namespace WTF {
 
+template<> struct EnumTraits<WebCore::TextIndicatorOption> {
+    using values = EnumValues<
+        WebCore::TextIndicatorOption,
+        WebCore::TextIndicatorOption::RespectTextColor,
+        WebCore::TextIndicatorOption::PaintBackgrounds,
+        WebCore::TextIndicatorOption::PaintAllContent,
+        WebCore::TextIndicatorOption::IncludeSnapshotWithSelectionHighlight,
+        WebCore::TextIndicatorOption::TightlyFitContent,
+        WebCore::TextIndicatorOption::UseBoundingRectAndPaintAllContentForComplexRanges,
+        WebCore::TextIndicatorOption::IncludeMarginIfRangeMatchesSelection,
+        WebCore::TextIndicatorOption::ExpandClipBeyondVisibleRect,
+        WebCore::TextIndicatorOption::DoNotClipToVisibleRect,
+        WebCore::TextIndicatorOption::IncludeSnapshotOfAllVisibleContentWithoutSelection,
+        WebCore::TextIndicatorOption::UseSelectionRectForSizing,
+        WebCore::TextIndicatorOption::ComputeEstimatedBackgroundColor
+    >;
+};
+
 template<> struct EnumTraits<WebCore::TextIndicatorPresentationTransition> {
     using values = EnumValues<
         WebCore::TextIndicatorPresentationTransition,

Modified: trunk/Source/WebCore/platform/PlatformEvent.h (263207 => 263208)


--- trunk/Source/WebCore/platform/PlatformEvent.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/platform/PlatformEvent.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -134,3 +134,19 @@
 };
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::PlatformEvent::Modifier> {
+    using values = EnumValues<
+        WebCore::PlatformEvent::Modifier,
+        WebCore::PlatformEvent::Modifier::AltKey,
+        WebCore::PlatformEvent::Modifier::ControlKey,
+        WebCore::PlatformEvent::Modifier::MetaKey,
+        WebCore::PlatformEvent::Modifier::ShiftKey,
+        WebCore::PlatformEvent::Modifier::CapsLockKey,
+        WebCore::PlatformEvent::Modifier::AltGraphKey
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (263207 => 263208)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2008-2009 Torch Mobile, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -771,6 +771,35 @@
     >;
 };
 
+template<> struct EnumTraits<WebCore::GraphicsContextState::Change> {
+    using values = EnumValues<
+        WebCore::GraphicsContextState::Change,
+        WebCore::GraphicsContextState::Change::StrokeGradientChange,
+        WebCore::GraphicsContextState::Change::StrokePatternChange,
+        WebCore::GraphicsContextState::Change::FillGradientChange,
+        WebCore::GraphicsContextState::Change::FillPatternChange,
+        WebCore::GraphicsContextState::Change::StrokeThicknessChange,
+        WebCore::GraphicsContextState::Change::StrokeColorChange,
+        WebCore::GraphicsContextState::Change::StrokeStyleChange,
+        WebCore::GraphicsContextState::Change::FillColorChange,
+        WebCore::GraphicsContextState::Change::FillRuleChange,
+        WebCore::GraphicsContextState::Change::ShadowChange,
+        WebCore::GraphicsContextState::Change::ShadowsIgnoreTransformsChange,
+        WebCore::GraphicsContextState::Change::AlphaChange,
+        WebCore::GraphicsContextState::Change::CompositeOperationChange,
+        WebCore::GraphicsContextState::Change::BlendModeChange,
+        WebCore::GraphicsContextState::Change::TextDrawingModeChange,
+        WebCore::GraphicsContextState::Change::ShouldAntialiasChange,
+        WebCore::GraphicsContextState::Change::ShouldSmoothFontsChange,
+        WebCore::GraphicsContextState::Change::ShouldSubpixelQuantizeFontsChange,
+        WebCore::GraphicsContextState::Change::DrawLuminanceMaskChange,
+        WebCore::GraphicsContextState::Change::ImageInterpolationQualityChange
+#if HAVE(OS_DARK_MODE_SUPPORT)
+        , WebCore::GraphicsContextState::Change::UseDarkAppearanceChange
+#endif
+    >;
+};
+
 template<> struct EnumTraits<WebCore::StrokeStyle> {
     using values = EnumValues<
     WebCore::StrokeStyle,
@@ -783,4 +812,15 @@
     >;
 };
 
+template<> struct EnumTraits<WebCore::TextDrawingMode> {
+    using values = EnumValues<
+        WebCore::TextDrawingMode,
+        WebCore::TextDrawingMode::Fill,
+        WebCore::TextDrawingMode::Stroke
+#if ENABLE(LETTERPRESS)
+        , WebCore::TextDrawingMode::Letterpress
+#endif
+    >;
+};
+
 } // namespace WTF

Modified: trunk/Source/WebKit/ChangeLog (263207 => 263208)


--- trunk/Source/WebKit/ChangeLog	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/ChangeLog	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,3 +1,40 @@
+2020-06-18  David Kilzer  <ddkil...@apple.com>
+
+        [IPC hardening] OptionSet<> values should be validated
+        <https://webkit.org/b/213199>
+        <rdar://problem/64369963>
+
+        Reviewed by Anders Carlsson.
+
+        Summary:
+        - Add WTF::EnumTraits<> for all OptionSet<> enums.
+        - Specify unsigned backing types for enum classes.
+
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkSession.h:
+        * Platform/IPC/ArgumentCoders.h:
+        (IPC::ArgumentCoder<OptionSet<T>>::encode):
+        (IPC::ArgumentCoder<OptionSet<T>>::decode):
+        - Add WTF::isValidOptionSet() checks.
+        * Platform/IPC/Decoder.h:
+        * Platform/IPC/Encoder.h:
+        - Replace <wtf/EnumTraits.h> with <wtf/OptionSet.h> since the
+          latter now includes the former.
+        * Platform/IPC/MessageFlags.h:
+        * Shared/DocumentEditingContext.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
+        * Shared/WebEvent.h:
+        * Shared/WebsiteAutoplayQuirk.h:
+        * Shared/WebsiteData/WebsiteData.h:
+        * Shared/WebsiteData/WebsiteDataFetchOption.h:
+        * Shared/WebsiteData/WebsiteDataType.h:
+        * Shared/ios/GestureTypes.h:
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Plugins/PluginProcessManager.h:
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * WebProcess/WebProcess.h:
+
 2020-06-18  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][WPE] Add API to configure and handle service worker registrations to WebKitWebsiteDataManager

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (263207 => 263208)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -107,8 +107,8 @@
 class WebSWServerToContextConnection;
 enum class ShouldGrandfatherStatistics : bool;
 enum class StorageAccessStatus : uint8_t;
-enum class WebsiteDataFetchOption;
-enum class WebsiteDataType;
+enum class WebsiteDataFetchOption : uint8_t;
+enum class WebsiteDataType : uint32_t;
 struct NetworkProcessCreationParameters;
 struct WebsiteDataStoreParameters;
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (263207 => 263208)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -60,7 +60,7 @@
 class WebSocketTask;
 struct NetworkSessionCreationParameters;
 
-enum class WebsiteDataType;
+enum class WebsiteDataType : uint32_t;
 
 namespace NetworkCache {
 class Cache;

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (263207 => 263208)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -32,6 +32,7 @@
 #include <wtf/CheckedArithmetic.h>
 #include <wtf/Forward.h>
 #include <wtf/MonotonicTime.h>
+#include <wtf/OptionSet.h>
 #include <wtf/SHA1.h>
 #include <wtf/Unexpected.h>
 #include <wtf/Variant.h>
@@ -55,6 +56,7 @@
 template<typename T> struct ArgumentCoder<OptionSet<T>> {
     static void encode(Encoder& encoder, const OptionSet<T>& optionSet)
     {
+        ASSERT(WTF::isValidOptionSet(optionSet));
         encoder << optionSet.toRaw();
     }
 
@@ -63,8 +65,9 @@
         typename OptionSet<T>::StorageType value;
         if (!decoder.decode(value))
             return false;
-
         optionSet = OptionSet<T>::fromRaw(value);
+        if (!WTF::isValidOptionSet(optionSet))
+            return false;
         return true;
     }
 
@@ -74,7 +77,10 @@
         decoder >> value;
         if (!value)
             return WTF::nullopt;
-        return OptionSet<T>::fromRaw(*value);
+        auto optionSet = OptionSet<T>::fromRaw(*value);
+        if (!WTF::isValidOptionSet(optionSet))
+            return WTF::nullopt;
+        return optionSet;
     }
 };
 

Modified: trunk/Source/WebKit/Platform/IPC/Decoder.h (263207 => 263208)


--- trunk/Source/WebKit/Platform/IPC/Decoder.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Platform/IPC/Decoder.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -30,7 +30,6 @@
 #include "MessageNames.h"
 #include "StringReference.h"
 #include <WebCore/ContextMenuItem.h>
-#include <wtf/EnumTraits.h>
 #include <wtf/OptionSet.h>
 #include <wtf/Vector.h>
 

Modified: trunk/Source/WebKit/Platform/IPC/Encoder.h (263207 => 263208)


--- trunk/Source/WebKit/Platform/IPC/Encoder.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Platform/IPC/Encoder.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -30,7 +30,7 @@
 #include "MessageNames.h"
 #include "StringReference.h"
 #include <WebCore/ContextMenuItem.h>
-#include <wtf/EnumTraits.h>
+#include <wtf/OptionSet.h>
 #include <wtf/Vector.h>
 
 namespace IPC {

Modified: trunk/Source/WebKit/Platform/IPC/MessageFlags.h (263207 => 263208)


--- trunk/Source/WebKit/Platform/IPC/MessageFlags.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Platform/IPC/MessageFlags.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,3 +41,17 @@
 };
 
 } // namespace IPC
+
+namespace WTF {
+
+template<> struct EnumTraits<IPC::MessageFlags> {
+    using values = EnumValues<
+        IPC::MessageFlags,
+        IPC::MessageFlags::SyncMessage,
+        IPC::MessageFlags::DispatchMessageWhenWaitingForSyncReply,
+        IPC::MessageFlags::DispatchMessageWhenWaitingForUnboundedSyncReply,
+        IPC::MessageFlags::UseFullySynchronousModeForTesting
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebKit/Shared/DocumentEditingContext.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/DocumentEditingContext.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/DocumentEditingContext.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -108,4 +108,20 @@
 };
 }
 
-#endif
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::DocumentEditingContextRequest::Options> {
+    using values = EnumValues<
+        WebKit::DocumentEditingContextRequest::Options,
+        WebKit::DocumentEditingContextRequest::Options::Text,
+        WebKit::DocumentEditingContextRequest::Options::AttributedText,
+        WebKit::DocumentEditingContextRequest::Options::Rects,
+        WebKit::DocumentEditingContextRequest::Options::Spatial,
+        WebKit::DocumentEditingContextRequest::Options::Annotation,
+        WebKit::DocumentEditingContextRequest::Options::MarkedTextRects
+    >;
+};
+
+} // namespace WTF
+
+#endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -325,3 +325,51 @@
 };
 
 } // namespace WebKit
+
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::RemoteLayerTreeTransaction::LayerChange> {
+    using values = EnumValues<
+        WebKit::RemoteLayerTreeTransaction::LayerChange,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::NameChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ChildrenChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::PositionChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BoundsChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BackgroundColorChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::AnchorPointChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BorderWidthChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BorderColorChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::OpacityChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::TransformChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::SublayerTransformChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::HiddenChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::GeometryFlippedChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::DoubleSidedChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::MasksToBoundsChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::OpaqueChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ContentsHiddenChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::MaskLayerChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ClonedContentsChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ContentsRectChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ContentsScaleChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::CornerRadiusChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ShapeRoundedRectChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::ShapePathChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::MinificationFilterChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::MagnificationFilterChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BlendModeChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::WindRuleChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::SpeedChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::TimeOffsetChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BackingStoreChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::BackingStoreAttachmentChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::FiltersChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::AnimationsChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::EdgeAntialiasingMaskChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::CustomAppearanceChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::UserInteractionEnabledChanged,
+        WebKit::RemoteLayerTreeTransaction::LayerChange::EventRegionChanged
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebKit/Shared/WebEvent.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/WebEvent.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/WebEvent.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -497,6 +497,17 @@
 
 namespace WTF {
 
+template<> struct EnumTraits<WebKit::WebEvent::Modifier> {
+    using values = EnumValues<
+        WebKit::WebEvent::Modifier,
+        WebKit::WebEvent::Modifier::ShiftKey,
+        WebKit::WebEvent::Modifier::ControlKey,
+        WebKit::WebEvent::Modifier::AltKey,
+        WebKit::WebEvent::Modifier::MetaKey,
+        WebKit::WebEvent::Modifier::CapsLockKey
+    >;
+};
+
 template<> struct EnumTraits<WebKit::WebMouseEvent::Button> {
     using values = EnumValues<
         WebKit::WebMouseEvent::Button,

Modified: trunk/Source/WebKit/Shared/WebsiteAutoplayQuirk.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/WebsiteAutoplayQuirk.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/WebsiteAutoplayQuirk.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2020 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,9 +25,11 @@
 
 #pragma once
 
+#include <wtf/OptionSet.h>
+
 namespace WebKit {
 
-enum class WebsiteAutoplayQuirk {
+enum class WebsiteAutoplayQuirk : uint8_t {
     SynthesizedPauseEvents = 1 << 0,
     InheritedUserGestures = 1 << 1,
     ArbitraryUserGestures = 1 << 2,
@@ -35,3 +37,17 @@
 };
 
 }
+
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::WebsiteAutoplayQuirk> {
+    using values = EnumValues<
+        WebKit::WebsiteAutoplayQuirk,
+        WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents,
+        WebKit::WebsiteAutoplayQuirk::InheritedUserGestures,
+        WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures,
+        WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/WebsiteData/WebsiteData.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -38,7 +38,7 @@
 
 namespace WebKit {
 
-enum class WebsiteDataType;
+enum class WebsiteDataType : uint32_t;
 
 enum class WebsiteDataProcessType { Network, UI, Web };
 

Modified: trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataFetchOption.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataFetchOption.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataFetchOption.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,10 +27,21 @@
 
 namespace WebKit {
 
-enum class WebsiteDataFetchOption {
+enum class WebsiteDataFetchOption : uint8_t {
     ComputeSizes = 1 << 0,
     DoNotCreateProcesses = 1 << 1,
 };
 
-}
+} // namespace WebKit
 
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::WebsiteDataFetchOption> {
+    using values = EnumValues<
+        WebKit::WebsiteDataFetchOption,
+        WebKit::WebsiteDataFetchOption::ComputeSizes,
+        WebKit::WebsiteDataFetchOption::DoNotCreateProcesses
+    >;
+};
+
+} // namespace WTF

Modified: trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataType.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataType.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataType.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -29,7 +29,7 @@
 
 namespace WebKit {
 
-enum class WebsiteDataType {
+enum class WebsiteDataType : uint32_t {
     Cookies = 1 << 0,
     DiskCache = 1 << 1,
     MemoryCache = 1 << 2,

Modified: trunk/Source/WebKit/Shared/ios/GestureTypes.h (263207 => 263208)


--- trunk/Source/WebKit/Shared/ios/GestureTypes.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/Shared/ios/GestureTypes.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -83,6 +83,18 @@
 
 namespace WTF {
 
+template<> struct EnumTraits<WebKit::GestureRecognizerState> {
+    using values = EnumValues<
+        WebKit::GestureRecognizerState,
+        WebKit::GestureRecognizerState::Possible,
+        WebKit::GestureRecognizerState::Began,
+        WebKit::GestureRecognizerState::Changed,
+        WebKit::GestureRecognizerState::Ended,
+        WebKit::GestureRecognizerState::Cancelled,
+        WebKit::GestureRecognizerState::Failed
+    >;
+};
+
 template<> struct EnumTraits<WebKit::GestureType> {
     using values = EnumValues<
         WebKit::GestureType,
@@ -103,6 +115,14 @@
     >;
 };
 
+template<> struct EnumTraits<WebKit::SelectionFlags> {
+    using values = EnumValues<
+        WebKit::SelectionFlags,
+        WebKit::SelectionFlags::WordIsNearTap,
+        WebKit::SelectionFlags::PhraseBoundaryChanged
+    >;
+};
+
 template<> struct EnumTraits<WebKit::SelectionTouch> {
     using values = EnumValues<
         WebKit::SelectionTouch,
@@ -115,17 +135,4 @@
     >;
 };
 
-
-template<> struct EnumTraits<WebKit::GestureRecognizerState> {
-    using values = EnumValues<
-        WebKit::GestureRecognizerState,
-        WebKit::GestureRecognizerState::Possible,
-        WebKit::GestureRecognizerState::Began,
-        WebKit::GestureRecognizerState::Changed,
-        WebKit::GestureRecognizerState::Ended,
-        WebKit::GestureRecognizerState::Cancelled,
-        WebKit::GestureRecognizerState::Failed
-    >;
-};
-
 } // namespace WTF

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (263207 => 263208)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -75,8 +75,8 @@
 
 enum class ShouldGrandfatherStatistics : bool;
 enum class StorageAccessStatus : uint8_t;
-enum class WebsiteDataFetchOption;
-enum class WebsiteDataType;
+enum class WebsiteDataFetchOption : uint8_t;
+enum class WebsiteDataType : uint32_t;
 
 struct FrameInfoData;
 struct NetworkProcessCreationParameters;

Modified: trunk/Source/WebKit/UIProcess/Plugins/PluginProcessManager.h (263207 => 263208)


--- trunk/Source/WebKit/UIProcess/Plugins/PluginProcessManager.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/UIProcess/Plugins/PluginProcessManager.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -47,7 +47,7 @@
 class PluginInfoStore;
 class PluginProcessProxy;
 class WebProcessProxy;
-enum class WebsiteDataFetchOption;
+enum class WebsiteDataFetchOption : uint8_t;
 
 class PluginProcessManager {
     WTF_MAKE_NONCOPYABLE(PluginProcessManager);

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (263207 => 263208)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -94,7 +94,7 @@
 class WebProcessPool;
 class WebUserContentControllerProxy;
 class WebsiteDataStore;
-enum class WebsiteDataType;
+enum class WebsiteDataType : uint32_t;
 struct BackForwardListItemState;
 struct UserMessage;
 struct WebNavigationDataStore;

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (263207 => 263208)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -81,8 +81,8 @@
 class WebProcessProxy;
 class WebResourceLoadStatisticsStore;
 enum class CacheModel : uint8_t;
-enum class WebsiteDataFetchOption;
-enum class WebsiteDataType;
+enum class WebsiteDataFetchOption : uint8_t;
+enum class WebsiteDataType : uint32_t;
 struct WebsiteDataRecord;
 struct WebsiteDataStoreParameters;
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (263207 => 263208)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2020-06-18 14:25:41 UTC (rev 263207)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2020-06-18 15:53:25 UTC (rev 263208)
@@ -125,7 +125,7 @@
 struct WebProcessCreationParameters;
 struct WebProcessDataStoreParameters;
 class WebProcessSupplement;
-enum class WebsiteDataType;
+enum class WebsiteDataType : uint32_t;
 struct WebPageCreationParameters;
 struct WebPageGroupData;
 struct WebPreferencesStore;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to