Skip to content

Commit

Permalink
Renderer-calculated style values for an edge may not be fresh on call…
Browse files Browse the repository at this point in the history
… to getter #2608

Rendered style is generally recalculated at the start of a frame rather than synchronously at the time of dirtying.  This avoids redundant calculations.  Further an edge is not explicitly dirtied when at least one of its connected nodes changes in dimensions (position, width, etc.).  Instead, it is implicitly marked as dirty via the `cleanConnected` flag on the node.

An immediate, synchronous recalculation of rendered style may happen for public functions that read rendered style, such as `edge.midpoint()`.  For this case, `recalculateRenderedStyle()` must check whether an edge is implicitly dirty via `cleanConnected`.
  • Loading branch information
maxkfranz committed Jan 24, 2020
1 parent 8dacf19 commit 3bf1652
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/extensions/renderer/base/coord-ele-math/rendered-style.js
Expand Up @@ -75,8 +75,10 @@ BRp.onUpdateEleCalcs = function( fn ){
};

BRp.recalculateRenderedStyle = function( eles, useCache ){
var edges = [];
var nodes = [];
let isCleanConnected = ele => ele._private.rstyle.cleanConnected;

let edges = [];
let nodes = [];

// the renderer can't be used for calcs when destroyed, e.g. ele.boundingBox()
if( this.destroyed ){ return; }
Expand All @@ -89,6 +91,12 @@ BRp.recalculateRenderedStyle = function( eles, useCache ){
var _p = ele._private;
var rstyle = _p.rstyle;

// an edge may be implicitly dirty b/c of one of its connected nodes
// (and a request for recalc may come in between frames)
if( ele.isEdge() && (!isCleanConnected(ele.source()) || !isCleanConnected(ele.target())) ){
rstyle.clean = false;
}

// only update if dirty and in graph
if( (useCache && rstyle.clean) || ele.removed() ){ continue; }

Expand Down

0 comments on commit 3bf1652

Please sign in to comment.