Bug 1538042 Part 1: Change nsIFind::Find to have access to text length. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D25005

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-03-29 15:55:57 +00:00
Родитель a7991ad77c
Коммит 3e8325f6fb
5 изменённых файлов: 5 добавлений и 23 удалений

Просмотреть файл

@ -448,7 +448,7 @@ char16_t nsFind::PeekNextChar(State& aState) const {
// Take nodes out of the tree with NextNode, until null (NextNode will return 0 // Take nodes out of the tree with NextNode, until null (NextNode will return 0
// at the end of our range). // at the end of our range).
NS_IMETHODIMP NS_IMETHODIMP
nsFind::Find(const char16_t* aPatText, nsRange* aSearchRange, nsFind::Find(const nsAString& aPatText, nsRange* aSearchRange,
nsRange* aStartPoint, nsRange* aEndPoint, nsRange** aRangeRet) { nsRange* aStartPoint, nsRange* aEndPoint, nsRange** aRangeRet) {
DEBUG_FIND_PRINTF("============== nsFind::Find('%s'%s, %p, %p, %p)\n", DEBUG_FIND_PRINTF("============== nsFind::Find('%s'%s, %p, %p, %p)\n",
NS_LossyConvertUTF16toASCII(aPatText).get(), NS_LossyConvertUTF16toASCII(aPatText).get(),
@ -469,10 +469,6 @@ nsFind::Find(const char16_t* aPatText, nsRange* aSearchRange,
*aRangeRet = 0; *aRangeRet = 0;
if (!aPatText) {
return NS_ERROR_NULL_POINTER;
}
nsAutoString patAutoStr(aPatText); nsAutoString patAutoStr(aPatText);
if (!mCaseSensitive) { if (!mCaseSensitive) {
ToLowerCase(patAutoStr); ToLowerCase(patAutoStr);

Просмотреть файл

@ -2,7 +2,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIWordBreaker; interface nsIWordBreaker;
@ -30,6 +30,6 @@ interface nsIFind : nsISupports
* end (forward) or start (backward). * end (forward) or start (backward).
* @retval A range spanning the match that was found (or null). * @retval A range spanning the match that was found (or null).
*/ */
Range Find(in wstring aPatText, in Range aSearchRange, Range Find(in AString aPatText, in Range aSearchRange,
in Range aStartPoint, in Range aEndPoint); in Range aStartPoint, in Range aEndPoint);
}; };

Просмотреть файл

@ -673,7 +673,7 @@ nsresult nsWebBrowserFind::SearchInFrame(nsPIDOMWindowOuter* aWindow,
rv = GetSearchLimits(searchRange, startPt, endPt, theDoc, sel, aWrapping); rv = GetSearchLimits(searchRange, startPt, endPt, theDoc, sel, aWrapping);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = find->Find(mSearchString.get(), searchRange, startPt, endPt, rv = find->Find(mSearchString, searchRange, startPt, endPt,
getter_AddRefs(foundRange)); getter_AddRefs(foundRange));
if (NS_SUCCEEDED(rv) && foundRange) { if (NS_SUCCEEDED(rv) && foundRange) {

Просмотреть файл

@ -434,7 +434,7 @@ nsresult nsTypeAheadFind::FindItNow(nsIPresShell* aPresShell, bool aIsLinksOnly,
while (true) { // ----- Outer while loop: go through all docs ----- while (true) { // ----- Outer while loop: go through all docs -----
while (true) { // === Inner while loop: go through a single doc === while (true) { // === Inner while loop: go through a single doc ===
mFind->Find(mTypeAheadBuffer.get(), mSearchRange, mStartPointRange, mFind->Find(mTypeAheadBuffer, mSearchRange, mStartPointRange,
mEndPointRange, getter_AddRefs(returnRange)); mEndPointRange, getter_AddRefs(returnRange));
if (!returnRange) { if (!returnRange) {
break; // Nothing found in this doc, go to outer loop (try next doc) break; // Nothing found in this doc, go to outer loop (try next doc)

Просмотреть файл

@ -33,20 +33,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=450048
var startPt = searchRange; var startPt = searchRange;
var endPt = searchRange; var endPt = searchRange;
// Check |null| detection on |aPatText| parameter.
try {
rf.Find(null, searchRange, startPt, endPt);
ok(false, "Missing NS_ERROR_NULL_POINTER exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_NULL_POINTER) {
ok(true, null);
} else {
throw wrappedError;
}
}
// Check |null| detection on |aSearchRange| parameter. // Check |null| detection on |aSearchRange| parameter.
try { try {
rf.Find("", null, startPt, endPt); rf.Find("", null, startPt, endPt);