From 7b9f3acd583af672d8464019a88e5045612f6556 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Thu, 30 Jul 2015 19:45:25 +0200 Subject: [PATCH] Bug 1186603 - Add a "Contains" method for string classes and use it in HTMLInputElement. r=nfroyd --- dom/html/HTMLInputElement.cpp | 2 +- xpcom/string/nsTSubstring.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 0e46cb180c6..4df8f95e630 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -7213,7 +7213,7 @@ HTMLInputElement::SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker) filterBundle->GetStringFromName(MOZ_UTF16("videoFilter"), getter_Copies(extensionListStr)); } else if (token.First() == '.') { - if (token.FindChar(';') >= 0 || token.FindChar('*') >= 0) { + if (token.Contains(';') || token.Contains('*')) { // Ignore this filter as it contains reserved characters continue; } diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h index 6bc4e358d8f..d333f2ff3a4 100644 --- a/xpcom/string/nsTSubstring.h +++ b/xpcom/string/nsTSubstring.h @@ -283,6 +283,10 @@ public: size_type NS_FASTCALL CountChar(char_type) const; int32_t NS_FASTCALL FindChar(char_type, index_type aOffset = 0) const; + inline bool Contains(char_type aChar) const + { + return FindChar(aChar) != kNotFound; + } /** * equality