From 0092576ecfc0fe58bff359290eb0f4eb4ba3ac43 Mon Sep 17 00:00:00 2001 From: Roy Tam Date: Mon, 20 May 2019 21:13:15 +0800 Subject: [PATCH] reverted nsFind changes as it caused crash. --- embedding/components/find/nsFind.cpp | 6 +++++- embedding/components/find/nsIFind.idl | 2 +- embedding/components/find/nsWebBrowserFind.cpp | 2 +- toolkit/components/typeaheadfind/nsTypeAheadFind.cpp | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/embedding/components/find/nsFind.cpp b/embedding/components/find/nsFind.cpp index 9bbfa4fd0..2765c6f05 100644 --- a/embedding/components/find/nsFind.cpp +++ b/embedding/components/find/nsFind.cpp @@ -853,7 +853,7 @@ nsFind::ResetAll() // Take nodes out of the tree with NextNode, until null (NextNode will return 0 // at the end of our range). NS_IMETHODIMP -nsFind::Find(const nsAString& aPatText, nsIDOMRange* aSearchRange, +nsFind::Find(const char16_t* aPatText, nsIDOMRange* aSearchRange, nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint, nsIDOMRange** aRangeRet) { @@ -870,6 +870,10 @@ nsFind::Find(const nsAString& aPatText, nsIDOMRange* aSearchRange, NS_ENSURE_ARG_POINTER(aRangeRet); *aRangeRet = 0; + if (!aPatText) { + return NS_ERROR_NULL_POINTER; + } + ResetAll(); nsAutoString patAutoStr(aPatText); diff --git a/embedding/components/find/nsIFind.idl b/embedding/components/find/nsIFind.idl index dcc721620..35ca0f5fa 100644 --- a/embedding/components/find/nsIFind.idl +++ b/embedding/components/find/nsIFind.idl @@ -34,6 +34,6 @@ interface nsIFind : nsISupports * end (forward) or start (backward). * @retval A range spanning the match that was found (or null). */ - nsIDOMRange Find(in AString aPatText, in nsIDOMRange aSearchRange, + nsIDOMRange Find(in wstring aPatText, in nsIDOMRange aSearchRange, in nsIDOMRange aStartPoint, in nsIDOMRange aEndPoint); }; diff --git a/embedding/components/find/nsWebBrowserFind.cpp b/embedding/components/find/nsWebBrowserFind.cpp index 2cfcd9899..9cfd93c2e 100644 --- a/embedding/components/find/nsWebBrowserFind.cpp +++ b/embedding/components/find/nsWebBrowserFind.cpp @@ -756,7 +756,7 @@ nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow, bool aWrapping, NS_ENSURE_SUCCESS(rv, rv); - rv = find->Find(mSearchString, searchRange, startPt, endPt, + rv = find->Find(mSearchString.get(), searchRange, startPt, endPt, getter_AddRefs(foundRange)); if (NS_SUCCEEDED(rv) && foundRange) { diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp index 15ae18001..2cbcda2c6 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp @@ -396,7 +396,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly, while (true) { // ----- Outer while loop: go through all docs ----- while (true) { // === Inner while loop: go through a single doc === - mFind->Find(mTypeAheadBuffer, mSearchRange, mStartPointRange, + mFind->Find(mTypeAheadBuffer.get(), mSearchRange, mStartPointRange, mEndPointRange, getter_AddRefs(returnRange)); if (!returnRange)