Diff
Modified: trunk/Source/WTF/ChangeLog (237989 => 237990)
--- trunk/Source/WTF/ChangeLog 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WTF/ChangeLog 2018-11-08 18:51:59 UTC (rev 237990)
@@ -1,3 +1,19 @@
+2018-11-08 Dean Jackson <[email protected]>
+
+ Add a String literal that returns a String
+ https://bugs.webkit.org/show_bug.cgi?id=191425
+ <rdar://problem/45914556>
+
+ Reviewed by Sam Weinig.
+
+ Add a new String literal, _str, that will return a String type.
+ This is useful when ""_s won't work, such as for things that
+ don't take an ASCIILiteral directly e.g. ExceptionOr<String>
+ or Variants.
+
+ * wtf/text/WTFString.h:
+ (WTF::StringLiterals::operator _str): Added.
+
2018-11-06 Justin Fan <[email protected]>
[WebGPU] Experimental prototype for WebGPURenderPipeline and WebGPUSwapChain
Modified: trunk/Source/WTF/wtf/text/WTFString.h (237989 => 237990)
--- trunk/Source/WTF/wtf/text/WTFString.h 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2018-11-08 18:51:59 UTC (rev 237990)
@@ -631,6 +631,15 @@
return startsWithLettersIgnoringASCIICase(string.impl(), lowercaseLetters);
}
+inline namespace StringLiterals {
+
+inline String operator"" _str(const char* characters, size_t)
+{
+ return ASCIILiteral::fromLiteralUnsafe(characters);
+}
+
+} // inline StringLiterals
+
} // namespace WTF
using WTF::KeepTrailingZeros;
Modified: trunk/Source/WebCore/ChangeLog (237989 => 237990)
--- trunk/Source/WebCore/ChangeLog 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/ChangeLog 2018-11-08 18:51:59 UTC (rev 237990)
@@ -1,3 +1,48 @@
+2018-11-08 Dean Jackson <[email protected]>
+
+ Add a String literal that returns a String
+ https://bugs.webkit.org/show_bug.cgi?id=191425
+ <rdar://problem/45914556>
+
+ Reviewed by Sam Weinig.
+
+ Use _str where possible.
+
+ API Test in WPT.
+
+ * Modules/fetch/FetchRequest.cpp:
+ (WebCore::computeReferrer):
+ * Modules/indexeddb/IDBKeyPath.cpp:
+ (WebCore::loggingString):
+ * Modules/webdatabase/OriginLock.cpp:
+ (WebCore::OriginLock::lockFileNameForPath):
+ * css/CSSBasicShapes.cpp:
+ (WebCore::updateCornerRadiusWidthAndHeight):
+ * html/canvas/WebGL2RenderingContext.cpp:
+ (WebCore::WebGL2RenderingContext::getParameter):
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::getParameter):
+ * loader/LinkHeader.cpp:
+ (WebCore::parseParameterValue):
+ * loader/LinkLoader.cpp:
+ (WebCore::LinkLoader::preloadIfNeeded):
+ * page/NavigatorBase.cpp:
+ (WebCore::NavigatorBase::platform):
+ * platform/DateComponents.cpp:
+ (WebCore::DateComponents::toString const):
+ * platform/mac/PlatformEventFactoryMac.mm:
+ (WebCore::keyIdentifierForKeyEvent):
+ * rendering/RenderListMarker.cpp:
+ (WebCore::RenderListMarker::suffix const):
+ * rendering/RenderMenuList.cpp:
+ (RenderMenuList::setText):
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::userInterfaceDirectionPolicy):
+ (WebCore::InternalSettings::systemLayoutDirection):
+ * testing/Internals.cpp:
+ (WebCore::Internals::shadowRootType const):
+ (WebCore::Internals::getCurrentCursorInfo):
+
2018-11-08 Jonathan Hammer <[email protected]>
Plain text drag in contenteditable is always DragOperationCopy, never DragOperationMove
Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (237989 => 237990)
--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -48,7 +48,7 @@
static ExceptionOr<String> computeReferrer(ScriptExecutionContext& context, const String& referrer)
{
if (referrer.isEmpty())
- return String { "no-referrer"_s };
+ return "no-referrer"_str;
// FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser.
URL referrerURL = context.completeURL(referrer);
@@ -56,10 +56,10 @@
return Exception { TypeError, "Referrer is not a valid URL."_s };
if (referrerURL.protocolIs("about") && referrerURL.path() == "client")
- return String { "client"_s };
+ return "client"_str;
if (!(context.securityOrigin() && context.securityOrigin()->canRequest(referrerURL)))
- return String { "client"_s };
+ return "client"_str;
return String { referrerURL.string() };
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp (237989 => 237990)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -230,7 +230,7 @@
return makeString("< ", string, " >");
}, [](const Vector<String>& strings) {
if (strings.isEmpty())
- return String("< >");
+ return "< >"_str;
StringBuilder builder;
builder.append("< ");
Modified: trunk/Source/WebCore/Modules/webdatabase/OriginLock.cpp (237989 => 237990)
--- trunk/Source/WebCore/Modules/webdatabase/OriginLock.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/Modules/webdatabase/OriginLock.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -32,7 +32,7 @@
String OriginLock::lockFileNameForPath(String originPath)
{
- return FileSystem::pathByAppendingComponent(originPath, String(".lock"));
+ return FileSystem::pathByAppendingComponent(originPath, ".lock"_s);
}
OriginLock::OriginLock(String originPath)
Modified: trunk/Source/WebCore/css/CSSBasicShapes.cpp (237989 => 237990)
--- trunk/Source/WebCore/css/CSSBasicShapes.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/css/CSSBasicShapes.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -386,7 +386,7 @@
return;
Pair* radius = corner->pairValue();
- width = radius->first() ? radius->first()->cssText() : String("0");
+ width = radius->first() ? radius->first()->cssText() : "0"_str;
if (radius->second())
height = radius->second()->cssText();
}
Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (237989 => 237990)
--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -1870,7 +1870,7 @@
case GraphicsContext3D::RENDERBUFFER_BINDING:
return m_renderbufferBinding;
case GraphicsContext3D::RENDERER:
- return String { "WebKit WebGL"_s };
+ return "WebKit WebGL"_str;
case GraphicsContext3D::SAMPLE_BUFFERS:
return getIntParameter(pname);
case GraphicsContext3D::SAMPLE_COVERAGE_INVERT:
@@ -1936,15 +1936,15 @@
case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL:
return m_unpackColorspaceConversion;
case GraphicsContext3D::VENDOR:
- return String { "WebKit" };
+ return "WebKit"_str;
case GraphicsContext3D::VERSION:
- return String { "WebGL 2.0" };
+ return "WebGL 2.0"_str;
case GraphicsContext3D::VIEWPORT:
return getWebGLIntArrayParameter(pname);
case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
if (m_webglDebugRendererInfo) {
#if PLATFORM(IOS_FAMILY)
- return String { "Apple GPU" };
+ return "Apple GPU"_str;
#else
return m_context->getString(GraphicsContext3D::RENDERER);
#endif
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (237989 => 237990)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -520,7 +520,7 @@
case GraphicsContext3D::RENDERBUFFER_BINDING:
return m_renderbufferBinding;
case GraphicsContext3D::RENDERER:
- return String { "WebKit WebGL"_s };
+ return "WebKit WebGL"_str;
case GraphicsContext3D::SAMPLE_BUFFERS:
return getIntParameter(pname);
case GraphicsContext3D::SAMPLE_COVERAGE_INVERT:
@@ -586,9 +586,9 @@
case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL:
return m_unpackColorspaceConversion;
case GraphicsContext3D::VENDOR:
- return String { "WebKit" };
+ return "WebKit"_str;
case GraphicsContext3D::VERSION:
- return String { "WebGL 1.0" };
+ return "WebGL 1.0"_str;
case GraphicsContext3D::VIEWPORT:
return getWebGLIntArrayParameter(pname);
case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives
@@ -599,7 +599,7 @@
case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
if (m_webglDebugRendererInfo) {
#if PLATFORM(IOS_FAMILY)
- return String { "Apple GPU" };
+ return "Apple GPU"_str;
#else
return m_context->getString(GraphicsContext3D::RENDERER);
#endif
Modified: trunk/Source/WebCore/loader/LinkHeader.cpp (237989 => 237990)
--- trunk/Source/WebCore/loader/LinkHeader.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/loader/LinkHeader.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -252,7 +252,7 @@
valueEnd = position;
skipWhile<CharacterType, isSpaceOrTab>(position, end);
if ((!completeQuotes && valueStart == valueEnd) || (position != end && !isParameterValueEnd(*position))) {
- value = String("");
+ value = emptyString();
return false;
}
if (hasQuotes)
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (237989 => 237990)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -233,12 +233,12 @@
ASSERT(RuntimeEnabledFeatures::sharedFeatures().linkPreloadEnabled());
if (!href.isValid()) {
- document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, String("<link rel=preload> has an invalid `href` value"));
+ document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `href` value"_s);
return nullptr;
}
auto type = LinkLoader::resourceTypeFromAsAttribute(as);
if (!type) {
- document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, String("<link rel=preload> must have a valid `as` value"));
+ document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> must have a valid `as` value"_s);
return nullptr;
}
if (!MediaQueryEvaluator::mediaAttributeMatches(document, media))
Modified: trunk/Source/WebCore/page/NavigatorBase.cpp (237989 => 237990)
--- trunk/Source/WebCore/page/NavigatorBase.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/page/NavigatorBase.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -105,7 +105,7 @@
if (!String(WEBCORE_NAVIGATOR_PLATFORM).isEmpty())
return WEBCORE_NAVIGATOR_PLATFORM;
struct utsname osname;
- static NeverDestroyed<String> platformName(uname(&osname) >= 0 ? String(osname.sysname) + String(" ") + String(osname.machine) : emptyString());
+ static NeverDestroyed<String> platformName(uname(&osname) >= 0 ? String(osname.sysname) + " "_str + String(osname.machine) : emptyString());
return platformName;
#else
return WEBCORE_NAVIGATOR_PLATFORM;
Modified: trunk/Source/WebCore/platform/DateComponents.cpp (237989 => 237990)
--- trunk/Source/WebCore/platform/DateComponents.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/platform/DateComponents.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -708,7 +708,7 @@
return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
case DateTime:
return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
- + toStringForTime(format) + String("Z");
+ + toStringForTime(format) + "Z"_str;
case DateTimeLocal:
return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
+ toStringForTime(format);
@@ -722,7 +722,7 @@
break;
}
ASSERT_NOT_REACHED();
- return String("(Invalid DateComponents)");
+ return "(Invalid DateComponents)"_str;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm (237989 => 237990)
--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm 2018-11-08 18:51:59 UTC (rev 237990)
@@ -492,22 +492,22 @@
switch ([event keyCode]) {
case 54: // Right Command
case 55: // Left Command
- return String("Meta");
+ return "Meta"_str;
case 57: // Capslock
- return String("CapsLock");
+ return "CapsLock"_str;
case 56: // Left Shift
case 60: // Right Shift
- return String("Shift");
+ return "Shift"_str;
case 58: // Left Alt
case 61: // Right Alt
- return String("Alt");
+ return "Alt"_str;
case 59: // Left Ctrl
case 62: // Right Ctrl
- return String("Control");
+ return "Control"_str;
default:
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (237989 => 237990)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -1750,7 +1750,7 @@
const UChar suffix = listMarkerSuffix(type, m_listItem.value());
if (suffix == ' ')
- return String(" ");
+ return " "_str;
// If the suffix is not ' ', an extra space is needed
UChar data[2];
Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (237989 => 237990)
--- trunk/Source/WebCore/rendering/RenderMenuList.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -270,7 +270,7 @@
void RenderMenuList::setText(const String& s)
{
- String textToUse = s.isEmpty() ? String("\n"_s) : s;
+ String textToUse = s.isEmpty() ? "\n"_str : s;
if (m_buttonText)
m_buttonText->setText(textToUse.impl(), true);
Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (237989 => 237990)
--- trunk/Source/WebCore/testing/InternalSettings.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -801,9 +801,9 @@
return Exception { InvalidAccessError };
switch (settings().userInterfaceDirectionPolicy()) {
case UserInterfaceDirectionPolicy::Content:
- return String { "Content"_s };
+ return "Content"_str;
case UserInterfaceDirectionPolicy::System:
- return String { "View"_s };
+ return "View"_str;
}
ASSERT_NOT_REACHED();
return Exception { InvalidAccessError };
@@ -830,9 +830,9 @@
return Exception { InvalidAccessError };
switch (settings().systemLayoutDirection()) {
case TextDirection::LTR:
- return String { "LTR"_s };
+ return "LTR"_str;
case TextDirection::RTL:
- return String { "RTL"_s };
+ return "RTL"_str;
}
ASSERT_NOT_REACHED();
return Exception { InvalidAccessError };
Modified: trunk/Source/WebCore/testing/Internals.cpp (237989 => 237990)
--- trunk/Source/WebCore/testing/Internals.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Source/WebCore/testing/Internals.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -1134,14 +1134,14 @@
switch (downcast<ShadowRoot>(root).mode()) {
case ShadowRootMode::UserAgent:
- return String("UserAgentShadowRoot");
+ return "UserAgentShadowRoot"_str;
case ShadowRootMode::Closed:
- return String("ClosedShadowRoot");
+ return "ClosedShadowRoot"_str;
case ShadowRootMode::Open:
- return String("OpenShadowRoot");
+ return "OpenShadowRoot"_str;
default:
ASSERT_NOT_REACHED();
- return String("Unknown");
+ return "Unknown"_str;
}
}
@@ -3187,7 +3187,7 @@
#endif
return result.toString();
#else
- return String { "FAIL: Cursor details not available on this platform." };
+ return "FAIL: Cursor details not available on this platform."_str;
#endif
}
Modified: trunk/Tools/ChangeLog (237989 => 237990)
--- trunk/Tools/ChangeLog 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Tools/ChangeLog 2018-11-08 18:51:59 UTC (rev 237990)
@@ -1,3 +1,16 @@
+2018-11-08 Dean Jackson <[email protected]>
+
+ Add a String literal that returns a String
+ https://bugs.webkit.org/show_bug.cgi?id=191425
+ <rdar://problem/45914556>
+
+ Reviewed by Sam Weinig.
+
+ Test _str.
+
+ * TestWebKitAPI/Tests/WTF/WTFString.cpp:
+ (TestWebKitAPI::TEST):
+
2018-11-08 Jonathan Bedard <[email protected]>
webkitpy: Generalize trailing SDK specifier (Part 2)
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (237989 => 237990)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2018-11-08 16:16:18 UTC (rev 237989)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2018-11-08 18:51:59 UTC (rev 237990)
@@ -35,11 +35,17 @@
TEST(WTF, StringCreationFromLiteral)
{
- String stringFromLiteral("Explicit construction syntax"_s);
- EXPECT_EQ(strlen("Explicit construction syntax"), stringFromLiteral.length());
- EXPECT_EQ("Explicit construction syntax", stringFromLiteral);
+ String stringFromLiteralViaASCII("Explicit construction syntax"_s);
+ EXPECT_EQ(strlen("Explicit construction syntax"), stringFromLiteralViaASCII.length());
+ EXPECT_EQ("Explicit construction syntax", stringFromLiteralViaASCII);
+ EXPECT_TRUE(stringFromLiteralViaASCII.is8Bit());
+ EXPECT_EQ(String("Explicit construction syntax"), stringFromLiteralViaASCII);
+
+ String stringFromLiteral = "String Literal"_str;
+ EXPECT_EQ(strlen("String Literal"), stringFromLiteral.length());
+ EXPECT_EQ("String Literal", stringFromLiteral);
EXPECT_TRUE(stringFromLiteral.is8Bit());
- EXPECT_EQ(String("Explicit construction syntax"), stringFromLiteral);
+ EXPECT_EQ(String("String Literal"), stringFromLiteral);
String stringWithTemplate("Template Literal", String::ConstructFromLiteral);
EXPECT_EQ(strlen("Template Literal"), stringWithTemplate.length());