Unverified Commit 0e251e0a authored by Tong Mu's avatar Tong Mu Committed by GitHub

[key_codegen] Remove webValues (#81678)

Removes webValues from logical_key_data.json. Web's logical mapping should map webNames to logical key values, i.e. entry.value.
parent d28737ee
// Copyright 2014 The Flutter Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -9,7 +9,6 @@
// Edit the template dev/tools/gen_keycodes/data/web_key_map_dart.tmpl instead.
// See dev/tools/gen_keycodes/README.md for more information.
// @dart = 2.12
part of engine;
/// Maps Web KeyboardEvent codes to the matching LogicalKeyboardKey id.
......
......@@ -158,14 +158,12 @@ class LogicalKeyData {
value: value + kLeftModifierPlane,
name: pair.left,
keyLabel: null, // Modifier keys don't have keyLabels
)..webNames.add(pair.left)
..webValues.add(value + kLeftModifierPlane);
)..webNames.add(pair.left);
data[pair.right] = LogicalKeyEntry.fromName(
value: value + kRightModifierPlane,
name: pair.right,
keyLabel: null, // Modifier keys don't have keyLabels
)..webNames.add(pair.right)
..webValues.add(value + kRightModifierPlane);
)..webNames.add(pair.right);
continue;
}
......@@ -177,8 +175,7 @@ class LogicalKeyData {
value: char.codeUnitAt(0) + kNumpadPlane,
name: numpadName,
keyLabel: null, // Don't add keyLabel for numpad counterparts
)..webNames.add(numpadName)
..webValues.add(char.codeUnitAt(0) + kNumpadPlane);
)..webNames.add(numpadName);
unusedNumpad.remove(char);
}
......@@ -190,8 +187,7 @@ class LogicalKeyData {
value: value + (isPrintable ? kUnicodePlane : kUnprintablePlane),
name: name,
keyLabel: keyLabel,
)..webNames.add(webName)
..webValues.add(value);
)..webNames.add(webName);
});
}
......@@ -418,7 +414,6 @@ class LogicalKeyEntry {
required this.name,
this.keyLabel,
}) : webNames = <String>[],
webValues = <int>[],
macOsKeyCodeNames = <String>[],
macOsKeyCodeValues = <int>[],
iosKeyCodeNames = <String>[],
......@@ -446,18 +441,17 @@ class LogicalKeyEntry {
: value = map['value'] as int,
name = map['name'] as String,
webNames = _toNonEmptyArray<String>(map['names']['web']),
webValues = _toNonEmptyArray<int>(map['values']['web']),
macOsKeyCodeNames = _toNonEmptyArray<String>(map['names']['macOs']),
macOsKeyCodeValues = _toNonEmptyArray<int>(map['values']['macOs']),
macOsKeyCodeValues = _toNonEmptyArray<int>(map['values']?['macOs']),
iosKeyCodeNames = _toNonEmptyArray<String>(map['names']['ios']),
iosKeyCodeValues = _toNonEmptyArray<int>(map['values']['ios']),
iosKeyCodeValues = _toNonEmptyArray<int>(map['values']?['ios']),
gtkNames = _toNonEmptyArray<String>(map['names']['gtk']),
gtkValues = _toNonEmptyArray<int>(map['values']['gtk']),
gtkValues = _toNonEmptyArray<int>(map['values']?['gtk']),
windowsNames = _toNonEmptyArray<String>(map['names']['windows']),
windowsValues = _toNonEmptyArray<int>(map['values']['windows']),
windowsValues = _toNonEmptyArray<int>(map['values']?['windows']),
androidNames = _toNonEmptyArray<String>(map['names']['android']),
androidValues = _toNonEmptyArray<int>(map['values']['android']),
fuchsiaValues = _toNonEmptyArray<int>(map['values']['fuchsia']),
androidValues = _toNonEmptyArray<int>(map['values']?['android']),
fuchsiaValues = _toNonEmptyArray<int>(map['values']?['fuchsia']),
keyLabel = map['keyLabel'] as String?;
final int value;
......@@ -474,9 +468,6 @@ class LogicalKeyEntry {
/// symbol name.
final List<String> webNames;
/// The value of the key.
final List<int> webValues;
/// The names of the key codes that corresponds to this logical key on macOS,
/// created from the corresponding physical keys.
final List<String> macOsKeyCodeNames;
......@@ -544,7 +535,6 @@ class LogicalKeyEntry {
'android': androidNames,
},
'values': <String, List<int>>{
'web': webValues,
'macOs': macOsKeyCodeValues,
'ios': iosKeyCodeValues,
'gtk': gtkValues,
......
......@@ -50,7 +50,7 @@ class MacOsCodeGenerator extends PlatformCodeGenerator {
final StringBuffer result = StringBuffer();
for (final LogicalKeyEntry entry in logicalData.entries) {
zipStrict(entry.macOsKeyCodeValues, entry.macOsKeyCodeNames, (int macOsValue, String macOsName) {
result.writeln(' @${toHex(macOsValue)} : @${toHex(entry.value, digits: 10)}, // $macOsName');
result.writeln(' @${toHex(macOsValue)} : @${toHex(entry.value, digits: 11)}, // $macOsName');
});
}
return result.toString().trimRight();
......
......@@ -21,13 +21,13 @@ class WebCodeGenerator extends PlatformCodeGenerator {
/// This generates the map of Web KeyboardEvent codes to logical key ids.
String get _webLogicalKeyCodeMap {
final StringBuffer result = StringBuffer();
final OutputLines<String> lines = OutputLines<String>('Web logical map');
for (final LogicalKeyEntry entry in logicalData.entries) {
zipStrict(entry.webValues, entry.webNames, (int value, String name) {
result.writeln(" '$name': ${toHex(value, digits: 10)},");
});
for (final String name in entry.webNames) {
lines.add(name, " '$name': ${toHex(entry.value, digits: 11)},");
}
}
return result.toString().trimRight();
return lines.sortedJoin().trimRight();
}
/// This generates the map of Web KeyboardEvent codes to physical key USB HID codes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment