Debug tool for incoming/outcoming/keyboard msgs

Signed-off-by: Neil Guertin <neil.guertin@collabora.com>
Change-Id: I157cf9b651069e8f4c81b4595cddf7748323c062
This commit is contained in:
Neil Guertin 2024-01-29 15:40:00 -05:00 committed by Michael Meeks
parent d462bf907d
commit d0ee423b32
6 changed files with 81 additions and 18 deletions

View file

@ -249,6 +249,42 @@ L.DebugManager = L.Class.extend({
},
});
this._addDebugTool({
name: 'Log incoming messages',
category: 'Logging',
startsOn: true,
onAdd: function () {
self.logIncomingMessages = true;
},
onRemove: function () {
self.logIncomingMessages = false;
},
});
this._addDebugTool({
name: 'Log outgoing messages',
category: 'Logging',
startsOn: true,
onAdd: function () {
self.logOutgoingMessages = true;
},
onRemove: function () {
self.logOutgoingMessages = false;
},
});
this._addDebugTool({
name: 'Log keyboard events',
category: 'Logging',
startsOn: true,
onAdd: function () {
self.logKeyboardEvents = true;
},
onRemove: function () {
self.logKeyboardEvents = false;
},
});
this._addDebugTool({
name: 'Tile Dumping',
category: 'Logging',

View file

@ -35,6 +35,8 @@ L.Log = {
},
_getEntries: function () {
if (!this._logs)
this._logs = [];
this._logs.sort(function (a, b) {
if (a.time < b.time) { return -1; }
if (a.time > b.time) { return 1; }

View file

@ -176,9 +176,11 @@ app.definitions.Socket = L.Class.extend({
},
_doSend: function(msg) {
// Only attempt to log text frames, not binary ones.
if (typeof msg === 'string')
this._logSocket('OUTGOING', msg);
if (this._map._debug.logOutgoingMessages) {
// Only attempt to log text frames, not binary ones.
if (typeof msg === 'string')
this._logSocket('OUTGOING', msg);
}
this.socket.send(msg);
},
@ -561,7 +563,9 @@ app.definitions.Socket = L.Class.extend({
textMsg = e.textMsg;
imgBytes = e.imgBytes;
this._logSocket('INCOMING', textMsg);
if (this._map._debug.logIncomingMessages) {
this._logSocket('INCOMING', textMsg);
}
var command = this.parseServerCmd(textMsg);
if (textMsg.startsWith('coolserver ')) {

View file

@ -348,7 +348,9 @@ L.A11yTextInput = L.TextInput.extend({
if (L.Browser.gecko && (!this._hasSelection || this._isLastSelectionEmpty()) &&
this._getLastCursorPosition() === this.getPlainTextContent().length &&
this._deleteHint === 'delete') {
window.app.console.log('Sending delete');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Sending delete');
}
this._removeEmptySelectionIfAny();
this._removeTextContent(0, 1);
}
@ -419,7 +421,9 @@ L.A11yTextInput = L.TextInput.extend({
// We use a different leading and terminal space character
// to differentiate backspace from delete, then replace the character.
if (!this._hasPreSpace()) { // missing initial space
window.app.console.log('Sending backspace');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Sending backspace');
}
if (!ignoreBackspace) {
this._removeEmptySelectionIfAny();
this._removeTextContent(1, 0);
@ -432,7 +436,9 @@ L.A11yTextInput = L.TextInput.extend({
return;
}
if (!this._hasPostSpace()) { // missing trailing space.
window.app.console.log('Sending delete');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Sending delete');
}
this._removeTextContent(0, this._hasSelection && this._isLastSelectionEmpty() ? 2 : 1);
this._appendSpace();
var pos = this._getLastCursorPosition();
@ -483,9 +489,11 @@ L.A11yTextInput = L.TextInput.extend({
while (matchTo < compareUpTo && content[matchTo] === lastContent[matchTo])
matchTo++;
window.app.console.log('Comparison matchAt ' + matchTo + '\n' +
'\tnew "' + this.codePointsToString(content) + '" (' + content.length + ')' + '\n' +
'\told "' + this.codePointsToString(lastContent) + '" (' + lastContent.length + ')');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Comparison matchAt ' + matchTo + '\n' +
'\tnew "' + this.codePointsToString(content) + '" (' + content.length + ')' + '\n' +
'\told "' + this.codePointsToString(lastContent) + '" (' + lastContent.length + ')');
}
// no new content
if (matchTo === content.length && matchTo === lastContent.length)

View file

@ -658,7 +658,9 @@ L.TextInput = L.Layer.extend({
// Firefox is not able to delete the <img> post space. Since no 'input' event is generated,
// we need to handle a <delete> at the end of the paragraph, here.
if (L.Browser.gecko && this._isCursorAtEnd() && this._deleteHint === 'delete') {
window.app.console.log('Sending delete');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Sending delete');
}
this._removeTextContent(0, 1);
this._emptyArea();
}
@ -703,14 +705,18 @@ L.TextInput = L.Layer.extend({
// We use a different leading and terminal space character
// to differentiate backspace from delete, then replace the character.
if (!this._hasPreSpace()) { // missing initial space
window.app.console.log('Sending backspace');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Sending backspace');
}
if (!ignoreBackspace)
this._removeTextContent(1, 0);
this._emptyArea();
return;
}
if (!this._hasPostSpace()) { // missing trailing space.
window.app.console.log('Sending delete');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Sending delete');
}
this._removeTextContent(0, 1);
this._emptyArea();
return;
@ -734,9 +740,11 @@ L.TextInput = L.Layer.extend({
while (matchTo < sharedLength && content[matchTo] === this._lastContent[matchTo])
matchTo++;
window.app.console.log('Comparison matchAt ' + matchTo + '\n' +
'\tnew "' + this.codePointsToString(content) + '" (' + content.length + ')' + '\n' +
'\told "' + this.codePointsToString(this._lastContent) + '" (' + this._lastContent.length + ')');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Comparison matchAt ' + matchTo + '\n' +
'\tnew "' + this.codePointsToString(content) + '" (' + content.length + ')' + '\n' +
'\told "' + this.codePointsToString(this._lastContent) + '" (' + this._lastContent.length + ')');
}
var removeBefore = this._lastContent.length - matchTo;
var removeAfter = 0;
@ -1159,7 +1167,9 @@ L.TextInput = L.Layer.extend({
// message.
// Will remove characters from the queue first, if there are any.
_removeTextContent: function(before, after) {
window.app.console.log('Remove ' + before + ' before, and ' + after + ' after');
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('Remove ' + before + ' before, and ' + after + ' after');
}
/// TODO: rename the event to 'removetextcontent' as soon as coolwsd supports it
/// TODO: Ask Marco about it

View file

@ -374,8 +374,11 @@ L.Map.Keyboard = L.Handler.extend({
)
return;
if (this._map._debug.logKeyboardEvents) {
window.app.console.log('keyboard handler:', ev.type, ev.key, ev.charCode, this._expectingInput, ev);
}
var completeEvent = app.socket.createCompleteTraceEvent('L.Map.Keyboard._onKeyDown', { type: ev.type, charCode: ev.charCode });
window.app.console.log('keyboard handler:', ev.type, ev.key, ev.charCode, this._expectingInput, ev);
if (ev.charCode == 0) {
this._handleKeyEvent(ev);