loleaflet/src/control/Control.ColumnHeader.js | 7 ++++++ loleaflet/src/control/Control.RowHeader.js | 7 ++++++ loleaflet/src/layer/tile/CalcTileLayer.js | 30 +++++++++++++++++++------- 3 files changed, 36 insertions(+), 8 deletions(-)
New commits: commit 3f97c85218705f29206a0c22eea6419c5698066a Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Sun May 10 01:57:01 2020 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Sat Jul 4 18:06:03 2020 +0200 Do not rely on js ordering of multi event execution On getting a .uno:ViewRowColumnHeaders message, the order of header painting should be the headers elements first, then the cursor indication on the header, then the selection area indication on the header if any. More importantly none of these painting will be correct if the data in the tickMap member of both headers is stale. As of now all three of these are executed by three different events. Lets avoid depending on the implicit ordering of execution of these and do these synchronously as part of the main event ('viewrowcolumnheaders') handler. Change-Id: I4da29ba893c408af45159073e4389481b2eaecc7 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97937 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js index 8c049fd93..f9d3feedb 100644 --- a/loleaflet/src/control/Control.ColumnHeader.js +++ b/loleaflet/src/control/Control.ColumnHeader.js @@ -378,6 +378,13 @@ L.Control.ColumnHeader = L.Control.Header.extend({ viewRowColumnHeaders: function (e) { if (e.data.columns && e.data.columns.length > 0) { this.fillColumns(e.data.columns, e.data.columnGroups, e.converter, e.context); + this._onUpdateCurrentColumn(e.cursor); + if (e.selection && e.selection.hasSelection) { + this._onUpdateSelection(e.selection); + } + else { + this._onClearSelection(); + } } }, diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js index d1f475723..0bf1fcb38 100644 --- a/loleaflet/src/control/Control.RowHeader.js +++ b/loleaflet/src/control/Control.RowHeader.js @@ -367,6 +367,13 @@ L.Control.RowHeader = L.Control.Header.extend({ viewRowColumnHeaders: function (e) { if (e.data.rows && e.data.rows.length) { this.fillRows(e.data.rows, e.data.rowGroups, e.converter, e.context); + this._onUpdateCurrentRow(e.cursor); + if (e.selection && e.selection.hasSelection) { + this._onUpdateSelection(e.selection); + } + else { + this._onClearSelection(); + } } }, diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js index 1e82f2598..684d559c1 100644 --- a/loleaflet/src/layer/tile/CalcTileLayer.js +++ b/loleaflet/src/layer/tile/CalcTileLayer.js @@ -373,6 +373,10 @@ L.CalcTileLayer = L.TileLayer.extend({ }, _onUpdateCurrentHeader: function() { + this._map.fire('updatecurrentheader', this._getCursorPosSize()); + }, + + _getCursorPosSize: function () { var x = -1, y = -1; if (this._cellCursorXY) { x = this._cellCursorXY.x + 1; @@ -382,20 +386,30 @@ L.CalcTileLayer = L.TileLayer.extend({ if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) { size = this._cellCursorTwips.getSize(); } - this._map.fire('updatecurrentheader', {curX: x, curY: y, width: size.x, height: size.y}); + + return { curX: x, curY: y, width: size.x, height: size.y }; }, _onUpdateSelectionHeader: function () { + var selectionHeaderData = this._getSelectionHeaderData(); + if (selectionHeaderData.hasSelection) { + this._map.fire('updateselectionheader', selectionHeaderData); + return; + } + + this._map.fire('clearselectionheader'); + }, + + _getSelectionHeaderData: function() { var layers = this._selections.getLayers(); var layer = layers.pop(); if (layers.length === 0 && layer && layer.getLatLngs().length === 1) { var start = this._latLngToTwips(layer.getBounds().getNorthWest()).add([1, 1]); var end = this._latLngToTwips(layer.getBounds().getSouthEast()).subtract([1, 1]); - this._map.fire('updateselectionheader', {start: start, end: end}); - } - else { - this._map.fire('clearselectionheader'); + return { hasSelection: true, start: start, end: end }; } + + return { hasSelection: false }; }, _onStatusMsg: function (textMsg) { @@ -452,14 +466,14 @@ L.CalcTileLayer = L.TileLayer.extend({ var comment; if (values.commandName === '.uno:ViewRowColumnHeaders') { -// console.log('view row column headers: ' + JSON.stringify(values)); this._map.fire('viewrowcolumnheaders', { data: values, + cursor: this._getCursorPosSize(), + selection: this._getSelectionHeaderData(), converter: this._twipsToPixels, context: this }); - this._onUpdateCurrentHeader(); - this._onUpdateSelectionHeader(); + } else if (values.comments) { this.clearAnnotations(); for (var index in values.comments) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits