Title: [235472] trunk/Source
Revision
235472
Author
wenson_hs...@apple.com
Date
2018-08-29 12:17:45 -0700 (Wed, 29 Aug 2018)

Log Message

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.

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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235471 => 235472)


--- trunk/Source/WebCore/ChangeLog	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebCore/ChangeLog	2018-08-29 19:17:45 UTC (rev 235472)
@@ -1,3 +1,17 @@
+2018-08-29  Wenson Hsieh  <wenson_hs...@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  <ddkil...@apple.com>
 
         Remove empty directories from from svn.webkit.org repository

Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.cpp (235471 => 235472)


--- trunk/Source/WebCore/html/HTMLAttachmentElement.cpp	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.cpp	2018-08-29 19:17:45 UTC (rev 235472)
@@ -144,15 +144,15 @@
     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);
 
-    if (newContentType)
-        setAttributeWithoutSynchronization(HTMLNames::typeAttr, *newContentType);
+    if (!newContentType.isNull())
+        setAttributeWithoutSynchronization(HTMLNames::typeAttr, newContentType);
     else
         removeAttribute(HTMLNames::typeAttr);
 

Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.h (235471 => 235472)


--- trunk/Source/WebCore/html/HTMLAttachmentElement.h	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.h	2018-08-29 19:17:45 UTC (rev 235472)
@@ -48,7 +48,7 @@
     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;

Modified: trunk/Source/WebKit/ChangeLog (235471 => 235472)


--- trunk/Source/WebKit/ChangeLog	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebKit/ChangeLog	2018-08-29 19:17:45 UTC (rev 235472)
@@ -1,3 +1,20 @@
+2018-08-29  Wenson Hsieh  <wenson_hs...@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.olmst...@sony.com>
 
         [CMake] Use CMake's FindFreetype

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (235471 => 235472)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-29 19:17:45 UTC (rev 235472)
@@ -7703,9 +7703,7 @@
     }
 
     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)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (235471 => 235472)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-08-29 19:17:45 UTC (rev 235472)
@@ -6073,11 +6073,11 @@
     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();
-        attachment->updateAttributes(WTFMove(fileSize), contentType, WTFMove(newFilename));
+        attachment->updateAttributes(WTFMove(fileSize), contentType, fileName);
     }
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (235471 => 235472)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2018-08-29 19:17:45 UTC (rev 235472)
@@ -1073,7 +1073,7 @@
 
 #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)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (235471 => 235472)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-08-29 18:44:22 UTC (rev 235471)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2018-08-29 19:17:45 UTC (rev 235472)
@@ -511,7 +511,7 @@
 
 #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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to