Changeset 222584 in webkit
- Timestamp:
- Sep 27, 2017 4:50:21 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r222576 r222584 1 2017-09-27 Alex Christensen <achristensen@webkit.org> 2 3 Allow modern decoding of std::optional<T> 4 https://bugs.webkit.org/show_bug.cgi?id=177519 5 6 Reviewed by Tim Horton. 7 8 * platform/DragItem.h: 9 (WebCore::DragItem::decode): 10 1 11 2017-09-27 Myles C. Maxfield <mmaxfield@apple.com> 2 12 -
trunk/Source/WebCore/platform/DragItem.h
r221907 r222584 93 93 return false; 94 94 if (hasIndicatorData) { 95 TextIndicatorData indicatorData; 96 if (!decoder.decode(indicatorData)) 95 std::optional<TextIndicatorData> indicatorData; 96 decoder >> indicatorData; 97 if (!indicatorData) 97 98 return false; 98 result.image.setIndicatorData( indicatorData);99 result.image.setIndicatorData(*indicatorData); 99 100 } 100 101 return true; -
trunk/Source/WebKit/ChangeLog
r222583 r222584 1 2017-09-27 Alex Christensen <achristensen@webkit.org> 2 3 Allow modern decoding of std::optional<T> 4 https://bugs.webkit.org/show_bug.cgi?id=177519 5 6 Reviewed by Tim Horton. 7 8 * Platform/IPC/ArgumentCoders.h: 9 (IPC::ArgumentCoder<std::optional<T>>::decode): 10 * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: 11 (IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode): 12 (IPC::ArgumentCoder<WebCore::PaymentError>::decode): 13 (IPC::ArgumentCoder<WebCore::PaymentMethodUpdate>::decode): 14 (IPC::ArgumentCoder<WebCore::ShippingContactUpdate>::decode): 15 (IPC::ArgumentCoder<WebCore::ShippingMethodUpdate>::decode): 16 * Shared/WebCoreArgumentCoders.cpp: 17 (IPC::ArgumentCoder<IntPoint>::decode): 18 (IPC::ArgumentCoder<IntSize>::decode): 19 * Shared/WebCoreArgumentCoders.h: 20 * Shared/WebPageCreationParameters.cpp: 21 (WebKit::WebPageCreationParameters::decode): 22 1 23 2017-09-27 Commit Queue <commit-queue@webkit.org> 2 24 -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h
r222233 r222584 111 111 return true; 112 112 } 113 114 static std::optional<std::optional<T>> decode(Decoder& decoder) 115 { 116 std::optional<bool> isEngaged; 117 decoder >> isEngaged; 118 if (!isEngaged) 119 return std::nullopt; 120 if (*isEngaged) { 121 std::optional<T> value; 122 decoder >> value; 123 if (!value) 124 return std::nullopt; 125 return std::optional<std::optional<T>>(WTFMove(*value)); 126 } 127 return std::optional<std::optional<T>>(std::optional<T>(std::nullopt)); 128 } 113 129 }; 114 130 -
trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
r222233 r222584 89 89 } 90 90 91 bool ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode(Decoder& decoder, WebCore::PaymentAuthorizationResult& result) 92 { 93 if (!decoder.decode(result.status)) 94 return false; 95 if (!decoder.decode(result.errors)) 96 return false; 97 98 return true; 91 std::optional<WebCore::PaymentAuthorizationResult> ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode(Decoder& decoder) 92 { 93 std::optional<PaymentAuthorizationStatus> status; 94 decoder >> status; 95 if (!status) 96 return std::nullopt; 97 98 std::optional<Vector<PaymentError>> errors; 99 decoder >> errors; 100 if (!errors) 101 return std::nullopt; 102 103 return {{ WTFMove(*status), WTFMove(*errors) }}; 99 104 } 100 105 … … 142 147 std::optional<WebCore::PaymentError> ArgumentCoder<WebCore::PaymentError>::decode(Decoder& decoder) 143 148 { 144 WebCore::PaymentError error; 145 if (!decoder.decode(error.code)) 146 return std::nullopt; 147 if (!decoder.decode(error.message)) 148 return std::nullopt; 149 if (!decoder.decode(error.contactField)) 150 return std::nullopt; 151 152 return WTFMove(error); 149 std::optional<WebCore::PaymentError::Code> code; 150 decoder >> code; 151 if (!code) 152 return std::nullopt; 153 154 std::optional<String> message; 155 decoder >> message; 156 if (!message) 157 return std::nullopt; 158 159 std::optional<std::optional<WebCore::PaymentError::ContactField>> contactField; 160 decoder >> contactField; 161 if (!contactField) 162 return std::nullopt; 163 164 return {{ WTFMove(*code), WTFMove(*message), WTFMove(*contactField) }}; 153 165 } 154 166 … … 227 239 } 228 240 229 bool ArgumentCoder<WebCore::PaymentMethodUpdate>::decode(Decoder& decoder, WebCore::PaymentMethodUpdate& update)241 std::optional<WebCore::PaymentMethodUpdate> ArgumentCoder<WebCore::PaymentMethodUpdate>::decode(Decoder& decoder) 230 242 { 231 243 std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems; 232 244 decoder >> newTotalAndLineItems; 233 245 if (!newTotalAndLineItems) 234 return false; 235 update = { WTFMove(*newTotalAndLineItems) }; 236 return true; 246 return std::nullopt; 247 return {{ WTFMove(*newTotalAndLineItems) }}; 237 248 } 238 249 … … 448 459 } 449 460 450 bool ArgumentCoder<WebCore::ShippingContactUpdate>::decode(Decoder& decoder, WebCore::ShippingContactUpdate& update) 451 { 452 if (!decoder.decode(update.errors)) 453 return false; 454 if (!decoder.decode(update.newShippingMethods)) 455 return false; 461 std::optional<WebCore::ShippingContactUpdate> ArgumentCoder<WebCore::ShippingContactUpdate>::decode(Decoder& decoder) 462 { 463 std::optional<Vector<PaymentError>> errors; 464 decoder >> errors; 465 if (!errors) 466 return std::nullopt; 467 468 std::optional<Vector<ApplePaySessionPaymentRequest::ShippingMethod>> newShippingMethods; 469 decoder >> newShippingMethods; 470 if (!newShippingMethods) 471 return std::nullopt; 456 472 457 473 std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems; 458 474 decoder >> newTotalAndLineItems; 459 475 if (!newTotalAndLineItems) 460 return false; 461 update.newTotalAndLineItems = WTFMove(*newTotalAndLineItems); 462 463 return true; 476 return std::nullopt; 477 478 return {{ WTFMove(*errors), WTFMove(*newShippingMethods), WTFMove(*newTotalAndLineItems) }}; 464 479 } 465 480 … … 469 484 } 470 485 471 bool ArgumentCoder<WebCore::ShippingMethodUpdate>::decode(Decoder& decoder, WebCore::ShippingMethodUpdate& update)486 std::optional<WebCore::ShippingMethodUpdate> ArgumentCoder<WebCore::ShippingMethodUpdate>::decode(Decoder& decoder) 472 487 { 473 488 std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems; 474 489 decoder >> newTotalAndLineItems; 475 490 if (!newTotalAndLineItems) 476 return false; 477 update = { WTFMove(*newTotalAndLineItems) }; 478 return true; 491 return std::nullopt; 492 return {{ WTFMove(*newTotalAndLineItems) }}; 479 493 } 480 494 -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r222392 r222584 560 560 } 561 561 562 std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder) 563 { 564 FloatPoint floatPoint; 565 if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint)) 566 return std::nullopt; 567 return WTFMove(floatPoint); 568 } 562 569 563 570 void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint) … … 659 666 } 660 667 668 std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder) 669 { 670 IntPoint intPoint; 671 if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint)) 672 return std::nullopt; 673 return WTFMove(intPoint); 674 } 661 675 662 676 void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect) … … 678 692 } 679 693 680 681 694 void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize) 682 695 { … … 689 702 } 690 703 704 std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder) 705 { 706 IntSize intSize; 707 if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize)) 708 return std::nullopt; 709 return WTFMove(intSize); 710 } 691 711 692 712 void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize) … … 2299 2319 } 2300 2320 2301 bool ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder, TextIndicatorData& textIndicatorData) 2302 { 2321 std::optional<TextIndicatorData> ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder) 2322 { 2323 TextIndicatorData textIndicatorData; 2303 2324 if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates)) 2304 return false;2325 return std::nullopt; 2305 2326 2306 2327 if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates)) 2307 return false;2328 return std::nullopt; 2308 2329 2309 2330 if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates)) 2310 return false;2331 return std::nullopt; 2311 2332 2312 2333 if (!decoder.decode(textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates)) 2313 return false;2334 return std::nullopt; 2314 2335 2315 2336 if (!decoder.decode(textIndicatorData.contentImageScaleFactor)) 2316 return false;2337 return std::nullopt; 2317 2338 2318 2339 if (!decoder.decode(textIndicatorData.estimatedBackgroundColor)) 2319 return false;2340 return std::nullopt; 2320 2341 2321 2342 if (!decoder.decodeEnum(textIndicatorData.presentationTransition)) 2322 return false;2343 return std::nullopt; 2323 2344 2324 2345 uint64_t options; 2325 2346 if (!decoder.decode(options)) 2326 return false;2347 return std::nullopt; 2327 2348 textIndicatorData.options = static_cast<TextIndicatorOptions>(options); 2328 2349 2329 2350 if (!decodeOptionalImage(decoder, textIndicatorData.contentImage)) 2330 return false;2351 return std::nullopt; 2331 2352 2332 2353 if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight)) 2333 return false;2354 return std::nullopt; 2334 2355 2335 2356 if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithoutSelection)) 2336 return false;2337 2338 return true;2357 return std::nullopt; 2358 2359 return WTFMove(textIndicatorData); 2339 2360 } 2340 2361 … … 2409 2430 return false; 2410 2431 2411 if (!decoder.decode(result.textIndicator)) 2412 return false; 2432 std::optional<TextIndicatorData> textIndicator; 2433 decoder >> textIndicator; 2434 if (!textIndicator) 2435 return false; 2436 result.textIndicator = WTFMove(*textIndicator); 2413 2437 2414 2438 #if PLATFORM(COCOA) -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r222392 r222584 232 232 static void encode(Encoder&, const WebCore::FloatPoint&); 233 233 static bool decode(Decoder&, WebCore::FloatPoint&); 234 static std::optional<WebCore::FloatPoint> decode(Decoder&); 234 235 }; 235 236 … … 275 276 static void encode(Encoder&, const WebCore::IntPoint&); 276 277 static bool decode(Decoder&, WebCore::IntPoint&); 278 static std::optional<WebCore::IntPoint> decode(Decoder&); 277 279 }; 278 280 … … 286 288 static void encode(Encoder&, const WebCore::IntSize&); 287 289 static bool decode(Decoder&, WebCore::IntSize&); 290 static std::optional<WebCore::IntSize> decode(Decoder&); 288 291 }; 289 292 … … 525 528 template<> struct ArgumentCoder<WebCore::TextIndicatorData> { 526 529 static void encode(Encoder&, const WebCore::TextIndicatorData&); 527 static bool decode(Decoder&, WebCore::TextIndicatorData&);530 static std::optional<WebCore::TextIndicatorData> decode(Decoder&); 528 531 }; 529 532 … … 566 569 template<> struct ArgumentCoder<WebCore::PaymentAuthorizationResult> { 567 570 static void encode(Encoder&, const WebCore::PaymentAuthorizationResult&); 568 static bool decode(Decoder&, WebCore::PaymentAuthorizationResult&);571 static std::optional<WebCore::PaymentAuthorizationResult> decode(Decoder&); 569 572 }; 570 573 … … 591 594 template<> struct ArgumentCoder<WebCore::PaymentMethodUpdate> { 592 595 static void encode(Encoder&, const WebCore::PaymentMethodUpdate&); 593 static bool decode(Decoder&, WebCore::PaymentMethodUpdate&);596 static std::optional<WebCore::PaymentMethodUpdate> decode(Decoder&); 594 597 }; 595 598 … … 626 629 template<> struct ArgumentCoder<WebCore::ShippingContactUpdate> { 627 630 static void encode(Encoder&, const WebCore::ShippingContactUpdate&); 628 static bool decode(Decoder&, WebCore::ShippingContactUpdate&);631 static std::optional<WebCore::ShippingContactUpdate> decode(Decoder&); 629 632 }; 630 633 631 634 template<> struct ArgumentCoder<WebCore::ShippingMethodUpdate> { 632 635 static void encode(Encoder&, const WebCore::ShippingMethodUpdate&); 633 static bool decode(Decoder&, WebCore::ShippingMethodUpdate&);636 static std::optional<WebCore::ShippingMethodUpdate> decode(Decoder&); 634 637 }; 635 638 -
trunk/Source/WebKit/Shared/WebHitTestResultData.cpp
r213010 r222584 165 165 166 166 if (hasLinkTextIndicator) { 167 WebCore::TextIndicatorData indicatorData; 168 if (!decoder.decode(indicatorData)) 167 std::optional<WebCore::TextIndicatorData> indicatorData; 168 decoder >> indicatorData; 169 if (!indicatorData) 169 170 return false; 170 171 171 hitTestResultData.linkTextIndicator = WebCore::TextIndicator::create( indicatorData);172 hitTestResultData.linkTextIndicator = WebCore::TextIndicator::create(*indicatorData); 172 173 } 173 174 -
trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp
r222233 r222584 192 192 if (!decoder.decodeEnum(parameters.scrollPinningBehavior)) 193 193 return std::nullopt; 194 if (!decoder.decode(parameters.scrollbarOverlayStyle)) 195 return std::nullopt; 194 195 std::optional<std::optional<uint32_t>> scrollbarOverlayStyle; 196 decoder >> scrollbarOverlayStyle; 197 if (!scrollbarOverlayStyle) 198 return std::nullopt; 199 parameters.scrollbarOverlayStyle = WTFMove(*scrollbarOverlayStyle); 200 196 201 if (!decoder.decode(parameters.backgroundExtendsBeyondPage)) 197 202 return std::nullopt; … … 247 252 return std::nullopt; 248 253 249 if (!decoder.decode(parameters.cpuLimit)) 250 return std::nullopt; 254 std::optional<std::optional<double>> cpuLimit; 255 decoder >> cpuLimit; 256 if (!cpuLimit) 257 return std::nullopt; 258 parameters.cpuLimit = WTFMove(*cpuLimit); 251 259 252 260 if (!decoder.decode(parameters.urlSchemeHandlers)) -
trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm
r220506 r222584 145 145 return false; 146 146 147 if (!decoder.decode(result.linkIndicator)) 148 return false; 147 std::optional<WebCore::TextIndicatorData> linkIndicator; 148 decoder >> linkIndicator; 149 if (!linkIndicator) 150 return false; 151 result.linkIndicator = WTFMove(*linkIndicator); 149 152 150 153 ShareableBitmap::Handle handle; -
trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm
r220979 r222584 98 98 99 99 if (hasDetectedDataTextIndicator) { 100 WebCore::TextIndicatorData indicatorData; 101 if (!decoder.decode(indicatorData)) 100 std::optional<WebCore::TextIndicatorData> indicatorData; 101 decoder >> indicatorData; 102 if (!indicatorData) 102 103 return false; 103 104 104 hitTestResultData.detectedDataTextIndicator = WebCore::TextIndicator::create( indicatorData);105 hitTestResultData.detectedDataTextIndicator = WebCore::TextIndicator::create(*indicatorData); 105 106 } 106 107
Note: See TracChangeset
for help on using the changeset viewer.