Skip to content

Commit

Permalink
Backed out 9 changesets (bug 1695817) for causing failures at browser…
Browse files Browse the repository at this point in the history
…_all_files_referenced.js. CLOSED TREE

Backed out changeset df4086427aaf (bug 1695817)
Backed out changeset 119a24f8be08 (bug 1695817)
Backed out changeset fd277ae2a7b8 (bug 1695817)
Backed out changeset a2c86a645fa8 (bug 1695817)
Backed out changeset c73705233fc4 (bug 1695817)
Backed out changeset 0a80eea3c0fa (bug 1695817)
Backed out changeset 9af42c7a3ca7 (bug 1695817)
Backed out changeset a2d11a0849d5 (bug 1695817)
Backed out changeset ba3ddcc28cbf (bug 1695817)
  • Loading branch information
Butkovits Atila committed May 28, 2021
1 parent 06a2145 commit 711401e
Show file tree
Hide file tree
Showing 43 changed files with 6 additions and 3,457 deletions.
4 changes: 0 additions & 4 deletions docshell/base/nsAboutRedirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::MAKE_LINKABLE | nsIAboutModule::URI_CAN_LOAD_IN_CHILD},
{"support", "chrome://global/content/aboutSupport.xhtml",
nsIAboutModule::ALLOW_SCRIPT},
#ifdef XP_WIN
{"third-party", "chrome://global/content/aboutThirdParty.html",
nsIAboutModule::ALLOW_SCRIPT},
#endif
#ifndef MOZ_GLEAN_ANDROID
{"glean", "chrome://global/content/aboutGlean.html",
nsIAboutModule::HIDE_FROM_ABOUTABOUT | nsIAboutModule::ALLOW_SCRIPT},
Expand Down
2 changes: 0 additions & 2 deletions docshell/build/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ if defined('MOZ_CRASHREPORTER'):
about_pages.append('crashes')
if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android':
about_pages.append('profiles')
if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'windows':
about_pages.append('third-party')
if not defined('MOZ_GLEAN_ANDROID'):
about_pages.append('glean')

Expand Down
116 changes: 0 additions & 116 deletions mfbt/BinarySearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define mozilla_BinarySearch_h

#include "mozilla/Assertions.h"
#include "mozilla/CompactPair.h"

#include <stddef.h>

Expand Down Expand Up @@ -129,121 +128,6 @@ bool BinarySearch(const Container& aContainer, size_t aBegin, size_t aEnd,
aMatchOrInsertionPoint);
}

/*
* LowerBound(), UpperBound(), and EqualRange() are equivalent to
* std::lower_bound(), std::upper_bound(), and std::equal_range() respectively.
*
* LowerBound() returns an index pointing to the first element in the range
* in which each element is considered *not less than* the given value passed
* via |aCompare|, or the length of |aContainer| if no such element is found.
*
* UpperBound() returns an index pointing to the first element in the range
* in which each element is considered *greater than* the given value passed
* via |aCompare|, or the length of |aContainer| if no such element is found.
*
* EqualRange() returns a range [first, second) containing all elements are
* considered equivalent to the given value via |aCompare|. If you need
* either the first or last index of the range, LowerBound() or UpperBound(),
* which is slightly faster than EqualRange(), should suffice.
*
* Example (another example is given in TestBinarySearch.cpp):
*
* Vector<const char*> sortedStrings = ...
*
* struct Comparator {
* const nsACString& mStr;
* explicit Comparator(const nsACString& aStr) : mStr(aStr) {}
* int32_t operator()(const char* aVal) const {
* return mStr.Compare(aVal);
* }
* };
*
* auto bounds = EqualRange(sortedStrings, 0, sortedStrings.length(),
* Comparator("needle I'm looking for"_ns));
* printf("Found the range [%zd %zd)\n", bounds.first(), bounds.second());
*
*/
template <typename Container, typename Comparator>
size_t LowerBound(const Container& aContainer, size_t aBegin, size_t aEnd,
const Comparator& aCompare) {
MOZ_ASSERT(aBegin <= aEnd);

size_t low = aBegin;
size_t high = aEnd;
while (high != low) {
size_t middle = low + (high - low) / 2;

// Allow any intermediate type so long as it provides a suitable ordering
// relation.
const int result = aCompare(aContainer[middle]);

// The range returning from LowerBound does include elements
// equivalent to the given value i.e. aCompare(element) == 0
if (result <= 0) {
high = middle;
} else {
low = middle + 1;
}
}

return low;
}

template <typename Container, typename Comparator>
size_t UpperBound(const Container& aContainer, size_t aBegin, size_t aEnd,
const Comparator& aCompare) {
MOZ_ASSERT(aBegin <= aEnd);

size_t low = aBegin;
size_t high = aEnd;
while (high != low) {
size_t middle = low + (high - low) / 2;

// Allow any intermediate type so long as it provides a suitable ordering
// relation.
const int result = aCompare(aContainer[middle]);

// The range returning from UpperBound does NOT include elements
// equivalent to the given value i.e. aCompare(element) == 0
if (result < 0) {
high = middle;
} else {
low = middle + 1;
}
}

return high;
}

template <typename Container, typename Comparator>
CompactPair<size_t, size_t> EqualRange(const Container& aContainer,
size_t aBegin, size_t aEnd,
const Comparator& aCompare) {
MOZ_ASSERT(aBegin <= aEnd);

size_t low = aBegin;
size_t high = aEnd;
while (high != low) {
size_t middle = low + (high - low) / 2;

// Allow any intermediate type so long as it provides a suitable ordering
// relation.
const int result = aCompare(aContainer[middle]);

if (result < 0) {
high = middle;
} else if (result > 0) {
low = middle + 1;
} else {
return MakeCompactPair(
LowerBound(aContainer, low, middle, aCompare),
UpperBound(aContainer, middle + 1, high, aCompare));
}
}

return MakeCompactPair(low, high);
}

} // namespace mozilla

#endif // mozilla_BinarySearch_h
53 changes: 0 additions & 53 deletions mfbt/tests/TestBinarySearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "mozilla/BinarySearch.h"
#include "mozilla/Vector.h"

#include <cstdlib>

using mozilla::ArrayLength;
using mozilla::BinarySearch;
using mozilla::BinarySearchIf;
Expand Down Expand Up @@ -100,59 +98,8 @@ static void TestBinarySearchIf() {
A(!BinarySearchIf(v1, 0, len, RangeFinder(10, 12), &m) && m == 10);
}

static void TestEqualRange() {
struct CompareN {
int mVal;
explicit CompareN(int n) : mVal(n) {}
int operator()(int aVal) const { return mVal - aVal; }
};

constexpr int kMaxNumber = 100;
constexpr int kMaxRepeat = 2;

Vector<int> sortedArray;
MOZ_RELEASE_ASSERT(sortedArray.reserve(kMaxNumber * kMaxRepeat));

// Make a sorted array by appending the loop counter [0, kMaxRepeat] times
// in each iteration. The array will be something like:
// [0, 0, 1, 1, 2, 2, 8, 9, ..., kMaxNumber]
for (int i = 0; i <= kMaxNumber; ++i) {
int repeat = rand() % (kMaxRepeat + 1);
for (int j = 0; j < repeat; ++j) {
MOZ_RELEASE_ASSERT(sortedArray.emplaceBack(i));
}
}

for (int i = -1; i < kMaxNumber + 1; ++i) {
auto bounds = EqualRange(sortedArray, 0, sortedArray.length(), CompareN(i));

MOZ_RELEASE_ASSERT(bounds.first() <= sortedArray.length());
MOZ_RELEASE_ASSERT(bounds.second() <= sortedArray.length());
MOZ_RELEASE_ASSERT(bounds.first() <= bounds.second());

if (bounds.first() == 0) {
MOZ_RELEASE_ASSERT(sortedArray[0] >= i);
} else if (bounds.first() == sortedArray.length()) {
MOZ_RELEASE_ASSERT(sortedArray[sortedArray.length() - 1] < i);
} else {
MOZ_RELEASE_ASSERT(sortedArray[bounds.first() - 1] < i);
MOZ_RELEASE_ASSERT(sortedArray[bounds.first()] >= i);
}

if (bounds.second() == 0) {
MOZ_RELEASE_ASSERT(sortedArray[0] > i);
} else if (bounds.second() == sortedArray.length()) {
MOZ_RELEASE_ASSERT(sortedArray[sortedArray.length() - 1] <= i);
} else {
MOZ_RELEASE_ASSERT(sortedArray[bounds.second() - 1] <= i);
MOZ_RELEASE_ASSERT(sortedArray[bounds.second()] > i);
}
}
}

int main() {
TestBinarySearch();
TestBinarySearchIf();
TestEqualRange();
return 0;
}
19 changes: 5 additions & 14 deletions mozglue/misc/NativeNt.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,20 +471,11 @@ inline void GetLeafName(PUNICODE_STRING aDestString,

#if defined(MOZILLA_INTERNAL_API)

inline const nsDependentSubstring GetLeafName(const nsAString& aString) {
auto it = aString.EndReading();
size_t pos = aString.Length();
while (it > aString.BeginReading()) {
if (*(it - 1) == u'\\') {
return Substring(aString, pos);
}

MOZ_ASSERT(pos > 0);
--pos;
--it;
}

return Substring(aString, 0); // No backslash in the string
inline const nsDependentSubstring GetLeafName(const nsString& aString) {
int32_t lastBackslashPos = aString.RFindChar(L'\\');
int32_t leafStartPos =
(lastBackslashPos == kNotFound) ? 0 : (lastBackslashPos + 1);
return Substring(aString, leafStartPos);
}

#endif // defined(MOZILLA_INTERNAL_API)
Expand Down
36 changes: 0 additions & 36 deletions mozglue/tests/gtest/TestNativeNtGTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,3 @@ TEST(TestNativeNtGTest, GenerateDependentModuleSet)
EXPECT_TRUE(dependentModules.Contains(u"MOZGLUE.dll"_ns));
EXPECT_FALSE(dependentModules.Contains(u"xxx.dll"_ns));
}

TEST(TestNativeNtGTest, GetLeafName)
{
nsAutoString str;
str = mozilla::nt::GetLeafName(u""_ns);
EXPECT_STREQ(str.get(), L"");
str = mozilla::nt::GetLeafName(u"\\"_ns);
EXPECT_STREQ(str.get(), L"");
str = mozilla::nt::GetLeafName(u"\\\\"_ns);
EXPECT_STREQ(str.get(), L"");
str = mozilla::nt::GetLeafName(u"abc\\def\\ghi"_ns);
EXPECT_STREQ(str.get(), L"ghi");
str = mozilla::nt::GetLeafName(u"abcdef"_ns);
EXPECT_STREQ(str.get(), L"abcdef");
str = mozilla::nt::GetLeafName(u"\\abcdef"_ns);
EXPECT_STREQ(str.get(), L"abcdef");

const auto kEntireText =
u"\\"_ns
u"\\\\abc"_ns
u"\\x\\y\\z"_ns
u"123\\456\\"_ns
u"789"_ns;
str = mozilla::nt::GetLeafName(Substring(kEntireText, 0, 0));
EXPECT_STREQ(str.get(), L"");
str = mozilla::nt::GetLeafName(Substring(kEntireText, 0, 1));
EXPECT_STREQ(str.get(), L"");
str = mozilla::nt::GetLeafName(Substring(kEntireText, 1, 5));
EXPECT_STREQ(str.get(), L"abc");
str = mozilla::nt::GetLeafName(Substring(kEntireText, 6, 6));
EXPECT_STREQ(str.get(), L"z");
str = mozilla::nt::GetLeafName(Substring(kEntireText, 12, 8));
EXPECT_STREQ(str.get(), L"");
str = mozilla::nt::GetLeafName(Substring(kEntireText, 20));
EXPECT_STREQ(str.get(), L"789");
}
Loading

0 comments on commit 711401e

Please sign in to comment.