[PATCH 2 of 4] hgweb: calculate <canvas> width and height client-side

Yuya Nishihara yuya at tcha.org
Thu Dec 14 07:07:38 EST 2017


On Wed, 13 Dec 2017 00:27:47 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6 at dwimlabs.net>
> # Date 1512892582 -28800
> #      Sun Dec 10 15:56:22 2017 +0800
> # Node ID 2319d0216460c6f3b91f174a5027190aa80e07b7
> # Parent  e35959da063b5944369277f3b2c69c3af06e2710
> hgweb: calculate <canvas> width and height client-side
> 
> hgweb determines and passes to templates some variables related to graph
> appearance, like bg_height, canvaswidth and canvasheight. bg_height was and
> still is used for graph.scale() call in graph.tmpl, and the two latter
> variables were used in <canvas> element as width and height properties, and
> they were set before JS code got to run. Setting these properties server-side
> doesn't make a lot of sense, because a graph that has been scaled should
> calculate things like width and height on its own when being rendered.
> 
> Let's move (re)sizing <canvas> to JavaScript (to Graph.render function) and
> stop parsing HTML with regular expressions just to know new width and height.

I'm okay with this change, but it might be bad in UX as the resize occurs
very late.


More information about the Mercurial-devel mailing list