mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1034668 - The getMappedSelection
method for all canvas graphs should clamp the selection bounds, r=pbrosset
This commit is contained in:
parent
fa40f4ef56
commit
cecde6961f
@ -65,6 +65,14 @@ function testGraph(graph) {
|
||||
"The mapped selection's min value is correct (5).");
|
||||
is(graph.getMappedSelection().max, max,
|
||||
"The mapped selection's max value is correct (6).");
|
||||
|
||||
graph.setSelection({ start: graph.width + 100, end: -100 });
|
||||
min = map(0, 0, graph.width, 112, 4180);
|
||||
max = map(graph.width, 0, graph.width, 112, 4180);
|
||||
is(graph.getMappedSelection().min, min,
|
||||
"The mapped selection's min value is correct (7).");
|
||||
is(graph.getMappedSelection().max, max,
|
||||
"The mapped selection's max value is correct (8).");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,7 +395,7 @@ AbstractCanvasGraph.prototype = {
|
||||
*/
|
||||
getMappedSelection: function(unpack = e => e.delta) {
|
||||
if (!this.hasData() || !this.hasSelection()) {
|
||||
return { start: null, end: null };
|
||||
return { min: null, max: null };
|
||||
}
|
||||
let selection = this.getSelection();
|
||||
let totalTicks = this._data.length;
|
||||
@ -404,8 +404,9 @@ AbstractCanvasGraph.prototype = {
|
||||
|
||||
// The selection's start and end values are not guaranteed to be ascending.
|
||||
// This can happen, for example, when click & dragging from right to left.
|
||||
let min = Math.min(selection.start, selection.end);
|
||||
let max = Math.max(selection.start, selection.end);
|
||||
// Also make sure that the selection bounds fit inside the canvas bounds.
|
||||
let min = Math.max(Math.min(selection.start, selection.end), 0);
|
||||
let max = Math.min(Math.max(selection.start, selection.end), this._width);
|
||||
min = map(min, 0, this._width, firstTick, lastTick);
|
||||
max = map(max, 0, this._width, firstTick, lastTick);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user