From 2fd0a320bd3ebc037df2a9a1fb7f0eee418451e7 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Thu, 14 Aug 2014 09:24:08 -0400 Subject: [PATCH] Bug 1053248 - Add new gesture debug logger. r=yzen --- accessible/jsat/Gestures.jsm | 8 ++++---- accessible/jsat/Utils.jsm | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/accessible/jsat/Gestures.jsm b/accessible/jsat/Gestures.jsm index cecd40b648a1..3d2fd2fde982 100644 --- a/accessible/jsat/Gestures.jsm +++ b/accessible/jsat/Gestures.jsm @@ -228,7 +228,7 @@ this.GestureTracker = { // jshint ignore:line * @param {Number} aTimeStamp A new pointer event timeStamp. */ handle: function GestureTracker_handle(aDetail, aTimeStamp) { - Logger.debug(() => { + Logger.gesture(() => { return ['Pointer event', aDetail.type, 'at:', aTimeStamp, JSON.stringify(aDetail.points)]; }); @@ -332,7 +332,7 @@ function compileDetail(aType, aPoints, keyMap = {x: 'startX', y: 'startY'}) { */ function Gesture(aTimeStamp, aPoints = {}, aLastEvent = undefined) { this.startTime = Date.now(); - Logger.debug('Creating', this.id, 'gesture.'); + Logger.gesture('Creating', this.id, 'gesture.'); this.points = aPoints; this.lastEvent = aLastEvent; this._deferred = Promise.defer(); @@ -509,7 +509,7 @@ Gesture.prototype = { if (this.isComplete) { return; } - Logger.debug('Resolving', this.id, 'gesture.'); + Logger.gesture('Resolving', this.id, 'gesture.'); this.isComplete = true; let detail = this.compile(); if (detail) { @@ -533,7 +533,7 @@ Gesture.prototype = { if (this.isComplete) { return; } - Logger.debug('Rejecting', this.id, 'gesture.'); + Logger.gesture('Rejecting', this.id, 'gesture.'); this.isComplete = true; return { id: this.id, diff --git a/accessible/jsat/Utils.jsm b/accessible/jsat/Utils.jsm index d7fc792578db..57ab6c5176d3 100644 --- a/accessible/jsat/Utils.jsm +++ b/accessible/jsat/Utils.jsm @@ -473,11 +473,12 @@ State.prototype = { }; this.Logger = { // jshint ignore:line + GESTURE: -1, DEBUG: 0, INFO: 1, WARNING: 2, ERROR: 3, - _LEVEL_NAMES: ['DEBUG', 'INFO', 'WARNING', 'ERROR'], + _LEVEL_NAMES: ['GESTURE', 'DEBUG', 'INFO', 'WARNING', 'ERROR'], logLevel: 1, // INFO; @@ -490,7 +491,7 @@ this.Logger = { // jshint ignore:line let args = Array.prototype.slice.call(arguments, 1); let message = (typeof(args[0]) === 'function' ? args[0]() : args).join(' '); - message = '[' + Utils.ScriptName + '] ' + this._LEVEL_NAMES[aLogLevel] + + message = '[' + Utils.ScriptName + '] ' + this._LEVEL_NAMES[aLogLevel + 1] + ' ' + message + '\n'; dump(message); // Note: used for testing purposes. If |this.test| is true, also log to @@ -509,6 +510,11 @@ this.Logger = { // jshint ignore:line this, [this.INFO].concat(Array.prototype.slice.call(arguments))); }, + gesture: function gesture() { + this.log.apply( + this, [this.GESTURE].concat(Array.prototype.slice.call(arguments))); + }, + debug: function debug() { this.log.apply( this, [this.DEBUG].concat(Array.prototype.slice.call(arguments))); @@ -552,14 +558,16 @@ this.Logger = { // jshint ignore:line }, accessibleToString: function accessibleToString(aAccessible) { - let str = '[ defunct ]'; - try { - str = '[ ' + Utils.AccRetrieval.getStringRole(aAccessible.role) + - ' | ' + aAccessible.name + ' ]'; - } catch (x) { + if (!aAccessible) { + return '[ null ]'; } - return str; + try { + return'[ ' + Utils.AccRetrieval.getStringRole(aAccessible.role) + + ' | ' + aAccessible.name + ' ]'; + } catch (x) { + return '[ defunct ]'; + } }, eventToString: function eventToString(aEvent) {