WebBackForwardListItem::setPageState should receive pageState by rvalue reference
https://bugs.webkit.org/show_bug.cgi?id=199535

Reviewed by Alex Christensen

Coverity is complaining here about copying PageState by value in the parameter list. It's
sort of a false positive, in that the PageState really does need to be copied here, so this
is the best we can do. But pass by value and then WTFMove() is a pretty strange way to write
it. Passing by rvalue reference would be better. This makes the copy more clear.

* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::setPageState):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::updateBackForwardItem):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 3285e6f..58a5249 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,20 @@
+2019-07-12  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        WebBackForwardListItem::setPageState should receive pageState by rvalue reference
+        https://bugs.webkit.org/show_bug.cgi?id=199535
+
+        Reviewed by Alex Christensen
+
+        Coverity is complaining here about copying PageState by value in the parameter list. It's
+        sort of a false positive, in that the PageState really does need to be copied here, so this
+        is the best we can do. But pass by value and then WTFMove() is a pretty strange way to write
+        it. Passing by rvalue reference would be better. This makes the copy more clear.
+
+        * Shared/WebBackForwardListItem.h:
+        (WebKit::WebBackForwardListItem::setPageState):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::updateBackForwardItem):
+
 2019-07-12  Youenn Fablet  <youenn@apple.com>
 
         Add release logging for quota checks
diff --git a/Source/WebKit/Shared/WebBackForwardListItem.h b/Source/WebKit/Shared/WebBackForwardListItem.h
index 3b9b0bf..3a45e1c 100644
--- a/Source/WebKit/Shared/WebBackForwardListItem.h
+++ b/Source/WebKit/Shared/WebBackForwardListItem.h
@@ -60,7 +60,7 @@
     WebCore::ProcessIdentifier lastProcessIdentifier() const { return m_lastProcessIdentifier; }
     void setLastProcessIdentifier(const WebCore::ProcessIdentifier& identifier) { m_lastProcessIdentifier = identifier; }
 
-    void setPageState(PageState pageState) { m_itemState.pageState = WTFMove(pageState); }
+    void setPageState(PageState&& pageState) { m_itemState.pageState = WTFMove(pageState); }
     const PageState& pageState() const { return m_itemState.pageState; }
 
     const String& originalURL() const { return m_itemState.pageState.mainFrameState.originalURLString; }
diff --git a/Source/WebKit/UIProcess/WebProcessProxy.cpp b/Source/WebKit/UIProcess/WebProcessProxy.cpp
index 404b438..ea42f0c 100644
--- a/Source/WebKit/UIProcess/WebProcessProxy.cpp
+++ b/Source/WebKit/UIProcess/WebProcessProxy.cpp
@@ -592,7 +592,7 @@
     if (!item || !isAllowedToUpdateBackForwardItem(*item))
         return;
 
-    item->setPageState(itemState.pageState);
+    item->setPageState(PageState { itemState.pageState });
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)