On Thu, 14 Dec 2017 21:07:38 +0900
Yuya Nishihara <y...@tcha.org> wrote:

> On Wed, 13 Dec 2017 00:27:47 +0800, Anton Shestakov wrote:
> > # HG changeset patch
> > # User Anton Shestakov <a...@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.

I don't think the way it's resized now would cause any problems:

- <canvas> is an absolutely-positioned element that is simply stacked on
  top of the list of commits, which means the rest of the page doesn't
  really depend on its size,

- it is also fully transparent initially and after any resizing, so its
  size is not something that can be easily seen without devtools,

- and most importantly, while the way JS code updates the page has been
  changed from

    resize <canvas>, copy new HTML, render on <canvas>

  to
 
    copy new HTML, resize <canvas>, render on <canvas>

  DOM updates still happen only when scripting has finished the
  execution (if it's synchronous, like in our case), so the result can
  only be seen after all three "functions" complete anyway,

I think even if we switched to SVG and did the resizing part at the
very end, it would still be only one "visible" update to the page
(I'll do some experiments when I actually try to do graph in SVG).
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to