Commit Graph

39 Commits

Author SHA1 Message Date
Pierre Ossman 2c5491e131 Enforce space after function name 2018-09-06 17:34:15 +02:00
Pierre Ossman 0ae5c54ab3 Enforce explicit semi-colons 2018-09-06 17:25:02 +02:00
Pierre Ossman ae2e1ff7bd Move sinon to karma framework
This frees us from manual imports, and makes things less magical
as those aren't ES modules even if the code suggest that the are.
2018-07-13 15:57:24 +02:00
Juanjo Diaz 651c23ece3 Use fat arrow functions `const foo = () => { ... };` for callbacks
and any other function that is passed around and it's not a top level function
2018-07-12 19:06:57 +02:00
Juanjo Diaz 2b5f94fa6a Prefer const/let over var 2018-05-24 00:27:09 +03:00
Juanjo Diaz 9e1bd410aa Remove jshint comments 2018-01-31 07:38:29 -08:00
Solly Ross af4deba893 Fix slice usage in display tests on IE11
IE11 doesn't support the `slice` method on ArrayBufferViews, so
we have to use the old `Array.prototype.slice.call` trick in the
tests instead.
2018-01-10 11:08:21 -05:00
Pierre Ossman 1f9d0cb12f Add test for 16x16 tiles
We have a special cache and therefore special code paths that need
to be tested when rendering 16x16 tiles.
2017-12-14 12:59:25 +01:00
Pierre Ossman 9b84f51685 Move resize handling in to RFB object
Makes the API simpler and makes it easier for other frontends to
get this functionality.
2017-12-06 11:29:57 +01:00
Pierre Ossman 002907d2ce Remove "downscale only" mode
The normal scaling mode should be sufficient for most use cases, so
let's keep the interface simple.
2017-11-09 13:13:41 +01:00
Pierre Ossman 0460e5fdbe Improve naming for viewport properties 2017-11-09 13:13:41 +01:00
Pierre Ossman a80aa41628 Change clippingDisplay() to a property
It fits much better as a property given that it only tells what the
current state of things are.
2017-11-09 13:13:41 +01:00
Pierre Ossman 747b462337 Use standard JavaScript properties
Use normal properties with JavaScript setters and getters instead of
our homegrown stuff.

This also changes the properties to follow normal naming conventions.
2017-11-09 13:03:32 +01:00
Pierre Ossman fdff59eeb4 Move cursor URI check to RFB object
Keeps the Display object simpler, and avoids having to abuse a
property to transfer the information.
2017-11-09 12:52:05 +01:00
Pierre Ossman 134ec26ee0 Remove non-JavaScript render code
It wasn't used anyway so simplify things.
2017-11-09 12:52:05 +01:00
Pierre Ossman 3d7bb02036 Change some attributes to arguments
Some attributes are better suited as arguments, primarily because they
are associated with a specific method and cannot be changed later.
2017-11-09 12:52:05 +01:00
Samuel Mannehed 13d9108f91 Setup chai extensions centrally
They have global effects so make that clear by doing the setup in a
single place.
2017-09-28 14:10:19 +02:00
Samuel Mannehed 0aaf59c2f9 Upgrade and fix sinon.js
Converted version downloaded from sinonjs.org. Fixed version that
doesn't register itself on the global object. This forces all modules to
do a proper import.
2017-09-28 14:05:20 +02:00
Samuel Mannehed afb621d577 Add missing semicolon 2017-05-13 01:56:35 +02:00
Pierre Ossman 26586b9ddf Remove colour map support
It was broken and unused. Remove it so we can simplify the code.
2017-05-04 15:13:33 +02:00
Solly Ross dfae3209eb Update tests to work with new structure
This updates the tests to work with the new structure, and removes the
old `utils/run_from_console.js` files in favor of just using Karma
directly.  The Karma debug page now displays the normal mocha HTML, so
we can use that instead of the HTML generation functionality of the old
test runner.

Note that PhantomJS does not work at the moment (PhantomJS 1.5 should
make it possible to test on PhantomJS again).
2017-03-21 17:39:07 -04:00
Samuel Mannehed 280676c7e9 Properly encapsulate the scale in Display
Other parts of the code shouldn't have to care about this. Let Display
convert between canvas coordinates and framebuffer coordinates.
2017-02-16 14:00:39 +01:00
Pierre Ossman adf345fdc4 Clean up viewport handling
Make sure the viewport is properly updated when necessary, on respects
given restrictions.
2016-12-09 09:20:50 +01:00
Pierre Ossman 3f781f2aa3 Remove max dimension handling
The viewport handling is now a lot clearer, so simply limit the size
of the viewport in the caller rather than having this extra layer
of checks.
2016-12-09 09:20:50 +01:00
Pierre Ossman e549ae074f Prevent access to sensitive display variables
These should not be directly accessed. Instead use drawing operation
and Display.resize().
2016-12-09 09:20:50 +01:00
Pierre Ossman 2ba767a7fe Use double buffering for the display
Do all rendering to a hidden canvas and then copy over the finished
frame to the visible canvas once everything is done. This simplifies
things and solves some bugs as we can retain a copy of the entire
frame buffer.
2016-12-09 09:20:50 +01:00
Pierre Ossman 3181a032f8 Add test for Display.flush() 2016-12-09 09:20:50 +01:00
Pierre Ossman 74e390512d Remove blitStringImage() in favour of imageRect()
The latter is more generic and can easily be modified for other
mechanisms in the future.
2016-12-09 09:20:50 +01:00
Pierre Ossman bb6965f2e6 Wait for proper image load event
There is a specific event for when an image has finished loading,
so trigger on that rather than polling. The polling interval of
requestAnimationFrame() can also be very large.
2016-10-24 14:42:13 +02:00
Pierre Ossman 1578fa68ac Hide image handling in display object
The callers don't need to concern themselves with how images are
rendered, so hide the details behind the API. This also avoids
exposing the render queue.
2016-10-24 14:42:13 +02:00
Solly Ross e4fef7be2d Util shouldn't modify window object
This commits prevents Util from modifying the window object.

- `window.requestAnimFrame` was removed (no polyfill is needed anymore)
- the potential redefinition of `console.log` and friends was removed
  (all supported browsers have `console.xyz` defined anyway)
2016-09-16 15:49:52 -04:00
Solly Ross a369a80c24 Fix bug in non-true-color code
There was a bug caused by 38781d931e
which prevented color map look-ups sent by rfb.js from working properly,
since display.js expected a single-item array, and rfb.js sent just them
item value itself (a number) instead.  This fixes that, and tweaks the
corresponding test to match that behavior.
2015-08-24 19:34:30 -04:00
Solly Ross 58ded70d15 Create RFB object on connect
In e543525faa, we switched to creating
a new RFB object on disconnect.  This caused issues, however, since
any errors were only displayed briefly before the new "loaded" text
was displayed instead.

Now, we create the RFB object on connect.  This essentially removes
the usefulness of the "loaded" state, but prevents the aforementioned
problem.

To facilitate this, the code which does detection of cursor URI support
was moved from this Display constructor (which now calls the new
function) into its own function, `Util.browserSupportsCursorURIs()`.

Fixes #467
2015-03-26 17:09:05 -04:00
samhed fdedbafb1d * Don't check specific html elements from the display code (Fixes #446)
* Renamed and reworked fbuClip to clippingDisplay
* Added tests for clippingDisplay
* Use the a noVNC_container which covers the entire page to get the full size
  (Fixes #463)
* Added maxWidth and maxHeight to the canvas which can limit the viewport size
* Only show either the canvas or the logo, hide one when the other is shown
* Always center the canvas (previously it was only centered when not clipping)
* Removed iOS specific "position-fixed" fixes and start calling setBarPosition
  on every resize
* Removed the noVNC_screen_pad
2015-03-09 14:30:56 +01:00
Solly Ross 72747869a7 Support local scaling
This commit adds two new addition scaling options.  Both options do
local scaling.  The first "Local Scaling", does both upscaling and
downscaling.  The second option, "Local Downscaling", only downscales.

This is based on work by @mightypenguin (with an additional bug
reported by @glazik12).
2015-03-03 13:15:49 -05:00
samhed 636be753b2 Support automatic resize [Part 1/4]: display.js
* Split viewportChange into two functions, one for changing size and the other for changing position.
* Modified viewport code to be capable of changing to a bigger size in the context of a
  client-initiated resize.
* Made clearer distinctions between when viewport-clipping or not.
* Added public function for telling when viewport-clipping.
* Updated tests that were using viewportChange.
2015-02-06 16:54:14 +01:00
Solly Ross 53762c31fe Fixed Cursor URI Support Detection
There was a bug in cursor URI support detection due to the way
set_defaults now works -- the code was checking for `null`, whereas
when not set, options default to `undefined` unless otherwise
specified.  The code now checks for either `null` or `undefined`.
Tests have been added to ensure that this works properly.
2014-09-19 14:51:15 -04:00
Solly Ross 2c9623b5a7 Fixed assertion collision issues
When run via karma, all the tests are loaded into the same page.
This was causing a collision in the 'displayed' assertion dealing
with using viewportLoc.

The assertions are now in their own file, pulled in by tests that
need them.  Additionally, several tests which only set fb_width
and fb_height were correct to set viewportLoc as well.

Closes #392

Also-Authored-By: Martin André (github: mandre)
2014-09-19 12:16:06 -04:00
Solly Ross 1e13775bd5 Cleanup: Display Helper
File: display.js
Tests Added: True (preliminary)

Changes:
- De-crockford-ified the file

NOTE: the tests included for display.js cover basic functionality, but
are by no means nearly as comprehensive as the ones presented for
rfb.js.
2014-09-15 16:46:02 -04:00