Skip to content

Commit

Permalink
Backed out changeset 8d131b6770d7 (bug 257061) for exceptions in find…
Browse files Browse the repository at this point in the history
…bar.xml
  • Loading branch information
Ed Morley committed May 1, 2014
1 parent eb17aba commit 5a2f38f
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 501 deletions.
2 changes: 0 additions & 2 deletions modules/libpref/src/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,6 @@ pref("accessibility.typeaheadfind.enabletimeout", true);
pref("accessibility.typeaheadfind.soundURL", "beep");
pref("accessibility.typeaheadfind.enablesound", true);
pref("accessibility.typeaheadfind.prefillwithselection", true);
pref("accessibility.typeaheadfind.matchesCountTimeout", 250);
pref("accessibility.typeaheadfind.matchesCountLimit", 100);

// use Mac OS X Appearance panel text smoothing setting when rendering text, disabled by default
pref("gfx.use_text_smoothing_setting", false);
Expand Down
7 changes: 1 addition & 6 deletions toolkit/components/typeaheadfind/nsITypeAheadFind.idl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface nsIDocShell;

/****************************** nsTypeAheadFind ******************************/

[scriptable, uuid(f4411c5b-761b-498c-8050-dcfc8311f69e)]
[scriptable, uuid(0749a445-19d3-4eb9-9d66-78eca8c6f604)]
interface nsITypeAheadFind : nsISupports
{
/****************************** Initializer ******************************/
Expand All @@ -37,9 +37,6 @@ interface nsITypeAheadFind : nsISupports
/* Find another match in the page. */
unsigned short findAgain(in boolean findBackwards, in boolean aLinksOnly);

/* Return the range of the most recent match. */
nsIDOMRange getFoundRange();


/**************************** Helper functions ***************************/

Expand All @@ -56,8 +53,6 @@ interface nsITypeAheadFind : nsISupports
* necessarily happen automatically. */
void collapseSelection();

/* Check if a range is visible */
boolean isRangeVisible(in nsIDOMRange aRange, in boolean aMustBeInViewPort);

/******************************* Attributes ******************************/

Expand Down
44 changes: 1 addition & 43 deletions toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTypeAheadFind)
NS_IMPL_CYCLE_COLLECTION(nsTypeAheadFind, mFoundLink, mFoundEditable,
mCurrentWindow, mStartFindRange, mSearchRange,
mStartPointRange, mEndPointRange, mSoundInterface,
mFind, mFoundRange)
mFind)

static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);

Expand Down Expand Up @@ -176,7 +176,6 @@ nsTypeAheadFind::SetDocShell(nsIDocShell* aDocShell)

mFoundLink = nullptr;
mFoundEditable = nullptr;
mFoundRange = nullptr;
mCurrentWindow = nullptr;

mSelectionController = nullptr;
Expand Down Expand Up @@ -276,7 +275,6 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
*aResult = FIND_NOTFOUND;
mFoundLink = nullptr;
mFoundEditable = nullptr;
mFoundRange = nullptr;
mCurrentWindow = nullptr;
nsCOMPtr<nsIPresShell> startingPresShell (GetPresShell());
if (!startingPresShell) {
Expand Down Expand Up @@ -439,8 +437,6 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
continue;
}

mFoundRange = returnRange;

// ------ Success! -------
// Hide old selection (new one may be on a different controller)
if (selection) {
Expand Down Expand Up @@ -1095,44 +1091,6 @@ nsTypeAheadFind::GetSelection(nsIPresShell *aPresShell,
}
}

NS_IMETHODIMP
nsTypeAheadFind::GetFoundRange(nsIDOMRange** aFoundRange)
{
NS_ENSURE_ARG_POINTER(aFoundRange);
if (mFoundRange == nullptr) {
*aFoundRange = nullptr;
return NS_OK;
}

mFoundRange->CloneRange(aFoundRange);
return NS_OK;
}

NS_IMETHODIMP
nsTypeAheadFind::IsRangeVisible(nsIDOMRange *aRange,
bool aMustBeInViewPort,
bool *aResult)
{
// Jump through hoops to extract the docShell from the range.
nsCOMPtr<nsIDOMNode> node;
aRange->GetStartContainer(getter_AddRefs(node));
nsCOMPtr<nsIDOMDocument> document;
node->GetOwnerDocument(getter_AddRefs(document));
nsCOMPtr<nsIDOMWindow> window;
document->GetDefaultView(getter_AddRefs(window));
nsCOMPtr<nsIWebNavigation> navNav (do_GetInterface(window));
nsCOMPtr<nsIDocShell> docShell (do_GetInterface(navNav));

// Set up the arguments needed to check if a range is visible.
nsCOMPtr<nsIPresShell> presShell (docShell->GetPresShell());
nsRefPtr<nsPresContext> presContext = presShell->GetPresContext();
nsCOMPtr<nsIDOMRange> startPointRange = new nsRange(presShell->GetDocument());
*aResult = IsRangeVisible(presShell, presContext, aRange,
aMustBeInViewPort, false,
getter_AddRefs(startPointRange),
nullptr);
return NS_OK;
}

bool
nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
Expand Down
1 change: 0 additions & 1 deletion toolkit/components/typeaheadfind/nsTypeAheadFind.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class nsTypeAheadFind : public nsITypeAheadFind,
bool mCaretBrowsingOn;
nsCOMPtr<nsIDOMElement> mFoundLink; // Most recent elem found, if a link
nsCOMPtr<nsIDOMElement> mFoundEditable; // Most recent elem found, if editable
nsCOMPtr<nsIDOMRange> mFoundRange; // Most recent range found
nsCOMPtr<nsIDOMWindow> mCurrentWindow;
// mLastFindLength is the character length of the last find string. It is used for
// disabling the "not found" sound when using backspace or delete
Expand Down
110 changes: 3 additions & 107 deletions toolkit/content/tests/chrome/findbar_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,8 @@
testDrop();
testQuickFindLink();
if (gHasFindClipboard)
testStatusText(afterStatusText);
else
afterStatusText();
function afterStatusText() {
testFindCountUI(function() {
gFindBar.close();
ok(gFindBar.hidden, "Failed to close findbar after testFindCountUI");
testQuickFindClose();
});
}
testStatusText();
testQuickFindClose();
}
function testFindbarSelection() {
Expand Down Expand Up @@ -172,10 +163,9 @@
setTimeout(_isClosedCallback, gFindBar._quickFindTimeoutLength + 100);
}
function testStatusText(aCallback) {
function testStatusText() {
var _delayedCheckStatusText = function() {
ok(gStatusText == SAMPLE_URL, "testStatusText: Failed to set status text of found link");
aCallback();
};
setTimeout(_delayedCheckStatusText, 100);
}
Expand Down Expand Up @@ -394,100 +384,6 @@
testClipboardSearchString(SEARCH_TEXT);
}
// Perform an async function in serial on each of the list items.
function asyncForEach(list, async, callback) {
let i = 0;
let len = list.length;
if (!len)
return callback();
async(list[i], function handler() {
i++;
if (i < len) {
async(list[i], handler, i);
} else {
callback();
}
}, i);
}
function testFindCountUI(callback) {
clearFocus();
document.getElementById("cmd_find").doCommand();
ok(!gFindBar.hidden, "testFindCountUI: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
"testFindCountUI: find field is not focused");
let matchCase = gFindBar.getElement("find-case-sensitive");
if (matchCase.checked)
matchCase.click();
let foundMatches = gFindBar._foundMatches;
let tests = [{
text: "t",
current: 5,
total: 10,
}, {
text: "te",
current: 3,
total: 5,
}, {
text: "tes",
current: 1,
total: 2,
}, {
text: "texxx",
current: 0,
total: 0
}];
let regex = /([\d]*)\sof\s([\d]*)/;
let timeout = gFindBar._matchesCountTimeoutLength + 20;
function assertMatches(aTest, aMatches) {
window.opener.wrappedJSObject.SimpleTest.is(aTest.current, aMatches[1],
"Currently highlighted match should be at " + aTest.current);
window.opener.wrappedJSObject.SimpleTest.is(aTest.total, aMatches[2],
"Total amount of matches should be " + aTest.total);
}
function testString(aTest, aNext) {
gFindBar.clear();
enterStringIntoFindField(aTest.text);
setTimeout(function() {
let matches = foundMatches.value.match(regex);
if (!aTest.total) {
ok(!matches, "No message should be shown when 0 matches are expected");
aNext();
} else {
assertMatches(aTest, matches);
let cycleTests = [];
let cycles = aTest.total;
while (--cycles) {
aTest.current++;
if (aTest.current > aTest.total)
aTest.current = 1;
cycleTests.push({
current: aTest.current,
total: aTest.total
});
}
asyncForEach(cycleTests, function(aCycleTest, aNextCycle) {
gFindBar.onFindAgainCommand();
setTimeout(function() {
assertMatches(aCycleTest, foundMatches.value.match(regex));
aNextCycle();
}, timeout);
}, aNext);
}
}, timeout);
}
asyncForEach(tests, testString, callback);
}
function testClipboardSearchString(aExpected) {
if (!gHasFindClipboard)
return;
Expand Down
9 changes: 3 additions & 6 deletions toolkit/content/tests/chrome/test_findbar.xul
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=257061
https://bugzilla.mozilla.org/show_bug.cgi?id=288254
-->
<window title="Mozilla Bug 257061 and Bug 288254"
<window title="Mozilla Bug 288254"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=257061">Mozilla Bug 257061</a>
<a target="_blank"
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=288254">Mozilla Bug 288254</a>
<p id="display"></p>
<div id="content" style="display: none">
Expand All @@ -29,7 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=288254
<script class="testbody" type="application/javascript">
<![CDATA[
/** Test for Bug 257061 and Bug 288254 **/
/** Test for Bug 288254 **/
SimpleTest.waitForExplicitFinish();
window.open("findbar_window.xul", "findbartest",
"chrome,width=600,height=600");
Expand Down
Loading

0 comments on commit 5a2f38f

Please sign in to comment.