0

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] f7455871a3: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: Frédéric Wang <fwang@igalia.com>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Darwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753581}
This commit is contained in:
Delan Azabani
2020-03-26 11:48:50 +00:00
committed by Commit Bot
parent 980e53c140
commit b17acbfb79
6 changed files with 8 additions and 8 deletions
third_party/blink/renderer

@ -204,11 +204,11 @@ static String ConvertDragOperationToEffectAllowed(DragOperation op) {
}
// We provide the IE clipboard types (URL and Text), and the clipboard types
// specified in the WHATWG Web Applications 1.0 draft see
// http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3
// specified in the HTML spec. See
// https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface
static String NormalizeType(const String& type,
bool* convert_to_url = nullptr) {
String clean_type = type.StripWhiteSpace().DeprecatedLower();
String clean_type = type.StripWhiteSpace().LowerASCII();
if (clean_type == kMimeTypeText ||
clean_type.StartsWith(kMimeTypeTextPlainEtc))
return kMimeTypeTextPlain;

@ -62,7 +62,7 @@ TEST_F(EditingCommandTest, CreateCommandFromStringCaseFolding) {
Editor& dummy_editor = GetDocument().GetFrame()->GetEditor();
for (const auto& entry : kCommandNameEntries) {
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())
<< entry.name;
const EditorCommand upper_name_command =

@ -132,7 +132,7 @@ Node* DOMPatchSupport::PatchNode(Node* node,
old_list.push_back(CreateDigest(child, nullptr));
// Compose the new list.
String markup_copy = markup.DeprecatedLower();
String markup_copy = markup.LowerASCII();
HeapVector<Member<Digest>> new_list;
for (Node* child = parent_node->firstChild(); child != node;
child = child->nextSibling())

@ -33,7 +33,7 @@ enum RequestedImageMimeType {
ImageEncodingMimeType ImageEncoderUtils::ToEncodingMimeType(
const String& mime_type_name,
const EncodeReason encode_reason) {
String lowercase_mime_type = mime_type_name.DeprecatedLower();
String lowercase_mime_type = mime_type_name.LowerASCII();
RequestedImageMimeType requested_mime_type;
if (mime_type_name.IsNull())

@ -234,7 +234,7 @@ MIMEHeader* MIMEHeader::ParseHeader(SharedBufferChunkReader* buffer) {
MIMEHeader::Encoding MIMEHeader::ParseContentTransferEncoding(
const String& text) {
String encoding = text.StripWhiteSpace().DeprecatedLower();
String encoding = text.StripWhiteSpace().LowerASCII();
if (encoding == "base64")
return Encoding::kBase64;
if (encoding == "quoted-printable")

@ -193,7 +193,7 @@ bool MIMETypeRegistry::IsSupportedFontMIMEType(const String& mime_type) {
static const unsigned kFontLen = 5;
if (!mime_type.StartsWithIgnoringASCIICase("font/"))
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" ||
sub_type == "ttf" || sub_type == "sfnt";
}