Previously we were using CSS to make the text's colour transparent.
However that proved to cause a lot of problems with pre-existing
transition animations in the host webpage. There didn't seem to be
anyway to disable the transition time for text transitioning to
transparent, without also disabling all transitions.
Also added censorship to password input boxes.
This is so you can immediately clear the URL bar upon toggling. Which
saves you holding down the backspace key if you want to ente a new URL.
Only for input boxes. And SHIFT-ARROW isn't implemented.
No doubt a lot of this code is reinventing the wheel, after all this is
basically now a simple text editor. I'm sure there'll be a few bugs to
iron out.
Using the `-http-server` argument will now start Browsh in HTTP Server
mode. It will accept request like this:
`curl brow.sh/http://news.ycombinator.com`
This will return a plain text version of the Hacker News front page,
with a width of 100 characters, with each line separated by a line
break.
Also:
* Use webextension to navigate URLs instead of the DOM. This means
that crashed pages can still be navigated away from.
* An attempt to implement mouse dragndrop, but it doesn't work :(
Unit tests needed tab objects to be created.
Integration tests needed more max time for start up and to make sure
that the final tab doesn't get closed.
Adding, cycling, deleting. The width of the tab handle is currently
fixed to 20. And if there are more tabs than can fit in the tab bar then
the extra ones just dissapear off to the right, but they can still be
cycled to with CTRL-Tab.
The marks the end of feature development in preperation for a version
1 release.
Input boxes are currently only one line and to not properly wrap. So
textareas are also one line. TBC...
Also includes:
* First implementation of the DOM MutationObserver. This needs to have
an eye kept on it in case some websites trigger too mutatation
events. For now it doesn't seem too bad. Although strangely it seems
to stop on Youtube after about 15 seconds.
Text in the real browser only needs to be displayed when parsing with
the Text Builder in order to get the text's colour and z-index. Text
parsing should be done in frequently as it likely doesn't change often.
However graphics building of the current viewport is set to
automatically parse ever 250ms and it doesn't need to know anything
about text. So there's no point defaulting to having text on and hiding
it for every graphics frame.
This tweak has improved the perforance of the graphics parsing for small
frames (the same size as the viewport) from around 100ms to around 4ms!
There are still some curious and inexplicable CPU spikes when
scrolling... TBC
Firstly, this improves performance on a larger pages. But it also
prevents browser crashes a very large pages by setting a limit to how
much work is done per frame.
Also includes:
* Thread safe cell map for simultaneously reading and writing to the
buffered frame of TTY cells.
* Improved webext tests so that they programmaticlly build DOM rects
based off simple text strings.
* CLI is now prepared for supporting multiple tabs.
* Refactored global vars into relevant files
* Now using real types in JSON sent to CLI
* Still doesn't fix integration tests
This offloads significant CPU load from the browser. However it's become
clear that the previous feature of parsing the entire DOM needs to have
an upper limit imposed. For instance large Wikipedia pages still cause
problematic CPU load.
This commit does not fix the broken UI so integration tests fail.
Instead of mirroring the browser's viewport, as if we had a camera over
the browser, the entire DOM is now sent in the frame. This means that
the CLI itself can scroll without having to wait for updates from the
webextension screenshotter.
After moving to Tcell and implementing its screen diff updates, we can
no longer watch STDOUT to get frames during integration tests. Instead
we need to use Tcell's SimulationScreen and which has a GetContents()
method. This is actually also a much more robust way of being able to
see what Browsh actually outputs during testing.
This was primarily to get native diff'ed frame rendering.
Termbox-go doesn't support true colours, thus the switch to Tcell, but
as it turns out Tcell claims to have wider platform support, so it looks
like an especially good change.
So now the CLI will only try to update the terminal screen when cells
actually change. This has some significant performant gains, especially
when using Browsh over SSH.
Also note that this required a complete change of the frame data
structure sent over the websocket. Previously it was a little
structured, but now it is just a plain 1 dimensional array of pure
strings, even the RGB components are sent as integers in strings. If I
can find a way to unmarshal mixed arrays in Golang then it'll be worth
sending a mixed JSON array to save some compute overhead.
This gets around a few problems caused by the fact that Firefox's first
ever run on a new profile is quiet different from a normal startup. Note
that this only effects Browsh in Docker.
In the endless struggle to squash a Travis-specific bug, we now have
screenshots. Currently the screenshots are of the custom block font
state, so you can't read the text. But I'm planning on changing the
default state of the page to use a normal font - such that the
frame builder needs to toggle the block font on to build a frame. This
will make it more likely that screenshots will contain actual text.
Also removes the Mozilla Cliqz disclaimer tab on first startup.
Interestingly it has a carriage return in its HTML page title, which is
of course zero-width. But also the fact that this tab can sometimes load
before the requested tab at startup is a showstopper for automated
tests.
This means that Browsh can now be entirely run just by running the CLI
binary. The client launches Firefox as a subprocess, then connects to it
via the Marionette protocol, installs the webextension and finally
triggers a new tab with, currently, the Google homepage in it.
I was trying to set this up for automated testing as well by installing
the built webextension as a temporary addon, because otherwise you need
to sign the extension everytime with a unique semantic version. However
for some reason I can't quite recreate the environment that MDN's
`web-ext` creates. The extension installs fine but fails to load the
`content.js` script, I can't find a backtrace or any other details about
the failure. So for now, we're just going to have to use `web-ext` as
seperate process and have the client connect to that. Which is what one
should do during development anyway, so it's not a huge loss.
After weighing up the options it seems that Golang's termbox-go TTY
library has better support for terminals, and it's cross-platform out of
the box. So this commit is the first working version where the
interfacer launches a websocket server, makes a connection to the
webextension and listens to STDIN from the CLI, sending all input to the
webextenstion.
This proves that frames can be generated on Firefox using the canvas and
a Tree Walker to examine text nodes. Already with little optimisation
frames don't ever take longer than 200ms to render.
Chrome has a MediaStream of the viewport, hopefully that will prove
performant as well.
This doesn't have functioning text colour detection or text occlusion
support. But early research suggests this will possible by comparing 2
screenshots: one with and the other without rendered text.