]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Move cursor URI check to RFB object
authorPierre Ossman <ossman@cendio.se>
Sat, 14 Oct 2017 14:49:07 +0000 (16:49 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 9 Nov 2017 11:52:05 +0000 (12:52 +0100)
Keeps the Display object simpler, and avoids having to abuse a
property to transfer the information.

core/display.js
core/rfb.js
core/util/browsers.js
docs/API-internal.md
tests/test.display.js

index 6b036ff5c815602d394d050b32f49f83e9330bcd..07997cba1a93e83ffcacc3049417191fc6cef824 100644 (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
 ]);
 
index 59f0c4cd0c1f5925a8e29d314e29731d5a0e244a..55a9650fc51b46a4d700f9a77e628872b5de0bec 100644 (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");
index 77fca12f75fbb55a57c7a964a4d9a1bb47d4122f..50f5986340ea1c05d4ac24440ab24f84bc18bcd9 100644 (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;
-    }
-}
index e33f80698d3ccbac7534fe153c13b3ba601047e8..b9f3be8c31169c587de27907748dadf85f66b4ab 100644 (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
 
index 3a8c13d1594813ffde3301cbddfd8b2fc9183faf..32d054e3fe4b9f77d89b2e75f6510c320492457b 100644 (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 () {