Diff
Modified: trunk/Source/WebCore/ChangeLog (222583 => 222584)
--- trunk/Source/WebCore/ChangeLog 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebCore/ChangeLog 2017-09-27 23:50:21 UTC (rev 222584)
@@ -1,3 +1,13 @@
+2017-09-27 Alex Christensen <[email protected]>
+
+ Allow modern decoding of std::optional<T>
+ https://bugs.webkit.org/show_bug.cgi?id=177519
+
+ Reviewed by Tim Horton.
+
+ * platform/DragItem.h:
+ (WebCore::DragItem::decode):
+
2017-09-27 Myles C. Maxfield <[email protected]>
"Tag" codepoints require the complex text codepath
Modified: trunk/Source/WebCore/platform/DragItem.h (222583 => 222584)
--- trunk/Source/WebCore/platform/DragItem.h 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebCore/platform/DragItem.h 2017-09-27 23:50:21 UTC (rev 222584)
@@ -92,10 +92,11 @@
if (!decoder.decode(hasIndicatorData))
return false;
if (hasIndicatorData) {
- TextIndicatorData indicatorData;
- if (!decoder.decode(indicatorData))
+ std::optional<TextIndicatorData> indicatorData;
+ decoder >> indicatorData;
+ if (!indicatorData)
return false;
- result.image.setIndicatorData(indicatorData);
+ result.image.setIndicatorData(*indicatorData);
}
return true;
}
Modified: trunk/Source/WebKit/ChangeLog (222583 => 222584)
--- trunk/Source/WebKit/ChangeLog 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/ChangeLog 2017-09-27 23:50:21 UTC (rev 222584)
@@ -1,3 +1,25 @@
+2017-09-27 Alex Christensen <[email protected]>
+
+ Allow modern decoding of std::optional<T>
+ https://bugs.webkit.org/show_bug.cgi?id=177519
+
+ Reviewed by Tim Horton.
+
+ * Platform/IPC/ArgumentCoders.h:
+ (IPC::ArgumentCoder<std::optional<T>>::decode):
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode):
+ (IPC::ArgumentCoder<WebCore::PaymentError>::decode):
+ (IPC::ArgumentCoder<WebCore::PaymentMethodUpdate>::decode):
+ (IPC::ArgumentCoder<WebCore::ShippingContactUpdate>::decode):
+ (IPC::ArgumentCoder<WebCore::ShippingMethodUpdate>::decode):
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<IntPoint>::decode):
+ (IPC::ArgumentCoder<IntSize>::decode):
+ * Shared/WebCoreArgumentCoders.h:
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::decode):
+
2017-09-27 Commit Queue <[email protected]>
Unreviewed, rolling out r222541.
Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (222583 => 222584)
--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h 2017-09-27 23:50:21 UTC (rev 222584)
@@ -110,6 +110,22 @@
optional = WTFMove(value);
return true;
}
+
+ static std::optional<std::optional<T>> decode(Decoder& decoder)
+ {
+ std::optional<bool> isEngaged;
+ decoder >> isEngaged;
+ if (!isEngaged)
+ return std::nullopt;
+ if (*isEngaged) {
+ std::optional<T> value;
+ decoder >> value;
+ if (!value)
+ return std::nullopt;
+ return std::optional<std::optional<T>>(WTFMove(*value));
+ }
+ return std::optional<std::optional<T>>(std::optional<T>(std::nullopt));
+ }
};
template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> {
Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (222583 => 222584)
--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2017-09-27 23:50:21 UTC (rev 222584)
@@ -88,14 +88,19 @@
encoder << result.errors;
}
-bool ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode(Decoder& decoder, WebCore::PaymentAuthorizationResult& result)
+std::optional<WebCore::PaymentAuthorizationResult> ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode(Decoder& decoder)
{
- if (!decoder.decode(result.status))
- return false;
- if (!decoder.decode(result.errors))
- return false;
+ std::optional<PaymentAuthorizationStatus> status;
+ decoder >> status;
+ if (!status)
+ return std::nullopt;
- return true;
+ std::optional<Vector<PaymentError>> errors;
+ decoder >> errors;
+ if (!errors)
+ return std::nullopt;
+
+ return {{ WTFMove(*status), WTFMove(*errors) }};
}
void ArgumentCoder<WebCore::PaymentContact>::encode(Encoder& encoder, const WebCore::PaymentContact& paymentContact)
@@ -141,15 +146,22 @@
std::optional<WebCore::PaymentError> ArgumentCoder<WebCore::PaymentError>::decode(Decoder& decoder)
{
- WebCore::PaymentError error;
- if (!decoder.decode(error.code))
+ std::optional<WebCore::PaymentError::Code> code;
+ decoder >> code;
+ if (!code)
return std::nullopt;
- if (!decoder.decode(error.message))
+
+ std::optional<String> message;
+ decoder >> message;
+ if (!message)
return std::nullopt;
- if (!decoder.decode(error.contactField))
+
+ std::optional<std::optional<WebCore::PaymentError::ContactField>> contactField;
+ decoder >> contactField;
+ if (!contactField)
return std::nullopt;
- return WTFMove(error);
+ return {{ WTFMove(*code), WTFMove(*message), WTFMove(*contactField) }};
}
void ArgumentCoder<WebCore::PaymentMerchantSession>::encode(Encoder& encoder, const WebCore::PaymentMerchantSession& paymentMerchantSession)
@@ -226,14 +238,13 @@
encoder << update.newTotalAndLineItems;
}
-bool ArgumentCoder<WebCore::PaymentMethodUpdate>::decode(Decoder& decoder, WebCore::PaymentMethodUpdate& update)
+std::optional<WebCore::PaymentMethodUpdate> ArgumentCoder<WebCore::PaymentMethodUpdate>::decode(Decoder& decoder)
{
std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems;
decoder >> newTotalAndLineItems;
if (!newTotalAndLineItems)
- return false;
- update = { WTFMove(*newTotalAndLineItems) };
- return true;
+ return std::nullopt;
+ return {{ WTFMove(*newTotalAndLineItems) }};
}
void ArgumentCoder<ApplePaySessionPaymentRequest>::encode(Encoder& encoder, const ApplePaySessionPaymentRequest& request)
@@ -447,20 +458,24 @@
encoder << update.newTotalAndLineItems;
}
-bool ArgumentCoder<WebCore::ShippingContactUpdate>::decode(Decoder& decoder, WebCore::ShippingContactUpdate& update)
+std::optional<WebCore::ShippingContactUpdate> ArgumentCoder<WebCore::ShippingContactUpdate>::decode(Decoder& decoder)
{
- if (!decoder.decode(update.errors))
- return false;
- if (!decoder.decode(update.newShippingMethods))
- return false;
+ std::optional<Vector<PaymentError>> errors;
+ decoder >> errors;
+ if (!errors)
+ return std::nullopt;
+ std::optional<Vector<ApplePaySessionPaymentRequest::ShippingMethod>> newShippingMethods;
+ decoder >> newShippingMethods;
+ if (!newShippingMethods)
+ return std::nullopt;
+
std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems;
decoder >> newTotalAndLineItems;
if (!newTotalAndLineItems)
- return false;
- update.newTotalAndLineItems = WTFMove(*newTotalAndLineItems);
-
- return true;
+ return std::nullopt;
+
+ return {{ WTFMove(*errors), WTFMove(*newShippingMethods), WTFMove(*newTotalAndLineItems) }};
}
void ArgumentCoder<WebCore::ShippingMethodUpdate>::encode(Encoder& encoder, const WebCore::ShippingMethodUpdate& update)
@@ -468,14 +483,13 @@
encoder << update.newTotalAndLineItems;
}
-bool ArgumentCoder<WebCore::ShippingMethodUpdate>::decode(Decoder& decoder, WebCore::ShippingMethodUpdate& update)
+std::optional<WebCore::ShippingMethodUpdate> ArgumentCoder<WebCore::ShippingMethodUpdate>::decode(Decoder& decoder)
{
std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems;
decoder >> newTotalAndLineItems;
if (!newTotalAndLineItems)
- return false;
- update = { WTFMove(*newTotalAndLineItems) };
- return true;
+ return std::nullopt;
+ return {{ WTFMove(*newTotalAndLineItems) }};
}
}
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (222583 => 222584)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2017-09-27 23:50:21 UTC (rev 222584)
@@ -559,6 +559,13 @@
return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
}
+std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder)
+{
+ FloatPoint floatPoint;
+ if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint))
+ return std::nullopt;
+ return WTFMove(floatPoint);
+}
void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
{
@@ -658,6 +665,13 @@
return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
}
+std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder)
+{
+ IntPoint intPoint;
+ if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint))
+ return std::nullopt;
+ return WTFMove(intPoint);
+}
void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
{
@@ -677,7 +691,6 @@
return WTFMove(rect);
}
-
void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
{
SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
@@ -688,6 +701,13 @@
return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
}
+std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder)
+{
+ IntSize intSize;
+ if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize))
+ return std::nullopt;
+ return WTFMove(intSize);
+}
void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
{
@@ -2298,44 +2318,45 @@
encodeOptionalImage(encoder, textIndicatorData.contentImageWithoutSelection.get());
}
-bool ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder, TextIndicatorData& textIndicatorData)
+std::optional<TextIndicatorData> ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder)
{
+ TextIndicatorData textIndicatorData;
if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates))
- return false;
+ return std::nullopt;
if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates))
- return false;
+ return std::nullopt;
if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates))
- return false;
+ return std::nullopt;
if (!decoder.decode(textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates))
- return false;
+ return std::nullopt;
if (!decoder.decode(textIndicatorData.contentImageScaleFactor))
- return false;
+ return std::nullopt;
if (!decoder.decode(textIndicatorData.estimatedBackgroundColor))
- return false;
+ return std::nullopt;
if (!decoder.decodeEnum(textIndicatorData.presentationTransition))
- return false;
+ return std::nullopt;
uint64_t options;
if (!decoder.decode(options))
- return false;
+ return std::nullopt;
textIndicatorData.options = static_cast<TextIndicatorOptions>(options);
if (!decodeOptionalImage(decoder, textIndicatorData.contentImage))
- return false;
+ return std::nullopt;
if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight))
- return false;
+ return std::nullopt;
if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithoutSelection))
- return false;
+ return std::nullopt;
- return true;
+ return WTFMove(textIndicatorData);
}
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -2408,8 +2429,11 @@
if (!decoder.decode(result.origin))
return false;
- if (!decoder.decode(result.textIndicator))
+ std::optional<TextIndicatorData> textIndicator;
+ decoder >> textIndicator;
+ if (!textIndicator)
return false;
+ result.textIndicator = WTFMove(*textIndicator);
#if PLATFORM(COCOA)
bool hadOptions;
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (222583 => 222584)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2017-09-27 23:50:21 UTC (rev 222584)
@@ -231,6 +231,7 @@
template<> struct ArgumentCoder<WebCore::FloatPoint> {
static void encode(Encoder&, const WebCore::FloatPoint&);
static bool decode(Decoder&, WebCore::FloatPoint&);
+ static std::optional<WebCore::FloatPoint> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::FloatPoint3D> {
@@ -274,6 +275,7 @@
template<> struct ArgumentCoder<WebCore::IntPoint> {
static void encode(Encoder&, const WebCore::IntPoint&);
static bool decode(Decoder&, WebCore::IntPoint&);
+ static std::optional<WebCore::IntPoint> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::IntRect> {
@@ -285,6 +287,7 @@
template<> struct ArgumentCoder<WebCore::IntSize> {
static void encode(Encoder&, const WebCore::IntSize&);
static bool decode(Decoder&, WebCore::IntSize&);
+ static std::optional<WebCore::IntSize> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::LayoutSize> {
@@ -524,7 +527,7 @@
template<> struct ArgumentCoder<WebCore::TextIndicatorData> {
static void encode(Encoder&, const WebCore::TextIndicatorData&);
- static bool decode(Decoder&, WebCore::TextIndicatorData&);
+ static std::optional<WebCore::TextIndicatorData> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::DictionaryPopupInfo> {
@@ -565,7 +568,7 @@
template<> struct ArgumentCoder<WebCore::PaymentAuthorizationResult> {
static void encode(Encoder&, const WebCore::PaymentAuthorizationResult&);
- static bool decode(Decoder&, WebCore::PaymentAuthorizationResult&);
+ static std::optional<WebCore::PaymentAuthorizationResult> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::PaymentContact> {
@@ -590,7 +593,7 @@
template<> struct ArgumentCoder<WebCore::PaymentMethodUpdate> {
static void encode(Encoder&, const WebCore::PaymentMethodUpdate&);
- static bool decode(Decoder&, WebCore::PaymentMethodUpdate&);
+ static std::optional<WebCore::PaymentMethodUpdate> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest> {
@@ -625,12 +628,12 @@
template<> struct ArgumentCoder<WebCore::ShippingContactUpdate> {
static void encode(Encoder&, const WebCore::ShippingContactUpdate&);
- static bool decode(Decoder&, WebCore::ShippingContactUpdate&);
+ static std::optional<WebCore::ShippingContactUpdate> decode(Decoder&);
};
template<> struct ArgumentCoder<WebCore::ShippingMethodUpdate> {
static void encode(Encoder&, const WebCore::ShippingMethodUpdate&);
- static bool decode(Decoder&, WebCore::ShippingMethodUpdate&);
+ static std::optional<WebCore::ShippingMethodUpdate> decode(Decoder&);
};
#endif
Modified: trunk/Source/WebKit/Shared/WebHitTestResultData.cpp (222583 => 222584)
--- trunk/Source/WebKit/Shared/WebHitTestResultData.cpp 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/WebHitTestResultData.cpp 2017-09-27 23:50:21 UTC (rev 222584)
@@ -164,11 +164,12 @@
return false;
if (hasLinkTextIndicator) {
- WebCore::TextIndicatorData indicatorData;
- if (!decoder.decode(indicatorData))
+ std::optional<WebCore::TextIndicatorData> indicatorData;
+ decoder >> indicatorData;
+ if (!indicatorData)
return false;
- hitTestResultData.linkTextIndicator = WebCore::TextIndicator::create(indicatorData);
+ hitTestResultData.linkTextIndicator = WebCore::TextIndicator::create(*indicatorData);
}
return platformDecode(decoder, hitTestResultData);
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (222583 => 222584)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2017-09-27 23:50:21 UTC (rev 222584)
@@ -191,8 +191,13 @@
return std::nullopt;
if (!decoder.decodeEnum(parameters.scrollPinningBehavior))
return std::nullopt;
- if (!decoder.decode(parameters.scrollbarOverlayStyle))
+
+ std::optional<std::optional<uint32_t>> scrollbarOverlayStyle;
+ decoder >> scrollbarOverlayStyle;
+ if (!scrollbarOverlayStyle)
return std::nullopt;
+ parameters.scrollbarOverlayStyle = WTFMove(*scrollbarOverlayStyle);
+
if (!decoder.decode(parameters.backgroundExtendsBeyondPage))
return std::nullopt;
if (!decoder.decodeEnum(parameters.layerHostingMode))
@@ -246,8 +251,11 @@
if (!decoder.decode(parameters.overrideContentSecurityPolicy))
return std::nullopt;
- if (!decoder.decode(parameters.cpuLimit))
+ std::optional<std::optional<double>> cpuLimit;
+ decoder >> cpuLimit;
+ if (!cpuLimit)
return std::nullopt;
+ parameters.cpuLimit = WTFMove(*cpuLimit);
if (!decoder.decode(parameters.urlSchemeHandlers))
return std::nullopt;
Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm (222583 => 222584)
--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm 2017-09-27 23:50:21 UTC (rev 222584)
@@ -144,8 +144,11 @@
if (!decoder.decode(result.textAfter))
return false;
- if (!decoder.decode(result.linkIndicator))
+ std::optional<WebCore::TextIndicatorData> linkIndicator;
+ decoder >> linkIndicator;
+ if (!linkIndicator)
return false;
+ result.linkIndicator = WTFMove(*linkIndicator);
ShareableBitmap::Handle handle;
if (!decoder.decode(handle))
Modified: trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm (222583 => 222584)
--- trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm 2017-09-27 23:25:07 UTC (rev 222583)
+++ trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm 2017-09-27 23:50:21 UTC (rev 222584)
@@ -97,11 +97,12 @@
return false;
if (hasDetectedDataTextIndicator) {
- WebCore::TextIndicatorData indicatorData;
- if (!decoder.decode(indicatorData))
+ std::optional<WebCore::TextIndicatorData> indicatorData;
+ decoder >> indicatorData;
+ if (!indicatorData)
return false;
- hitTestResultData.detectedDataTextIndicator = WebCore::TextIndicator::create(indicatorData);
+ hitTestResultData.detectedDataTextIndicator = WebCore::TextIndicator::create(*indicatorData);
}
return true;