lib/carto/renderer.js
function inheritDefinitions(definitions, env) {
    var inheritTime = +new Date();
    // definitions are ordered by specificity,
    // high (index 0) to low
    var byAttachment = {},
        byFilter = {};
    var result = [];
    var current, attachment;

    // Evaluate the filters specified by each definition with the given
    // environment to correctly resolve variable references
    definitions.forEach(function(d) {
        d.filters.ev(env);
    });

    for (var i = 0; i < definitions.length; i++) {

        attachment = definitions[i].attachment;
        current = [definitions[i]];

        if (!byAttachment[attachment]) {
            byAttachment[attachment] = [];
            byAttachment[attachment].attachment = attachment;
            byFilter[attachment] = {};
            result.push(byAttachment[attachment]);
        }

        // Iterate over all subsequent rules.
        for (var j = i + 1; j < definitions.length; j++) {
            if (definitions[j].attachment === attachment) {
                // Only inherit rules from the same attachment.
                current = addRules(current, definitions[j], byFilter[attachment]);
            }
        }

        for (var k = 0; k < current.length; k++) {
            byFilter[attachment][current[k].filters] = current[k];
            byAttachment[attachment].push(current[k]);
        }
    }

    if (env.benchmark) console.warn('Inheritance time: ' + ((new Date() - inheritTime)) + 'ms');

    return result;

}
function inheritDefinitions(definitions, env) {
    var inheritTime = +new Date();
    // definitions are ordered by specificity,
    // high (index 0) to low
    var byAttachment = {},
        byFilter = {};
    var result = [];
    var current, attachment;

    // Evaluate the filters specified by each definition with the given
    // environment to correctly resolve variable references
    definitions.forEach(function(d) {
        d.filters.ev(env);
    });

    for (var i = 0; i < definitions.length; i++) {

        attachment = definitions[i].attachment;
        current = [definitions[i]];

        if (!byAttachment[attachment]) {
            byAttachment[attachment] = [];
            byAttachment[attachment].attachment = attachment;
            byFilter[attachment] = {};
            result.push(byAttachment[attachment]);
        }

        // Iterate over all subsequent rules.
        for (var j = i + 1; j < definitions.length; j++) {
            if (definitions[j].attachment === attachment) {
                // Only inherit rules from the same attachment.
                current = addRules(current, definitions[j], byFilter[attachment]);
            }
        }

        for (var k = 0; k < current.length; k++) {
            byFilter[attachment][current[k].filters] = current[k];
            byAttachment[attachment].push(current[k]);
        }
    }

    if (env.benchmark) console.warn('Inheritance time: ' + ((new Date() - inheritTime)) + 'ms');

    return result;

}
function inheritDefinitions ( definitions , env ) { var inheritTime = + new Date ( ) ; // definitions are ordered by specificity, // high (index 0) to low var byAttachment = { } , byFilter = { } ; var result = [ ] ; var current , attachment ; // Evaluate the filters specified by each definition with the given // environment to correctly resolve variable references definitions . forEach ( function ( d ) { d . filters . ev ( env ) ; } ) ; for ( var i = 0 ; i < definitions . length ; i ++ ) { attachment = definitions [ i ] . attachment ; current = [ definitions [ i ] ] ; if ( ! byAttachment [ attachment ] ) { byAttachment [ attachment ] = [ ] ; byAttachment [ attachment ] . attachment = attachment ; byFilter [ attachment ] = { } ; result . push ( byAttachment [ attachment ] ) ; } // Iterate over all subsequent rules. for ( var j = i + 1 ; j < definitions . length ; j ++ ) { if ( definitions [ j ] . attachment === attachment ) { // Only inherit rules from the same attachment. current = addRules ( current , definitions [ j ] , byFilter [ attachment ] ) ; } } for ( var k = 0 ; k < current . length ; k ++ ) { byFilter [ attachment ] [ current [ k ] . filters ] = current [ k ] ; byAttachment [ attachment ] . push ( current [ k ] ) ; } } if ( env . benchmark ) console . warn ( 'Inheritance time: ' + ( ( new Date ( ) - inheritTime ) ) + 'ms' ) ; return result ; }
Apply inherited styles from their ancestors to them.

called either once per render (in the case of mss) or per layer
(for mml)

@param {Object} definitions - a list of definitions objects
that contain .rules
@param {Object} env - the environment
@return {Array<Array>} an array of arrays is returned,
in which each array refers to a specific attachment
Apply inherited styles from their ancestors to them .