Closed Bug 1147775 Opened 5 years ago Closed 4 years ago

Add new DOM keys(e.g. Media Controller Keys)

Categories

(Core :: DOM: Events, defect)

defect
Not set

Tracking

()

RESOLVED WORKSFORME
FxOS-S5 (21Aug)
feature-b2g 2.5+

People

(Reporter: chunmin, Unassigned)

References

Details

With the coming of new firefox products like FxOS TV, we need add more DOM Keys such as 'ChannelDown', 'ChannelUp', 'Color*' in [1].
[1] http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-media-controller
Summary: Add new KeyboardEvent key Values(e.g. Media Controller Keys) → Add new DOM keys(e.g. Media Controller Keys)
The keys(new keyName) introduced in DOM 3 are already added in [1] by Masayuki in bug 1119609, so we can get the corrsponding keyName from NativeKeyCode[2]. However, the corresponding DOMKeyCode has not been implemented yet. We need to add the new keys in DOM3 to kKeyMapping[3] and define VirtualKeyCode in [4] with a proper DOMKeyCode[5] when we try to convert the NativeKeyCode into DOMKeyCode[6].

[1] https://dxr.mozilla.org/mozilla-central/source/dom/events/KeyNameList.h
[2] https://dxr.mozilla.org/mozilla-central/source/widget/gonk/nsAppShell.cpp#262
[3] https://dxr.mozilla.org/mozilla-central/source/widget/gonk/GonkKeyMapping.h#26
[4] https://dxr.mozilla.org/mozilla-central/source/dom/events/VirtualKeyCodeList.h
[5] https://dxr.mozilla.org/mozilla-central/source/dom/interfaces/events/nsIDOMKeyEvent.idl
[6] https://dxr.mozilla.org/mozilla-central/source/widget/gonk/nsAppShell.cpp#260
> NativeKeyCode --> DOMKeyCode  ==> it's platform-dependent
> NativeKeyCode --> DOMKeyName  ==> it's platform-dependent
The conversion of getting DOMKeyName and DOMKeyCode both are platform-dependent now.

If one DOMKeyCode is only mapped to one DOMKeyName, why don't we we just get DOMKeyCode from NativeKeyCode, and map DOMKeyCode to DOMKeyName? That is: 
> NativeKeyCode --> DOMKeyCode --> DOMKeyName
By above, the conversion to get DOMKeyName will be "platform-independent" and it will be easier to add a new platform to map keys' information(we only need to make a mapping table from NativeKeyCode to DOMKeyCode).
See Also: → 1163494
(In reply to Chun-Min Chang[:chunmin] from comment #2)
> > NativeKeyCode --> DOMKeyCode  ==> it's platform-dependent
> > NativeKeyCode --> DOMKeyName  ==> it's platform-dependent
> The conversion of getting DOMKeyName and DOMKeyCode both are
> platform-dependent now.
> 
> If one DOMKeyCode is only mapped to one DOMKeyName, why don't we we just get
> DOMKeyCode from NativeKeyCode, and map DOMKeyCode to DOMKeyName? That is: 
> > NativeKeyCode --> DOMKeyCode --> DOMKeyName
> By above, the conversion to get DOMKeyName will be "platform-independent"
> and it will be easier to add a new platform to map keys' information(we only
> need to make a mapping table from NativeKeyCode to DOMKeyCode).
Hi, Masayuki,
I was wondering if you could take a look at the question on comment #2
Flags: needinfo?(masayuki)
First, don't add new keyCode values anymore. .key should be used to handle new keys.

And .keyCode and .key are not related in strict speaking. .keyCode is legacy attribute, it shouldn't be used by new applications but on the other hand, it's value is important for keeping compatibility with older Gecko.
Flags: needinfo?(masayuki)
Blocks: TV_FxOS2.5
Hi Chun-Min,
This will be in 2.5 scope.
Could you help to mark target milestone? Thanks!
feature-b2g: --- → 2.5+
Flags: needinfo?(cchang)
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #4)
> First, don't add new keyCode values anymore. .key should be used to handle
> new keys.
> 
> And .keyCode and .key are not related in strict speaking. .keyCode is legacy
> attribute, it shouldn't be used by new applications but on the other hand,
> it's value is important for keeping compatibility with older Gecko.

1) NativeKeyCode --> DOMKeyCode  ==> it's platform-dependent
2) NativeKeyCode --> DOMKeyName  ==> it's platform-dependent

Ok, so we don't need to implement the path 1 above when we try to add new key, right? we only need to add new keyname for event.key. 

I'll check all keys that might be used in 2.5 scope on path 2
Flags: needinfo?(cchang)
Target Milestone: --- → FxOS-S5 (21Aug)
Most keys that are used in 2.5 already can be converted to DOMKeyName from their NativeKeyCode.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.