WebKit Bugzilla
Attachment 339277 Details for
Bug 185186
: Use pointer instead of std::optional<std::reference_wrapper<>>
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185186-20180502141016.patch (text/plain), 17.67 KB, created by
Yusuke Suzuki
on 2018-05-01 22:10:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-05-01 22:10:17 PDT
Size:
17.67 KB
patch
obsolete
>Subversion Revision: 231223 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 68751546a07533ee398537506088ee2cba6beb67..7213232c39d5531abd104a20cd89e2e889ef31ec 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,43 @@ >+2018-05-01 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Use pointer instead of std::optional<std::reference_wrapper<>> >+ https://bugs.webkit.org/show_bug.cgi?id=185186 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ std::optional<T&> is not accepted in C++17 spec. So we replaced it >+ with std::optional<std::reference_wrapper<T>>. >+ >+ In this patch, we replace it with T*, which is well-aligned to >+ WebKit's convention. >+ >+ * Modules/mediastream/RTCPeerConnection.cpp: >+ (WebCore::iceServersFromConfiguration): >+ (WebCore::RTCPeerConnection::initializeConfiguration): >+ (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): >+ * dom/DatasetDOMStringMap.h: >+ * dom/Element.cpp: >+ (WebCore::Element::insertAdjacentHTML): >+ * dom/Element.h: >+ * html/canvas/CanvasStyle.cpp: >+ (WebCore::parseColor): >+ * inspector/DOMEditor.cpp: >+ * platform/network/curl/CurlFormDataStream.cpp: >+ (WebCore::CurlFormDataStream::getPostData): >+ * platform/network/curl/CurlFormDataStream.h: >+ * platform/network/curl/CurlRequest.cpp: >+ (WebCore::CurlRequest::setupPOST): >+ * testing/MockCDMFactory.cpp: >+ (WebCore::MockCDMFactory::keysForSessionWithID const): >+ (WebCore::MockCDMInstance::updateLicense): >+ * testing/MockCDMFactory.h: >+ > 2018-05-01 Yusuke Suzuki <utatane.tea@gmail.com> > > Use default std::optional if it is provided >diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >index 536c5526a28b567b05f05fc57cc2acd50f7fbe70..0e3c4f603d94ffb1a59be64cf168795f7678a126 100644 >--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >@@ -301,12 +301,12 @@ void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOM > } > > // Implementation of https://w3c.github.io/webrtc-pc/#set-pc-configuration >-static inline ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& newConfiguration, std::optional<std::reference_wrapper<const RTCConfiguration>> existingConfiguration, bool isLocalDescriptionSet) >+static inline ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& newConfiguration, const RTCConfiguration* existingConfiguration, bool isLocalDescriptionSet) > { >- if (existingConfiguration && newConfiguration.bundlePolicy != existingConfiguration->get().bundlePolicy) >+ if (existingConfiguration && newConfiguration.bundlePolicy != existingConfiguration->bundlePolicy) > return Exception { InvalidModificationError, "IceTransportPolicy does not match existing policy" }; > >- if (existingConfiguration && newConfiguration.iceCandidatePoolSize != existingConfiguration->get().iceCandidatePoolSize && isLocalDescriptionSet) >+ if (existingConfiguration && newConfiguration.iceCandidatePoolSize != existingConfiguration->iceCandidatePoolSize && isLocalDescriptionSet) > return Exception { InvalidModificationError, "IceTransportPolicy pool size does not match existing pool size" }; > > Vector<MediaEndpointConfiguration::IceServerInfo> servers; >@@ -342,7 +342,7 @@ ExceptionOr<void> RTCPeerConnection::initializeConfiguration(RTCConfiguration&& > { > INFO_LOG(LOGIDENTIFIER); > >- auto servers = iceServersFromConfiguration(configuration, std::nullopt, false); >+ auto servers = iceServersFromConfiguration(configuration, nullptr, false); > if (servers.hasException()) > return servers.releaseException(); > >@@ -360,7 +360,7 @@ ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configu > > INFO_LOG(LOGIDENTIFIER); > >- auto servers = iceServersFromConfiguration(configuration, std::cref(m_configuration), m_backend->isLocalDescriptionSet()); >+ auto servers = iceServersFromConfiguration(configuration, &m_configuration, m_backend->isLocalDescriptionSet()); > if (servers.hasException()) > return servers.releaseException(); > >diff --git a/Source/WebCore/css/parser/CSSParser.cpp b/Source/WebCore/css/parser/CSSParser.cpp >index 33f52e1a653e5bd30ff64cddf2020d73bfa50e71..84138018651470f9751960ca6bca17c46519e2dc 100644 >--- a/Source/WebCore/css/parser/CSSParser.cpp >+++ b/Source/WebCore/css/parser/CSSParser.cpp >@@ -178,14 +178,14 @@ Color CSSParser::parseColor(const String& string, bool strict) > return primitiveValue.color(); > } > >-Color CSSParser::parseSystemColor(const String& string, std::optional<std::reference_wrapper<const CSSParserContext>> context) >+Color CSSParser::parseSystemColor(const String& string, const CSSParserContext* context) > { > CSSValueID id = cssValueKeywordID(string); > if (!StyleColor::isSystemColor(id)) > return Color(); > > OptionSet<StyleColor::Options> options; >- if (context && context->get().useSystemAppearance) >+ if (context && context->useSystemAppearance) > options |= StyleColor::Options::UseSystemAppearance; > return RenderTheme::singleton().systemColor(id, options); > } >diff --git a/Source/WebCore/css/parser/CSSParser.h b/Source/WebCore/css/parser/CSSParser.h >index aee78e57a1f79307e4201772d4246948b11580ba..2930d45098a10ba197137713ea0bd6071302ae7b 100644 >--- a/Source/WebCore/css/parser/CSSParser.h >+++ b/Source/WebCore/css/parser/CSSParser.h >@@ -78,7 +78,7 @@ class CSSParser { > 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<std::reference_wrapper<const CSSParserContext>>); >+ static Color parseSystemColor(const String&, const CSSParserContext*); > > private: > ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important); >diff --git a/Source/WebCore/dom/DatasetDOMStringMap.cpp b/Source/WebCore/dom/DatasetDOMStringMap.cpp >index 8e86aeefe5dc7885377facc92f6cdc5c555122c6..ec6315c960b5a77e7992b4c6d9e23af25725c015 100644 >--- a/Source/WebCore/dom/DatasetDOMStringMap.cpp >+++ b/Source/WebCore/dom/DatasetDOMStringMap.cpp >@@ -188,7 +188,7 @@ Vector<String> DatasetDOMStringMap::supportedPropertyNames() const > return names; > } > >-std::optional<std::reference_wrapper<const AtomicString>> DatasetDOMStringMap::item(const String& propertyName) const >+const AtomicString* DatasetDOMStringMap::item(const String& propertyName) const > { > if (m_element.hasAttributes()) { > AttributeIteratorAccessor attributeIteratorAccessor = m_element.attributesIterator(); >@@ -198,23 +198,23 @@ std::optional<std::reference_wrapper<const AtomicString>> DatasetDOMStringMap::i > // 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 std::cref(attribute.value()); >+ return &attribute.value(); > } else { > AtomicString attributeName = convertPropertyNameToAttributeName(propertyName); > for (const Attribute& attribute : attributeIteratorAccessor) { > if (attribute.localName() == attributeName) >- return std::cref(attribute.value()); >+ return &attribute.value(); > } > } > } > >- return std::nullopt; >+ return nullptr; > } > > String DatasetDOMStringMap::namedItem(const AtomicString& name) const > { >- if (auto value = item(name)) >- return value->get(); >+ if (const auto* value = item(name)) >+ return *value; > return String { }; > } > >diff --git a/Source/WebCore/dom/DatasetDOMStringMap.h b/Source/WebCore/dom/DatasetDOMStringMap.h >index d6d10d126122dccc997d978f5ea254c3224fff34..9100db8c88ccade140eebd35a4a0e599c5ba115e 100644 >--- a/Source/WebCore/dom/DatasetDOMStringMap.h >+++ b/Source/WebCore/dom/DatasetDOMStringMap.h >@@ -53,7 +53,7 @@ class DatasetDOMStringMap final : public ScriptWrappable { > Element& element() { return m_element; } > > private: >- std::optional<std::reference_wrapper<const AtomicString>> item(const String& name) const; >+ const AtomicString* item(const String& name) const; > > Element& m_element; > }; >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index 273d8cae726adaa56be550e20a70bae2671bad5e..24faa3f5a9eecb9ce87462cd36e55d0ab3b1c147 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -3733,7 +3733,7 @@ static ExceptionOr<Ref<Element>> contextElementForInsertion(const String& where, > } > > // https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml >-ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup, std::optional<std::reference_wrapper<NodeVector>> addedNodes) >+ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup, NodeVector* addedNodes) > { > // Steps 1 and 2. > auto contextElement = contextElementForInsertion(where, *this); >@@ -3747,7 +3747,7 @@ ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& > 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->get() = collectChildNodes(fragment.returnValue()); >+ *addedNodes = collectChildNodes(fragment.returnValue()); > } > > // Step 4. >@@ -3759,7 +3759,7 @@ ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& > > ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup) > { >- return insertAdjacentHTML(where, markup, std::nullopt); >+ return insertAdjacentHTML(where, markup, nullptr); > } > > ExceptionOr<void> Element::insertAdjacentText(const String& where, const String& text) >diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h >index 9af411304f4d998aab11b924af91d2190006fd96..1c4db86823c6e41ec5fc3ab3f20194516eaffa06 100644 >--- a/Source/WebCore/dom/Element.h >+++ b/Source/WebCore/dom/Element.h >@@ -314,7 +314,7 @@ class Element : public ContainerNode { > WEBCORE_EXPORT void setTabIndex(int); > virtual RefPtr<Element> focusDelegate(); > >- ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html, std::optional<std::reference_wrapper<NodeVector>> addedNodes); >+ ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html, NodeVector* addedNodes); > > WEBCORE_EXPORT ExceptionOr<Element*> insertAdjacentElement(const String& where, Element& newChild); > WEBCORE_EXPORT ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html); >diff --git a/Source/WebCore/html/canvas/CanvasStyle.cpp b/Source/WebCore/html/canvas/CanvasStyle.cpp >index ff49ad108defd88d6f7388246d181c000b67837d..aca8a60d8c62b3ece8aaed4853a59001829bc1da 100644 >--- a/Source/WebCore/html/canvas/CanvasStyle.cpp >+++ b/Source/WebCore/html/canvas/CanvasStyle.cpp >@@ -53,7 +53,7 @@ static Color parseColor(const String& colorString) > Color color = CSSParser::parseColor(colorString); > if (color.isValid()) > return color; >- return CSSParser::parseSystemColor(colorString, std::nullopt); >+ return CSSParser::parseSystemColor(colorString, nullptr); > } > > Color currentColor(HTMLCanvasElement* canvas) >diff --git a/Source/WebCore/inspector/DOMEditor.cpp b/Source/WebCore/inspector/DOMEditor.cpp >index 59eccd405c037ef2a440c4d551c9cbca121c6aa0..e0af0fdecc7f3861a9234fafe1a21ec8102868c3 100644 >--- a/Source/WebCore/inspector/DOMEditor.cpp >+++ b/Source/WebCore/inspector/DOMEditor.cpp >@@ -266,7 +266,7 @@ class DOMEditor::InsertAdjacentHTMLAction final : public InspectorHistory::Actio > > ExceptionOr<void> redo() final > { >- auto result = m_element->insertAdjacentHTML(m_position, m_html, std::ref(m_addedNodes)); >+ auto result = m_element->insertAdjacentHTML(m_position, m_html, &m_addedNodes); > if (result.hasException()) > return result.releaseException(); > return { }; >diff --git a/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp b/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp >index 2ad6a18724b2fac0424065601c529aaf92c9824a..889892dce319b7a9771e0975d80d33453e6dbc85 100644 >--- a/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp >+++ b/Source/WebCore/platform/network/curl/CurlFormDataStream.cpp >@@ -69,15 +69,15 @@ void CurlFormDataStream::clean() > } > } > >-std::optional<std::reference_wrapper<const Vector<char>>> CurlFormDataStream::getPostData() >+const Vector<char>* CurlFormDataStream::getPostData() > { > if (!m_formData) >- return std::nullopt; >+ return nullptr; > > if (!m_postData) > m_postData = std::make_unique<Vector<char>>(m_formData->flatten()); > >- return std::cref(*m_postData); >+ return m_postData.get(); > } > > bool CurlFormDataStream::shouldUseChunkTransfer() >diff --git a/Source/WebCore/platform/network/curl/CurlFormDataStream.h b/Source/WebCore/platform/network/curl/CurlFormDataStream.h >index d33df78033a14579c1ecb25b84e5df0217a198fe..4f1b3081208416f7d35933efd8c2f46744781ba0 100644 >--- a/Source/WebCore/platform/network/curl/CurlFormDataStream.h >+++ b/Source/WebCore/platform/network/curl/CurlFormDataStream.h >@@ -41,7 +41,7 @@ class CurlFormDataStream { > > size_t elementSize() { return m_formData ? m_formData->elements().size() : 0; } > >- std::optional<std::reference_wrapper<const Vector<char>>> getPostData(); >+ const Vector<char>* getPostData(); > bool shouldUseChunkTransfer(); > unsigned long long totalSize(); > >diff --git a/Source/WebCore/platform/network/curl/CurlRequest.cpp b/Source/WebCore/platform/network/curl/CurlRequest.cpp >index 00799a30e0154626b7d6d4a0c1d1078489d68716..f2d0c9b670e94c4a1d43c01bacc2b27959cd9743 100644 >--- a/Source/WebCore/platform/network/curl/CurlRequest.cpp >+++ b/Source/WebCore/platform/network/curl/CurlRequest.cpp >@@ -489,9 +489,9 @@ void CurlRequest::setupPOST(ResourceRequest& request) > > // Do not stream for simple POST data > if (elementSize == 1) { >- auto postData = m_formDataStream.getPostData(); >- if (postData && postData->get().size()) >- m_curlHandle->setPostFields(postData->get().data(), postData->get().size()); >+ const auto* postData = m_formDataStream.getPostData(); >+ if (postData && postData->size()) >+ m_curlHandle->setPostFields(postData->data(), postData->size()); > } else > setupSendData(false); > } >diff --git a/Source/WebCore/testing/MockCDMFactory.cpp b/Source/WebCore/testing/MockCDMFactory.cpp >index 445ea9b5879748f8d60d629f933c93e099701a0f..e2fdfbc1ca4ca1b1eb58bc875990da9a4d96c6bc 100644 >--- a/Source/WebCore/testing/MockCDMFactory.cpp >+++ b/Source/WebCore/testing/MockCDMFactory.cpp >@@ -81,12 +81,12 @@ Vector<Ref<SharedBuffer>> MockCDMFactory::removeKeysFromSessionWithID(const Stri > return WTFMove(it->value); > } > >-std::optional<std::reference_wrapper<const Vector<Ref<SharedBuffer>>>> MockCDMFactory::keysForSessionWithID(const String& id) const >+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 std::cref(it->value); >+ return nullptr; >+ return &it->value; > } > > void MockCDMFactory::setSupportedDataTypes(Vector<String>&& types) >@@ -314,11 +314,11 @@ void MockCDMInstance::updateLicense(const String& sessionID, LicenseType, const > > std::optional<KeyStatusVector> changedKeys; > if (responseVector.contains(String(ASCIILiteral("keys-changed")))) { >- std::optional<std::reference_wrapper<const Vector<Ref<SharedBuffer>>>> keys = factory->keysForSessionWithID(sessionID); >+ const auto* keys = factory->keysForSessionWithID(sessionID); > if (keys) { > KeyStatusVector keyStatusVector; >- keyStatusVector.reserveInitialCapacity(keys->get().size()); >- for (auto& key : (*keys).get()) >+ keyStatusVector.reserveInitialCapacity(keys->size()); >+ for (auto& key : *keys) > keyStatusVector.uncheckedAppend({ key.copyRef(), KeyStatus::Usable }); > > changedKeys = WTFMove(keyStatusVector); >diff --git a/Source/WebCore/testing/MockCDMFactory.h b/Source/WebCore/testing/MockCDMFactory.h >index 3e6db21d01bcd5a50af5e97650c3f14b8b79648d..418d390bf06d7fb7ddf90ea78435abadb5aaedd8 100644 >--- a/Source/WebCore/testing/MockCDMFactory.h >+++ b/Source/WebCore/testing/MockCDMFactory.h >@@ -73,7 +73,7 @@ class MockCDMFactory : public RefCounted<MockCDMFactory>, private CDMFactory { > 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<std::reference_wrapper<const Vector<Ref<SharedBuffer>>>> keysForSessionWithID(const String& id) const; >+ const Vector<Ref<SharedBuffer>>* keysForSessionWithID(const String& id) const; > Vector<Ref<SharedBuffer>> removeKeysFromSessionWithID(const String& id); > > private:
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
Flags:
achristensen
:
review+
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185186
: 339277 |
339292