зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b89936db7178 (bug 202251) for bc failures at browser_misused_characters_in_strings.js. CLOSED TREE
This commit is contained in:
Родитель
db27a01299
Коммит
4b11b63400
|
@ -162,32 +162,6 @@ void ToFoldedCase(const char16_t* aIn, char16_t* aOut, uint32_t aLen) {
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t ToNaked(uint32_t aChar) {
|
||||
if (IS_ASCII(aChar)) {
|
||||
return aChar;
|
||||
}
|
||||
return mozilla::unicode::GetNaked(aChar);
|
||||
}
|
||||
|
||||
void ToNaked(nsAString& aString) {
|
||||
char16_t* buf = aString.BeginWriting();
|
||||
ToNaked(buf, buf, aString.Length());
|
||||
}
|
||||
|
||||
void ToNaked(const char16_t* aIn, char16_t* aOut, uint32_t aLen) {
|
||||
for (uint32_t i = 0; i < aLen; i++) {
|
||||
uint32_t ch = aIn[i];
|
||||
if (i < aLen - 1 && NS_IS_SURROGATE_PAIR(ch, aIn[i + 1])) {
|
||||
ch = mozilla::unicode::GetNaked(SURROGATE_TO_UCS4(ch, aIn[i + 1]));
|
||||
NS_ASSERTION(!IS_IN_BMP(ch), "stripping crossed BMP/SMP boundary!");
|
||||
aOut[i++] = H_SURROGATE(ch);
|
||||
aOut[i] = L_SURROGATE(ch);
|
||||
continue;
|
||||
}
|
||||
aOut[i] = ToNaked(ch);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t nsCaseInsensitiveStringComparator::operator()(const char16_t* lhs,
|
||||
const char16_t* rhs,
|
||||
uint32_t lLength,
|
||||
|
|
|
@ -56,10 +56,6 @@ uint32_t ToFoldedCase(uint32_t aChar);
|
|||
void ToFoldedCase(nsAString& aString);
|
||||
void ToFoldedCase(const char16_t* aIn, char16_t* aOut, uint32_t aLen);
|
||||
|
||||
uint32_t ToNaked(uint32_t aChar);
|
||||
void ToNaked(nsAString& aString);
|
||||
void ToNaked(const char16_t* aIn, char16_t* aOut, uint32_t aLen);
|
||||
|
||||
class nsCaseInsensitiveStringComparator : public nsStringComparator {
|
||||
public:
|
||||
nsCaseInsensitiveStringComparator() = default;
|
||||
|
|
|
@ -8,11 +8,8 @@
|
|||
#include "nsUnicodePropertyData.cpp"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/HashTable.h"
|
||||
#include "nsCharTraits.h"
|
||||
|
||||
#include "unicode/normalizer2.h"
|
||||
|
||||
#define UNICODE_BMP_LIMIT 0x10000
|
||||
#define UNICODE_LIMIT 0x110000
|
||||
|
||||
|
@ -308,50 +305,6 @@ uint32_t CountGraphemeClusters(const char16_t* aText, uint32_t aLength) {
|
|||
return result;
|
||||
}
|
||||
|
||||
uint32_t GetNaked(uint32_t aCh) {
|
||||
using namespace mozilla;
|
||||
|
||||
static const UNormalizer2* normalizer;
|
||||
static HashMap<uint32_t, uint32_t> decompositions;
|
||||
|
||||
HashMap<uint32_t, uint32_t>::Ptr entry = decompositions.lookup(aCh);
|
||||
if (entry.found()) {
|
||||
return entry->value();
|
||||
}
|
||||
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
if (!normalizer) {
|
||||
normalizer = unorm2_getNFDInstance(&error);
|
||||
if (U_FAILURE(error)) {
|
||||
return aCh;
|
||||
}
|
||||
}
|
||||
|
||||
UChar ds[16];
|
||||
uint32_t dc;
|
||||
if (unorm2_getDecomposition(normalizer, aCh, ds, sizeof(ds) / sizeof(UChar),
|
||||
&error) > 0) {
|
||||
if (NS_IS_HIGH_SURROGATE(ds[0])) {
|
||||
dc = SURROGATE_TO_UCS4(ds[0], ds[1]);
|
||||
} else {
|
||||
dc = ds[0];
|
||||
}
|
||||
if (IS_IN_BMP(dc) != IS_IN_BMP(aCh)) {
|
||||
// Mappings that would change the length of a UTF-16 string are not
|
||||
// currently supported.
|
||||
dc = aCh;
|
||||
}
|
||||
if (!decompositions.putNew(aCh, dc)) {
|
||||
// We're out of memory, so delete the cache to free some up.
|
||||
decompositions.clearAndCompact();
|
||||
}
|
||||
} else {
|
||||
dc = aCh;
|
||||
}
|
||||
|
||||
return dc;
|
||||
}
|
||||
|
||||
} // end namespace unicode
|
||||
|
||||
} // end namespace mozilla
|
||||
|
|
|
@ -229,9 +229,6 @@ class ClusterIterator {
|
|||
// Count the number of grapheme clusters in the given string
|
||||
uint32_t CountGraphemeClusters(const char16_t* aText, uint32_t aLength);
|
||||
|
||||
// Remove diacritics from a character
|
||||
uint32_t GetNaked(uint32_t aCh);
|
||||
|
||||
// A simple reverse iterator for a string of char16_t codepoints that
|
||||
// advances by Unicode grapheme clusters
|
||||
class ClusterReverseIterator {
|
||||
|
|
|
@ -238,7 +238,6 @@ pref("accessibility.typeaheadfind.flashBar", 1);
|
|||
pref("accessibility.typeaheadfind.linksonly", false);
|
||||
pref("accessibility.typeaheadfind.casesensitive", 0);
|
||||
pref("accessibility.browsewithcaret_shortcut.enabled", false);
|
||||
pref("findbar.matchdiacritics", 0);
|
||||
|
||||
// Whether the character encoding menu is under the main Firefox button. This
|
||||
// preference is a string so that localizers can alter it.
|
||||
|
|
|
@ -332,7 +332,6 @@ class GeckoViewContent extends GeckoViewModule {
|
|||
|
||||
finder.caseSensitive = !!aData.matchCase;
|
||||
finder.entireWord = !!aData.wholeWord;
|
||||
finder.matchDiacritics = !!aData.matchDiacritics;
|
||||
finder.addResultListener(this._finderListener);
|
||||
|
||||
const drawOutline =
|
||||
|
|
|
@ -768,11 +768,6 @@ pref("accessibility.typeaheadfind.matchesCountLimit", 1000);
|
|||
pref("findbar.highlightAll", false);
|
||||
pref("findbar.entireword", false);
|
||||
pref("findbar.iteratorTimeout", 100);
|
||||
// matchdiacritics: controls the find bar's diacritic matching
|
||||
// 0 - "never" (ignore diacritics)
|
||||
// 1 - "always" (match diacritics)
|
||||
// other - "auto" (match diacritics if input has diacritics, ignore otherwise)
|
||||
pref("findbar.matchdiacritics", 0);
|
||||
|
||||
// use Mac OS X Appearance panel text smoothing setting when rendering text, disabled by default
|
||||
pref("gfx.use_text_smoothing_setting", false);
|
||||
|
|
|
@ -28,10 +28,6 @@ class FinderChild extends JSWindowActorChild {
|
|||
this.finder.caseSensitive = data.caseSensitive;
|
||||
break;
|
||||
|
||||
case "Finder:MatchDiacritics":
|
||||
this.finder.matchDiacritics = data.matchDiacritics;
|
||||
break;
|
||||
|
||||
case "Finder:EntireWord":
|
||||
this.finder.entireWord = data.entireWord;
|
||||
break;
|
||||
|
|
|
@ -51,7 +51,6 @@ class FindContent {
|
|||
* @param {string} queryphrase - the text to search for.
|
||||
* @param {boolean} caseSensitive - whether to use case sensitive matches.
|
||||
* @param {boolean} includeRangeData - whether to collect and return range data.
|
||||
* @param {boolean} matchDiacritics - whether diacritics must match.
|
||||
* @param {boolean} searchString - whether to collect and return rect data.
|
||||
*
|
||||
* @returns {object} that includes:
|
||||
|
@ -67,7 +66,6 @@ class FindContent {
|
|||
entireWord,
|
||||
includeRangeData,
|
||||
includeRectData,
|
||||
matchDiacritics,
|
||||
} = params;
|
||||
|
||||
this.iterator.reset();
|
||||
|
@ -79,7 +77,6 @@ class FindContent {
|
|||
entireWord: !!entireWord,
|
||||
finder: this.finder,
|
||||
listener: this.finder,
|
||||
matchDiacritics: !!matchDiacritics,
|
||||
useSubFrames: false,
|
||||
});
|
||||
|
||||
|
|
|
@ -61,10 +61,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFind)
|
|||
NS_IMPL_CYCLE_COLLECTION(nsFind)
|
||||
|
||||
nsFind::nsFind()
|
||||
: mFindBackward(false),
|
||||
mCaseSensitive(false),
|
||||
mMatchDiacritics(false),
|
||||
mWordBreaker(nullptr) {}
|
||||
: mFindBackward(false), mCaseSensitive(false), mWordBreaker(nullptr) {}
|
||||
|
||||
nsFind::~nsFind() = default;
|
||||
|
||||
|
@ -400,22 +397,6 @@ nsFind::SetEntireWord(bool aEntireWord) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFind::GetMatchDiacritics(bool* aMatchDiacritics) {
|
||||
if (!aMatchDiacritics) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aMatchDiacritics = mMatchDiacritics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFind::SetMatchDiacritics(bool aMatchDiacritics) {
|
||||
mMatchDiacritics = aMatchDiacritics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Here begins the find code. A ten-thousand-foot view of how it works: Find
|
||||
// needs to be able to compare across inline (but not block) nodes, e.g. find
|
||||
// for "abc" should match a<b>b</b>c. So after we've searched a node, we're not
|
||||
|
@ -526,9 +507,6 @@ nsFind::Find(const nsAString& aPatText, nsRange* aSearchRange,
|
|||
if (!mCaseSensitive) {
|
||||
ToFoldedCase(patAutoStr);
|
||||
}
|
||||
if (!mMatchDiacritics) {
|
||||
ToNaked(patAutoStr);
|
||||
}
|
||||
|
||||
// Ignore soft hyphens in the pattern
|
||||
static const char kShy[] = {char(CH_SHY), 0};
|
||||
|
@ -707,13 +685,8 @@ nsFind::Find(const nsAString& aPatText, nsRange* aSearchRange,
|
|||
}
|
||||
if (!inWhitespace && IsSpace(patc)) {
|
||||
inWhitespace = true;
|
||||
} else if (!inWhitespace) {
|
||||
if (!mCaseSensitive) {
|
||||
c = ToFoldedCase(c);
|
||||
}
|
||||
if (!mMatchDiacritics) {
|
||||
c = ToNaked(c);
|
||||
}
|
||||
} else if (!inWhitespace && !mCaseSensitive) {
|
||||
c = ToFoldedCase(c);
|
||||
}
|
||||
|
||||
if (c == CH_SHY) {
|
||||
|
|
|
@ -42,7 +42,6 @@ class nsFind : public nsIFind {
|
|||
// Parameters set from the interface:
|
||||
bool mFindBackward;
|
||||
bool mCaseSensitive;
|
||||
bool mMatchDiacritics;
|
||||
|
||||
// Use "find entire words" mode by setting to a word breaker or null, to
|
||||
// disable "entire words" mode.
|
||||
|
|
|
@ -79,13 +79,3 @@ NS_IMETHODIMP nsFindService::SetMatchCase(bool aMatchCase) {
|
|||
mMatchCase = aMatchCase;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFindService::GetMatchDiacritics(bool* aMatchDiacritics) {
|
||||
NS_ENSURE_ARG_POINTER(aMatchDiacritics);
|
||||
*aMatchDiacritics = mMatchDiacritics;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsFindService::SetMatchDiacritics(bool aMatchDiacritics) {
|
||||
mMatchDiacritics = aMatchDiacritics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -40,5 +40,4 @@ class nsFindService : public nsIFindService {
|
|||
bool mWrapFind;
|
||||
bool mEntireWord;
|
||||
bool mMatchCase;
|
||||
bool mMatchDiacritics;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,6 @@ interface nsIFind : nsISupports
|
|||
attribute boolean findBackwards;
|
||||
attribute boolean caseSensitive;
|
||||
attribute boolean entireWord;
|
||||
attribute boolean matchDiacritics;
|
||||
|
||||
/**
|
||||
* Find some text in the current context. The implementation is
|
||||
|
|
|
@ -22,6 +22,5 @@ interface nsIFindService : nsISupports
|
|||
attribute boolean wrapFind;
|
||||
attribute boolean entireWord;
|
||||
attribute boolean matchCase;
|
||||
attribute boolean matchDiacritics;
|
||||
|
||||
};
|
||||
|
|
|
@ -79,13 +79,6 @@ interface nsIWebBrowserFind : nsISupports
|
|||
*/
|
||||
attribute boolean matchCase;
|
||||
|
||||
/**
|
||||
* matchDiacritics
|
||||
*
|
||||
* Whether to match diacritics when searching. Default is false.
|
||||
*/
|
||||
attribute boolean matchDiacritics;
|
||||
|
||||
/**
|
||||
* searchFrames
|
||||
*
|
||||
|
|
|
@ -54,7 +54,6 @@ nsWebBrowserFind::nsWebBrowserFind()
|
|||
mWrapFind(false),
|
||||
mEntireWord(false),
|
||||
mMatchCase(false),
|
||||
mMatchDiacritics(false),
|
||||
mSearchSubFrames(true),
|
||||
mSearchParentFrames(true) {}
|
||||
|
||||
|
@ -291,19 +290,6 @@ nsWebBrowserFind::SetMatchCase(bool aMatchCase) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserFind::GetMatchDiacritics(bool* aMatchDiacritics) {
|
||||
NS_ENSURE_ARG_POINTER(aMatchDiacritics);
|
||||
*aMatchDiacritics = mMatchDiacritics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserFind::SetMatchDiacritics(bool aMatchDiacritics) {
|
||||
mMatchDiacritics = aMatchDiacritics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsWebBrowserFind::SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow,
|
||||
nsRange* aRange) {
|
||||
RefPtr<Document> doc = aWindow->GetDoc();
|
||||
|
@ -640,7 +626,6 @@ nsresult nsWebBrowserFind::SearchInFrame(nsPIDOMWindowOuter* aWindow,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
(void)find->SetCaseSensitive(mMatchCase);
|
||||
(void)find->SetMatchDiacritics(mMatchDiacritics);
|
||||
(void)find->SetFindBackwards(mFindBackwards);
|
||||
|
||||
(void)find->SetEntireWord(mEntireWord);
|
||||
|
|
|
@ -81,7 +81,6 @@ class nsWebBrowserFind : public nsIWebBrowserFind,
|
|||
bool mWrapFind;
|
||||
bool mEntireWord;
|
||||
bool mMatchCase;
|
||||
bool mMatchDiacritics;
|
||||
|
||||
bool mSearchSubFrames;
|
||||
bool mSearchParentFrames;
|
||||
|
|
|
@ -70,7 +70,6 @@ interface nsITypeAheadFind : nsISupports
|
|||
readonly attribute AString searchString;
|
||||
// Most recent search string
|
||||
attribute boolean caseSensitive; // Searches are case sensitive
|
||||
attribute boolean matchDiacritics; // Searches preserve diacritics
|
||||
attribute boolean entireWord; // Search for whole words only
|
||||
readonly attribute Element foundLink;
|
||||
// Most recent elem found, if a link
|
||||
|
|
|
@ -86,8 +86,7 @@ nsTypeAheadFind::nsTypeAheadFind()
|
|||
mLastFindLength(0),
|
||||
mIsSoundInitialized(false),
|
||||
mCaseSensitive(false),
|
||||
mEntireWord(false),
|
||||
mMatchDiacritics(false) {}
|
||||
mEntireWord(false) {}
|
||||
|
||||
nsTypeAheadFind::~nsTypeAheadFind() {
|
||||
nsCOMPtr<nsIPrefBranch> prefInternal(
|
||||
|
@ -212,24 +211,6 @@ nsTypeAheadFind::GetEntireWord(bool* isEntireWord) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypeAheadFind::SetMatchDiacritics(bool matchDiacritics) {
|
||||
mMatchDiacritics = matchDiacritics;
|
||||
|
||||
if (mFind) {
|
||||
mFind->SetMatchDiacritics(mMatchDiacritics);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypeAheadFind::GetMatchDiacritics(bool* matchDiacritics) {
|
||||
*matchDiacritics = mMatchDiacritics;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypeAheadFind::SetDocShell(nsIDocShell* aDocShell) {
|
||||
mDocShell = do_GetWeakReference(aDocShell);
|
||||
|
|
|
@ -120,7 +120,6 @@ class nsTypeAheadFind : public nsITypeAheadFind,
|
|||
|
||||
bool mCaseSensitive;
|
||||
bool mEntireWord;
|
||||
bool mMatchDiacritics;
|
||||
|
||||
bool EnsureFind() {
|
||||
if (mFind) {
|
||||
|
@ -134,7 +133,6 @@ class nsTypeAheadFind : public nsITypeAheadFind,
|
|||
|
||||
mFind->SetCaseSensitive(mCaseSensitive);
|
||||
mFind->SetEntireWord(mEntireWord);
|
||||
mFind->SetMatchDiacritics(mMatchDiacritics);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=202251
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=450048
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=969980
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1589786
|
||||
|
@ -14,6 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1589786
|
|||
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 450048 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
async function runTests() {
|
||||
|
@ -47,13 +47,12 @@ async function runTests() {
|
|||
rf.findBackwards = false;
|
||||
|
||||
rf.caseSensitive = false;
|
||||
rf.matchDiacritics = false;
|
||||
|
||||
searchValue = "TexT";
|
||||
retRange = rf.Find(searchValue, searchRange, startPt, endPt);
|
||||
ok(retRange, "\"" + searchValue + "\" not found (not caseSensitive)");
|
||||
|
||||
searchValue = "λογος";
|
||||
searchValue = "λόγος";
|
||||
retRange = rf.Find(searchValue, searchRange, startPt, endPt);
|
||||
ok(retRange, "\"" + searchValue + "\" not found (not caseSensitive)");
|
||||
|
||||
|
@ -65,15 +64,9 @@ async function runTests() {
|
|||
retRange = rf.Find(searchValue, searchRange, startPt, endPt);
|
||||
ok(retRange, "\"" + searchValue + "\" not found (not caseSensitive)");
|
||||
|
||||
rf.matchDiacritics = true;
|
||||
|
||||
searchValue = "λογος";
|
||||
retRange = rf.Find(searchValue, searchRange, startPt, endPt);
|
||||
ok(!retRange, "\"" + searchValue + "\" found (not caseSensitive)");
|
||||
|
||||
rf.caseSensitive = true;
|
||||
|
||||
searchValue = "TexT";
|
||||
// searchValue = "TexT";
|
||||
retRange = rf.Find(searchValue, searchRange, startPt, endPt);
|
||||
ok(!retRange, "\"" + searchValue + "\" found (caseSensitive)");
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
await testFind();
|
||||
await testFindAgain();
|
||||
await testCaseSensitivity();
|
||||
await testDiacriticMatching();
|
||||
await testHighlight();
|
||||
}
|
||||
|
||||
|
@ -144,24 +143,6 @@
|
|||
await ContentTask.spawn(gBrowser, null, () => content.getSelection().removeAllRanges());
|
||||
}
|
||||
|
||||
async function testDiacriticMatching() {
|
||||
info("Testing normal diacritic matching.");
|
||||
let promise = once(gFindBar, "finddiacriticmatchingchange", false);
|
||||
|
||||
let matchDiacriticsCheckbox = gFindBar.getElement("find-match-diacritics");
|
||||
matchDiacriticsCheckbox.click();
|
||||
|
||||
let e = await promise;
|
||||
ok(e.detail.matchDiacritics, "find should match diacritics");
|
||||
|
||||
// Toggle it back to the original setting.
|
||||
matchDiacriticsCheckbox.click();
|
||||
|
||||
// Changing diacritic matching does the search so clear the selected text
|
||||
// before the next test.
|
||||
await ContentTask.spawn(gBrowser, null, () => content.getSelection().removeAllRanges());
|
||||
}
|
||||
|
||||
async function testHighlight() {
|
||||
info("Testing find with highlight all.");
|
||||
// Update the find state so the highlight button is clickable.
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
const SAMPLE_URL = "http://www.mozilla.org/";
|
||||
const SAMPLE_TEXT = "Some text in a text field.";
|
||||
const SEARCH_TEXT = "Text Test (δοκιμή)";
|
||||
const SEARCH_TEXT = "Text Test";
|
||||
const NOT_FOUND_TEXT = "This text is not on the page."
|
||||
const ITERATOR_TIMEOUT = gPrefsvc.getIntPref("findbar.iteratorTimeout");
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
|||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
let promise = BrowserTestUtils.browserLoaded(gBrowser);
|
||||
BrowserTestUtils.loadURI(gBrowser, "data:text/html;charset=utf-8,<h2 id='h2'>" + SEARCH_TEXT +
|
||||
BrowserTestUtils.loadURI(gBrowser, "data:text/html,<h2 id='h2'>" + SEARCH_TEXT +
|
||||
"</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2><input id='text' type='text' value='" +
|
||||
SAMPLE_TEXT + "'></input><input id='button' type='button'></input><img id='img' width='50' height='50'/>",
|
||||
{ triggeringPrincipal: window.document.nodePrincipal });
|
||||
|
@ -735,24 +735,6 @@
|
|||
ok(gFindBar.hidden, "Successful Find Again leaves the find bar closed.");
|
||||
}
|
||||
|
||||
async function testToggleDiacriticMatching() {
|
||||
await openFindbar();
|
||||
let promise = promiseFindResult();
|
||||
await enterStringIntoFindField("δοκιμη", false);
|
||||
let result = await promise;
|
||||
is(result.result, Ci.nsITypeAheadFind.FIND_FOUND, "Text should be found");
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, ITERATOR_TIMEOUT + 20));
|
||||
promise = promiseFindResult();
|
||||
let check = gFindBar.getElement("find-match-diacritics");
|
||||
check.click();
|
||||
result = await promise;
|
||||
is(result.result, Ci.nsITypeAheadFind.FIND_NOTFOUND, "Text should NOT be found");
|
||||
|
||||
check.click();
|
||||
gFindBar.close(true);
|
||||
}
|
||||
|
||||
async function testToggleEntireWord() {
|
||||
await openFindbar();
|
||||
let promise = promiseFindResult();
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
]);
|
||||
const PREFS_TO_OBSERVE_INT = new Map([
|
||||
["typeAheadCaseSensitive", "accessibility.typeaheadfind.casesensitive"],
|
||||
["matchDiacritics", "findbar.matchdiacritics"],
|
||||
]);
|
||||
const PREFS_TO_OBSERVE_ALL = new Map([
|
||||
...PREFS_TO_OBSERVE_BOOL,
|
||||
|
@ -73,12 +72,9 @@
|
|||
data-l10n-id="findbar-highlight-all2" oncommand="toggleHighlight(this.checked);" type="checkbox" />
|
||||
<toolbarbutton anonid="find-case-sensitive" class="findbar-case-sensitive findbar-button tabbable"
|
||||
data-l10n-id="findbar-case-sensitive" oncommand="_setCaseSensitivity(this.checked ? 1 : 0);" type="checkbox" />
|
||||
<toolbarbutton anonid="find-match-diacritics" class="findbar-match-diacritics findbar-button tabbable"
|
||||
data-l10n-id="findbar-match-diacritics" oncommand="_setDiacriticMatching(this.checked ? 1 : 0);" type="checkbox" />
|
||||
<toolbarbutton anonid="find-entire-word" class="findbar-entire-word findbar-button tabbable"
|
||||
data-l10n-id="findbar-entire-word" oncommand="toggleEntireWord(this.checked);" type="checkbox" />
|
||||
<label anonid="match-case-status" class="findbar-find-fast" />
|
||||
<label anonid="match-diacritics-status" class="findbar-find-fast" />
|
||||
<label anonid="entire-word-status" class="findbar-find-fast" />
|
||||
<label anonid="found-matches" class="findbar-find-fast found-matches" hidden="true" />
|
||||
<image anonid="find-status-icon" class="findbar-find-fast find-status-icon" />
|
||||
|
@ -394,9 +390,6 @@
|
|||
case "findbar.highlightAll":
|
||||
this.toggleHighlight(prefsvc.getBoolPref(prefName), true);
|
||||
break;
|
||||
case "findbar.matchdiacritics":
|
||||
this._setDiacriticMatching(prefsvc.getIntPref(prefName));
|
||||
break;
|
||||
case "findbar.modalHighlight":
|
||||
this._useModalHighlight = prefsvc.getBoolPref(prefName);
|
||||
if (this.browser.finder) {
|
||||
|
@ -605,55 +598,6 @@
|
|||
this._dispatchFindEvent("casesensitivitychange");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the diacritic-matching mode of the findbar and its UI.
|
||||
*
|
||||
* @param {String} [str] The string for which diacritic matching might be
|
||||
* turned on. This is only used when diacritic
|
||||
* matching is in auto mode, see
|
||||
* `_shouldMatchDiacritics`. The default value for
|
||||
* this parameter is the find-field value.
|
||||
* @see _shouldMatchDiacritics.
|
||||
*/
|
||||
_updateDiacriticMatching(str) {
|
||||
let val = str || this._findField.value;
|
||||
|
||||
let matchDiacritics = this._shouldMatchDiacritics(val);
|
||||
let checkbox = this.getElement("find-match-diacritics");
|
||||
let statusLabel = this.getElement("match-diacritics-status");
|
||||
checkbox.checked = matchDiacritics;
|
||||
|
||||
statusLabel.value = matchDiacritics ? this._matchDiacriticsStr : "";
|
||||
|
||||
// Show the checkbox on the full Find bar in non-auto mode.
|
||||
// Show the label in all other cases.
|
||||
let hideCheckbox =
|
||||
this.findMode != this.FIND_NORMAL ||
|
||||
(this._matchDiacritics != 0 && this._matchDiacritics != 1);
|
||||
checkbox.hidden = hideCheckbox;
|
||||
statusLabel.hidden = !hideCheckbox;
|
||||
|
||||
this.browser.finder.matchDiacritics = matchDiacritics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the findbar diacritic-matching mode
|
||||
* @param {Number} diacriticMatching 0 - ignore diacritics,
|
||||
* 1 - match diacritics,
|
||||
* 2 - auto = match diacritics if the
|
||||
* matching string contains
|
||||
* diacritics.
|
||||
* @see _shouldMatchDiacritics
|
||||
*/
|
||||
_setDiacriticMatching(diacriticMatching) {
|
||||
this._matchDiacritics = diacriticMatching;
|
||||
this._updateDiacriticMatching();
|
||||
this._findFailedString = null;
|
||||
this._find();
|
||||
|
||||
this._dispatchFindEvent("diacriticmatchingchange");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the entire-word mode of the findbar and its UI.
|
||||
*/
|
||||
|
@ -715,7 +659,6 @@
|
|||
this._fastFindStr = bundle.GetStringFromName("FastFind");
|
||||
this._fastFindLinksStr = bundle.GetStringFromName("FastFindLinks");
|
||||
this._caseSensitiveStr = bundle.GetStringFromName("CaseSensitive");
|
||||
this._matchDiacriticsStr = bundle.GetStringFromName("MatchDiacritics");
|
||||
this._entireWordStr = bundle.GetStringFromName("EntireWord");
|
||||
}
|
||||
|
||||
|
@ -840,17 +783,6 @@
|
|||
return str != str.toLowerCase();
|
||||
}
|
||||
|
||||
_shouldMatchDiacritics(str) {
|
||||
if (this._matchDiacritics == 0) {
|
||||
return false;
|
||||
}
|
||||
if (this._matchDiacritics == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return str != str.normalize("NFD");
|
||||
}
|
||||
|
||||
onMouseUp() {
|
||||
if (!this.hidden && this.findMode != this.FIND_NORMAL) {
|
||||
this.close();
|
||||
|
@ -952,7 +884,6 @@
|
|||
).hidden = showMinimalUI;
|
||||
foundMatches.hidden = showMinimalUI || !foundMatches.value;
|
||||
this._updateCaseSensitivity();
|
||||
this._updateDiacriticMatching();
|
||||
this._setEntireWord();
|
||||
this._setHighlightAll();
|
||||
|
||||
|
@ -1002,7 +933,6 @@
|
|||
|
||||
this._enableFindButtons(val);
|
||||
this._updateCaseSensitivity(val);
|
||||
this._updateDiacriticMatching(val);
|
||||
this._setEntireWord();
|
||||
|
||||
this.browser.finder.fastFind(
|
||||
|
@ -1096,7 +1026,6 @@
|
|||
event.initCustomEvent("find" + type, true, true, {
|
||||
query: this._findField.value,
|
||||
caseSensitive: !!this._typeAheadCaseSensitive,
|
||||
matchDiacritics: !!this._matchDiacritics,
|
||||
entireWord: this._entireWord,
|
||||
highlightAll: this._highlightAll,
|
||||
findPrevious,
|
||||
|
|
|
@ -10,7 +10,6 @@ NormalFind=Find in page
|
|||
FastFind=Quick find
|
||||
FastFindLinks=Quick find (links only)
|
||||
CaseSensitive=(Case sensitive)
|
||||
MatchDiacritics=(Matching diacritics)
|
||||
EntireWord=(Whole words only)
|
||||
# LOCALIZATION NOTE (FoundMatches): Semicolon-separated list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
|
|
|
@ -25,11 +25,6 @@ findbar-case-sensitive =
|
|||
.accesskey = C
|
||||
.tooltiptext = Search with case sensitivity
|
||||
|
||||
findbar-match-diacritics =
|
||||
.label = Match Diacritics
|
||||
.accesskey = D
|
||||
.tooltiptext = Distinguish between accented letters and their base letters (for example, when searching for "resume", "résumé" will not be matched)
|
||||
|
||||
findbar-entire-word =
|
||||
.label = Whole Words
|
||||
.accesskey = W
|
||||
|
|
|
@ -170,14 +170,6 @@ Finder.prototype = {
|
|||
this.iterator.reset();
|
||||
},
|
||||
|
||||
set matchDiacritics(aMatchDiacritics) {
|
||||
if (this._fastFind.matchDiacritics === aMatchDiacritics) {
|
||||
return;
|
||||
}
|
||||
this._fastFind.matchDiacritics = aMatchDiacritics;
|
||||
this.iterator.reset();
|
||||
},
|
||||
|
||||
set entireWord(aEntireWord) {
|
||||
if (this._fastFind.entireWord === aEntireWord) {
|
||||
return;
|
||||
|
@ -349,7 +341,6 @@ Finder.prototype = {
|
|||
caseSensitive: this._fastFind.caseSensitive,
|
||||
entireWord: this._fastFind.entireWord,
|
||||
linksOnly: aArgs.linksOnly,
|
||||
matchDiacritics: this._fastFind.matchDiacritics,
|
||||
word: aArgs.searchString,
|
||||
useSubFrames: aArgs.useSubFrames,
|
||||
})
|
||||
|
@ -598,7 +589,6 @@ Finder.prototype = {
|
|||
caseSensitive: this._fastFind.caseSensitive,
|
||||
entireWord: this._fastFind.entireWord,
|
||||
linksOnly: aLinksOnly,
|
||||
matchDiacritics: this._fastFind.matchDiacritics,
|
||||
word: aWord,
|
||||
useSubFrames: aUseSubFrames,
|
||||
};
|
||||
|
|
|
@ -284,7 +284,6 @@ FinderHighlighter.prototype = {
|
|||
word,
|
||||
finder: this.finder,
|
||||
listener: this,
|
||||
matchDiacritics: this.finder._fastFind.matchDiacritics,
|
||||
useCache: true,
|
||||
useSubFrames,
|
||||
window,
|
||||
|
|
|
@ -88,8 +88,6 @@ FinderIterator.prototype = {
|
|||
* - onIteratorReset();
|
||||
* - onIteratorRestart({Object} iterParams);
|
||||
* - onIteratorStart({Object} iterParams);
|
||||
* @param {Boolean} options.matchDiacritics Whether to search in
|
||||
* diacritic-matching mode
|
||||
* @param {Boolean} [options.useCache] Whether to allow results already
|
||||
* present in the cache or demand fresh.
|
||||
* Optional, defaults to `false`.
|
||||
|
@ -106,7 +104,6 @@ FinderIterator.prototype = {
|
|||
limit,
|
||||
linksOnly,
|
||||
listener,
|
||||
matchDiacritics,
|
||||
useCache,
|
||||
word,
|
||||
useSubFrames,
|
||||
|
@ -135,9 +132,6 @@ FinderIterator.prototype = {
|
|||
if (typeof entireWord != "boolean") {
|
||||
throw new Error("Missing required option 'entireWord'");
|
||||
}
|
||||
if (typeof matchDiacritics != "boolean") {
|
||||
throw new Error("Missing required option 'matchDiacritics'");
|
||||
}
|
||||
if (!finder) {
|
||||
throw new Error("Missing required option 'finder'");
|
||||
}
|
||||
|
@ -164,7 +158,6 @@ FinderIterator.prototype = {
|
|||
caseSensitive,
|
||||
entireWord,
|
||||
linksOnly,
|
||||
matchDiacritics,
|
||||
useCache,
|
||||
window,
|
||||
word,
|
||||
|
@ -311,8 +304,6 @@ FinderIterator.prototype = {
|
|||
* @param {Boolean} options.entireWord Whether to search in entire-word mode
|
||||
* @param {Boolean} options.linksOnly Whether to search for the word to be
|
||||
* present in links only
|
||||
* @param {Boolean} options.matchDiacritics Whether to search in
|
||||
* diacritic-matching mode
|
||||
* @param {String} options.word The word being searched for
|
||||
* @param (Boolean) options.useSubFrames Whether to search subframes
|
||||
* @return {Boolean}
|
||||
|
@ -321,7 +312,6 @@ FinderIterator.prototype = {
|
|||
caseSensitive,
|
||||
entireWord,
|
||||
linksOnly,
|
||||
matchDiacritics,
|
||||
word,
|
||||
useSubFrames,
|
||||
}) {
|
||||
|
@ -330,7 +320,6 @@ FinderIterator.prototype = {
|
|||
this._currentParams.caseSensitive === caseSensitive &&
|
||||
this._currentParams.entireWord === entireWord &&
|
||||
this._currentParams.linksOnly === linksOnly &&
|
||||
this._currentParams.matchDiacritics === matchDiacritics &&
|
||||
this._currentParams.word == word &&
|
||||
this._currentParams.useSubFrames == useSubFrames
|
||||
);
|
||||
|
@ -385,8 +374,6 @@ FinderIterator.prototype = {
|
|||
* @param {Boolean} options.entireWord Whether to search in entire-word mode
|
||||
* @param {Boolean} options.linksOnly Whether to search for the word to be
|
||||
* present in links only
|
||||
* @param {Boolean} options.matchDiacritics Whether to search in
|
||||
* diacritic-matching mode
|
||||
* @param {Boolean} options.useCache Whether the consumer wants to use the
|
||||
* cached previous result at all
|
||||
* @param {String} options.word The word being searched for
|
||||
|
@ -396,7 +383,6 @@ FinderIterator.prototype = {
|
|||
caseSensitive,
|
||||
entireWord,
|
||||
linksOnly,
|
||||
matchDiacritics,
|
||||
useCache,
|
||||
word,
|
||||
}) {
|
||||
|
@ -406,7 +392,6 @@ FinderIterator.prototype = {
|
|||
caseSensitive,
|
||||
entireWord,
|
||||
linksOnly,
|
||||
matchDiacritics,
|
||||
word,
|
||||
}) &&
|
||||
this._previousRanges.length
|
||||
|
@ -430,7 +415,6 @@ FinderIterator.prototype = {
|
|||
paramSet1.caseSensitive === paramSet2.caseSensitive &&
|
||||
paramSet1.entireWord === paramSet2.entireWord &&
|
||||
paramSet1.linksOnly === paramSet2.linksOnly &&
|
||||
paramSet1.matchDiacritics === paramSet2.matchDiacritics &&
|
||||
paramSet1.window === paramSet2.window &&
|
||||
paramSet1.useSubFrames === paramSet2.useSubFrames &&
|
||||
NLP.levenshtein(paramSet1.word, paramSet2.word) <= allowDistance
|
||||
|
@ -640,16 +624,11 @@ FinderIterator.prototype = {
|
|||
* sensitive mode
|
||||
* @param {Boolean} options.entireWord Whether to search in entire-word
|
||||
* mode
|
||||
* @param {Boolean} options.matchDiacritics Whether to search in
|
||||
* diacritic-matching mode
|
||||
* @param {String} options.word The word to search for
|
||||
* @param {nsIDOMWindow} window The window to search in
|
||||
* @yield {Range}
|
||||
*/
|
||||
*_iterateDocument(
|
||||
{ caseSensitive, entireWord, matchDiacritics, word },
|
||||
window
|
||||
) {
|
||||
*_iterateDocument({ caseSensitive, entireWord, word }, window) {
|
||||
let doc = window.document;
|
||||
let body = doc.body || doc.documentElement;
|
||||
|
||||
|
@ -673,7 +652,6 @@ FinderIterator.prototype = {
|
|||
.QueryInterface(Ci.nsIFind);
|
||||
nsIFind.caseSensitive = caseSensitive;
|
||||
nsIFind.entireWord = entireWord;
|
||||
nsIFind.matchDiacritics = matchDiacritics;
|
||||
|
||||
while ((retRange = nsIFind.Find(word, searchRange, startPt, endPt))) {
|
||||
yield retRange;
|
||||
|
|
|
@ -217,12 +217,6 @@ FinderParent.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
set matchDiacritics(aMatchDiacritics) {
|
||||
this.sendMessageToAllContexts("Finder:MatchDiacritics", {
|
||||
matchDiacritics: aMatchDiacritics,
|
||||
});
|
||||
},
|
||||
|
||||
async setSearchStringToSelection() {
|
||||
return this.setToSelection("Finder:SetSearchStringToSelection", false);
|
||||
},
|
||||
|
|
|
@ -58,7 +58,6 @@ add_task(async function test_start() {
|
|||
Assert.equal(range.toString(), findText, "Text content should match");
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
|
@ -89,7 +88,6 @@ add_task(async function test_subframes() {
|
|||
Assert.equal(range.toString(), findText, "Text content should match");
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
useSubFrames: true,
|
||||
});
|
||||
|
@ -121,7 +119,6 @@ add_task(async function test_valid_arguments() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
|
@ -140,7 +137,6 @@ add_task(async function test_valid_arguments() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
}),
|
||||
/Missing required option 'caseSensitive'/,
|
||||
|
@ -152,7 +148,6 @@ add_task(async function test_valid_arguments() {
|
|||
() =>
|
||||
finderIterator.start({
|
||||
caseSensitive: false,
|
||||
entireWord: false,
|
||||
listener: {
|
||||
onIteratorRangeFound(range) {
|
||||
++count;
|
||||
|
@ -160,23 +155,6 @@ add_task(async function test_valid_arguments() {
|
|||
},
|
||||
word: findText,
|
||||
}),
|
||||
/Missing required option 'matchDiacritics'/,
|
||||
"Should throw when missing an argument"
|
||||
);
|
||||
finderIterator.reset();
|
||||
|
||||
Assert.throws(
|
||||
() =>
|
||||
finderIterator.start({
|
||||
caseSensitive: false,
|
||||
listener: {
|
||||
onIteratorRangeFound(range) {
|
||||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
}),
|
||||
/Missing required option 'entireWord'/,
|
||||
"Should throw when missing an argument"
|
||||
);
|
||||
|
@ -192,7 +170,6 @@ add_task(async function test_valid_arguments() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
}),
|
||||
/Missing required option 'finder'/,
|
||||
|
@ -206,7 +183,6 @@ add_task(async function test_valid_arguments() {
|
|||
caseSensitive: true,
|
||||
entireWord: false,
|
||||
finder: gMockFinder,
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
}),
|
||||
/Missing valid, required option 'listener'/,
|
||||
|
@ -225,7 +201,6 @@ add_task(async function test_valid_arguments() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
}),
|
||||
/Missing required option 'word'/,
|
||||
"Should throw when missing an argument"
|
||||
|
@ -250,7 +225,6 @@ add_task(async function test_stop() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
|
@ -278,7 +252,6 @@ add_task(async function test_reset() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
|
@ -321,11 +294,10 @@ add_task(async function test_parallel_starts() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
await new Promise(resolve => gMockWindow.setTimeout(resolve, 100));
|
||||
await new Promise(resolve => gMockWindow.setTimeout(resolve, 120));
|
||||
Assert.ok(finderIterator.running, "We ought to be running here");
|
||||
|
||||
let count2 = 0;
|
||||
|
@ -338,7 +310,6 @@ add_task(async function test_parallel_starts() {
|
|||
++count2;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
|
@ -389,7 +360,6 @@ add_task(async function test_allowDistance() {
|
|||
++count;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: findText,
|
||||
});
|
||||
|
||||
|
@ -403,7 +373,6 @@ add_task(async function test_allowDistance() {
|
|||
++count2;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: "gu",
|
||||
});
|
||||
|
||||
|
@ -418,7 +387,6 @@ add_task(async function test_allowDistance() {
|
|||
++count3;
|
||||
},
|
||||
},
|
||||
matchDiacritics: false,
|
||||
word: "gu",
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче