Move cursor URI check to RFB object

Keeps the Display object simpler, and avoids having to abuse a
property to transfer the information.
This commit is contained in:
Pierre Ossman 2017-10-14 16:49:07 +02:00
parent 134ec26ee0
commit fdff59eeb4
5 changed files with 2 additions and 45 deletions

View File

@ -10,7 +10,6 @@
/*jslint browser: true, white: false */
/*global Util, Base64, changeCursor */
import { browserSupportsCursorURIs as cursorURIsSupported } from './util/browsers.js';
import { set_defaults, make_properties } from './util/properties.js';
import * as Log from './util/logging.js';
import Base64 from "./base64.js";
@ -77,12 +76,6 @@ export default function Display(target, defaults) {
throw new Error("Canvas does not support createImageData");
}
// Determine browser support for setting the cursor via data URI scheme
if (this._cursor_uri || this._cursor_uri === null ||
this._cursor_uri === undefined) {
this._cursor_uri = cursorURIsSupported();
}
Log.Debug("<< Display.constructor");
};
@ -483,11 +476,6 @@ Display.prototype = {
},
changeCursor: function (pixels, mask, hotx, hoty, w, h) {
if (this._cursor_uri === false) {
Log.Warn("changeCursor called but no cursor data URI support");
return;
}
Display.changeCursor(this._target, pixels, mask, hotx, hoty, w, h);
},
@ -681,8 +669,6 @@ make_properties(Display, [
['width', 'ro', 'int'], // Display area width
['height', 'ro', 'int'], // Display area height
['cursor_uri', 'rw', 'raw'], // Can we render cursor using data URI
['onFlush', 'rw', 'func'], // onFlush(): A flush request has finished
]);

View File

@ -14,6 +14,7 @@ import * as Log from './util/logging.js';
import _ from './util/localization.js';
import { decodeUTF8 } from './util/strings.js';
import { set_defaults, make_properties } from './util/properties.js';
import { browserSupportsCursorURIs } from './util/browsers.js';
import Display from "./display.js";
import Keyboard from "./input/keyboard.js";
import Mouse from "./input/mouse.js";
@ -1470,7 +1471,7 @@ RFB.prototype.set_local_cursor = function (cursor) {
this._local_cursor = false;
this._display.disableLocalCursor(); //Only show server-side cursor
} else {
if (this._display.get_cursor_uri()) {
if (browserSupportsCursorURIs()) {
this._local_cursor = true;
} else {
Log.Warn("Browser does not support local cursor");

View File

@ -43,11 +43,3 @@ export function browserSupportsCursorURIs () {
return _cursor_uris_supported;
};
export function _forceCursorURIs(enabled) {
if (enabled === undefined || enabled) {
_cursor_uris_supported = true;
} else {
_cursor_uris_supported = false;
}
}

View File

@ -97,7 +97,6 @@ None
| viewport | bool | RW | false | Use viewport clipping
| width | int | RO | | Display area width
| height | int | RO | | Display area height
| cursor_uri | raw | RW | | Can we render cursor using data URI
### 2.3.2 Methods

View File

@ -3,7 +3,6 @@ var expect = chai.expect;
import Base64 from '../core/base64.js';
import Display from '../core/display.js';
import { _forceCursorURIs, browserSupportsCursorURIs } from '../core/util/browsers.js';
import sinon from '../vendor/sinon.js';
@ -37,26 +36,6 @@ describe('Display/Canvas Helper', function () {
return Base64.decode(data);
}
describe('checking for cursor uri support', function () {
it('should disable cursor URIs if there is no support', function () {
_forceCursorURIs(false);
var display = new Display(document.createElement('canvas'), { viewport: false });
expect(display._cursor_uri).to.be.false;
});
it('should enable cursor URIs if there is support', function () {
_forceCursorURIs(true);
var display = new Display(document.createElement('canvas'), { viewport: false });
expect(display._cursor_uri).to.be.true;
});
it('respect the cursor_uri option if there is support', function () {
_forceCursorURIs(false);
var display = new Display(document.createElement('canvas'), { viewport: false, cursor_uri: false });
expect(display._cursor_uri).to.be.false;
});
});
describe('viewport handling', function () {
var display;
beforeEach(function () {