Commit 60fa9805 authored by robert.bradford's avatar robert.bradford Committed by Commit bot

ozone: Fix events_unittests build with use_xkbcommon==1

In r311421 a test was modified that called into
XkbKeyboardLayoutEngine::ParseLayoutName but this function was not exposed in
the header file. This change exposes this method in the header file and fixes
the build.

Original CL that introduced issue: https://codereview.chromium.org/848833002

BUG=None
TEST=Compile of events_unittests completes

Review URL: https://codereview.chromium.org/812613004

Cr-Commit-Position: refs/heads/master@{#311523}
parent 147cef6e
...@@ -625,32 +625,13 @@ const PrintableSimpleEntry kSimpleMap[] = { ...@@ -625,32 +625,13 @@ const PrintableSimpleEntry kSimpleMap[] = {
{0x0259, VKEY_OEM_3}, // schwa {0x0259, VKEY_OEM_3}, // schwa
}; };
void ParseLayoutName(const std::string& layout_name,
std::string* layout_id,
std::string* layout_variant) {
size_t dash_index = layout_name.find('-');
size_t parentheses_index = layout_name.find('(');
*layout_id = layout_name;
*layout_variant = "";
if (parentheses_index != std::string::npos) {
*layout_id = layout_name.substr(0, parentheses_index);
size_t close_index = layout_name.find(')', parentheses_index);
if (close_index == std::string::npos)
close_index = layout_name.size();
*layout_variant = layout_name.substr(parentheses_index + 1,
close_index - parentheses_index - 1);
} else if (dash_index != std::string::npos) {
*layout_id = layout_name.substr(0, dash_index);
*layout_variant = layout_name.substr(dash_index + 1);
}
}
void LoadKeymap(const std::string& layout_name, void LoadKeymap(const std::string& layout_name,
scoped_refptr<base::SingleThreadTaskRunner> reply_runner, scoped_refptr<base::SingleThreadTaskRunner> reply_runner,
const LoadKeymapCallback& reply_callback) { const LoadKeymapCallback& reply_callback) {
std::string layout_id; std::string layout_id;
std::string layout_variant; std::string layout_variant;
ParseLayoutName(layout_name, &layout_id, &layout_variant); XkbKeyboardLayoutEngine::ParseLayoutName(layout_name, &layout_id,
&layout_variant);
xkb_rule_names names = {.rules = NULL, xkb_rule_names names = {.rules = NULL,
.model = "pc101", .model = "pc101",
.layout = layout_id.c_str(), .layout = layout_id.c_str(),
...@@ -951,4 +932,23 @@ base::char16 XkbKeyboardLayoutEngine::XkbSubCharacter( ...@@ -951,4 +932,23 @@ base::char16 XkbKeyboardLayoutEngine::XkbSubCharacter(
return character; return character;
} }
void XkbKeyboardLayoutEngine::ParseLayoutName(const std::string& layout_name,
std::string* layout_id,
std::string* layout_variant) {
size_t dash_index = layout_name.find('-');
size_t parentheses_index = layout_name.find('(');
*layout_id = layout_name;
*layout_variant = "";
if (parentheses_index != std::string::npos) {
*layout_id = layout_name.substr(0, parentheses_index);
size_t close_index = layout_name.find(')', parentheses_index);
if (close_index == std::string::npos)
close_index = layout_name.size();
*layout_variant = layout_name.substr(parentheses_index + 1,
close_index - parentheses_index - 1);
} else if (dash_index != std::string::npos) {
*layout_id = layout_name.substr(0, dash_index);
*layout_variant = layout_name.substr(dash_index + 1);
}
}
} // namespace ui } // namespace ui
...@@ -41,6 +41,10 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine ...@@ -41,6 +41,10 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
KeyboardCode* key_code, KeyboardCode* key_code,
uint32* platform_keycode) const override; uint32* platform_keycode) const override;
static void ParseLayoutName(const std::string& layout_name,
std::string* layout_id,
std::string* layout_variant);
protected: protected:
// Table for EventFlagsToXkbFlags(). // Table for EventFlagsToXkbFlags().
struct XkbFlagMapEntry { struct XkbFlagMapEntry {
......
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