Case-sensitive still affects all find bars globally

VERIFIED FIXED in mozilla35

Status

()

Toolkit
Find Toolbar
VERIFIED FIXED
4 years ago
3 years ago

People

(Reporter: quicksaver, Assigned: tomasz)

Tracking

25 Branch
mozilla35
Points:
2
Bug Flags:
firefox-backlog +
in-testsuite +
qe-verify +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 5 obsolete attachments)

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

Comment 1

4 years ago
(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: 950073
Whiteboard: [triage]
Blocks: 950073
No longer depends on: 950073

Updated

4 years ago
Whiteboard: [triage]

Updated

4 years ago
Whiteboard: p=0

Updated

4 years ago
No longer blocks: 950073
Flags: firefox-backlog+

Updated

4 years ago
Whiteboard: p=0 → p=2
(Assignee)

Comment 4

3 years ago
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
(Assignee)

Updated

3 years ago
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(Assignee)

Comment 5

3 years ago
Created attachment 8480220 [details] [diff] [review]
find-tabwise-casesensitivity.patch

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.

Updated

3 years ago
Points: --- → 2
Flags: qe-verify?
Whiteboard: p=2
(Assignee)

Comment 6

3 years ago
Created attachment 8480756 [details] [diff] [review]
find-tabwise-casesensitivity.patch

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).
(Assignee)

Comment 9

3 years ago
Created attachment 8480959 [details] [diff] [review]
find-tabwise-casesensitivity.patch

I addressed the issues. Will post try run later.
Attachment #8480756 - Attachment is obsolete: true
Attachment #8480959 - Flags: review+
(Assignee)

Comment 10

3 years ago
Created attachment 8481538 [details] [diff] [review]
find-tabwise-casesensitivity.patch

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)

Updated

3 years ago
Iteration: --- → 35.1

Updated

3 years ago
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+
(Assignee)

Comment 12

3 years ago
Created attachment 8483798 [details] [diff] [review]
find-tabwise-casesensitivity.patch

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+
(Assignee)

Comment 14

3 years ago
Created attachment 8484409 [details] [diff] [review]
find-tabwise-casesensitivity.patch

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+
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
https://hg.mozilla.org/integration/fx-team/rev/dcf08554c45b
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/dcf08554c45b
Status: ASSIGNED → RESOLVED
Last Resolved: 3 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.