Changeset 283048 in webkit
- Timestamp:
- Sep 24, 2021, 11:01:49 AM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r283046 r283048 1 2021-09-24 Eric Hutchison <ehutchison@apple.com> 2 3 Unreviewed, reverting r283024. 4 5 Causes slowdown and crash on EWS 6 7 Reverted changeset: 8 9 "[WebKit2] Refactor some IPC argument encoder logic to work 10 with StreamConnectionEncoder" 11 https://bugs.webkit.org/show_bug.cgi?id=230714 12 https://commits.webkit.org/r283024 13 1 14 2021-09-24 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp
r283024 r283048 31 31 #include "PrivateClickMeasurementEncoder.h" 32 32 #include "StreamConnectionEncoder.h" 33 #include <wtf/text/AtomString.h>34 33 #include <wtf/text/CString.h> 35 34 #include <wtf/text/WTFString.h> … … 220 219 221 220 #if HAVE(AUDIT_TOKEN) 222 223 221 void ArgumentCoder<audit_token_t>::encode(Encoder& encoder, const audit_token_t& auditToken) 224 222 { … … 235 233 return true; 236 234 } 237 238 #endif // HAVE(AUDIT_TOKEN) 235 #endif 236 237 void ArgumentCoder<Monostate>::encode(Encoder&, const Monostate&) 238 { 239 } 240 241 WARN_UNUSED_RETURN std::optional<Monostate> ArgumentCoder<Monostate>::decode(Decoder&) 242 { 243 return Monostate { }; 244 } 239 245 240 246 } // namespace IPC -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h
r283024 r283048 41 41 namespace IPC { 42 42 43 #define DEFINE_SIMPLE_ARGUMENT_CODER(className) template<> struct ArgumentCoder<className> : SimpleArgumentCoder<className> { }; \44 template void SimpleArgumentCoder<className>::encode<Encoder>(Encoder&, const className&); \45 template bool SimpleArgumentCoder<className>::decode<Decoder>(Decoder&, className&);46 47 43 // An argument coder works on POD types 48 44 template<typename T> struct SimpleArgumentCoder { … … 53 49 } 54 50 55 template<typename Decoder>56 51 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, T& t) 57 52 { … … 113 108 114 109 template<typename T> struct ArgumentCoder<OptionSet<T>> { 115 template<typename Encoder>116 110 static void encode(Encoder& encoder, const OptionSet<T>& optionSet) 117 111 { … … 120 114 } 121 115 122 template<typename Decoder>123 116 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, OptionSet<T>& optionSet) 124 117 { … … 132 125 } 133 126 134 template<typename Decoder>135 127 static std::optional<OptionSet<T>> decode(Decoder& decoder) 136 128 { … … 196 188 197 189 template<typename T> struct ArgumentCoder<Box<T>> { 198 template<typename Encoder>199 190 static void encode(Encoder& encoder, const Box<T>& box) 200 191 { … … 208 199 } 209 200 210 template<typename Decoder>211 201 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Box<T>& box) 212 202 { … … 228 218 } 229 219 230 template<typename Decoder>231 220 static std::optional<Box<T>> decode(Decoder& decoder) 232 221 { … … 247 236 248 237 template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> { 249 template<typename Encoder>250 238 static void encode(Encoder& encoder, const std::pair<T, U>& pair) 251 239 { … … 253 241 } 254 242 255 template<typename Decoder>256 243 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, std::pair<T, U>& pair) 257 244 { … … 269 256 } 270 257 271 template<typename Decoder>272 258 static std::optional<std::pair<T, U>> decode(Decoder& decoder) 273 259 { … … 380 366 381 367 template<typename KeyType, typename ValueType> struct ArgumentCoder<WTF::KeyValuePair<KeyType, ValueType>> { 382 template<typename Encoder>383 368 static void encode(Encoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair) 384 369 { … … 386 371 } 387 372 388 template<typename Decoder>389 373 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair) 390 374 { … … 414 398 } 415 399 416 template<typename Decoder>417 400 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector) 418 401 { … … 454 437 } 455 438 456 template<typename Decoder>457 439 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector) 458 440 { … … 465 447 466 448 auto size = static_cast<size_t>(decodedSize); 449 450 // Since we know the total size of the elements, we can allocate the vector in 451 // one fell swoop. Before allocating we must however make sure that the decoder buffer 452 // is big enough. 453 if (!decoder.bufferIsLargeEnoughToContain<T>(size)) 454 return false; 455 456 Vector<T, inlineCapacity, OverflowHandler, minCapacity> temp; 457 temp.grow(size); 458 459 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T))) 460 return false; 461 462 vector.swap(temp); 463 return true; 464 } 465 466 template<typename Decoder> 467 static std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder) 468 { 469 std::optional<uint64_t> decodedSize; 470 decoder >> decodedSize; 471 if (!decodedSize) 472 return std::nullopt; 473 474 if (!isInBounds<size_t>(decodedSize)) 475 return std::nullopt; 476 477 auto size = static_cast<size_t>(*decodedSize); 467 478 468 479 // Since we know the total size of the elements, we can allocate the vector in … … 470 481 // is big enough. 471 482 if (!decoder.template bufferIsLargeEnoughToContain<T>(size)) 472 return false;473 474 Vector<T, inlineCapacity, OverflowHandler, minCapacity> temp;475 temp.grow(size);476 477 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T)))478 return false;479 480 vector.swap(temp);481 return true;482 }483 484 template<typename Decoder>485 static std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)486 {487 std::optional<uint64_t> decodedSize;488 decoder >> decodedSize;489 if (!decodedSize)490 return std::nullopt;491 492 if (!isInBounds<size_t>(decodedSize))493 return std::nullopt;494 495 auto size = static_cast<size_t>(*decodedSize);496 497 // Since we know the total size of the elements, we can allocate the vector in498 // one fell swoop. Before allocating we must however make sure that the decoder buffer499 // is big enough.500 if (!decoder.template bufferIsLargeEnoughToContain<T>(size))501 483 return std::nullopt; 502 484 … … 516 498 typedef HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg, HashTableTraits> HashMapType; 517 499 518 template<typename Encoder>519 500 static void encode(Encoder& encoder, const HashMapType& hashMap) 520 501 { … … 524 505 } 525 506 526 template<typename Decoder>527 507 static std::optional<HashMapType> decode(Decoder& decoder) 528 508 { … … 555 535 } 556 536 557 template<typename Decoder>558 537 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashMapType& hashMap) 559 538 { … … 570 549 typedef HashSet<KeyArg, HashArg, KeyTraitsArg, HashTableTraits> HashSetType; 571 550 572 template<typename Encoder>573 551 static void encode(Encoder& encoder, const HashSetType& hashSet) 574 552 { … … 578 556 } 579 557 580 template<typename Decoder>581 558 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashSetType& hashSet) 582 559 { … … 590 567 } 591 568 592 template<typename Decoder>593 569 static std::optional<HashSetType> decode(Decoder& decoder) 594 570 { … … 620 596 typedef HashCountedSet<KeyArg, HashArg, KeyTraitsArg> HashCountedSetType; 621 597 622 template<typename Encoder>623 598 static void encode(Encoder& encoder, const HashCountedSetType& hashCountedSet) 624 599 { … … 631 606 } 632 607 633 template<typename Decoder>634 608 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashCountedSetType& hashCountedSet) 635 609 { … … 663 637 664 638 template<typename ValueType, typename ErrorType> struct ArgumentCoder<Expected<ValueType, ErrorType>> { 665 template<typename Encoder>666 639 static void encode(Encoder& encoder, const Expected<ValueType, ErrorType>& expected) 667 640 { … … 675 648 } 676 649 677 template<typename Decoder>678 650 static std::optional<Expected<ValueType, ErrorType>> decode(Decoder& decoder) 679 651 { … … 702 674 template<size_t index, typename... Types> 703 675 struct VariantCoder { 704 template<typename Encoder>705 676 static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant, unsigned i) 706 677 { … … 712 683 } 713 684 714 template<typename Decoder>715 685 static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i) 716 686 { … … 728 698 template<typename... Types> 729 699 struct VariantCoder<0, Types...> { 730 template<typename Encoder>731 700 static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant, unsigned i) 732 701 { … … 735 704 } 736 705 737 template<typename Decoder>738 706 static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i) 739 707 { … … 748 716 749 717 template<typename... Types> struct ArgumentCoder<WTF::Variant<Types...>> { 750 template<typename Encoder>751 718 static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant) 752 719 { … … 756 723 } 757 724 758 template<typename Decoder>759 725 static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder) 760 726 { … … 808 774 809 775 template<> struct ArgumentCoder<Monostate> { 810 template<typename Encoder> 811 static void encode(Encoder&, const Monostate&) { } 812 813 template<typename Decoder> 814 static std::optional<Monostate> decode(Decoder&) 815 { 816 return Monostate { }; 817 } 776 static void encode(Encoder&, const Monostate&); 777 static std::optional<Monostate> decode(Decoder&); 818 778 }; 819 779 -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r283024 r283048 89 89 #include <WebCore/TextIndicator.h> 90 90 #include <WebCore/TimingFunction.h> 91 #include <WebCore/TransformationMatrix.h> 91 92 #include <WebCore/UserStyleSheet.h> 92 93 #include <WebCore/VelocityData.h> … … 229 230 230 231 return true; 232 } 233 234 void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform) 235 { 236 SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform); 237 } 238 239 bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform) 240 { 241 return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform); 231 242 } 232 243 … … 415 426 } 416 427 428 void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix) 429 { 430 encoder << transformationMatrix.m11(); 431 encoder << transformationMatrix.m12(); 432 encoder << transformationMatrix.m13(); 433 encoder << transformationMatrix.m14(); 434 435 encoder << transformationMatrix.m21(); 436 encoder << transformationMatrix.m22(); 437 encoder << transformationMatrix.m23(); 438 encoder << transformationMatrix.m24(); 439 440 encoder << transformationMatrix.m31(); 441 encoder << transformationMatrix.m32(); 442 encoder << transformationMatrix.m33(); 443 encoder << transformationMatrix.m34(); 444 445 encoder << transformationMatrix.m41(); 446 encoder << transformationMatrix.m42(); 447 encoder << transformationMatrix.m43(); 448 encoder << transformationMatrix.m44(); 449 } 450 451 bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix) 452 { 453 double m11; 454 if (!decoder.decode(m11)) 455 return false; 456 double m12; 457 if (!decoder.decode(m12)) 458 return false; 459 double m13; 460 if (!decoder.decode(m13)) 461 return false; 462 double m14; 463 if (!decoder.decode(m14)) 464 return false; 465 466 double m21; 467 if (!decoder.decode(m21)) 468 return false; 469 double m22; 470 if (!decoder.decode(m22)) 471 return false; 472 double m23; 473 if (!decoder.decode(m23)) 474 return false; 475 double m24; 476 if (!decoder.decode(m24)) 477 return false; 478 479 double m31; 480 if (!decoder.decode(m31)) 481 return false; 482 double m32; 483 if (!decoder.decode(m32)) 484 return false; 485 double m33; 486 if (!decoder.decode(m33)) 487 return false; 488 double m34; 489 if (!decoder.decode(m34)) 490 return false; 491 492 double m41; 493 if (!decoder.decode(m41)) 494 return false; 495 double m42; 496 if (!decoder.decode(m42)) 497 return false; 498 double m43; 499 if (!decoder.decode(m43)) 500 return false; 501 double m44; 502 if (!decoder.decode(m44)) 503 return false; 504 505 transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); 506 return true; 507 } 508 417 509 void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction) 418 510 { … … 526 618 } 527 619 620 void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint) 621 { 622 SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint); 623 } 624 625 bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint) 626 { 627 return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint); 628 } 629 630 std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder) 631 { 632 FloatPoint floatPoint; 633 if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint)) 634 return std::nullopt; 635 return floatPoint; 636 } 637 638 void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint) 639 { 640 SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint); 641 } 642 643 bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint) 644 { 645 return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint); 646 } 647 648 649 void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect) 650 { 651 SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect); 652 } 653 654 bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect) 655 { 656 return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect); 657 } 658 659 std::optional<FloatRect> ArgumentCoder<FloatRect>::decode(Decoder& decoder) 660 { 661 FloatRect floatRect; 662 if (!SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect)) 663 return std::nullopt; 664 return floatRect; 665 } 666 667 668 void ArgumentCoder<FloatBoxExtent>::encode(Encoder& encoder, const FloatBoxExtent& floatBoxExtent) 669 { 670 SimpleArgumentCoder<FloatBoxExtent>::encode(encoder, floatBoxExtent); 671 } 672 673 bool ArgumentCoder<FloatBoxExtent>::decode(Decoder& decoder, FloatBoxExtent& floatBoxExtent) 674 { 675 return SimpleArgumentCoder<FloatBoxExtent>::decode(decoder, floatBoxExtent); 676 } 677 678 679 void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize) 680 { 681 SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize); 682 } 683 684 bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize) 685 { 686 return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize); 687 } 688 689 690 void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect) 691 { 692 SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect); 693 } 694 695 bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect) 696 { 697 return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect); 698 } 699 528 700 #if ENABLE(META_VIEWPORT) 529 701 void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments) … … 555 727 { 556 728 return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes); 729 } 730 731 void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint) 732 { 733 SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint); 734 } 735 736 bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint) 737 { 738 return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint); 739 } 740 741 std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder) 742 { 743 IntPoint intPoint; 744 if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint)) 745 return std::nullopt; 746 return intPoint; 747 } 748 749 void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect) 750 { 751 SimpleArgumentCoder<IntRect>::encode(encoder, intRect); 752 } 753 754 bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect) 755 { 756 return SimpleArgumentCoder<IntRect>::decode(decoder, intRect); 757 } 758 759 std::optional<IntRect> ArgumentCoder<IntRect>::decode(Decoder& decoder) 760 { 761 IntRect rect; 762 if (!decode(decoder, rect)) 763 return std::nullopt; 764 return rect; 765 } 766 767 template<typename Encoder> 768 void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize) 769 { 770 SimpleArgumentCoder<IntSize>::encode(encoder, intSize); 771 } 772 773 template 774 void ArgumentCoder<IntSize>::encode<Encoder>(Encoder&, const IntSize&); 775 template 776 void ArgumentCoder<IntSize>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const IntSize&); 777 778 bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize) 779 { 780 return SimpleArgumentCoder<IntSize>::decode(decoder, intSize); 781 } 782 783 std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder) 784 { 785 IntSize intSize; 786 if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize)) 787 return std::nullopt; 788 return intSize; 789 } 790 791 void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize) 792 { 793 SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize); 794 } 795 796 bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize) 797 { 798 return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize); 799 } 800 801 802 void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint) 803 { 804 SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint); 805 } 806 807 bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint) 808 { 809 return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint); 557 810 } 558 811 -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r283024 r283048 27 27 28 28 #include "ArgumentCoders.h" 29 #include <WebCore/AffineTransform.h>30 29 #include <WebCore/AutoplayEvent.h> 31 30 #include <WebCore/ColorSpace.h> 32 31 #include <WebCore/DiagnosticLoggingClient.h> 33 #include <WebCore/FloatPoint.h>34 #include <WebCore/FloatPoint3D.h>35 #include <WebCore/FloatRect.h>36 #include <WebCore/FloatRoundedRect.h>37 #include <WebCore/FloatSize.h>38 32 #include <WebCore/FrameLoaderTypes.h> 39 33 #include <WebCore/IndexedDB.h> 40 34 #include <WebCore/InputMode.h> 41 #include <WebCore/IntPoint.h>42 #include <WebCore/IntRect.h>43 #include <WebCore/IntSize.h>44 #include <WebCore/LayoutPoint.h>45 #include <WebCore/LayoutSize.h>46 #include <WebCore/LengthBox.h>47 35 #include <WebCore/MediaSelectionOption.h> 48 36 #include <WebCore/NativeImage.h> … … 55 43 #include <WebCore/ServiceWorkerTypes.h> 56 44 #include <WebCore/StoredCredentialsPolicy.h> 57 #include <WebCore/TransformationMatrix.h>58 45 #include <WebCore/WorkerType.h> 59 46 #include <wtf/EnumTraits.h> … … 110 97 111 98 class AbsolutePositionConstraints; 99 class AffineTransform; 112 100 class AuthenticationChallenge; 113 101 class BlobPart; … … 122 110 class FilterOperation; 123 111 class FilterOperations; 112 class FloatPoint; 113 class FloatPoint3D; 114 class FloatRect; 115 class FloatRoundedRect; 116 class FloatSize; 124 117 class FixedPositionViewportConstraints; 125 118 class Font; 126 119 class FontPlatformData; 127 120 class HTTPHeaderMap; 121 class IntPoint; 122 class IntRect; 123 class IntSize; 128 124 class KeyframeValueList; 125 class LayoutSize; 126 class LayoutPoint; 129 127 class LinearTimingFunction; 130 128 class Notification; … … 143 141 class StickyPositionViewportConstraints; 144 142 class TextCheckingRequestData; 143 class TransformationMatrix; 145 144 class UserStyleSheet; 146 145 … … 176 175 struct ViewportAttributes; 177 176 struct WindowFeatures; 178 177 178 template<typename> class RectEdges; 179 using FloatBoxExtent = RectEdges<float>; 179 180 using IDBKeyPath = Variant<String, Vector<String>>; 180 181 … … 227 228 namespace IPC { 228 229 229 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::AffineTransform) 230 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatBoxExtent) 231 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatPoint) 232 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatPoint3D) 233 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatRect) 234 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatRoundedRect) 235 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatSize) 236 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntPoint) 237 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntRect) 238 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntSize) 239 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::LayoutSize) 240 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::LayoutPoint) 241 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::TransformationMatrix) 242 243 #if USE(CG) 244 DEFINE_SIMPLE_ARGUMENT_CODER(CGRect) 245 DEFINE_SIMPLE_ARGUMENT_CODER(CGSize) 246 DEFINE_SIMPLE_ARGUMENT_CODER(CGPoint) 247 DEFINE_SIMPLE_ARGUMENT_CODER(CGAffineTransform) 248 #endif 230 template<> struct ArgumentCoder<WebCore::AffineTransform> { 231 static void encode(Encoder&, const WebCore::AffineTransform&); 232 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::AffineTransform&); 233 }; 249 234 250 235 template<> struct ArgumentCoder<WebCore::AttributedString> { … … 281 266 static void encode(Encoder&, const WebCore::EventTrackingRegions&); 282 267 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::EventTrackingRegions&); 268 }; 269 270 template<> struct ArgumentCoder<WebCore::TransformationMatrix> { 271 static void encode(Encoder&, const WebCore::TransformationMatrix&); 272 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::TransformationMatrix&); 283 273 }; 284 274 … … 310 300 }; 311 301 302 template<> struct ArgumentCoder<WebCore::FloatPoint> { 303 static void encode(Encoder&, const WebCore::FloatPoint&); 304 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatPoint&); 305 static std::optional<WebCore::FloatPoint> decode(Decoder&); 306 }; 307 308 template<> struct ArgumentCoder<WebCore::FloatPoint3D> { 309 static void encode(Encoder&, const WebCore::FloatPoint3D&); 310 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatPoint3D&); 311 }; 312 313 template<> struct ArgumentCoder<WebCore::FloatRect> { 314 static void encode(Encoder&, const WebCore::FloatRect&); 315 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatRect&); 316 static std::optional<WebCore::FloatRect> decode(Decoder&); 317 }; 318 319 template<> struct ArgumentCoder<WebCore::FloatBoxExtent> { 320 static void encode(Encoder&, const WebCore::FloatBoxExtent&); 321 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatBoxExtent&); 322 }; 323 324 template<> struct ArgumentCoder<WebCore::FloatSize> { 325 static void encode(Encoder&, const WebCore::FloatSize&); 326 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatSize&); 327 }; 328 329 template<> struct ArgumentCoder<WebCore::FloatRoundedRect> { 330 static void encode(Encoder&, const WebCore::FloatRoundedRect&); 331 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatRoundedRect&); 332 }; 333 312 334 #if ENABLE(META_VIEWPORT) 313 335 template<> struct ArgumentCoder<WebCore::ViewportArguments> { … … 324 346 }; 325 347 348 template<> struct ArgumentCoder<WebCore::IntPoint> { 349 static void encode(Encoder&, const WebCore::IntPoint&); 350 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntPoint&); 351 static std::optional<WebCore::IntPoint> decode(Decoder&); 352 }; 353 354 template<> struct ArgumentCoder<WebCore::IntRect> { 355 static void encode(Encoder&, const WebCore::IntRect&); 356 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntRect&); 357 static std::optional<WebCore::IntRect> decode(Decoder&); 358 }; 359 360 template<> struct ArgumentCoder<WebCore::IntSize> { 361 template<typename Encoder> 362 static void encode(Encoder&, const WebCore::IntSize&); 363 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntSize&); 364 static std::optional<WebCore::IntSize> decode(Decoder&); 365 }; 366 367 template<> struct ArgumentCoder<WebCore::LayoutSize> { 368 static void encode(Encoder&, const WebCore::LayoutSize&); 369 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LayoutSize&); 370 }; 371 372 template<> struct ArgumentCoder<WebCore::LayoutPoint> { 373 static void encode(Encoder&, const WebCore::LayoutPoint&); 374 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LayoutPoint&); 375 }; 376 326 377 template<> struct ArgumentCoder<WebCore::Length> { 327 378 static void encode(Encoder&, const WebCore::Length&); … … 402 453 403 454 #if PLATFORM(COCOA) 404 405 455 template<> struct ArgumentCoder<WTF::MachSendRight> { 406 456 static void encode(Encoder&, const WTF::MachSendRight&); … … 414 464 }; 415 465 416 #endif // PLATFORM(COCOA) 466 template<> struct ArgumentCoder<CGPoint> { 467 static void encode(Encoder&, CGPoint); 468 static std::optional<CGPoint> decode(Decoder&); 469 }; 470 471 template<> struct ArgumentCoder<CGSize> { 472 static void encode(Encoder&, CGSize); 473 static std::optional<CGSize> decode(Decoder&); 474 }; 475 476 template<> struct ArgumentCoder<CGRect> { 477 static void encode(Encoder&, CGRect); 478 static std::optional<CGRect> decode(Decoder&); 479 }; 480 481 template<> struct ArgumentCoder<CGAffineTransform> { 482 static void encode(Encoder&, CGAffineTransform); 483 static std::optional<CGAffineTransform> decode(Decoder&); 484 }; 485 #endif 417 486 418 487 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm
r283024 r283048 322 322 } 323 323 324 void ArgumentCoder<CGRect>::encode(Encoder& encoder, CGRect rect) 325 { 326 encoder << rect.origin << rect.size; 327 } 328 329 std::optional<CGRect> ArgumentCoder<CGRect>::decode(Decoder& decoder) 330 { 331 std::optional<CGPoint> origin; 332 decoder >> origin; 333 if (!origin) 334 return { }; 335 336 std::optional<CGSize> size; 337 decoder >> size; 338 if (!size) 339 return { }; 340 341 return CGRect { *origin, *size }; 342 } 343 344 void ArgumentCoder<CGSize>::encode(Encoder& encoder, CGSize size) 345 { 346 encoder << size.width << size.height; 347 } 348 349 std::optional<CGSize> ArgumentCoder<CGSize>::decode(Decoder& decoder) 350 { 351 CGSize size; 352 if (!decoder.decode(size.width)) 353 return { }; 354 if (!decoder.decode(size.height)) 355 return { }; 356 return size; 357 } 358 359 void ArgumentCoder<CGPoint>::encode(Encoder& encoder, CGPoint point) 360 { 361 encoder << point.x << point.y; 362 } 363 364 std::optional<CGPoint> ArgumentCoder<CGPoint>::decode(Decoder& decoder) 365 { 366 CGPoint point; 367 if (!decoder.decode(point.x)) 368 return { }; 369 if (!decoder.decode(point.y)) 370 return { }; 371 return point; 372 } 373 374 void ArgumentCoder<CGAffineTransform>::encode(Encoder& encoder, CGAffineTransform transform) 375 { 376 encoder << transform.a << transform.b << transform.c << transform.d << transform.tx << transform.ty; 377 } 378 379 std::optional<CGAffineTransform> ArgumentCoder<CGAffineTransform>::decode(Decoder& decoder) 380 { 381 CGAffineTransform transform; 382 if (!decoder.decode(transform.a)) 383 return { }; 384 if (!decoder.decode(transform.b)) 385 return { }; 386 if (!decoder.decode(transform.c)) 387 return { }; 388 if (!decoder.decode(transform.d)) 389 return { }; 390 if (!decoder.decode(transform.tx)) 391 return { }; 392 if (!decoder.decode(transform.ty)) 393 return { }; 394 return transform; 395 } 396 324 397 #if ENABLE(CONTENT_FILTERING) 325 398
Note:
See TracChangeset
for help on using the changeset viewer.