From e549ae074fcea9febde32c0fa260a64c15cc1b8e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 11 Nov 2016 14:01:42 +0100 Subject: [PATCH] Prevent access to sensitive display variables These should not be directly accessed. Instead use drawing operation and Display.resize(). --- core/display.js | 15 ++------------- tests/test.display.js | 3 +-- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/core/display.js b/core/display.js index 1eb2626b..58a423df 100644 --- a/core/display.js +++ b/core/display.js @@ -566,24 +566,13 @@ }, // Overridden getters/setters - get_context: function () { - return this._drawCtx; - }, - set_scale: function (scale) { this._rescale(scale); }, - set_width: function (w) { - this._fb_width = w; - }, get_width: function () { return this._fb_width; }, - - set_height: function (h) { - this._fb_height = h; - }, get_height: function () { return this._fb_height; }, @@ -785,8 +774,8 @@ ['colourMap', 'rw', 'arr'], // Colour map array (when not true-color) ['scale', 'rw', 'float'], // Display area scale factor 0.0 - 1.0 ['viewport', 'rw', 'bool'], // Use viewport clipping - ['width', 'rw', 'int'], // Display area width - ['height', 'rw', 'int'], // Display area height + ['width', 'ro', 'int'], // Display area width + ['height', 'ro', 'int'], // Display area height ['maxWidth', 'rw', 'int'], // Viewport max width (0 if disabled) ['maxHeight', 'rw', 'int'], // Viewport max height (0 if disabled) diff --git a/tests/test.display.js b/tests/test.display.js index 95bf2fd6..663f0d7a 100644 --- a/tests/test.display.js +++ b/tests/test.display.js @@ -71,8 +71,7 @@ describe('Display/Canvas Helper', function () { }); it('should take viewport location into consideration when drawing images', function () { - display.set_width(4); - display.set_height(4); + display.resize(4, 4); display.viewportChangeSize(2, 2); display.drawImage(make_image_canvas(basic_data), 1, 1); display.flip();