Diff
Modified: trunk/Source/WebKit/ChangeLog (221619 => 221620)
--- trunk/Source/WebKit/ChangeLog 2017-09-05 17:19:10 UTC (rev 221619)
+++ trunk/Source/WebKit/ChangeLog 2017-09-05 17:33:06 UTC (rev 221620)
@@ -1,3 +1,20 @@
+2017-09-04 Alex Christensen <[email protected]>
+
+ Allow classes to have modern and legacy decoders to aid transition
+ https://bugs.webkit.org/show_bug.cgi?id=176186
+
+ Reviewed by Zan Dobersek.
+
+ To illustrate this, I made legacy and modern decoders to WTF::String and transitioned one String decoder.
+
+ * Platform/IPC/ArgumentCoder.h:
+ * Platform/IPC/ArgumentCoders.cpp:
+ (IPC::ArgumentCoder<String>::decode):
+ * Platform/IPC/ArgumentCoders.h:
+ * Platform/IPC/Decoder.h:
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::decode):
+
2017-09-05 Frederic Wang <[email protected]>
Use TilesBacking for iframes when async frame scrolling is enabled
Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h (221619 => 221620)
--- trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h 2017-09-05 17:19:10 UTC (rev 221619)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h 2017-09-05 17:33:06 UTC (rev 221620)
@@ -27,11 +27,19 @@
#include <wtf/Optional.h>
+namespace WebCore {
+class IntConstraint;
+class DoubleConstraint;
+class ResourceResponse;
+}
+
namespace IPC {
class Decoder;
class Encoder;
+template<typename> struct ArgumentCoder;
+
template<typename U>
class UsesModernDecoder {
private:
@@ -38,10 +46,43 @@
template<typename T, T> struct Helper;
template<typename T> static uint8_t check(Helper<std::optional<U> (*)(Decoder&), &T::decode>*);
template<typename T> static uint16_t check(...);
+ template<typename T> static uint8_t checkArgumentCoder(Helper<std::optional<U> (*)(Decoder&), &ArgumentCoder<T>::decode>*);
+ template<typename T> static uint16_t checkArgumentCoder(...);
public:
- static constexpr bool value = sizeof(check<U>(0)) == sizeof(uint8_t);
+ static constexpr bool argumentCoderValue = sizeof(check<U>(nullptr)) == sizeof(uint8_t);
+ static constexpr bool value = argumentCoderValue || sizeof(checkArgumentCoder<U>(nullptr)) == sizeof(uint8_t);
};
+template<typename U>
+class UsesLegacyDecoder {
+private:
+ template<typename T, T> struct Helper;
+ template<typename T> static uint8_t check(Helper<bool (*)(Decoder&, U&), &T::decode>*);
+ template<typename T> static uint16_t check(...);
+ template<typename T> static uint8_t checkArgumentCoder(Helper<bool (*)(Decoder&, U&), &ArgumentCoder<T>::decode>*);
+ template<typename T> static uint16_t checkArgumentCoder(...);
+public:
+ static constexpr bool argumentCoderValue = sizeof(check<U>(nullptr)) == sizeof(uint8_t);
+ static constexpr bool value = argumentCoderValue || sizeof(checkArgumentCoder<U>(nullptr)) == sizeof(uint8_t);
+};
+
+template<typename BoolType>
+class DefaultDecoderValues {
+public:
+ static constexpr bool argumentCoderValue = BoolType::value;
+ static constexpr bool value = BoolType::value;
+};
+
+// ResourceResponseBase has the legacy decode template, not ResourceResponse.
+template<> class UsesModernDecoder<WebCore::ResourceResponse> : public DefaultDecoderValues<std::false_type> { };
+template<> class UsesLegacyDecoder<WebCore::ResourceResponse> : public DefaultDecoderValues<std::true_type> { };
+
+// IntConstraint and DoubleConstraint have their legacy decoder templates in NumericConstraint.
+template<> class UsesModernDecoder<WebCore::IntConstraint> : public DefaultDecoderValues<std::false_type> { };
+template<> class UsesLegacyDecoder<WebCore::IntConstraint> : public DefaultDecoderValues<std::true_type> { };
+template<> class UsesModernDecoder<WebCore::DoubleConstraint> : public DefaultDecoderValues<std::false_type> { };
+template<> class UsesLegacyDecoder<WebCore::DoubleConstraint> : public DefaultDecoderValues<std::true_type> { };
+
template<typename T> struct ArgumentCoder {
static void encode(Encoder& encoder, const T& t)
{
@@ -48,13 +89,13 @@
t.encode(encoder);
}
- template<typename U = T, std::enable_if_t<!UsesModernDecoder<U>::value>* = nullptr>
+ template<typename U = T, std::enable_if_t<UsesLegacyDecoder<U>::argumentCoderValue>* = nullptr>
static bool decode(Decoder& decoder, U& u)
{
return U::decode(decoder, u);
}
- template<typename U = T, std::enable_if_t<UsesModernDecoder<U>::value>* = nullptr>
+ template<typename U = T, std::enable_if_t<UsesModernDecoder<U>::argumentCoderValue>* = nullptr>
static std::optional<U> decode(Decoder& decoder)
{
return U::decode(decoder);
Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp (221619 => 221620)
--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp 2017-09-05 17:19:10 UTC (rev 221619)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp 2017-09-05 17:33:06 UTC (rev 221620)
@@ -153,7 +153,6 @@
}
bool is8Bit;
-
if (!decoder.decode(is8Bit))
return false;
@@ -162,6 +161,31 @@
return decodeStringText<UChar>(decoder, length, result);
}
+std::optional<String> ArgumentCoder<String>::decode(Decoder& decoder)
+{
+ uint32_t length;
+ if (!decoder.decode(length))
+ return std::nullopt;
+
+ if (length == std::numeric_limits<uint32_t>::max()) {
+ // This is the null string.
+ return String();
+ }
+
+ bool is8Bit;
+ if (!decoder.decode(is8Bit))
+ return std::nullopt;
+
+ String result;
+ if (is8Bit) {
+ if (!decodeStringText<LChar>(decoder, length, result))
+ return std::nullopt;
+ return result;
+ }
+ if (!decodeStringText<UChar>(decoder, length, result))
+ return std::nullopt;
+ return result;
+}
void ArgumentCoder<SHA1::Digest>::encode(Encoder& encoder, const SHA1::Digest& digest)
{
Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (221619 => 221620)
--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h 2017-09-05 17:19:10 UTC (rev 221619)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h 2017-09-05 17:33:06 UTC (rev 221620)
@@ -446,6 +446,7 @@
template<> struct ArgumentCoder<String> {
static void encode(Encoder&, const String&);
static bool decode(Decoder&, String&);
+ static std::optional<String> decode(Decoder&);
};
template<> struct ArgumentCoder<SHA1::Digest> {
Modified: trunk/Source/WebKit/Platform/IPC/Decoder.h (221619 => 221620)
--- trunk/Source/WebKit/Platform/IPC/Decoder.h 2017-09-05 17:19:10 UTC (rev 221619)
+++ trunk/Source/WebKit/Platform/IPC/Decoder.h 2017-09-05 17:33:06 UTC (rev 221620)
@@ -123,7 +123,7 @@
return bufferIsLargeEnoughToContain(alignof(T), numElements * sizeof(T));
}
- template<typename T, std::enable_if_t<!std::is_enum<T>::value && !UsesModernDecoder<T>::value>* = nullptr>
+ template<typename T, std::enable_if_t<!std::is_enum<T>::value && UsesLegacyDecoder<T>::value>* = nullptr>
bool decode(T& t)
{
return ArgumentCoder<T>::decode(*this, t);
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (221619 => 221620)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2017-09-05 17:19:10 UTC (rev 221619)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2017-09-05 17:33:06 UTC (rev 221620)
@@ -144,8 +144,11 @@
return std::nullopt;
if (!decoder.decode(parameters.paginationLineGridEnabled))
return std::nullopt;
- if (!decoder.decode(parameters.userAgent))
+ std::optional<String> userAgent;
+ decoder >> userAgent;
+ if (!userAgent)
return std::nullopt;
+ parameters.userAgent = WTFMove(*userAgent);
if (!decoder.decode(parameters.itemStates))
return std::nullopt;
if (!decoder.decode(parameters.sessionID))