REGRESSION (r88886): Tabs restore blank when running Safari with a nightly build...
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2012 00:16:50 +0000 (00:16 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2012 00:16:50 +0000 (00:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76587
<rdar://problem/9739135>

Reviewed by Sam Weinig.

* UIProcess/cf/WebPageProxyCF.cpp:
Change CurrentSessionStateDataVersion back to 2.

* WebProcess/WebPage/DecoderAdapter.cpp:
(WebKit::DecoderAdapter::decodeString):
* WebProcess/WebPage/EncoderAdapter.cpp:
(WebKit::EncoderAdapter::encodeString):
Backport the CoreIPC string encoding and decoding functions that were in place prior to r88886.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp
Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp

index 70794c1..28bca5a 100644 (file)
@@ -1,3 +1,20 @@
+2012-01-18  Anders Carlsson  <andersca@apple.com>
+
+        REGRESSION (r88886): Tabs restore blank when running Safari with a nightly build for the first time
+        https://bugs.webkit.org/show_bug.cgi?id=76587
+        <rdar://problem/9739135>
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/cf/WebPageProxyCF.cpp:
+        Change CurrentSessionStateDataVersion back to 2.
+
+        * WebProcess/WebPage/DecoderAdapter.cpp:
+        (WebKit::DecoderAdapter::decodeString):
+        * WebProcess/WebPage/EncoderAdapter.cpp:
+        (WebKit::EncoderAdapter::encodeString):
+        Backport the CoreIPC string encoding and decoding functions that were in place prior to r88886.
+
 2012-01-17  Alexey Proskuryakov  <ap@apple.com>
 
         [Mac] Add a flag telling plug-in if it can enter sandbox
index 41fd01b..0524bc5 100644 (file)
@@ -44,7 +44,7 @@ namespace WebKit {
 DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryKey, (CFSTR("SessionHistory")));
 DEFINE_STATIC_GETTER(CFStringRef, ProvisionalURLKey, (CFSTR("ProvisionalURL")));
 
-static const UInt32 CurrentSessionStateDataVersion = 3;
+static const UInt32 CurrentSessionStateDataVersion = 2;
 
 PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback filter, void* context) const
 {
index 7c93dae..19083d6 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "DataReference.h"
 #include "WebCoreArgumentCoders.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
@@ -83,7 +84,43 @@ bool DecoderAdapter::decodeDouble(double& value)
 
 bool DecoderAdapter::decodeString(String& value)
 {
-    return m_decoder.decode(value);
+    // This mimics the CoreIPC binary encoding of Strings prior to r88886.
+    // Whenever the CoreIPC binary encoding changes, we'll have to "undo" the changes here.
+    // FIXME: We shouldn't use the CoreIPC binary encoding format for history,
+    // and we should come up with a migration strategy so we can actually bump the version number
+    // without breaking encoding/decoding of the history tree.
+
+    uint32_t length;
+    if (!m_decoder.decode(length))
+        return false;
+
+    if (length == std::numeric_limits<uint32_t>::max()) {
+        // This is the null string.
+        value = String();
+        return true;
+    }
+
+    uint64_t lengthInBytes;
+    if (!m_decoder.decode(lengthInBytes))
+        return false;
+
+    if (lengthInBytes % sizeof(UChar) || lengthInBytes / sizeof(UChar) != length) {
+        m_decoder.markInvalid();
+        return false;
+    }
+
+    if (!m_decoder.bufferIsLargeEnoughToContain<UChar>(length)) {
+        m_decoder.markInvalid();
+        return false;
+    }
+
+    UChar* buffer;
+    String string = String::createUninitialized(length, buffer);
+    if (!m_decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar), __alignof(UChar)))
+        return false;
+
+    value = string;
+    return true;
 }
 
 }
index 547b68d..1f0e13c 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "DataReference.h"
 #include "WebCoreArgumentCoders.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
@@ -83,7 +84,24 @@ void EncoderAdapter::encodeDouble(double value)
 
 void EncoderAdapter::encodeString(const String& value)
 {
-    m_encoder->encode(value);
+    // This mimics the CoreIPC binary encoding of Strings prior to r88886.
+    // Whenever the CoreIPC binary encoding changes, we'll have to "undo" the changes here.
+    // FIXME: We shouldn't use the CoreIPC binary encoding format for history,
+    // and we should come up with a migration strategy so we can actually bump the version number
+    // without breaking encoding/decoding of the history tree.
+
+    // Special case the null string.
+    if (value.isNull()) {
+        m_encoder->encodeUInt32(std::numeric_limits<uint32_t>::max());
+        return;
+    }
+
+    uint32_t length = value.length();
+    m_encoder->encode(length);
+
+    uint64_t lengthInBytes = length * sizeof(UChar);
+    m_encoder->encode(lengthInBytes);
+    m_encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(value.characters()), length * sizeof(UChar), __alignof(UChar)); 
 }
 
 }