(out, hostEl, style, rect)
| 8841 | } |
| 8842 | |
| 8843 | function getBoxPosition(out, hostEl, style, rect) { |
| 8844 | var baseX = style.x || 0; |
| 8845 | var baseY = style.y || 0; |
| 8846 | var textAlign = style.textAlign; |
| 8847 | var textVerticalAlign = style.textVerticalAlign; |
| 8848 | |
| 8849 | // Text position represented by coord |
| 8850 | if (rect) { |
| 8851 | var textPosition = style.textPosition; |
| 8852 | if (textPosition instanceof Array) { |
| 8853 | // Percent |
| 8854 | baseX = rect.x + parsePercent(textPosition[0], rect.width); |
| 8855 | baseY = rect.y + parsePercent(textPosition[1], rect.height); |
| 8856 | } |
| 8857 | else { |
| 8858 | var res = (hostEl && hostEl.calculateTextPosition) |
| 8859 | ? hostEl.calculateTextPosition(_tmpTextPositionResult, style, rect) |
| 8860 | : calculateTextPosition(_tmpTextPositionResult, style, rect); |
| 8861 | baseX = res.x; |
| 8862 | baseY = res.y; |
| 8863 | // Default align and baseline when has textPosition |
| 8864 | textAlign = textAlign || res.textAlign; |
| 8865 | textVerticalAlign = textVerticalAlign || res.textVerticalAlign; |
| 8866 | } |
| 8867 | |
| 8868 | // textOffset is only support in RectText, otherwise |
| 8869 | // we have to adjust boundingRect for textOffset. |
| 8870 | var textOffset = style.textOffset; |
| 8871 | if (textOffset) { |
| 8872 | baseX += textOffset[0]; |
| 8873 | baseY += textOffset[1]; |
| 8874 | } |
| 8875 | } |
| 8876 | |
| 8877 | out = out || {}; |
| 8878 | out.baseX = baseX; |
| 8879 | out.baseY = baseY; |
| 8880 | out.textAlign = textAlign; |
| 8881 | out.textVerticalAlign = textVerticalAlign; |
| 8882 | |
| 8883 | return out; |
| 8884 | } |
| 8885 | |
| 8886 | |
| 8887 | function setCtx(ctx, prop, value) { |
no test coverage detected