Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 52d883d

Browse files
authored
Merge pull request #583 from ficristo/move-fixupKey
Move fixupKey where it is used and fix headers inclusion
2 parents bc6fa8e + a2eaeeb commit 52d883d

File tree

6 files changed

+34
-39
lines changed

6 files changed

+34
-39
lines changed

appshell/appshell_extensions.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -774,15 +774,4 @@ void CreateProcessMessageDelegates(ClientHandler::ProcessMessageDelegateSet& del
774774
delegates.insert(new ProcessMessageDelegate);
775775
}
776776

777-
//Replace keyStroke with replaceString
778-
bool fixupKey(ExtensionString& key, ExtensionString keyStroke, ExtensionString replaceString)
779-
{
780-
size_t idx = key.find(keyStroke, 0);
781-
if (idx != ExtensionString::npos) {
782-
key = key.replace(idx, keyStroke.size(), replaceString);
783-
return true;
784-
}
785-
return false;
786-
}
787-
788777
} // namespace appshell_extensions

appshell/appshell_extensions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,4 @@ namespace appshell_extensions {
3131
// Create message delegates that run in the browser process
3232
void CreateProcessMessageDelegates(ClientHandler::ProcessMessageDelegateSet& delegates);
3333

34-
//Replace keyStroke with replaceString
35-
bool fixupKey(ExtensionString& key, ExtensionString keyStroke, ExtensionString replaceString);
36-
3734
} // namespace appshell_extensions

appshell/appshell_extensions_gtk.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323

2424
#include "appshell_extensions_platform.h"
25-
#include "appshell_extensions.h"
2625

2726
#include "client_app.h"
2827
#include <glib.h>

appshell/appshell_extensions_mac.mm

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
*/
2323

2424
#include "appshell_extensions_platform.h"
25-
#include "appshell_extensions.h"
2625

26+
#include "client_app.h"
2727
#include "native_menu_model.h"
2828

2929
#include "GoogleChrome.h"
@@ -1053,6 +1053,17 @@ int32 AddMenu(CefRefPtr<CefBrowser> browser, ExtensionString itemTitle, Extensio
10531053
return errCode;
10541054
}
10551055

1056+
// Replace keyStroke with replaceString
1057+
bool fixupKey(ExtensionString& key, ExtensionString keyStroke, ExtensionString replaceString)
1058+
{
1059+
size_t idx = key.find(keyStroke, 0);
1060+
if (idx != ExtensionString::npos) {
1061+
key = key.replace(idx, keyStroke.size(), replaceString);
1062+
return true;
1063+
}
1064+
return false;
1065+
}
1066+
10561067
// Looks at modifiers and special keys in "key",
10571068
// removes then and returns an unsigned int mask
10581069
// that can be used by setKeyEquivalentModifierMask
@@ -1063,17 +1074,17 @@ NSUInteger processKeyString(ExtensionString& key)
10631074
return 0;
10641075
}
10651076
NSUInteger mask = 0;
1066-
if (appshell_extensions::fixupKey(key, "Cmd-", "")) {
1077+
if (fixupKey(key, "Cmd-", "")) {
10671078
mask |= NSCommandKeyMask;
10681079
}
1069-
if (appshell_extensions::fixupKey(key, "Ctrl-", "")) {
1080+
if (fixupKey(key, "Ctrl-", "")) {
10701081
mask |= NSControlKeyMask;
10711082
}
1072-
if (appshell_extensions::fixupKey(key, "Shift-", "")) {
1083+
if (fixupKey(key, "Shift-", "")) {
10731084
mask |= NSShiftKeyMask;
10741085
}
1075-
if (appshell_extensions::fixupKey(key, "Alt-", "") ||
1076-
appshell_extensions::fixupKey(key, "Opt-", "")) {
1086+
if (fixupKey(key, "Alt-", "") ||
1087+
fixupKey(key, "Opt-", "")) {
10771088
mask |= NSAlternateKeyMask;
10781089
}
10791090

@@ -1094,23 +1105,23 @@ NSUInteger processKeyString(ExtensionString& key)
10941105
const ExtensionString tab = (ExtensionString() += NSTabCharacter);
10951106
const ExtensionString enter = (ExtensionString() += NSEnterCharacter);
10961107

1097-
appshell_extensions::fixupKey(key, "PageUp", pageUp);
1098-
appshell_extensions::fixupKey(key, "PageDown", pageDown);
1099-
appshell_extensions::fixupKey(key, "Home", home);
1100-
appshell_extensions::fixupKey(key, "End", end);
1101-
appshell_extensions::fixupKey(key, "Insert", ins);
1102-
appshell_extensions::fixupKey(key, "Delete", del);
1103-
appshell_extensions::fixupKey(key, "Backspace", backspace);
1104-
appshell_extensions::fixupKey(key, "Space", " ");
1105-
appshell_extensions::fixupKey(key, "Tab", tab);
1106-
appshell_extensions::fixupKey(key, "Enter", enter);
1107-
appshell_extensions::fixupKey(key, "Up", "");
1108-
appshell_extensions::fixupKey(key, "Down", "");
1109-
appshell_extensions::fixupKey(key, "Left", "");
1110-
appshell_extensions::fixupKey(key, "Right", "");
1108+
fixupKey(key, "PageUp", pageUp);
1109+
fixupKey(key, "PageDown", pageDown);
1110+
fixupKey(key, "Home", home);
1111+
fixupKey(key, "End", end);
1112+
fixupKey(key, "Insert", ins);
1113+
fixupKey(key, "Delete", del);
1114+
fixupKey(key, "Backspace", backspace);
1115+
fixupKey(key, "Space", " ");
1116+
fixupKey(key, "Tab", tab);
1117+
fixupKey(key, "Enter", enter);
1118+
fixupKey(key, "Up", "");
1119+
fixupKey(key, "Down", "");
1120+
fixupKey(key, "Left", "");
1121+
fixupKey(key, "Right", "");
11111122

11121123
// from unicode display char to ascii hyphen
1113-
appshell_extensions::fixupKey(key, "", "-");
1124+
fixupKey(key, "", "-");
11141125

11151126
// Check for F1 - F15 keys.
11161127
if (key.find("F") != ExtensionString::npos) {
@@ -1120,7 +1131,7 @@ NSUInteger processKeyString(ExtensionString& key)
11201131
if (key.find(fKey) != ExtensionString::npos) {
11211132
unichar ch = i;
11221133
NSString *actualKey = [NSString stringWithCharacters: &ch length: 1];
1123-
appshell_extensions::fixupKey(key, fKey, ExtensionString([actualKey UTF8String]));
1134+
fixupKey(key, fKey, ExtensionString([actualKey UTF8String]));
11241135
break;
11251136
}
11261137
}

appshell/appshell_extensions_win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
*/
2323

2424
#include "appshell_extensions_platform.h"
25-
#include "appshell_extensions.h"
2625

26+
#include "client_app.h"
2727
#include "native_menu_model.h"
2828
#include "client_handler.h"
2929

appshell/cefclient_mac.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "client_handler.h"
1717
#include "appshell/browser/resource_util.h"
1818
#include "config.h"
19-
#include "appshell_extensions.h"
2019
#include "command_callbacks.h"
2120
#include "appshell/common/client_switches.h"
2221
#include "native_menu_model.h"

0 commit comments

Comments
 (0)