Changeset 280651 in webkit
- Timestamp:
- Aug 4, 2021, 12:37:35 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/text/TextStream.h (modified) (1 diff)
-
Source/WTF/wtf/text/cocoa/TextStreamCocoa.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (5 diffs)
-
Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp (added)
-
Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r280626 r280651 1 2021-08-03 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Tweak the formatting for passing NSArrays to TextStreams 4 https://bugs.webkit.org/show_bug.cgi?id=228766 5 6 Reviewed by Simon Fraser. 7 8 Instead of using -[NSArray description], which puts its output on multiple lines, 9 instead use the same formatting as WTF::Vector, which puts its output on a single line. 10 11 We can also use this opportunity to tweak the implementation of operator<<(id) to 12 allow it to be called with Core Foundation types in raw C++ code. 13 14 * wtf/text/TextStream.h: 15 * wtf/text/cocoa/TextStreamCocoa.mm: 16 (WTF::TextStream::operator<<): 17 1 18 2021-08-03 Risul Islam <risul_islam@apple.com> 2 19 -
trunk/Source/WTF/wtf/text/TextStream.h
r279847 r280651 79 79 WTF_EXPORT_PRIVATE TextStream& operator<<(const FormatNumberRespectingIntegers&); 80 80 81 #if PLATFORM(COCOA) 82 WTF_EXPORT_PRIVATE TextStream& operator<<(id); 81 83 #ifdef __OBJC__ 82 WTF_EXPORT_PRIVATE TextStream& operator<<(id<NSObject>); 84 WTF_EXPORT_PRIVATE TextStream& operator<<(NSArray *); 85 #endif 83 86 #endif 84 87 -
trunk/Source/WTF/wtf/text/cocoa/TextStreamCocoa.mm
r277744 r280651 26 26 namespace WTF { 27 27 28 TextStream& TextStream::operator<<(id <NSObject>object)28 TextStream& TextStream::operator<<(id object) 29 29 { 30 m_text.append([object description]); 30 if ([object isKindOfClass:[NSArray class]]) 31 return *this << static_cast<NSArray *>(object); 32 33 if ([object conformsToProtocol:@protocol(NSObject)]) 34 m_text.append([object description]); 35 else 36 m_text.append("(id)"); 31 37 return *this; 32 38 } 33 39 40 TextStream& TextStream::operator<<(NSArray *array) 41 { 42 *this << "["; 43 44 for (NSUInteger i = 0; i < array.count; ++i) { 45 id item = array[i]; 46 *this << item; 47 if (i < array.count - 1) 48 *this << ", "; 49 } 50 51 return *this << "]"; 34 52 } 53 54 } -
trunk/Tools/ChangeLog
r280640 r280651 1 2021-08-03 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Tweak the formatting for passing NSArrays to TextStreams 4 https://bugs.webkit.org/show_bug.cgi?id=228766 5 6 Reviewed by Simon Fraser. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp: Added. 10 (TEST): 11 * TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm: Added. 12 (TEST): 13 1 14 2021-08-04 Jonathan Bedard <jbedard@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r280559 r280651 113 113 1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; }; 114 114 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; }; 115 1C4616A026BA5A2100F8C9F6 /* TextStreamCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C46169E26BA510700F8C9F6 /* TextStreamCocoa.mm */; }; 116 1C4616A726BB172F00F8C9F6 /* TextStreamCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C4616A626BB172F00F8C9F6 /* TextStreamCocoa.cpp */; }; 115 117 1C51534C261596D700FBC4FE /* UserInstalledAhem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C51534B261596BD00FBC4FE /* UserInstalledAhem.html */; }; 116 118 1C734B5320788C4800F430EA /* SystemColors.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C734B5220788C4800F430EA /* SystemColors.mm */; }; … … 1879 1881 1C2B81841C8924A200A5529F /* webfont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = webfont.html; sourceTree = "<group>"; }; 1880 1882 1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; }; 1883 1C46169E26BA510700F8C9F6 /* TextStreamCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextStreamCocoa.mm; sourceTree = "<group>"; }; 1884 1C4616A626BB172F00F8C9F6 /* TextStreamCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextStreamCocoa.cpp; sourceTree = "<group>"; }; 1881 1885 1C51534B261596BD00FBC4FE /* UserInstalledAhem.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = UserInstalledAhem.html; sourceTree = "<group>"; }; 1882 1886 1C734B5220788C4800F430EA /* SystemColors.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemColors.mm; sourceTree = "<group>"; }; … … 2002 2006 2E9896141D8F092B00739892 /* text-and-password-inputs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "text-and-password-inputs.html"; sourceTree = "<group>"; }; 2003 2007 2EB29D5D1F762DA50023A5F1 /* dump-datatransfer-types.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "dump-datatransfer-types.html"; sourceTree = "<group>"; }; 2004 2EC7034926AF5E88002B2D37 /* KeyboardEventTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyboardEventTests.mm;path = KeyboardEventTests.mm; sourceTree = "<group>"; };2008 2EC7034926AF5E88002B2D37 /* KeyboardEventTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardEventTests.mm; sourceTree = "<group>"; }; 2005 2009 2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlayingControlsTests.mm; sourceTree = "<group>"; }; 2006 2010 2EFF06C21D8862120004BB30 /* large-video-offscreen.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-offscreen.html"; sourceTree = "<group>"; }; … … 4973 4977 children = ( 4974 4978 BC3FEB63267FCF740054006A /* SpanCocoa.mm */, 4979 1C4616A626BB172F00F8C9F6 /* TextStreamCocoa.cpp */, 4980 1C46169E26BA510700F8C9F6 /* TextStreamCocoa.mm */, 4975 4981 E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */, 4976 4982 ); … … 5313 5319 7C83DF401D0A590C00FEBCF3 /* TestsController.cpp in Sources */, 5314 5320 9329AA291DE3F81E003ABD07 /* TextBreakIterator.cpp in Sources */, 5321 1C4616A726BB172F00F8C9F6 /* TextStreamCocoa.cpp in Sources */, 5322 1C4616A026BA5A2100F8C9F6 /* TextStreamCocoa.mm in Sources */, 5315 5323 7B2739F32632AB640040F182 /* ThreadAssertionsTest.cpp in Sources */, 5316 5324 E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.