Diff
Modified: trunk/Source/WTF/ChangeLog (280650 => 280651)
--- trunk/Source/WTF/ChangeLog 2021-08-04 19:24:47 UTC (rev 280650)
+++ trunk/Source/WTF/ChangeLog 2021-08-04 19:37:35 UTC (rev 280651)
@@ -1,3 +1,20 @@
+2021-08-03 Myles C. Maxfield <[email protected]>
+
+ [Cocoa] Tweak the formatting for passing NSArrays to TextStreams
+ https://bugs.webkit.org/show_bug.cgi?id=228766
+
+ Reviewed by Simon Fraser.
+
+ Instead of using -[NSArray description], which puts its output on multiple lines,
+ instead use the same formatting as WTF::Vector, which puts its output on a single line.
+
+ We can also use this opportunity to tweak the implementation of operator<<(id) to
+ allow it to be called with Core Foundation types in raw C++ code.
+
+ * wtf/text/TextStream.h:
+ * wtf/text/cocoa/TextStreamCocoa.mm:
+ (WTF::TextStream::operator<<):
+
2021-08-03 Risul Islam <[email protected]>
Add functions for parsing URL query string
Modified: trunk/Source/WTF/wtf/text/TextStream.h (280650 => 280651)
--- trunk/Source/WTF/wtf/text/TextStream.h 2021-08-04 19:24:47 UTC (rev 280650)
+++ trunk/Source/WTF/wtf/text/TextStream.h 2021-08-04 19:37:35 UTC (rev 280651)
@@ -78,9 +78,12 @@
// Deprecated. Use the NumberRespectingIntegers FormattingFlag instead.
WTF_EXPORT_PRIVATE TextStream& operator<<(const FormatNumberRespectingIntegers&);
+#if PLATFORM(COCOA)
+ WTF_EXPORT_PRIVATE TextStream& operator<<(id);
#ifdef __OBJC__
- WTF_EXPORT_PRIVATE TextStream& operator<<(id<NSObject>);
+ WTF_EXPORT_PRIVATE TextStream& operator<<(NSArray *);
#endif
+#endif
OptionSet<Formatting> formattingFlags() const { return m_formattingFlags; }
void setFormattingFlags(OptionSet<Formatting> flags) { m_formattingFlags = flags; }
Modified: trunk/Source/WTF/wtf/text/cocoa/TextStreamCocoa.mm (280650 => 280651)
--- trunk/Source/WTF/wtf/text/cocoa/TextStreamCocoa.mm 2021-08-04 19:24:47 UTC (rev 280650)
+++ trunk/Source/WTF/wtf/text/cocoa/TextStreamCocoa.mm 2021-08-04 19:37:35 UTC (rev 280651)
@@ -25,10 +25,30 @@
namespace WTF {
-TextStream& TextStream::operator<<(id<NSObject> object)
+TextStream& TextStream::operator<<(id object)
{
- m_text.append([object description]);
+ if ([object isKindOfClass:[NSArray class]])
+ return *this << static_cast<NSArray *>(object);
+
+ if ([object conformsToProtocol:@protocol(NSObject)])
+ m_text.append([object description]);
+ else
+ m_text.append("(id)");
return *this;
}
+TextStream& TextStream::operator<<(NSArray *array)
+{
+ *this << "[";
+
+ for (NSUInteger i = 0; i < array.count; ++i) {
+ id item = array[i];
+ *this << item;
+ if (i < array.count - 1)
+ *this << ", ";
+ }
+
+ return *this << "]";
}
+
+}
Modified: trunk/Tools/ChangeLog (280650 => 280651)
--- trunk/Tools/ChangeLog 2021-08-04 19:24:47 UTC (rev 280650)
+++ trunk/Tools/ChangeLog 2021-08-04 19:37:35 UTC (rev 280651)
@@ -1,3 +1,16 @@
+2021-08-03 Myles C. Maxfield <[email protected]>
+
+ [Cocoa] Tweak the formatting for passing NSArrays to TextStreams
+ https://bugs.webkit.org/show_bug.cgi?id=228766
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp: Added.
+ (TEST):
+ * TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm: Added.
+ (TEST):
+
2021-08-04 Jonathan Bedard <[email protected]>
[webkitcorepy] Add shared terminal input code
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (280650 => 280651)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-08-04 19:24:47 UTC (rev 280650)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-08-04 19:37:35 UTC (rev 280651)
@@ -112,6 +112,8 @@
1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */; };
1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; };
1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; };
+ 1C4616A026BA5A2100F8C9F6 /* TextStreamCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C46169E26BA510700F8C9F6 /* TextStreamCocoa.mm */; };
+ 1C4616A726BB172F00F8C9F6 /* TextStreamCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C4616A626BB172F00F8C9F6 /* TextStreamCocoa.cpp */; };
1C51534C261596D700FBC4FE /* UserInstalledAhem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C51534B261596BD00FBC4FE /* UserInstalledAhem.html */; };
1C734B5320788C4800F430EA /* SystemColors.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C734B5220788C4800F430EA /* SystemColors.mm */; };
1C79201C234BDD9B001EAF23 /* CopyRTF.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C79201B234BDD9B001EAF23 /* CopyRTF.mm */; };
@@ -1878,6 +1880,8 @@
1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresourcePlugIn.mm; sourceTree = "<group>"; };
1C2B81841C8924A200A5529F /* webfont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = webfont.html; sourceTree = "<group>"; };
1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; };
+ 1C46169E26BA510700F8C9F6 /* TextStreamCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextStreamCocoa.mm; sourceTree = "<group>"; };
+ 1C4616A626BB172F00F8C9F6 /* TextStreamCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextStreamCocoa.cpp; sourceTree = "<group>"; };
1C51534B261596BD00FBC4FE /* UserInstalledAhem.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = UserInstalledAhem.html; sourceTree = "<group>"; };
1C734B5220788C4800F430EA /* SystemColors.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemColors.mm; sourceTree = "<group>"; };
1C79201B234BDD9B001EAF23 /* CopyRTF.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CopyRTF.mm; sourceTree = "<group>"; };
@@ -2001,7 +2005,7 @@
2E92B8F8216490EA005B64F0 /* FontAttributes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributes.mm; sourceTree = "<group>"; };
2E9896141D8F092B00739892 /* text-and-password-inputs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "text-and-password-inputs.html"; sourceTree = "<group>"; };
2EB29D5D1F762DA50023A5F1 /* dump-datatransfer-types.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "dump-datatransfer-types.html"; sourceTree = "<group>"; };
- 2EC7034926AF5E88002B2D37 /* KeyboardEventTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyboardEventTests.mm; path = KeyboardEventTests.mm; sourceTree = "<group>"; };
+ 2EC7034926AF5E88002B2D37 /* KeyboardEventTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardEventTests.mm; sourceTree = "<group>"; };
2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlayingControlsTests.mm; sourceTree = "<group>"; };
2EFF06C21D8862120004BB30 /* large-video-offscreen.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-offscreen.html"; sourceTree = "<group>"; };
2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-click.html"; sourceTree = "<group>"; };
@@ -4972,6 +4976,8 @@
isa = PBXGroup;
children = (
BC3FEB63267FCF740054006A /* SpanCocoa.mm */,
+ 1C4616A626BB172F00F8C9F6 /* TextStreamCocoa.cpp */,
+ 1C46169E26BA510700F8C9F6 /* TextStreamCocoa.mm */,
E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */,
);
path = cocoa;
@@ -5312,6 +5318,8 @@
5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */,
7C83DF401D0A590C00FEBCF3 /* TestsController.cpp in Sources */,
9329AA291DE3F81E003ABD07 /* TextBreakIterator.cpp in Sources */,
+ 1C4616A726BB172F00F8C9F6 /* TextStreamCocoa.cpp in Sources */,
+ 1C4616A026BA5A2100F8C9F6 /* TextStreamCocoa.mm in Sources */,
7B2739F32632AB640040F182 /* ThreadAssertionsTest.cpp in Sources */,
E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */,
E38A0D351FD50CC300E98C8B /* Threading.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp (0 => 280651)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp 2021-08-04 19:37:35 UTC (rev 280651)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import <wtf/text/TextStream.h>
+
+#import <CoreFoundation/CoreFoundation.h>
+
+TEST(WTF_TextStream, CFString)
+{
+ TextStream ts;
+ ts << reinterpret_cast<id>(const_cast<CFMutableStringRef>(CFSTR("Test")));
+ EXPECT_EQ(ts.release(), "Test");
+}
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm (0 => 280651)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm 2021-08-04 19:37:35 UTC (rev 280651)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import <wtf/text/TextStream.h>
+
+#import <Foundation/Foundation.h>
+
+TEST(WTF_TextStream, NSString)
+{
+ TextStream ts;
+ ts << @"Test";
+ EXPECT_EQ(ts.release(), "Test");
+}
+
+TEST(WTF_TextStream, NSArray)
+{
+ {
+ TextStream ts;
+ ts << @[@"Test1", @"Test2"];
+ EXPECT_EQ(ts.release(), "[Test1, Test2]");
+ }
+ {
+ TextStream ts;
+ ts << @[@"Test1", @[@"Test2", @"Test3"]];
+ EXPECT_EQ(ts.release(), "[Test1, [Test2, Test3]]");
+ }
+}
+
+TEST(WTF_TextStream, NSNumber)
+{
+ TextStream ts;
+ ts << @(3);
+ EXPECT_EQ(ts.release(), "3");
+}
+
+TEST(WTF_TextStream, id)
+{
+ TextStream ts;
+ id value = @(3);
+ ts << value;
+ EXPECT_EQ(ts.release(), "3");
+}