Title: [170378] trunk/Source
Revision
170378
Author
ander...@apple.com
Date
2014-06-24 12:18:49 -0700 (Tue, 24 Jun 2014)

Log Message

Add PageState to HistoryItem conversion code
https://bugs.webkit.org/show_bug.cgi?id=134259

Reviewed by Andreas Kling.

Source/WebKit2:
* Shared/SessionState.h:
* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::decodeBackForwardTreeNode):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/SessionStateConversion.cpp: Added.
(WebKit::toFormData):
(WebKit::applyFrameState):
(WebKit::toHistoryItem):
* WebProcess/WebCoreSupport/SessionStateConversion.h: Added.

Source/WTF:
* wtf/Optional.h:
(WTF::Optional::valueOr):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (170377 => 170378)


--- trunk/Source/WTF/ChangeLog	2014-06-24 19:09:11 UTC (rev 170377)
+++ trunk/Source/WTF/ChangeLog	2014-06-24 19:18:49 UTC (rev 170378)
@@ -1,3 +1,13 @@
+2014-06-24  Anders Carlsson  <ander...@apple.com>
+
+        Add PageState to HistoryItem conversion code
+        https://bugs.webkit.org/show_bug.cgi?id=134259
+
+        Reviewed by Andreas Kling.
+
+        * wtf/Optional.h:
+        (WTF::Optional::valueOr):
+
 2014-06-24  László Langó  <llango.u-sze...@partner.samsung.com>
 
         [_javascript_Core] Enable concurrent JIT on EFL.

Modified: trunk/Source/WTF/wtf/Optional.h (170377 => 170378)


--- trunk/Source/WTF/wtf/Optional.h	2014-06-24 19:09:11 UTC (rev 170377)
+++ trunk/Source/WTF/wtf/Optional.h	2014-06-24 19:18:49 UTC (rev 170378)
@@ -161,6 +161,15 @@
         return m_value;
     }
 
+    template<typename U>
+    T valueOr(U&& value) const
+    {
+        if (m_isEngaged)
+            return m_value;
+
+        return std::forward<U>(value);
+    }
+
 private:
     bool m_isEngaged;
     union {

Modified: trunk/Source/WebKit2/ChangeLog (170377 => 170378)


--- trunk/Source/WebKit2/ChangeLog	2014-06-24 19:09:11 UTC (rev 170377)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-24 19:18:49 UTC (rev 170378)
@@ -1,3 +1,20 @@
+2014-06-24  Anders Carlsson  <ander...@apple.com>
+
+        Add PageState to HistoryItem conversion code
+        https://bugs.webkit.org/show_bug.cgi?id=134259
+
+        Reviewed by Andreas Kling.
+
+        * Shared/SessionState.h:
+        * UIProcess/mac/LegacySessionStateCoding.cpp:
+        (WebKit::decodeBackForwardTreeNode):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/SessionStateConversion.cpp: Added.
+        (WebKit::toFormData):
+        (WebKit::applyFrameState):
+        (WebKit::toHistoryItem):
+        * WebProcess/WebCoreSupport/SessionStateConversion.h: Added.
+
 2014-06-24  Antti Koivisto  <an...@apple.com>
 
         Only flush layers when the exposed rect actually changes

Modified: trunk/Source/WebKit2/Shared/SessionState.h (170377 => 170378)


--- trunk/Source/WebKit2/Shared/SessionState.h	2014-06-24 19:09:11 UTC (rev 170377)
+++ trunk/Source/WebKit2/Shared/SessionState.h	2014-06-24 19:18:49 UTC (rev 170378)
@@ -82,7 +82,7 @@
     String target;
 
     Vector<String> documentState;
-    Vector<uint8_t> stateObjectData;
+    Optional<Vector<uint8_t>> stateObjectData;
 
     int64_t documentSequenceNumber;
     int64_t itemSequenceNumber;

Modified: trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp (170377 => 170378)


--- trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-06-24 19:09:11 UTC (rev 170377)
+++ trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-06-24 19:18:49 UTC (rev 170378)
@@ -552,9 +552,13 @@
     bool hasStateObject;
     decoder >> hasStateObject;
 
-    if (hasStateObject)
-        decoder >> frameState.stateObjectData;
+    if (hasStateObject) {
+        Vector<uint8_t> stateObjectData;
+        decoder >> stateObjectData;
 
+        frameState.stateObjectData = std::move(stateObjectData);
+    }
+
     decoder >> frameState.target;
 }
 

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (170377 => 170378)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-06-24 19:09:11 UTC (rev 170377)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-06-24 19:18:49 UTC (rev 170378)
@@ -263,6 +263,8 @@
 		1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FBA2911E6862700DB1371 /* NetscapeBrowserFuncs.cpp */; };
 		1A6FBD2811E69BC200DB1371 /* NetscapePlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FBD2611E69BC200DB1371 /* NetscapePlugin.h */; };
 		1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FBD2711E69BC200DB1371 /* NetscapePlugin.cpp */; };
+		1A7284471959ED100007BCE5 /* SessionStateConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A7284451959ED100007BCE5 /* SessionStateConversion.h */; };
+		1A7284481959F8040007BCE5 /* SessionStateConversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7284441959ED100007BCE5 /* SessionStateConversion.cpp */; };
 		1A7865B916CAC71500ACE83A /* PluginProcessConnectionManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7865B716CAC71500ACE83A /* PluginProcessConnectionManagerMessageReceiver.cpp */; };
 		1A7865BA16CAC71500ACE83A /* PluginProcessConnectionManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A7865B816CAC71500ACE83A /* PluginProcessConnectionManagerMessages.h */; };
 		1A7C6CDA1378950800B9C04D /* EnvironmentVariables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7C6CD81378950800B9C04D /* EnvironmentVariables.cpp */; };
@@ -2212,6 +2214,8 @@
 		1A6FBA2911E6862700DB1371 /* NetscapeBrowserFuncs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapeBrowserFuncs.cpp; sourceTree = "<group>"; };
 		1A6FBD2611E69BC200DB1371 /* NetscapePlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePlugin.h; sourceTree = "<group>"; };
 		1A6FBD2711E69BC200DB1371 /* NetscapePlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePlugin.cpp; sourceTree = "<group>"; };
+		1A7284441959ED100007BCE5 /* SessionStateConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SessionStateConversion.cpp; sourceTree = "<group>"; };
+		1A7284451959ED100007BCE5 /* SessionStateConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SessionStateConversion.h; sourceTree = "<group>"; };
 		1A7865B616CAC6FD00ACE83A /* PluginProcessConnectionManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = PluginProcessConnectionManager.messages.in; sourceTree = "<group>"; };
 		1A7865B716CAC71500ACE83A /* PluginProcessConnectionManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessConnectionManagerMessageReceiver.cpp; sourceTree = "<group>"; };
 		1A7865B816CAC71500ACE83A /* PluginProcessConnectionManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessConnectionManagerMessages.h; sourceTree = "<group>"; };
@@ -5631,6 +5635,8 @@
 			children = (
 				2D28F3DF1885CCB4004B9EAE /* ios */,
 				BC111ADE112F5B9A00337BAB /* mac */,
+				1A7284441959ED100007BCE5 /* SessionStateConversion.cpp */,
+				1A7284451959ED100007BCE5 /* SessionStateConversion.h */,
 				CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */,
 				BC111A53112F4FBB00337BAB /* WebChromeClient.cpp */,
 				BC032D6010F4378D0058C15A /* WebChromeClient.h */,
@@ -6995,6 +7001,7 @@
 				1AF459321946559500F9D4A2 /* WKError.h in Headers */,
 				E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */,
 				1A9F28111958F478008CAC72 /* WKBackForwardListPrivate.h in Headers */,
+				1A7284471959ED100007BCE5 /* SessionStateConversion.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -9096,6 +9103,7 @@
 				C5237F6012441CA300780472 /* WebEditorClientMac.mm in Sources */,
 				BC575613126E0138006F0F12 /* APIError.cpp in Sources */,
 				BC111AE0112F5BC200337BAB /* WebErrorsMac.mm in Sources */,
+				1A7284481959F8040007BCE5 /* SessionStateConversion.cpp in Sources */,
 				1AFA3AC818E61C61003CCBAE /* WKUserContentController.mm in Sources */,
 				C0337DAE127A24FE008FF4F4 /* WebEvent.cpp in Sources */,
 				BC032DBA10F4380F0058C15A /* WebEventConversion.cpp in Sources */,

Added: trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.cpp (0 => 170378)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.cpp	2014-06-24 19:18:49 UTC (rev 170378)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SessionStateConversion.h"
+
+#include "SessionState.h"
+#include <WebCore/BlobData.h>
+#include <WebCore/FormData.h>
+#include <WebCore/HistoryItem.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static PassRefPtr<FormData> toFormData(const HTTPBody& httpBody)
+{
+    RefPtr<FormData> formData = FormData::create();
+
+    for (const auto& element : httpBody.elements) {
+        switch (element.type) {
+        case HTTPBody::Element::Type::Data:
+            formData->appendData(element.data.data(), element.data.size());
+            break;
+
+        case HTTPBody::Element::Type::File:
+            formData->appendFileRange(element.filePath, element.fileStart, element.fileLength.valueOr(BlobDataItem::toEndOfFile), element.expectedFileModificationTime.valueOr(invalidFileTime()));
+            break;
+
+        case HTTPBody::Element::Type::Blob:
+            formData->appendBlob(URL(URL(), element.blobURLString));
+            break;
+        }
+    }
+
+    return formData.release();
+}
+
+static void applyFrameState(HistoryItem& historyItem, const FrameState& frameState)
+{
+    historyItem.setOriginalURLString(frameState.originalURLString);
+    historyItem.setReferrer(frameState.referrer);
+    historyItem.setTarget(frameState.target);
+
+    historyItem.setDocumentState(frameState.documentState);
+
+    if (frameState.stateObjectData) {
+        Vector<uint8_t> stateObjectData = frameState.stateObjectData.value();
+        historyItem.setStateObject(SerializedScriptValue::adopt(stateObjectData));
+    }
+
+    historyItem.setDocumentSequenceNumber(frameState.documentSequenceNumber);
+    historyItem.setItemSequenceNumber(frameState.itemSequenceNumber);
+
+    historyItem.setScrollPoint(frameState.scrollPoint);
+    historyItem.setPageScaleFactor(frameState.pageScaleFactor);
+
+    if (frameState.httpBody) {
+        const auto& httpBody = frameState.httpBody.value();
+        historyItem.setFormContentType(httpBody.contentType);
+
+        historyItem.setFormData(toFormData(httpBody));
+    }
+
+    for (const auto& childFrameState : frameState.children) {
+        RefPtr<HistoryItem> childHistoryItem = HistoryItem::create(childFrameState.urlString, String());
+        applyFrameState(*childHistoryItem, childFrameState);
+
+        historyItem.addChildItem(childHistoryItem.release());
+    }
+}
+
+PassRefPtr<HistoryItem> toHistoryItem(const PageState& pageState)
+{
+    RefPtr<HistoryItem> historyItem = HistoryItem::create(pageState.mainFrameState.urlString, pageState.title);
+    applyFrameState(*historyItem, pageState.mainFrameState);
+
+    return historyItem.release();
+}
+
+} // namespace WebKit

Added: trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.h (0 => 170378)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.h	2014-06-24 19:18:49 UTC (rev 170378)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SessionStateConversion_h
+#define SessionStateConversion_h
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+class HistoryItem;
+};
+
+namespace WebKit {
+
+struct PageState;
+
+PassRefPtr<WebCore::HistoryItem> toHistoryItem(const PageState&);
+
+} // namespace WebKit
+
+#endif // SessionStateConversion_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to