Title: [170671] trunk/Source/WebKit2
Revision
170671
Author
ander...@apple.com
Date
2014-07-01 15:34:10 -0700 (Tue, 01 Jul 2014)

Log Message

Use the new legacy session state coding in WKPageCopySessionState
https://bugs.webkit.org/show_bug.cgi?id=134516

Reviewed by Tim Horton.

* UIProcess/API/C/WKPage.cpp:
(WKPageCopySessionState):
Call encodeLegacySessionState.

* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::encodeSessionHistoryEntryData):
Use leakPtr() so we won't attempt to double-free the buffer.

(WebKit::createDictionary):
Fix a typo.

(WebKit::encodeLegacySessionState):
Don't encode the provisional URL if it's empty.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170670 => 170671)


--- trunk/Source/WebKit2/ChangeLog	2014-07-01 22:25:25 UTC (rev 170670)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-01 22:34:10 UTC (rev 170671)
@@ -1,3 +1,24 @@
+2014-07-01  Anders Carlsson  <ander...@apple.com>
+
+        Use the new legacy session state coding in WKPageCopySessionState
+        https://bugs.webkit.org/show_bug.cgi?id=134516
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageCopySessionState):
+        Call encodeLegacySessionState.
+
+        * UIProcess/mac/LegacySessionStateCoding.cpp:
+        (WebKit::encodeSessionHistoryEntryData):
+        Use leakPtr() so we won't attempt to double-free the buffer.
+
+        (WebKit::createDictionary):
+        Fix a typo.
+
+        (WebKit::encodeLegacySessionState):
+        Don't encode the provisional URL if it's empty.
+
 2014-07-01  Chris Fleizach  <cfleiz...@apple.com>
 
         AX: [iOS WebKit2] Support for Speak selection

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (170670 => 170671)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-07-01 22:25:25 UTC (rev 170670)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-07-01 22:34:10 UTC (rev 170671)
@@ -34,6 +34,7 @@
 #include "APIPolicyClient.h"
 #include "APIUIClient.h"
 #include "ImmutableDictionary.h"
+#include "LegacySessionStateCoding.h"
 #include "NativeWebKeyboardEvent.h"
 #include "NativeWebWheelEvent.h"
 #include "NavigationActionData.h"
@@ -351,7 +352,7 @@
 
 WKDataRef WKPageCopySessionState(WKPageRef pageRef, void *context, WKPageSessionStateFilterCallback filter)
 {
-    return toAPI(toImpl(pageRef)->sessionStateData([pageRef, context, filter](WebBackForwardListItem& item) {
+    auto sessionState = toImpl(pageRef)->sessionState([pageRef, context, filter](WebBackForwardListItem& item) {
         if (filter) {
             if (!filter(pageRef, WKPageGetSessionBackForwardListItemValueType(), toAPI(&item), context))
                 return false;
@@ -361,7 +362,9 @@
         }
 
         return true;
-    }).leakRef());
+    });
+
+    return toAPI(encodeLegacySessionState(sessionState).release().leakRef());
 }
 
 void WKPageRestoreFromSessionState(WKPageRef pageRef, WKDataRef sessionStateData)

Modified: trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp (170670 => 170671)


--- trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-07-01 22:25:25 UTC (rev 170670)
+++ trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-07-01 22:34:10 UTC (rev 170671)
@@ -401,7 +401,7 @@
     size_t bufferSize;
     auto buffer = encodeSessionHistoryEntryData(frameState, bufferSize);
 
-    return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer.get(), bufferSize, fastMallocDeallocator));
+    return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer.leakPtr(), bufferSize, fastMallocDeallocator));
 }
 
 static RetainPtr<CFDictionaryRef> createDictionary(std::initializer_list<std::pair<CFStringRef, CFTypeRef>> keyValuePairs)
@@ -414,7 +414,7 @@
 
     for (const auto& keyValuePair : keyValuePairs) {
         keys.uncheckedAppend(keyValuePair.first);
-        keys.uncheckedAppend(keyValuePair.second);
+        values.uncheckedAppend(keyValuePair.second);
     }
 
     return adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys.data(), values.data(), keyValuePairs.size(), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
@@ -451,7 +451,7 @@
 RefPtr<API::Data> encodeLegacySessionState(const SessionState& sessionState)
 {
     auto sessionHistoryDictionary = encodeSessionHistory(sessionState.backForwardListState);
-    auto provisionalURLString = sessionState.provisionalURL.string().createCFString();
+    auto provisionalURLString = sessionState.provisionalURL.isNull() ? nullptr : sessionState.provisionalURL.string().createCFString();
 
     RetainPtr<CFDictionaryRef> stateDictionary;
     if (provisionalURLString)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to