File tree 1 file changed +20
-4
lines changed
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -10,25 +10,41 @@ var utils = {
10
10
} ,
11
11
12
12
calculateOutputEntrySize : function ( outputEntry ) {
13
+ if ( outputEntry . size ) {
14
+ return outputEntry . size ;
15
+ }
16
+
17
+ var size ;
13
18
switch ( outputEntry . style ) {
14
19
case 'text' :
15
- return { width : String ( outputEntry . args . content ) . length , height : 1 } ;
20
+ size = { width : String ( outputEntry . args . content ) . length , height : 1 } ;
21
+ break ;
16
22
case 'block' :
17
- return utils . calculateSize ( outputEntry . args ) ;
23
+ size = utils . calculateSize ( outputEntry . args ) ;
24
+ break ;
18
25
case 'raw' :
19
26
var arg = outputEntry . args ;
20
- return { width : arg . width , height : arg . height } ;
21
- default : return { width : 0 , height : 0 } ;
27
+ size = { width : arg . width , height : arg . height } ;
28
+ break ;
29
+ default : size = { width : 0 , height : 0 } ;
22
30
}
31
+
32
+ outputEntry . size = size ;
33
+ return size ;
23
34
} ,
24
35
25
36
calculateLineSize : function ( line ) {
37
+ if ( line . size ) {
38
+ return line . size ;
39
+ }
40
+
26
41
var size = { height : 1 , width : 0 } ;
27
42
line . forEach ( function ( outputEntry ) {
28
43
var outputEntrySize = utils . calculateOutputEntrySize ( outputEntry ) ;
29
44
size . width += outputEntrySize . width ;
30
45
size . height = Math . max ( outputEntrySize . height , size . height ) ;
31
46
} ) ;
47
+ line . size = size ;
32
48
return size ;
33
49
} ,
34
50
You can’t perform that action at this time.
0 commit comments