src/util/graphic.js
function applyDefaultTextStyle(textStyle) {
    var opt = textStyle.insideRollbackOpt;

    // Only `insideRollbackOpt` created (in `setTextStyleCommon`),
    // applyDefaultTextStyle works.
    if (!opt || textStyle.textFill != null) {
        return;
    }

    var useInsideStyle = opt.useInsideStyle;
    var textPosition = textStyle.insideRawTextPosition;
    var insideRollback;
    var autoColor = opt.autoColor;

    if (useInsideStyle !== false
        && (useInsideStyle === true
            || (opt.isRectText
                && textPosition
                // textPosition can be [10, 30]
                && typeof textPosition === 'string'
                && textPosition.indexOf('inside') >= 0
            )
        )
    ) {
        insideRollback = {
            textFill: null,
            textStroke: textStyle.textStroke,
            textStrokeWidth: textStyle.textStrokeWidth
        };
        textStyle.textFill = '#fff';
        // Consider text with #fff overflow its container.
        if (textStyle.textStroke == null) {
            textStyle.textStroke = autoColor;
            textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
        }
    }
    else if (autoColor != null) {
        insideRollback = {textFill: null};
        textStyle.textFill = autoColor;
    }

    // Always set `insideRollback`, for clearing previous.
    if (insideRollback) {
        textStyle.insideRollback = insideRollback;
    }
}
function applyDefaultTextStyle(textStyle) {
    var opt = textStyle.insideRollbackOpt;

    // Only `insideRollbackOpt` created (in `setTextStyleCommon`),
    // applyDefaultTextStyle works.
    if (!opt || textStyle.textFill != null) {
        return;
    }

    var useInsideStyle = opt.useInsideStyle;
    var textPosition = textStyle.insideRawTextPosition;
    var insideRollback;
    var autoColor = opt.autoColor;

    if (useInsideStyle !== false
        && (useInsideStyle === true
            || (opt.isRectText
                && textPosition
                // textPosition can be [10, 30]
                && typeof textPosition === 'string'
                && textPosition.indexOf('inside') >= 0
            )
        )
    ) {
        insideRollback = {
            textFill: null,
            textStroke: textStyle.textStroke,
            textStrokeWidth: textStyle.textStrokeWidth
        };
        textStyle.textFill = '#fff';
        // Consider text with #fff overflow its container.
        if (textStyle.textStroke == null) {
            textStyle.textStroke = autoColor;
            textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
        }
    }
    else if (autoColor != null) {
        insideRollback = {textFill: null};
        textStyle.textFill = autoColor;
    }

    // Always set `insideRollback`, for clearing previous.
    if (insideRollback) {
        textStyle.insideRollback = insideRollback;
    }
}
function applyDefaultTextStyle ( textStyle ) { var opt = textStyle . insideRollbackOpt ; // Only `insideRollbackOpt` created (in `setTextStyleCommon`), // applyDefaultTextStyle works. if ( ! opt || textStyle . textFill != null ) { return ; } var useInsideStyle = opt . useInsideStyle ; var textPosition = textStyle . insideRawTextPosition ; var insideRollback ; var autoColor = opt . autoColor ; if ( useInsideStyle !== false && ( useInsideStyle === true || ( opt . isRectText && textPosition // textPosition can be [10, 30] && typeof textPosition === 'string' && textPosition . indexOf ( 'inside' ) >= 0 ) ) ) { insideRollback = { textFill : null , textStroke : textStyle . textStroke , textStrokeWidth : textStyle . textStrokeWidth } ; textStyle . textFill = '#fff' ; // Consider text with #fff overflow its container. if ( textStyle . textStroke == null ) { textStyle . textStroke = autoColor ; textStyle . textStrokeWidth == null && ( textStyle . textStrokeWidth = 2 ) ; } } else if ( autoColor != null ) { insideRollback = { textFill : null } ; textStyle . textFill = autoColor ; } // Always set `insideRollback`, for clearing previous. if ( insideRollback ) { textStyle . insideRollback = insideRollback ; } }
Give some default value to the input `textStyle` object, based on the current settings
in this `textStyle` object.

The Scenario:
when text position is `inside` and `textFill` is not specified, we show
text border by default for better view. But it should be considered that text position
might be changed when hovering or being emphasis, where the `insideRollback` is used to
restore the style.

Usage (& NOTICE):
When a style object (eithor plain object or instance of `zrender/src/graphic/Style`) is
about to be modified on its text related properties, `rollbackDefaultTextStyle` should
be called before the modification and `applyDefaultTextStyle` should be called after that.
(For the case that all of the text related properties is reset, like `setTextStyleCommon`
does, `rollbackDefaultTextStyle` is not needed to be called).
Give some default value to the input textStyle object based on the current settings in this textStyle object .