WebKit Bugzilla
Attachment 339489 Details for
Bug 185159
: Use default std::optional if it is provided
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185159-20180504090345.patch (text/plain), 5.23 KB, created by
Yusuke Suzuki
on 2018-05-03 17:03:46 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-05-03 17:03:46 PDT
Size:
5.23 KB
patch
obsolete
>Subversion Revision: 231335 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 9e176b38d8be52b40235a99a561e1f32deae1e64..4a18b8c146516bdfcbfdb566297c0766fa221d3d 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,15 @@ >+2018-05-03 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Use default std::optional if it is provided >+ https://bugs.webkit.org/show_bug.cgi?id=185159 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/Expected.h: >+ * wtf/Optional.h: >+ Do not use <optional> for clang currently. >+ (WTF::valueOrCompute): >+ > 2018-05-03 Wenson Hsieh <wenson_hsieh@apple.com> > > Ads in NYTimes app are shifted downwards by the scroll view's top content inset >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index dd5597fbb51b590e0185c9784b8478ecde38de7f..cee2583240a9769d481060ab74e45f4bfac30048 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,15 @@ >+2018-05-03 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Use default std::optional if it is provided >+ https://bugs.webkit.org/show_bug.cgi?id=185159 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Shared/SandboxExtension.h: >+ (WebKit::SandboxExtension::Handle::decode): >+ * Shared/TouchBarMenuItemData.cpp: >+ (WebKit::TouchBarMenuItemData::decode): >+ > 2018-05-03 Justin Fan <justin_fan@apple.com> > > [WebGL] Add runtime flag for enabling ASTC support in WebGL >diff --git a/Source/WTF/wtf/Expected.h b/Source/WTF/wtf/Expected.h >index dd045e59875e4f4767eb2eb179c1c2719e0af2e2..e9b0ec9f9e645eceedd6f40e42cf891405737a54 100644 >--- a/Source/WTF/wtf/Expected.h >+++ b/Source/WTF/wtf/Expected.h >@@ -573,5 +573,5 @@ template<typename T, typename E> void swap(expected<T, E>& x, expected<T, E>& y) > > }}} // namespace std::experimental::fundamentals_v3 > >-__EXPECTED_INLINE_VARIABLE constexpr std::experimental::unexpected_t& unexpect = std::experimental::unexpect; >+__EXPECTED_INLINE_VARIABLE constexpr auto& unexpect = std::experimental::unexpect; > template<class T, class E> using Expected = std::experimental::expected<T, E>; >diff --git a/Source/WTF/wtf/Optional.h b/Source/WTF/wtf/Optional.h >index a3fc58908345ac1b0a224bc2f179846916d9d2d7..dcef37ab8d5037910f861f35e51d10322320370a 100644 >--- a/Source/WTF/wtf/Optional.h >+++ b/Source/WTF/wtf/Optional.h >@@ -47,6 +47,16 @@ > # include <wtf/Compiler.h> > # include <wtf/StdLibExtras.h> > >+#if !COMPILER(MSVC) && !COMPILER(CLANG) && __has_include(<optional>) >+# include <optional> >+#endif >+ >+#if !COMPILER(MSVC) && !COMPILER(CLANG) && defined(__cpp_lib_optional) && __cpp_lib_optional >= 201603 >+ >+// Use default std::optional. >+ >+#else >+ > # define TR2_OPTIONAL_REQUIRES(...) typename std::enable_if<__VA_ARGS__::value, bool>::type = false > > # if defined __GNUC__ // NOTE: GNUC is also defined for Clang >@@ -1012,20 +1022,6 @@ constexpr optional<X&> make_optional(std::reference_wrapper<X> v) > > } // namespace std > >-namespace WTF { >- >-// -- WebKit Additions -- >-template <class OptionalType, class Callback> >-ALWAYS_INLINE >-auto valueOrCompute(OptionalType optional, Callback callback) -> typename OptionalType::value_type >-{ >- if (optional) >- return *optional; >- return callback(); >-} >- >-} // namespace WTF >- > namespace std > { > template <typename T> >@@ -1054,4 +1050,20 @@ namespace std > # undef TR2_OPTIONAL_REQUIRES > # undef TR2_OPTIONAL_ASSERTED_EXPRESSION > >+#endif // defined(__cpp_lib_optional) >+ >+namespace WTF { >+ >+// -- WebKit Additions -- >+template <class OptionalType, class Callback> >+ALWAYS_INLINE >+auto valueOrCompute(OptionalType optional, Callback callback) -> typename OptionalType::value_type >+{ >+ if (optional) >+ return *optional; >+ return callback(); >+} >+ >+} // namespace WTF >+ > using WTF::valueOrCompute; >diff --git a/Source/WebKit/Shared/SandboxExtension.h b/Source/WebKit/Shared/SandboxExtension.h >index 1f76808564ed4db6e5c0ce1eb63021171e90ed1b..cb53aade63e39f32e2bf62678de7c3cb942df382 100644 >--- a/Source/WebKit/Shared/SandboxExtension.h >+++ b/Source/WebKit/Shared/SandboxExtension.h >@@ -120,7 +120,7 @@ class SandboxExtension : public RefCounted<SandboxExtension> { > inline SandboxExtension::Handle::Handle() { } > inline SandboxExtension::Handle::~Handle() { } > inline void SandboxExtension::Handle::encode(IPC::Encoder&) const { } >-inline std::optional<SandboxExtension::Handle> SandboxExtension::Handle::decode(IPC::Decoder&) { return {{ }}; } >+inline std::optional<SandboxExtension::Handle> SandboxExtension::Handle::decode(IPC::Decoder&) { return SandboxExtension::Handle { }; } > inline SandboxExtension::HandleArray::HandleArray() { } > inline SandboxExtension::HandleArray::~HandleArray() { } > inline void SandboxExtension::HandleArray::allocate(size_t) { } >diff --git a/Source/WebKit/Shared/TouchBarMenuItemData.cpp b/Source/WebKit/Shared/TouchBarMenuItemData.cpp >index d0226bb9a9ec1bae1835bbdde1348c12866bd103..3cdee82d0adf3435c8ed9cfcd7dbd4639f810180 100644 >--- a/Source/WebKit/Shared/TouchBarMenuItemData.cpp >+++ b/Source/WebKit/Shared/TouchBarMenuItemData.cpp >@@ -65,7 +65,7 @@ std::optional<TouchBarMenuItemData> TouchBarMenuItemData::decode(IPC::Decoder& d > if (!decoder.decode(result.priority)) > return std::nullopt; > >- return WTFMove(result); >+ return std::make_optional(WTFMove(result)); > } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185159
:
339186
|
339187
|
339188
|
339194
|
339197
|
339261
|
339262
|
339263
|
339267
|
339489
|
339491