Closed Bug 923801 Opened 11 years ago Closed 10 years ago

Case-sensitive still affects all find bars globally

Categories

(Toolkit :: Find Toolbar, defect)

25 Branch
defect
Not set
normal
Points:
2

Tracking

()

VERIFIED FIXED
mozilla35
Iteration:
35.1

People

(Reporter: quicksaver, Assigned: tomasz)

References

Details

Attachments

(1 file, 5 obsolete files)

Bug 537013 never took care of the match case button, as per bug 537013 comment 25, bug 537013 comment 26 and bug 537013 comment 27.

Right now, clicking the match case button will set the match case on all find bars, because they all still observe accessibility.typeaheadfind.casesensitive for changes. This goes against the per-tab nature of the new find bar (and can get a bit annoying at times when you don't expect the button state to change on all tabs when you just want it in a specific tab).

My proposal: accessibility.typeaheadfind.casesensitive should be considered only the default state of the button:

- when the find bar is initialized (and in other situations where it should assume default values, see bug 913536, bug 920031 and bug 920972) the button state would be set to the pref's value
- when the find bar is in use, the button won't change state every time the pref is changed, it only changes state upon user command
- clicking the match case button won't change the value of the pref, the pref can only be changed explicitly (i.e. in about:config)

Also, accessibility.typeaheadfind.casesensitive is currently an int pref, which can also have the value of 2, this triggers something like an "auto" mode, which uses a case sensitive search only if it finds any caps character in the find string. This is a very specific case which I doubt is used that much, plus if I wanted a case sensitive search only with non-caps chars, I'd still need to toggle the sensitivity mode anyway, so that system fails there. (If I'm failing to see the point of the "auto" mode please let me know)

Because of this, I would suggest dropping the "auto" mode as well, turning accessibility.typeaheadfind.casesensitive into a bool pref which would better fit the per-tab model IMO.
Component: Untriaged → Search
Component: Search → Find Toolbar
Product: Firefox → Toolkit
(In reply to Luís Miguel [:Quicksaver] from comment #0)

> Also, accessibility.typeaheadfind.casesensitive is currently an int pref,
> which can also have the value of 2, this triggers something like an "auto"
> mode, which uses a case sensitive search only if it finds any caps character
> in the find string. This is a very specific case which I doubt is used that
> much, plus if I wanted a case sensitive search only with non-caps chars, I'd
> still need to toggle the sensitivity mode anyway, so that system fails
> there. (If I'm failing to see the point of the "auto" mode please let me
> know)
> 
> Because of this, I would suggest dropping the "auto" mode as well, turning
> accessibility.typeaheadfind.casesensitive into a bool pref which would
> better fit the per-tab model IMO.

How would this affect the findbar in view source and other non-tabbed sessions?
(In reply to Philip Chee from comment #1)
> How would this affect the findbar in view source and other non-tabbed
> sessions?

As far as I can tell, it wouldn't affect those any more than expected for the normal firefox find bar.

I ran a search in mozilla-central for "casesensitive", all the results relevant to this preference can also be retrieved from searching for "typeaheadfind.casesensitive" (I only ran the broader search to confirm).

Except for tests, I haven't found any occasion for the specific use of a value of (int) 2; except for the findbar._shouldBeCaseSensitive() (http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/findbar.xml#731) and findbar._updateCaseSensitivity() (http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/findbar.xml#463) methods present in all find bars, which implement the auto-mode: _shouldBeCaseSensitive() could easily be by-passed entirely when it is called, or instead just reflect the case-sensitive checkbox check state; _updateCaseSensitivity() hides the checkbox when the pref is value (int) 2, removing this bit should be fairly direct.

As long as any other accompanying gets/sets of the preference are properly changed from (int) to (bool) values, I don't see a reason why any find bar in any context should misbehave.

Plus, I didn't find any way to toggle the pref to value (int) 2, it would have to be done explicitly in about:config; this isn't even documented in http://kb.mozillazine.org/Accessibility.typeaheadfind.casesensitive.

BTW, in http://mxr.mozilla.org/mozilla-central/source/modules/libpref/src/init/all.js#449:
> // casesensitive: controls the find bar's case-sensitivity
> //     0 - "never"  (case-insensitive)
> //     1 - "always" (case-sensitive)
> // other - "auto"   (case-sensitive for mixed-case input, insensitive otherwise)
The last is false, it doesn't check for mixed-case input, it checks if there are any upper-case chars in the string, i.e. it would also return true if all chars are upper-case ( _shouldBeCaseSensitive() ):
> return aString != aString.toLowerCase();
Of course, I don't know if any add-ons use/set this pref. I know mine don't, adapting the code from (int) to (bool) values shouldn't be hard on the add-ons developer side, and to keep the "auto" mode should they choose to, as I've shown, is just a matter of adding a single line of code and their own preference to go with it.
Depends on: fxdesktopbacklog
Whiteboard: [triage]
Whiteboard: [triage]
Whiteboard: p=0
No longer blocks: fxdesktopbacklog
Flags: firefox-backlog+
Whiteboard: p=0 → p=2
I'll work on this. I don't think, however, that there is much sense in removing that "auto" option as we don't know whether anyone's using it. And yes, I think there's no UI to change that value and I only know about it since I saw the source code. Personally, I don't find it useful at all.
Assignee: nobody → tkolodziejski
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
This is a proposed patch. It simply gets the pref value as the starting point. Then I don't touch prefs at all.

We can also consider pushing the current state to prefs so that the new search start with that default.
Points: --- → 2
Flags: qe-verify?
Whiteboard: p=2
I changed the logic back a little bit to pass the tests.

So: casesensitive pref gives just the default state for the findbar but if it is changed (for example set to auto) I update the current state. It seems quite natural because when someone changes that he changes the global state of the browser.

This patch comes now with a simple test making sure the state of one button does not influence the other one.
Attachment #8480220 - Attachment is obsolete: true
Attachment #8480756 - Flags: review?(gavin.sharp)
Comment on attachment 8480756 [details] [diff] [review]
find-tabwise-casesensitivity.patch

>diff --git a/toolkit/content/tests/browser/browser_findbar.js b/toolkit/content/tests/browser/browser_findbar.js

It might be clearer to have a separate sub-test for this, rather than incidentally testing this patch as part of a different basic test. 

>diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml

>       <method name="_setCaseSensitivity">

>+          this._typeAheadCaseSensitive = aCaseSensitive;

This should convert to 1/0.

Some people who always want case sensitivity might be upset that there is no longer an easy way to toggle it on globally. These people can still manually adjust the pref using about:config, but we might investigate exposing that default in the preferences (or writing an addon to easily toggle it globally).
Attachment #8480756 - Flags: review?(gavin.sharp) → review+
(In reply to :Gavin Sharp [email: gavin@gavinsharp.com] from comment #7)
> It might be clearer to have a separate sub-test for this, rather than
> incidentally testing this patch as part of a different basic test. 

Looks like you can convert this to use add_task relatively easily (since bug 872229).
I addressed the issues. Will post try run later.
Attachment #8480756 - Attachment is obsolete: true
Attachment #8480959 - Flags: review+
Now I made it clear how _setCaseSensitivity behaves.

https://tbpl.mozilla.org/?tree=Try&rev=4b052f95256c

Final look, gavin?
Attachment #8481538 - Flags: review?(gavin.sharp)
Iteration: --- → 35.1
Flags: qe-verify? → qe-verify+
Attachment #8480959 - Attachment is obsolete: true
Comment on attachment 8481538 [details] [diff] [review]
find-tabwise-casesensitivity.patch

>diff --git a/toolkit/content/tests/browser/browser_findbar.js b/toolkit/content/tests/browser/browser_findbar.js

>+function* test_found() {
>+  // Create second tab.
>+  yield promiseTestPageLoad();

It's no longer really a "second tab" - I would just remove the comment.

>+// Setting first findbar to case-sensitive mode should not affect
>+// new tab find bar.
>+add_task(function* test_tabwise_case_sensitive() {
>+  findbar.getElement("find-case-sensitive").click();
>+  yield Task.spawn(test_found);

It's a little sub-optimal that this test depends on the first "test task" in a somewhat non-obvious way. It's probably not worth changing this all around, but indicating the dependency with a comment could be useful. Something like "findbar still refers to the findbar opened in test_found(), compare its 'match case' state to our new findbar"

>diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml

>-        - @param aCaseSensitive (boolean)
>+        - @param aCaseSensitive (int)

While you're at it, I would rename this to "aCaseSentivity" to reflect that it isn't a boolean.
Attachment #8481538 - Flags: review?(gavin.sharp) → review+
Good point with the tests. They are now independent just as they should be.

I updated the argument name but it's still messy in the whole file (and global pref is also called accessibility.typeaheadfind.casesensitive so I didn't try to update it everywhere.

Will you have another look :gavin?
Attachment #8481538 - Attachment is obsolete: true
Attachment #8483798 - Flags: review?(gavin.sharp)
Comment on attachment 8483798 [details] [diff] [review]
find-tabwise-casesensitivity.patch

Sorry, guess I didn't realize the naming issue affected things more broadly - it's probably best to avoid introducing an inconsistency with the rest of the code and just stick with "aCaseSensitive".

r=me with that change - no need to re-request review!
Attachment #8483798 - Flags: review?(gavin.sharp) → review+
I just updated the patch to the current tip.

I didn't change it back to case sensitive it's mixed all over the place. Ping me if you want to undo it.

https://tbpl.mozilla.org/?tree=Try&rev=83553a48c2ac
Attachment #8483798 - Attachment is obsolete: true
Attachment #8484409 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/dcf08554c45b
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → mozilla35
QA Contact: cornel.ionce
Verified that "Match Case" works per tab now using Nightly 35.0a1 20140914030209 under Win 7 64-bit, Ubuntu 12.10 32-bit and Mac OSX 10.8.5.
Status: RESOLVED → VERIFIED
QA Contact: cornel.ionce → petruta.rasa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: