Commit b17acbfb authored by Delan Azabani's avatar Delan Azabani Committed by Commit Bot

Migrate DeprecatedLower to LowerASCII where only compared with ASCII

This CL changes DeprecatedLower calls to LowerASCII where the result
is only ever used in a comparison against one or more ASCII constants
(including predicates like StartsWith) but is otherwise dead, and I
believe it’s the last CL needed to finish our intent to remove Unicode
case-insensitivity for ASCII constants [1].

The correctness of the image_encoder_utils.cc change isn’t obvious,
but you can verify it by heading to the line in Chromium Code Search
[2], hovering over lowercase_mime_type, and observing that the only
reads are == MIME type literals and by two functions:

• IsSupportedImageMIMETypeForEncoding (line 78), which does the same
• ParseImageEncodingMimeType (line 80), which does the same

These changes are potentially author-facing, except where the constant
in question contains none of {s,k,S,K} [3], but I’ve optimistically
made them without any additional tests based on Rick Byers’ reasoning
on blink-dev [4]. Please let me know if that’s not sufficient here.

[1] https://groups.google.com/a/chromium.org/d/topic/blink-dev/sFOpNuQ91UU
[2] https://source.chromium.org/chromium/chromium/src/+/f7455871a37e53362183771af7de36844df73a38:third_party/blink/renderer/platform/image-encoders/image_encoder_utils.cc;l=36
[3] https://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt
[4] https://groups.google.com/a/chromium.org/d/msg/blink-dev/sFOpNuQ91UU/3u1HxbnQCQAJ

Change-Id: I10e621bb2a6947bc3004d9a0c156dcae2e05a6e8
Bug: 627682
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2114510
Commit-Queue: Delan Azabani <dazabani@igalia.com>
Reviewed-by: default avatarFrédéric Wang <fwang@igalia.com>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarDarwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753581}
parent 980e53c1
...@@ -204,11 +204,11 @@ static String ConvertDragOperationToEffectAllowed(DragOperation op) { ...@@ -204,11 +204,11 @@ static String ConvertDragOperationToEffectAllowed(DragOperation op) {
} }
// We provide the IE clipboard types (URL and Text), and the clipboard types // We provide the IE clipboard types (URL and Text), and the clipboard types
// specified in the WHATWG Web Applications 1.0 draft see // specified in the HTML spec. See
// http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3 // https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface
static String NormalizeType(const String& type, static String NormalizeType(const String& type,
bool* convert_to_url = nullptr) { bool* convert_to_url = nullptr) {
String clean_type = type.StripWhiteSpace().DeprecatedLower(); String clean_type = type.StripWhiteSpace().LowerASCII();
if (clean_type == kMimeTypeText || if (clean_type == kMimeTypeText ||
clean_type.StartsWith(kMimeTypeTextPlainEtc)) clean_type.StartsWith(kMimeTypeTextPlainEtc))
return kMimeTypeTextPlain; return kMimeTypeTextPlain;
......
...@@ -62,7 +62,7 @@ TEST_F(EditingCommandTest, CreateCommandFromStringCaseFolding) { ...@@ -62,7 +62,7 @@ TEST_F(EditingCommandTest, CreateCommandFromStringCaseFolding) {
Editor& dummy_editor = GetDocument().GetFrame()->GetEditor(); Editor& dummy_editor = GetDocument().GetFrame()->GetEditor();
for (const auto& entry : kCommandNameEntries) { for (const auto& entry : kCommandNameEntries) {
const EditorCommand lower_name_command = const EditorCommand lower_name_command =
dummy_editor.CreateCommand(String(entry.name).DeprecatedLower()); dummy_editor.CreateCommand(String(entry.name).LowerASCII());
EXPECT_EQ(static_cast<int>(entry.type), lower_name_command.IdForHistogram()) EXPECT_EQ(static_cast<int>(entry.type), lower_name_command.IdForHistogram())
<< entry.name; << entry.name;
const EditorCommand upper_name_command = const EditorCommand upper_name_command =
......
...@@ -132,7 +132,7 @@ Node* DOMPatchSupport::PatchNode(Node* node, ...@@ -132,7 +132,7 @@ Node* DOMPatchSupport::PatchNode(Node* node,
old_list.push_back(CreateDigest(child, nullptr)); old_list.push_back(CreateDigest(child, nullptr));
// Compose the new list. // Compose the new list.
String markup_copy = markup.DeprecatedLower(); String markup_copy = markup.LowerASCII();
HeapVector<Member<Digest>> new_list; HeapVector<Member<Digest>> new_list;
for (Node* child = parent_node->firstChild(); child != node; for (Node* child = parent_node->firstChild(); child != node;
child = child->nextSibling()) child = child->nextSibling())
......
...@@ -33,7 +33,7 @@ enum RequestedImageMimeType { ...@@ -33,7 +33,7 @@ enum RequestedImageMimeType {
ImageEncodingMimeType ImageEncoderUtils::ToEncodingMimeType( ImageEncodingMimeType ImageEncoderUtils::ToEncodingMimeType(
const String& mime_type_name, const String& mime_type_name,
const EncodeReason encode_reason) { const EncodeReason encode_reason) {
String lowercase_mime_type = mime_type_name.DeprecatedLower(); String lowercase_mime_type = mime_type_name.LowerASCII();
RequestedImageMimeType requested_mime_type; RequestedImageMimeType requested_mime_type;
if (mime_type_name.IsNull()) if (mime_type_name.IsNull())
......
...@@ -234,7 +234,7 @@ MIMEHeader* MIMEHeader::ParseHeader(SharedBufferChunkReader* buffer) { ...@@ -234,7 +234,7 @@ MIMEHeader* MIMEHeader::ParseHeader(SharedBufferChunkReader* buffer) {
MIMEHeader::Encoding MIMEHeader::ParseContentTransferEncoding( MIMEHeader::Encoding MIMEHeader::ParseContentTransferEncoding(
const String& text) { const String& text) {
String encoding = text.StripWhiteSpace().DeprecatedLower(); String encoding = text.StripWhiteSpace().LowerASCII();
if (encoding == "base64") if (encoding == "base64")
return Encoding::kBase64; return Encoding::kBase64;
if (encoding == "quoted-printable") if (encoding == "quoted-printable")
......
...@@ -193,7 +193,7 @@ bool MIMETypeRegistry::IsSupportedFontMIMEType(const String& mime_type) { ...@@ -193,7 +193,7 @@ bool MIMETypeRegistry::IsSupportedFontMIMEType(const String& mime_type) {
static const unsigned kFontLen = 5; static const unsigned kFontLen = 5;
if (!mime_type.StartsWithIgnoringASCIICase("font/")) if (!mime_type.StartsWithIgnoringASCIICase("font/"))
return false; return false;
String sub_type = mime_type.Substring(kFontLen).DeprecatedLower(); String sub_type = mime_type.Substring(kFontLen).LowerASCII();
return sub_type == "woff" || sub_type == "woff2" || sub_type == "otf" || return sub_type == "woff" || sub_type == "woff2" || sub_type == "otf" ||
sub_type == "ttf" || sub_type == "sfnt"; sub_type == "ttf" || sub_type == "sfnt";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment