Title: [105339] trunk/Source/WebKit2
Revision
105339
Author
ander...@apple.com
Date
2012-01-18 16:16:50 -0800 (Wed, 18 Jan 2012)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (105338 => 105339)


--- trunk/Source/WebKit2/ChangeLog	2012-01-19 00:12:52 UTC (rev 105338)
+++ trunk/Source/WebKit2/ChangeLog	2012-01-19 00:16:50 UTC (rev 105339)
@@ -1,3 +1,20 @@
+2012-01-18  Anders Carlsson  <ander...@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  <a...@apple.com>
 
         [Mac] Add a flag telling plug-in if it can enter sandbox

Modified: trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp (105338 => 105339)


--- trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp	2012-01-19 00:12:52 UTC (rev 105338)
+++ trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp	2012-01-19 00:16:50 UTC (rev 105339)
@@ -44,7 +44,7 @@
 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
 {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp (105338 => 105339)


--- trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp	2012-01-19 00:12:52 UTC (rev 105338)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp	2012-01-19 00:16:50 UTC (rev 105339)
@@ -28,6 +28,7 @@
 
 #include "DataReference.h"
 #include "WebCoreArgumentCoders.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
@@ -83,7 +84,43 @@
 
 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;
 }
 
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp (105338 => 105339)


--- trunk/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp	2012-01-19 00:12:52 UTC (rev 105338)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EncoderAdapter.cpp	2012-01-19 00:16:50 UTC (rev 105339)
@@ -28,6 +28,7 @@
 
 #include "DataReference.h"
 #include "WebCoreArgumentCoders.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
@@ -83,7 +84,24 @@
 
 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)); 
 }
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to