Closed Bug 444801 Opened 16 years ago Closed 16 years ago

Implement pref support on snav

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.1b2

People

(Reporter: tonikitoo, Assigned: tonikitoo)

References

Details

Attachments

(1 file, 9 obsolete files)

Now that bug 436084 has landed, snav needs to add support to its own preferences: snav.enabled snav.ignoreTextFields snav.disableJS snav.rectFudge snav.directionBias snav.keyCode.left snav.keyCode.right snav.keyCode.up snav.keyCode.down snav.keyCode.modifier as in old C++ based implementation.
Attached patch is that the way to go ? (obsolete) — Splinter Review
Patch v0 adds 'snav.enabled' support. off course there are a bunch of other prefs to be set, I just wondering if a global 'gPrefenreces' obj to handle them is the way to go. $cd mozilla-central $patch -p1 < ../BUG444801_v0.diff
Assignee: nobody → tonikitoo
Status: NEW → ASSIGNED
The PrefObserver seems like a nice place to hang getters for the snav preferences. You could make the prefService a class member, so it can be reused. You could also make PrefObserver a literal object instead of something that needs to be new'ed.
Attached patch is that the way to go ? (v2) (obsolete) — Splinter Review
addressed mark's comment. what do you think ? can I move for further prefs that way ?
Attachment #329106 - Attachment is obsolete: true
this is the way to go. change the name from PrefObserver to Prefs or SnavPrefs.
so, this actually does more than add prefs support in snav: 1) added the following prefs support: snav.enabled snav.ignoreTextFields snav.rectFudge (fixed value) snav.directionBias (fixed value) snav.keyCode.left snav.keyCode.right snav.keyCode.up snav.keyCode.down snav.keyCode.modifier 2) use "two space" based identation. 3) use the style: * if (..) { instead of * if (..) { 4) removed some dump code. note: snav.disableJS is still missing. dougt ?
Attachment #329371 - Attachment is obsolete: true
Attachment #331689 - Flags: review?(doug.turner)
Comment on attachment 331689 [details] [diff] [review] WIP preference support for snav (v2) the spacing is weird in this patch. in some places it is 2 and others it is 4. why is this QI needed: + event.QueryInterface(Ci.nsIDOMKeyEvent); why do you need to save the modifierKey You can clean up the modifierKey stuff, something like: var modkey = PrefObserver['keyCodeModifier']; if (modkey & 0x00100000 && !event.shiftKey) return; I do not think we need to support |ignoreTextFields|. remove these lines: + // user_pref("snav.keyCode.modifier", 1048594); + // user_pref("snav.keyCode.modifier", 0x00000012 | 0x00100000); Don't do stuff like: + try { + this.enabled = this._branch.getBoolPref("enabled"); + } catch (e){ + this.enabled = false; + } Instead, just call 'observe' with the aTopic of "nsPref:changed" and the aData of what you are interested in.
Attachment #331689 - Flags: review?(doug.turner) → review-
addressed dougt's comments
Attachment #331689 - Attachment is obsolete: true
Attachment #331819 - Flags: review?(doug.turner)
(In reply to comment #6) > (From update of attachment 331689 [details] [diff] [review]) > the spacing is weird in this patch. in some places it is 2 and others it is 4. odd, I tried to use 2 throughout the code. > why is this QI needed: > + event.QueryInterface(Ci.nsIDOMKeyEvent); not needed > why do you need to save the modifierKey > You can clean up the modifierKey stuff, something like: > var modkey = PrefObserver['keyCodeModifier']; > if (modkey & 0x00100000 && !event.shiftKey) > return; done > I do not think we need to support |ignoreTextFields|. k > remove these lines: > + // user_pref("snav.keyCode.modifier", 1048594); > + // user_pref("snav.keyCode.modifier", 0x00000012 | 0x00100000); k > Don't do stuff like: > + try { > + this.enabled = this._branch.getBoolPref("enabled"); > + } catch (e){ > + this.enabled = false; > + } > Instead, just call 'observe' with the aTopic of "nsPref:changed" and the aData > of what you are interested in. done. so, what about: snav.directionalBias; snav.rectFudge; should they be settable? we are only missing snav.disableJS. Investigating how to do this ...
after talking to doug, implemented snav prefs that interest to us, at this level: snav.enabled snav.keyCode.left snav.keyCode.right snav.keyCode.up snav.keyCode.down snav.keyCode.modifier mobile devices will usually set 'snav.keyCode.modifier' to 0, and use d-pad for directional, than keyCode.(left|right|up|down) can use default values. for celphones or any not-so-keyboard-friend device, they might have to map directions to their keys ...
Attached patch basic pref support to snav. (obsolete) — Splinter Review
patch ready for review.
Attachment #331819 - Attachment is obsolete: true
Attachment #333020 - Flags: review?(doug.turner)
Attachment #331819 - Flags: review?(doug.turner)
maybe we should just make keyCodeModifier a string? And have valid values include "shift", "alt", "ctrl". you can get away with only calling "this._branch.addObserver" once if you pass a first argument of snav., right? do we need to unregister anything?
add "accel" like the <key> modifiers?
Attached patch addressed doug't comments. (obsolete) — Splinter Review
> maybe we should just make keyCodeModifier a string? And have valid values > include "shift", "alt", "ctrl". done. '+' works as a the separator, and any value different from "shift", "alt", "ctrl" sets snav.modifier to "none" , previously '0'. > you can get away with only calling "this._branch.addObserver" once if you pass > a first argument of snav., right? we can not , actually. it is needed for the observer to work. > do we need to unregister anything? hum, we could do it add unregister in PrefObserver and call it from SpatialNavigation.uninit ? not sure if it is needed ...
Attachment #333020 - Attachment is obsolete: true
Attachment #335970 - Flags: review?(doug.turner)
Attachment #333020 - Flags: review?(doug.turner)
Comment on attachment 335970 [details] [diff] [review] addressed doug't comments. if the preference for the modifier is not set, but the user has the ALT key held down as they navigate, we aren't going to prevent them? looks good, but we should handle that case.
Attachment #335970 - Flags: review?(doug.turner) → review-
doug, I thought it was desired. use case: user does not set any modifier ("none"), and presses LEFT arrow holding ALT. Snav should not work, once it is pressing a valid modifier that is not set as snav modifier. So, the default action is called: Back()... make sense ?
Attached patch basic pref support to snav (v2) (obsolete) — Splinter Review
Fix dougt's point in comment #14. Added two mochitests for "snav.enabled" and "snav.keyCode.up|down|right|left" prefs. probably SpatialNavUtils.js has to be modified to support modifiers (alt, crtl) tests ?
Attachment #340188 - Flags: review?(doug.turner)
Attachment #335970 - Attachment is obsolete: true
Attached patch basic pref support to snav (v3) (obsolete) — Splinter Review
highlights: * adds pref support to snav. * adds two mochitest (test_snav_prefDisabled.xul and test_snav_prefKeyCode.xul ). The former tests just if snav.enabled works fine and the later tests "keyCode.right", "keyCode.left", "keyCode.down" and "keyCode.up". * Some changes in SpatialNavUtils.js were done: methods prepareTest and completeTest make sure all prefs have the right value before and after each test. * desired prefs have to be in each mochitest file.
Attachment #340188 - Attachment is obsolete: true
Attachment #340795 - Flags: review?(doug.turner)
Attachment #340188 - Flags: review?(doug.turner)
this looks fine. Clint, is there a better way to sent prefs in a mochitest?
Comment on attachment 340795 [details] [diff] [review] basic pref support to snav (v3) this is fine. one more review.
Attachment #340795 - Flags: review?(mark.finkle)
Attachment #340795 - Flags: review?(doug.turner)
Attachment #340795 - Flags: review+
Comment on attachment 340795 [details] [diff] [review] basic pref support to snav (v3) >diff -r 3f7ffb18fd55 toolkit/spatial-navigation/SpatialNavigation.js >- if (event.keyCode == event.DOM_VK_RIGHT || event.keyCode == event.DOM_VK_DOWN ) { >+ if (event.keyCode == PrefObserver['keyCodeRight'] || >+ event.keyCode == PrefObserver['keyCodeDown'] ) { > // we are moving forward into the document > if (target.textLength != target.selectionEnd) > return; will this leave the wrong indent?
Attachment #340795 - Flags: review?(mark.finkle) → review+
fixed indentation.
Attachment #340795 - Attachment is obsolete: true
Blocks: 458508
checkin-needed added. follow-up for fennec : bug 458508
> if there is no modifier than it default to nothing (from bug 458508 #2). done. - } catch(e) { - this.keyCodeModifier = kAlt+separator+kShift; - } + } catch(e) { + this.keyCodeModifier = kNone; + }
Attachment #341745 - Attachment is obsolete: true
(In reply to comment #19) > this looks fine. Clint, is there a better way to sent prefs in a mochitest? Sorry for missing this comment. I looked over the "final patch -2" and it looks good to me. I don't know of any other way to do it.
checkin-needed added, final patch - 2 is the last one, it addresses some small dougt and mfinkle requests thanks
Keywords: checkin-needed
Comment on attachment 341793 [details] [diff] [review] basic pref support to snav (final patch - 2) [Checkin: Comment 27] http://hg.mozilla.org/mozilla-central/rev/733d4a419520
Attachment #341793 - Attachment description: basic pref support to snav (final patch - 2) → basic pref support to snav (final patch - 2) [Checkin: Comment 27]
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Flags: in-testsuite+
Keywords: checkin-needed
OS: Linux → All
Hardware: PC → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.1b2
Component: Keyboard: Navigation → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: