Bug 1186603 - Add a "Contains" method for string classes and use it in HTMLInputElement. r=nfroyd
authorArnaud Bienner <arnaud.bienner@gmail.com>
Thu, 30 Jul 2015 19:45:25 +0200
changeset 287523 6bf7a4af01c21ae3040913bc4e4f62afb1646759
parent 287522 54c95895d3773789bacf8b9355d46ac160264c31
child 287524 67ee7f75059ed7f68cf457507b4981089dae5fe1
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1186603
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1186603 - Add a "Contains" method for string classes and use it in HTMLInputElement. r=nfroyd
dom/html/HTMLInputElement.cpp
xpcom/string/nsTSubstring.h
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -7208,17 +7208,17 @@ HTMLInputElement::SetFilePickerFiltersFr
       filterMask = nsIFilePicker::filterAudio;
       filterBundle->GetStringFromName(MOZ_UTF16("audioFilter"),
                                       getter_Copies(extensionListStr));
     } else if (token.EqualsLiteral("video/*")) {
       filterMask = nsIFilePicker::filterVideo;
       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;
       }
       extensionListStr = NS_LITERAL_STRING("*") + token;
       filterName = extensionListStr;
       atLeastOneFileExtensionFilter = true;
     } else {
       //... if no image/audio/video filter is found, check mime types filters
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -278,16 +278,20 @@ public:
   {
     NS_ASSERTION(mLength > 0, "|Last()| called on an empty string");
     return mData[mLength - 1];
   }
 
   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
    */
 
   bool NS_FASTCALL Equals(const self_type&) const;
   bool NS_FASTCALL Equals(const self_type&, const comparator_type&) const;