Diff
Modified: trunk/Source/WTF/ChangeLog (231222 => 231223)
--- trunk/Source/WTF/ChangeLog 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WTF/ChangeLog 2018-05-02 04:32:33 UTC (rev 231223)
@@ -1,3 +1,27 @@
+2018-05-01 Yusuke Suzuki <[email protected]>
+
+ Use default std::optional if it is provided
+ https://bugs.webkit.org/show_bug.cgi?id=185159
+
+ Reviewed by JF Bastien.
+
+ Now C++17 flag is enabled. It means that any standard libraries can use <optional> internally.
+ If we define std::optional regardless of the existence of the standard library's <optional>,
+ it causes compile errors. For example, in GCC 7 (specifically GCC 7.3.0) environment,
+ <optional> is included in <unordered_map>.
+ We do not define std::optional in WebKit side if <optional> is offered.
+
+ And we also remove std::optional<T&> use since this is not accepted in C++17. Use
+ std::optional<std::reference_wrapper<T>> instead.
+
+ * wtf/Expected.h:
+ constexpr does not mean const in C++17.
+
+ * wtf/Optional.h:
+ Do not define std::optional if <optional> is provided.
+
+ (WTF::valueOrCompute):
+
2018-05-01 Robin Morisset <[email protected]>
Correctly detect string overflow when using the 'Function' constructor
Modified: trunk/Source/WTF/wtf/Expected.h (231222 => 231223)
--- trunk/Source/WTF/wtf/Expected.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WTF/wtf/Expected.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -573,5 +573,5 @@
}}} // 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>;
Modified: trunk/Source/WTF/wtf/Optional.h (231222 => 231223)
--- trunk/Source/WTF/wtf/Optional.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WTF/wtf/Optional.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -47,6 +47,16 @@
# include <wtf/Compiler.h>
# include <wtf/StdLibExtras.h>
+#if !COMPILER(MSVC) && __has_include(<optional>)
+# include <optional>
+#endif
+
+#if !COMPILER(MSVC) && 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 @@
} // 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 @@
# 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;
Modified: trunk/Source/WebCore/ChangeLog (231222 => 231223)
--- trunk/Source/WebCore/ChangeLog 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/ChangeLog 2018-05-02 04:32:33 UTC (rev 231223)
@@ -1,3 +1,35 @@
+2018-05-01 Yusuke Suzuki <[email protected]>
+
+ Use default std::optional if it is provided
+ https://bugs.webkit.org/show_bug.cgi?id=185159
+
+ Reviewed by JF Bastien.
+
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::iceServersFromConfiguration):
+ (WebCore::RTCPeerConnection::setConfiguration):
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParser::parseSystemColor):
+ * css/parser/CSSParser.h:
+ * dom/DatasetDOMStringMap.cpp:
+ (WebCore::DatasetDOMStringMap::item const):
+ (WebCore::DatasetDOMStringMap::namedItem const):
+ (WebCore:: const): Deleted.
+ * dom/DatasetDOMStringMap.h:
+ * dom/Element.cpp:
+ (WebCore::Element::insertAdjacentHTML):
+ * dom/Element.h:
+ * inspector/DOMEditor.cpp:
+ * platform/network/curl/CurlFormDataStream.cpp:
+ (WebCore::CurlFormDataStream::getPostData):
+ (): Deleted.
+ * platform/network/curl/CurlFormDataStream.h:
+ * testing/MockCDMFactory.cpp:
+ (WebCore::MockCDMFactory::keysForSessionWithID const):
+ (WebCore::MockCDMInstance::updateLicense):
+ (WebCore:: const): Deleted.
+ * testing/MockCDMFactory.h:
+
2018-05-01 Chris Dumez <[email protected]>
Add release assertions in CFNetwork's SocketStreamHandleImpl to help debug a threading issue
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (231222 => 231223)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -301,12 +301,12 @@
}
// Implementation of https://w3c.github.io/webrtc-pc/#set-pc-configuration
-static inline ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& newConfiguration, std::optional<const RTCConfiguration&> existingConfiguration, bool isLocalDescriptionSet)
+static inline ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& newConfiguration, std::optional<std::reference_wrapper<const RTCConfiguration>> existingConfiguration, bool isLocalDescriptionSet)
{
- if (existingConfiguration && newConfiguration.bundlePolicy != existingConfiguration->bundlePolicy)
+ if (existingConfiguration && newConfiguration.bundlePolicy != existingConfiguration->get().bundlePolicy)
return Exception { InvalidModificationError, "IceTransportPolicy does not match existing policy" };
- if (existingConfiguration && newConfiguration.iceCandidatePoolSize != existingConfiguration->iceCandidatePoolSize && isLocalDescriptionSet)
+ if (existingConfiguration && newConfiguration.iceCandidatePoolSize != existingConfiguration->get().iceCandidatePoolSize && isLocalDescriptionSet)
return Exception { InvalidModificationError, "IceTransportPolicy pool size does not match existing pool size" };
Vector<MediaEndpointConfiguration::IceServerInfo> servers;
@@ -360,7 +360,7 @@
INFO_LOG(LOGIDENTIFIER);
- auto servers = iceServersFromConfiguration(configuration, m_configuration, m_backend->isLocalDescriptionSet());
+ auto servers = iceServersFromConfiguration(configuration, std::cref(m_configuration), m_backend->isLocalDescriptionSet());
if (servers.hasException())
return servers.releaseException();
Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (231222 => 231223)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -178,7 +178,7 @@
return primitiveValue.color();
}
-Color CSSParser::parseSystemColor(const String& string, std::optional<const CSSParserContext&> context)
+Color CSSParser::parseSystemColor(const String& string, std::optional<std::reference_wrapper<const CSSParserContext>> context)
{
CSSValueID id = cssValueKeywordID(string);
if (!StyleColor::isSystemColor(id))
@@ -185,7 +185,7 @@
return Color();
OptionSet<StyleColor::Options> options;
- if (context && context.value().useSystemAppearance)
+ if (context && context->get().useSystemAppearance)
options |= StyleColor::Options::UseSystemAppearance;
return RenderTheme::singleton().systemColor(id, options);
}
Modified: trunk/Source/WebCore/css/parser/CSSParser.h (231222 => 231223)
--- trunk/Source/WebCore/css/parser/CSSParser.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/css/parser/CSSParser.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -78,7 +78,7 @@
RefPtr<CSSValue> parseValueWithVariableReferences(CSSPropertyID, const CSSValue&, const CustomPropertyValueMap& customProperties, TextDirection, WritingMode);
static Color parseColor(const String&, bool strict = false);
- static Color parseSystemColor(const String&, std::optional<const CSSParserContext&>);
+ static Color parseSystemColor(const String&, std::optional<std::reference_wrapper<const CSSParserContext>>);
private:
ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important);
Modified: trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp (231222 => 231223)
--- trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -188,7 +188,7 @@
return names;
}
-std::optional<const AtomicString&> DatasetDOMStringMap::item(const String& propertyName) const
+std::optional<std::reference_wrapper<const AtomicString>> DatasetDOMStringMap::item(const String& propertyName) const
{
if (m_element.hasAttributes()) {
AttributeIteratorAccessor attributeIteratorAccessor = m_element.attributesIterator();
@@ -198,12 +198,12 @@
// Building a new AtomicString in that case is overkill so we do a direct character comparison.
const Attribute& attribute = *attributeIteratorAccessor.begin();
if (propertyNameMatchesAttributeName(propertyName, attribute.localName()))
- return attribute.value();
+ return std::cref(attribute.value());
} else {
AtomicString attributeName = convertPropertyNameToAttributeName(propertyName);
for (const Attribute& attribute : attributeIteratorAccessor) {
if (attribute.localName() == attributeName)
- return attribute.value();
+ return std::cref(attribute.value());
}
}
}
@@ -213,7 +213,9 @@
String DatasetDOMStringMap::namedItem(const AtomicString& name) const
{
- return item(name).value_or(String { });
+ if (auto value = item(name))
+ return value->get();
+ return String { };
}
ExceptionOr<void> DatasetDOMStringMap::setNamedItem(const String& name, const String& value)
Modified: trunk/Source/WebCore/dom/DatasetDOMStringMap.h (231222 => 231223)
--- trunk/Source/WebCore/dom/DatasetDOMStringMap.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/dom/DatasetDOMStringMap.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -53,7 +53,7 @@
Element& element() { return m_element; }
private:
- std::optional<const AtomicString&> item(const String& name) const;
+ std::optional<std::reference_wrapper<const AtomicString>> item(const String& name) const;
Element& m_element;
};
Modified: trunk/Source/WebCore/dom/Element.cpp (231222 => 231223)
--- trunk/Source/WebCore/dom/Element.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/dom/Element.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -3733,7 +3733,7 @@
}
// https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml
-ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup, std::optional<NodeVector&> addedNodes)
+ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup, std::optional<std::reference_wrapper<NodeVector>> addedNodes)
{
// Steps 1 and 2.
auto contextElement = contextElementForInsertion(where, *this);
@@ -3747,7 +3747,7 @@
if (UNLIKELY(addedNodes)) {
// Must be called before insertAdjacent, as otherwise the children of fragment will be moved
// to their new parent and will be harder to keep track of.
- *addedNodes = collectChildNodes(fragment.returnValue());
+ addedNodes->get() = collectChildNodes(fragment.returnValue());
}
// Step 4.
Modified: trunk/Source/WebCore/dom/Element.h (231222 => 231223)
--- trunk/Source/WebCore/dom/Element.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/dom/Element.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -314,7 +314,7 @@
WEBCORE_EXPORT void setTabIndex(int);
virtual RefPtr<Element> focusDelegate();
- ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html, std::optional<NodeVector&> addedNodes);
+ ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html, std::optional<std::reference_wrapper<NodeVector>> addedNodes);
WEBCORE_EXPORT ExceptionOr<Element*> insertAdjacentElement(const String& where, Element& newChild);
WEBCORE_EXPORT ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html);
Modified: trunk/Source/WebCore/inspector/DOMEditor.cpp (231222 => 231223)
--- trunk/Source/WebCore/inspector/DOMEditor.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/inspector/DOMEditor.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -266,7 +266,7 @@
ExceptionOr<void> redo() final
{
- auto result = m_element->insertAdjacentHTML(m_position, m_html, m_addedNodes);
+ auto result = m_element->insertAdjacentHTML(m_position, m_html, std::ref(m_addedNodes));
if (result.hasException())
return result.releaseException();
return { };
Modified: trunk/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp (231222 => 231223)
--- trunk/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -69,7 +69,7 @@
}
}
-std::optional<const Vector<char>&> CurlFormDataStream::getPostData()
+std::optional<std::reference_wrapper<const Vector<char>>> CurlFormDataStream::getPostData()
{
if (!m_formData)
return std::nullopt;
@@ -77,7 +77,7 @@
if (!m_postData)
m_postData = std::make_unique<Vector<char>>(m_formData->flatten());
- return *m_postData;
+ return std::cref(*m_postData);
}
bool CurlFormDataStream::shouldUseChunkTransfer()
Modified: trunk/Source/WebCore/platform/network/curl/CurlFormDataStream.h (231222 => 231223)
--- trunk/Source/WebCore/platform/network/curl/CurlFormDataStream.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/platform/network/curl/CurlFormDataStream.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -41,7 +41,7 @@
size_t elementSize() { return m_formData ? m_formData->elements().size() : 0; }
- std::optional<const Vector<char>&> getPostData();
+ std::optional<std::reference_wrapper<const Vector<char>>> getPostData();
bool shouldUseChunkTransfer();
unsigned long long totalSize();
Modified: trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp (231222 => 231223)
--- trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -490,8 +490,8 @@
// Do not stream for simple POST data
if (elementSize == 1) {
auto postData = m_formDataStream.getPostData();
- if (postData && postData->size())
- m_curlHandle->setPostFields(postData->data(), postData->size());
+ if (postData && postData->get().size())
+ m_curlHandle->setPostFields(postData->get().data(), postData->get().size());
} else
setupSendData(false);
}
Modified: trunk/Source/WebCore/testing/MockCDMFactory.cpp (231222 => 231223)
--- trunk/Source/WebCore/testing/MockCDMFactory.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/testing/MockCDMFactory.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -81,12 +81,12 @@
return WTFMove(it->value);
}
-std::optional<const Vector<Ref<SharedBuffer>>&> MockCDMFactory::keysForSessionWithID(const String& id) const
+std::optional<std::reference_wrapper<const Vector<Ref<SharedBuffer>>>> MockCDMFactory::keysForSessionWithID(const String& id) const
{
auto it = m_sessions.find(id);
if (it == m_sessions.end())
return std::nullopt;
- return it->value;
+ return std::cref(it->value);
}
void MockCDMFactory::setSupportedDataTypes(Vector<String>&& types)
@@ -314,11 +314,11 @@
std::optional<KeyStatusVector> changedKeys;
if (responseVector.contains(String(ASCIILiteral("keys-changed")))) {
- std::optional<const Vector<Ref<SharedBuffer>>&> keys = factory->keysForSessionWithID(sessionID);
+ std::optional<std::reference_wrapper<const Vector<Ref<SharedBuffer>>>> keys = factory->keysForSessionWithID(sessionID);
if (keys) {
KeyStatusVector keyStatusVector;
- keyStatusVector.reserveInitialCapacity(keys->size());
- for (auto& key : *keys)
+ keyStatusVector.reserveInitialCapacity(keys->get().size());
+ for (auto& key : (*keys).get())
keyStatusVector.uncheckedAppend({ key.copyRef(), KeyStatus::Usable });
changedKeys = WTFMove(keyStatusVector);
Modified: trunk/Source/WebCore/testing/MockCDMFactory.h (231222 => 231223)
--- trunk/Source/WebCore/testing/MockCDMFactory.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebCore/testing/MockCDMFactory.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -73,7 +73,7 @@
bool hasSessionWithID(const String& id) { return m_sessions.contains(id); }
void removeSessionWithID(const String& id) { m_sessions.remove(id); }
void addKeysToSessionWithID(const String& id, Vector<Ref<SharedBuffer>>&&);
- std::optional<const Vector<Ref<SharedBuffer>>&> keysForSessionWithID(const String& id) const;
+ std::optional<std::reference_wrapper<const Vector<Ref<SharedBuffer>>>> keysForSessionWithID(const String& id) const;
Vector<Ref<SharedBuffer>> removeKeysFromSessionWithID(const String& id);
private:
Modified: trunk/Source/WebKit/ChangeLog (231222 => 231223)
--- trunk/Source/WebKit/ChangeLog 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebKit/ChangeLog 2018-05-02 04:32:33 UTC (rev 231223)
@@ -1,3 +1,15 @@
+2018-05-01 Yusuke Suzuki <[email protected]>
+
+ Use default std::optional if it is provided
+ https://bugs.webkit.org/show_bug.cgi?id=185159
+
+ Reviewed by JF Bastien.
+
+ * Shared/SandboxExtension.h:
+ (WebKit::SandboxExtension::Handle::decode):
+ * Shared/TouchBarMenuItemData.cpp:
+ (WebKit::TouchBarMenuItemData::decode):
+
2018-05-01 Jer Noble <[email protected]>
Production build error in Migrate Header phase when WK_ALTERNATE_FRAMEWORKS_DIR is set to non-empty value
Modified: trunk/Source/WebKit/Shared/SandboxExtension.h (231222 => 231223)
--- trunk/Source/WebKit/Shared/SandboxExtension.h 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebKit/Shared/SandboxExtension.h 2018-05-02 04:32:33 UTC (rev 231223)
@@ -120,7 +120,7 @@
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) { }
Modified: trunk/Source/WebKit/Shared/TouchBarMenuItemData.cpp (231222 => 231223)
--- trunk/Source/WebKit/Shared/TouchBarMenuItemData.cpp 2018-05-02 04:05:41 UTC (rev 231222)
+++ trunk/Source/WebKit/Shared/TouchBarMenuItemData.cpp 2018-05-02 04:32:33 UTC (rev 231223)
@@ -65,7 +65,7 @@
if (!decoder.decode(result.priority))
return std::nullopt;
- return WTFMove(result);
+ return std::make_optional(WTFMove(result));
}
}