Use the null string instead of std::nullopt for missing attachment file names and...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2018 19:17:45 +0000 (19:17 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2018 19:17:45 +0000 (19:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189080

Reviewed by Tim Horton.

Replace instances of std::optional<String> with just String instead, and use the null string to represent a
missing value instead of std::nullopt. No change in behavior.

Source/WebCore:

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::updateAttributes):
* html/HTMLAttachmentElement.h:

Source/WebKit:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::updateAttachmentAttributes):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateAttachmentAttributes):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235472 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAttachmentElement.cpp
Source/WebCore/html/HTMLAttachmentElement.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index d17dc74..a7e7ed8 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-29  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Use the null string instead of std::nullopt for missing attachment file names and content types
+        https://bugs.webkit.org/show_bug.cgi?id=189080
+
+        Reviewed by Tim Horton.
+
+        Replace instances of std::optional<String> with just String instead, and use the null string to represent a
+        missing value instead of std::nullopt. No change in behavior.
+
+        * html/HTMLAttachmentElement.cpp:
+        (WebCore::HTMLAttachmentElement::updateAttributes):
+        * html/HTMLAttachmentElement.h:
+
 2018-08-29  David Kilzer  <ddkilzer@apple.com>
 
         Remove empty directories from from svn.webkit.org repository
 2018-08-29  David Kilzer  <ddkilzer@apple.com>
 
         Remove empty directories from from svn.webkit.org repository
index 3edbc51..6d1b2d1 100644 (file)
@@ -144,15 +144,15 @@ String HTMLAttachmentElement::attachmentPath() const
     return attributeWithoutSynchronization(webkitattachmentpathAttr);
 }
 
     return attributeWithoutSynchronization(webkitattachmentpathAttr);
 }
 
-void HTMLAttachmentElement::updateAttributes(std::optional<uint64_t>&& newFileSize, std::optional<String>&& newContentType, std::optional<String>&& newFilename)
+void HTMLAttachmentElement::updateAttributes(std::optional<uint64_t>&& newFileSize, const String& newContentType, const String& newFilename)
 {
 {
-    if (newFilename)
-        setAttributeWithoutSynchronization(HTMLNames::titleAttr, *newFilename);
+    if (!newFilename.isNull())
+        setAttributeWithoutSynchronization(HTMLNames::titleAttr, newFilename);
     else
         removeAttribute(HTMLNames::titleAttr);
 
     else
         removeAttribute(HTMLNames::titleAttr);
 
-    if (newContentType)
-        setAttributeWithoutSynchronization(HTMLNames::typeAttr, *newContentType);
+    if (!newContentType.isNull())
+        setAttributeWithoutSynchronization(HTMLNames::typeAttr, newContentType);
     else
         removeAttribute(HTMLNames::typeAttr);
 
     else
         removeAttribute(HTMLNames::typeAttr);
 
index bf9443c..2f24221 100644 (file)
@@ -48,7 +48,7 @@ public:
     const String& uniqueIdentifier() const { return m_uniqueIdentifier; }
     void setUniqueIdentifier(const String& uniqueIdentifier) { m_uniqueIdentifier = uniqueIdentifier; }
 
     const String& uniqueIdentifier() const { return m_uniqueIdentifier; }
     void setUniqueIdentifier(const String& uniqueIdentifier) { m_uniqueIdentifier = uniqueIdentifier; }
 
-    WEBCORE_EXPORT void updateAttributes(std::optional<uint64_t>&& newFileSize = std::nullopt, std::optional<String>&& newContentType = std::nullopt, std::optional<String>&& newFilename = std::nullopt);
+    WEBCORE_EXPORT void updateAttributes(std::optional<uint64_t>&& newFileSize, const String& newContentType, const String& newFilename);
 
     InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
     void removedFromAncestor(RemovalType, ContainerNode&) final;
 
     InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
     void removedFromAncestor(RemovalType, ContainerNode&) final;
index bf2a8ba..2cff410 100644 (file)
@@ -1,3 +1,20 @@
+2018-08-29  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Use the null string instead of std::nullopt for missing attachment file names and content types
+        https://bugs.webkit.org/show_bug.cgi?id=189080
+
+        Reviewed by Tim Horton.
+
+        Replace instances of std::optional<String> with just String instead, and use the null string to represent a
+        missing value instead of std::nullopt. No change in behavior.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::updateAttachmentAttributes):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updateAttachmentAttributes):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2018-08-28  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Use CMake's FindFreetype
 2018-08-28  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Use CMake's FindFreetype
index 7003120..5262d33 100644 (file)
@@ -7703,9 +7703,7 @@ void WebPageProxy::updateAttachmentAttributes(const API::Attachment& attachment,
     }
 
     auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken());
     }
 
     auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken());
-    auto name = attachment.fileName();
-    auto optionalName = name.isNull() ? std::nullopt : std::optional<WTF::String> { name };
-    m_process->send(Messages::WebPage::UpdateAttachmentAttributes(attachment.identifier(), attachment.fileSizeForDisplay(), attachment.contentType(), WTFMove(optionalName), callbackID), m_pageID);
+    m_process->send(Messages::WebPage::UpdateAttachmentAttributes(attachment.identifier(), attachment.fileSizeForDisplay(), attachment.contentType(), attachment.fileName(), callbackID), m_pageID);
 }
 
 void WebPageProxy::registerAttachmentIdentifierFromData(const String& identifier, const String& contentType, const String& preferredFileName, const IPC::DataReference& data)
 }
 
 void WebPageProxy::registerAttachmentIdentifierFromData(const String& identifier, const String& contentType, const String& preferredFileName, const IPC::DataReference& data)
index 3265997..76d2759 100644 (file)
@@ -6073,11 +6073,11 @@ void WebPage::insertAttachment(const String& identifier, std::optional<uint64_t>
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
-void WebPage::updateAttachmentAttributes(const String& identifier, std::optional<uint64_t>&& fileSize, const String& contentType, std::optional<String>&& newFilename, CallbackID callbackID)
+void WebPage::updateAttachmentAttributes(const String& identifier, std::optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, CallbackID callbackID)
 {
     if (auto attachment = attachmentElementWithIdentifier(identifier)) {
         attachment->document().updateLayout();
 {
     if (auto attachment = attachmentElementWithIdentifier(identifier)) {
         attachment->document().updateLayout();
-        attachment->updateAttributes(WTFMove(fileSize), contentType, WTFMove(newFilename));
+        attachment->updateAttributes(WTFMove(fileSize), contentType, fileName);
     }
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
     }
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
index 2559a0d..62fe50c 100644 (file)
@@ -1073,7 +1073,7 @@ public:
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     void insertAttachment(const String& identifier, std::optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID);
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     void insertAttachment(const String& identifier, std::optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID);
-    void updateAttachmentAttributes(const String& identifier, std::optional<uint64_t>&& fileSize, const String& contentType, std::optional<String>&& newFilename, CallbackID);
+    void updateAttachmentAttributes(const String& identifier, std::optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, CallbackID);
 #endif
 
 #if ENABLE(APPLICATION_MANIFEST)
 #endif
 
 #if ENABLE(APPLICATION_MANIFEST)
index 7ddcb9b..7e96a7a 100644 (file)
@@ -511,7 +511,7 @@ messages -> WebPage LegacyReceiver {
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     InsertAttachment(String identifier, std::optional<uint64_t> fileSize, String fileName, String contentType, WebKit::CallbackID callbackID)
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     InsertAttachment(String identifier, std::optional<uint64_t> fileSize, String fileName, String contentType, WebKit::CallbackID callbackID)
-    UpdateAttachmentAttributes(String identifier, std::optional<uint64_t> fileSize, String newContentType, std::optional<String> newFilename, WebKit::CallbackID callbackID)
+    UpdateAttachmentAttributes(String identifier, std::optional<uint64_t> fileSize, String contentType, String fileName, WebKit::CallbackID callbackID)
 #endif
 
 #if ENABLE(APPLICATION_MANIFEST)
 #endif
 
 #if ENABLE(APPLICATION_MANIFEST)