mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-08 05:29:36 +00:00
#375: M1287277 M1259677; temporarily disable M1351303 due to crashes
This commit is contained in:
parent
f7badd24e2
commit
75d95f15b3
|
@ -1649,9 +1649,10 @@ nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
|
||||||
sizeof(ChildrenHashEntry),
|
sizeof(ChildrenHashEntry),
|
||||||
aNumKids);
|
aNumKids);
|
||||||
for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
|
for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
|
||||||
|
Key key = curr->GetKey();
|
||||||
// This will never fail because of the initial size we gave the table.
|
// This will never fail because of the initial size we gave the table.
|
||||||
auto entry =
|
auto entry =
|
||||||
static_cast<ChildrenHashEntry*>(hash->Add(curr->mRule, fallible));
|
static_cast<ChildrenHashEntry*>(hash->Add(&key));
|
||||||
NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
|
NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
|
||||||
entry->mRuleNode = curr;
|
entry->mRuleNode = curr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,17 @@ namespace {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
MOZ_ALWAYS_INLINE nsDependentCString
|
||||||
|
getSharedString(mozIStorageValueArray* aValues, uint32_t aIndex) {
|
||||||
|
uint32_t len;
|
||||||
|
const char* str = aValues->AsSharedUTF8String(aIndex, &len);
|
||||||
|
if (!str) {
|
||||||
|
return nsDependentCString("", (uint32_t)0);
|
||||||
|
}
|
||||||
|
return nsDependentCString(str, len);
|
||||||
|
}
|
||||||
|
|
||||||
} // End anonymous namespace
|
} // End anonymous namespace
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
@ -202,36 +213,40 @@ namespace places {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void
|
nsDependentCSubstring
|
||||||
MatchAutoCompleteFunction::fixupURISpec(const nsCString &aURISpec,
|
MatchAutoCompleteFunction::fixupURISpec(const nsACString &aURISpec,
|
||||||
int32_t aMatchBehavior,
|
int32_t aMatchBehavior,
|
||||||
nsCString &_fixedSpec)
|
nsACString &aSpecBuf)
|
||||||
{
|
{
|
||||||
nsCString unescapedSpec;
|
nsDependentCSubstring fixedSpec;
|
||||||
(void)NS_UnescapeURL(aURISpec, esc_SkipControl | esc_AlwaysCopy,
|
|
||||||
unescapedSpec);
|
|
||||||
|
|
||||||
// If this unescaped string is valid UTF-8, we'll use it. Otherwise,
|
// Try to unescape the string. If that succeeds and yields a different
|
||||||
// we will simply use our original string.
|
// string which is also valid UTF-8, we'll use it.
|
||||||
NS_ASSERTION(_fixedSpec.IsEmpty(),
|
// Otherwise, we will simply use our original string.
|
||||||
"Passing a non-empty string as an out parameter!");
|
bool unescaped = NS_UnescapeURL(aURISpec.BeginReading(),
|
||||||
if (IsUTF8(unescapedSpec))
|
aURISpec.Length(), esc_SkipControl, aSpecBuf);
|
||||||
_fixedSpec.Assign(unescapedSpec);
|
if (unescaped && IsUTF8(aSpecBuf)) {
|
||||||
else
|
fixedSpec.Rebind(aSpecBuf, 0);
|
||||||
_fixedSpec.Assign(aURISpec);
|
} else {
|
||||||
|
fixedSpec.Rebind(aURISpec, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (aMatchBehavior == mozIPlacesAutoComplete::MATCH_ANYWHERE_UNMODIFIED)
|
if (aMatchBehavior == mozIPlacesAutoComplete::MATCH_ANYWHERE_UNMODIFIED)
|
||||||
return;
|
return fixedSpec;
|
||||||
|
|
||||||
if (StringBeginsWith(_fixedSpec, NS_LITERAL_CSTRING("http://")))
|
if (StringBeginsWith(fixedSpec, NS_LITERAL_CSTRING("http://"))) {
|
||||||
_fixedSpec.Cut(0, 7);
|
fixedSpec.Rebind(fixedSpec, 7);
|
||||||
else if (StringBeginsWith(_fixedSpec, NS_LITERAL_CSTRING("https://")))
|
} else if (StringBeginsWith(fixedSpec, NS_LITERAL_CSTRING("https://"))) {
|
||||||
_fixedSpec.Cut(0, 8);
|
fixedSpec.Rebind(fixedSpec, 8);
|
||||||
else if (StringBeginsWith(_fixedSpec, NS_LITERAL_CSTRING("ftp://")))
|
} else if (StringBeginsWith(fixedSpec, NS_LITERAL_CSTRING("ftp://"))) {
|
||||||
_fixedSpec.Cut(0, 6);
|
fixedSpec.Rebind(fixedSpec, 6);
|
||||||
|
}
|
||||||
|
|
||||||
if (StringBeginsWith(_fixedSpec, NS_LITERAL_CSTRING("www.")))
|
if (StringBeginsWith(fixedSpec, NS_LITERAL_CSTRING("www."))) {
|
||||||
_fixedSpec.Cut(0, 4);
|
fixedSpec.Rebind(fixedSpec, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fixedSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
@ -337,19 +352,19 @@ namespace places {
|
||||||
#define HAS_BEHAVIOR(aBitName) \
|
#define HAS_BEHAVIOR(aBitName) \
|
||||||
(searchBehavior & mozIPlacesAutoComplete::BEHAVIOR_##aBitName)
|
(searchBehavior & mozIPlacesAutoComplete::BEHAVIOR_##aBitName)
|
||||||
|
|
||||||
nsAutoCString searchString;
|
nsDependentCString searchString =
|
||||||
(void)aArguments->GetUTF8String(kArgSearchString, searchString);
|
getSharedString(aArguments, kArgSearchString);
|
||||||
nsCString url;
|
nsDependentCString url =
|
||||||
(void)aArguments->GetUTF8String(kArgIndexURL, url);
|
getSharedString(aArguments, kArgIndexURL);
|
||||||
|
|
||||||
int32_t matchBehavior = aArguments->AsInt32(kArgIndexMatchBehavior);
|
int32_t matchBehavior = aArguments->AsInt32(kArgIndexMatchBehavior);
|
||||||
|
|
||||||
// We only want to filter javascript: URLs if we are not supposed to search
|
// We only want to filter javascript: URLs if we are not supposed to search
|
||||||
// for them, and the search does not start with "javascript:".
|
// for them, and the search does not start with "javascript:".
|
||||||
if (matchBehavior != mozIPlacesAutoComplete::MATCH_ANYWHERE_UNMODIFIED &&
|
if (matchBehavior != mozIPlacesAutoComplete::MATCH_ANYWHERE_UNMODIFIED &&
|
||||||
|
StringBeginsWith(url, NS_LITERAL_CSTRING("javascript:")) &&
|
||||||
!HAS_BEHAVIOR(JAVASCRIPT) &&
|
!HAS_BEHAVIOR(JAVASCRIPT) &&
|
||||||
!StringBeginsWith(searchString, NS_LITERAL_CSTRING("javascript:")) &&
|
!StringBeginsWith(searchString, NS_LITERAL_CSTRING("javascript:"))) {
|
||||||
StringBeginsWith(url, NS_LITERAL_CSTRING("javascript:"))) {
|
|
||||||
NS_ADDREF(*_result = new IntegerVariant(0));
|
NS_ADDREF(*_result = new IntegerVariant(0));
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -357,8 +372,7 @@ namespace places {
|
||||||
int32_t visitCount = aArguments->AsInt32(kArgIndexVisitCount);
|
int32_t visitCount = aArguments->AsInt32(kArgIndexVisitCount);
|
||||||
bool typed = aArguments->AsInt32(kArgIndexTyped) ? true : false;
|
bool typed = aArguments->AsInt32(kArgIndexTyped) ? true : false;
|
||||||
bool bookmark = aArguments->AsInt32(kArgIndexBookmark) ? true : false;
|
bool bookmark = aArguments->AsInt32(kArgIndexBookmark) ? true : false;
|
||||||
nsAutoCString tags;
|
nsDependentCString tags = getSharedString(aArguments, kArgIndexTags);
|
||||||
(void)aArguments->GetUTF8String(kArgIndexTags, tags);
|
|
||||||
int32_t openPageCount = aArguments->AsInt32(kArgIndexOpenPageCount);
|
int32_t openPageCount = aArguments->AsInt32(kArgIndexOpenPageCount);
|
||||||
bool matches = false;
|
bool matches = false;
|
||||||
if (HAS_BEHAVIOR(RESTRICT)) {
|
if (HAS_BEHAVIOR(RESTRICT)) {
|
||||||
|
@ -388,11 +402,11 @@ namespace places {
|
||||||
searchFunctionPtr searchFunction = getSearchFunction(matchBehavior);
|
searchFunctionPtr searchFunction = getSearchFunction(matchBehavior);
|
||||||
|
|
||||||
// Clean up our URI spec and prepare it for searching.
|
// Clean up our URI spec and prepare it for searching.
|
||||||
nsCString fixedURI;
|
nsCString fixedUrlBuf;
|
||||||
fixupURISpec(url, matchBehavior, fixedURI);
|
nsDependentCSubstring fixedURI =
|
||||||
|
fixupURISpec(url, matchBehavior, fixedUrlBuf);
|
||||||
|
|
||||||
nsAutoCString title;
|
nsDependentCString title = getSharedString(aArguments, kArgIndexTitle);
|
||||||
(void)aArguments->GetUTF8String(kArgIndexTitle, title);
|
|
||||||
|
|
||||||
// Determine if every token matches either the bookmark title, tags, page
|
// Determine if every token matches either the bookmark title, tags, page
|
||||||
// title, or page URL.
|
// title, or page URL.
|
||||||
|
|
|
@ -166,11 +166,13 @@ private:
|
||||||
* @param aMatchBehavior
|
* @param aMatchBehavior
|
||||||
* The matching behavior to use defined by one of the
|
* The matching behavior to use defined by one of the
|
||||||
* mozIPlacesAutoComplete::MATCH_* values.
|
* mozIPlacesAutoComplete::MATCH_* values.
|
||||||
* @param _fixedSpec
|
* @param aSpecBuf
|
||||||
* An out parameter that is the fixed up string.
|
* A string buffer that the returned slice can point into, if needed.
|
||||||
|
* @return the fixed up string.
|
||||||
*/
|
*/
|
||||||
static void fixupURISpec(const nsCString &aURISpec, int32_t aMatchBehavior,
|
static nsDependentCSubstring fixupURISpec(const nsACString &aURISpec,
|
||||||
nsCString &_fixedSpec);
|
int32_t aMatchBehavior,
|
||||||
|
nsACString &aSpecBuf);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,8 @@ const SQL_BOOKMARK_TAGS_FRAGMENT =
|
||||||
|
|
||||||
// TODO bug 412736: in case of a frecency tie, we might break it with h.typed
|
// TODO bug 412736: in case of a frecency tie, we might break it with h.typed
|
||||||
// and h.visit_count. That is slower though, so not doing it yet...
|
// and h.visit_count. That is slower though, so not doing it yet...
|
||||||
|
// NB: as a slight performance optimization, we only evaluate the "btitle"
|
||||||
|
// and "tags" queries for bookmarked entries.
|
||||||
function defaultQuery(conditions = "") {
|
function defaultQuery(conditions = "") {
|
||||||
let query =
|
let query =
|
||||||
`SELECT :query_type, h.url, h.title, f.url, ${SQL_BOOKMARK_TAGS_FRAGMENT},
|
`SELECT :query_type, h.url, h.title, f.url, ${SQL_BOOKMARK_TAGS_FRAGMENT},
|
||||||
|
@ -121,7 +123,12 @@ function defaultQuery(conditions = "") {
|
||||||
LEFT JOIN moz_openpages_temp t ON t.url = h.url
|
LEFT JOIN moz_openpages_temp t ON t.url = h.url
|
||||||
WHERE h.frecency <> 0
|
WHERE h.frecency <> 0
|
||||||
AND AUTOCOMPLETE_MATCH(:searchString, h.url,
|
AND AUTOCOMPLETE_MATCH(:searchString, h.url,
|
||||||
IFNULL(btitle, h.title), tags,
|
CASE WHEN bookmarked THEN
|
||||||
|
IFNULL(btitle, h.title)
|
||||||
|
ELSE h.title END,
|
||||||
|
CASE WHEN bookmarked THEN
|
||||||
|
tags
|
||||||
|
ELSE '' END,
|
||||||
h.visit_count, h.typed,
|
h.visit_count, h.typed,
|
||||||
bookmarked, t.open_count,
|
bookmarked, t.open_count,
|
||||||
:matchBehavior, :searchBehavior)
|
:matchBehavior, :searchBehavior)
|
||||||
|
|
|
@ -654,7 +654,7 @@ NS_NewAtom(const char16_t* aUTF16String)
|
||||||
return NS_NewAtom(nsDependentString(aUTF16String));
|
return NS_NewAtom(nsDependentString(aUTF16String));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equivalent to current NS_Atomize and called by NS_AtomizeMainThread.
|
// Equivalent to current NS_Atomize.
|
||||||
// Left as such for legacy callers in our older 45-era codebase.
|
// Left as such for legacy callers in our older 45-era codebase.
|
||||||
already_AddRefed<nsIAtom>
|
already_AddRefed<nsIAtom>
|
||||||
NS_NewAtom(const nsAString& aUTF16String)
|
NS_NewAtom(const nsAString& aUTF16String)
|
||||||
|
@ -680,6 +680,7 @@ NS_NewAtom(const nsAString& aUTF16String)
|
||||||
already_AddRefed<nsIAtom>
|
already_AddRefed<nsIAtom>
|
||||||
NS_AtomizeMainThread(const nsAString& aUTF16String)
|
NS_AtomizeMainThread(const nsAString& aUTF16String)
|
||||||
{
|
{
|
||||||
|
#if(0)
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
nsCOMPtr<nsIAtom> retVal;
|
nsCOMPtr<nsIAtom> retVal;
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
|
@ -687,7 +688,7 @@ NS_AtomizeMainThread(const nsAString& aUTF16String)
|
||||||
uint32_t index = hash % RECENTLY_USED_MAIN_THREAD_ATOM_CACHE_SIZE;
|
uint32_t index = hash % RECENTLY_USED_MAIN_THREAD_ATOM_CACHE_SIZE;
|
||||||
nsIAtom* atom = sRecentlyUsedMainThreadAtoms[index];
|
nsIAtom* atom = sRecentlyUsedMainThreadAtoms[index];
|
||||||
|
|
||||||
if (atom) {
|
if (atom && atom->GetUTF16String()) { // wallpaper
|
||||||
// This isn't ideal, but covers for the collision case, I guess.
|
// This isn't ideal, but covers for the collision case, I guess.
|
||||||
// The atom names shouldn't be very long in any event.
|
// The atom names shouldn't be very long in any event.
|
||||||
uint32_t length = atom->GetLength();
|
uint32_t length = atom->GetLength();
|
||||||
|
@ -711,6 +712,9 @@ NS_AtomizeMainThread(const nsAString& aUTF16String)
|
||||||
|
|
||||||
sRecentlyUsedMainThreadAtoms[index] = retVal;
|
sRecentlyUsedMainThreadAtoms[index] = retVal;
|
||||||
return retVal.forget();
|
return retVal.forget();
|
||||||
|
#else
|
||||||
|
return NS_NewAtom(aUTF16String);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIAtom*
|
nsIAtom*
|
||||||
|
|
|
@ -540,6 +540,9 @@ NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(aResult.IsEmpty(),
|
||||||
|
"Passing a non-empty string as an out parameter!");
|
||||||
|
|
||||||
if (aLen < 0) {
|
if (aLen < 0) {
|
||||||
aLen = strlen(aStr);
|
aLen = strlen(aStr);
|
||||||
}
|
}
|
||||||
|
@ -550,6 +553,10 @@ NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags,
|
||||||
bool skipControl = !!(aFlags & esc_SkipControl);
|
bool skipControl = !!(aFlags & esc_SkipControl);
|
||||||
bool skipInvalidHostChar = !!(aFlags & esc_Host);
|
bool skipInvalidHostChar = !!(aFlags & esc_Host);
|
||||||
|
|
||||||
|
if (writing) {
|
||||||
|
aResult.SetCapacity(aLen);
|
||||||
|
}
|
||||||
|
|
||||||
const char* last = aStr;
|
const char* last = aStr;
|
||||||
const char* p = aStr;
|
const char* p = aStr;
|
||||||
|
|
||||||
|
@ -563,7 +570,10 @@ NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags,
|
||||||
((c1 < '8' && !ignoreAscii) || (c1 >= '8' && !ignoreNonAscii)) &&
|
((c1 < '8' && !ignoreAscii) || (c1 >= '8' && !ignoreNonAscii)) &&
|
||||||
!(skipControl &&
|
!(skipControl &&
|
||||||
(c1 < '2' || (c1 == '7' && (c2 == 'f' || c2 == 'F'))))) {
|
(c1 < '2' || (c1 == '7' && (c2 == 'f' || c2 == 'F'))))) {
|
||||||
writing = true;
|
if (!writing) {
|
||||||
|
writing = true;
|
||||||
|
aResult.SetCapacity(aLen);
|
||||||
|
}
|
||||||
if (p > last) {
|
if (p > last) {
|
||||||
aResult.Append(last, p - last);
|
aResult.Append(last, p - last);
|
||||||
last = p;
|
last = p;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user