@@ -619,7 +619,7 @@ drawing.savedBBoxes = {};
619
619
var savedBBoxesCount = 0 ;
620
620
var maxSavedBBoxes = 10000 ;
621
621
622
- drawing . bBox = function ( node ) {
622
+ drawing . bBox = function ( node , hash ) {
623
623
/*
624
624
* Cache elements we've already measured so we don't have to
625
625
* remeasure the same thing many times
@@ -628,16 +628,16 @@ drawing.bBox = function(node) {
628
628
* These will not generate a hash (unless we figure out an appropriate
629
629
* hash key for them) and thus we will not hash them.
630
630
*/
631
- var hash = nodeHash ( node ) ;
631
+ if ( ! hash ) hash = nodeHash ( node ) ;
632
632
var out ;
633
633
if ( hash ) {
634
634
out = drawing . savedBBoxes [ hash ] ;
635
635
if ( out ) return Lib . extendFlat ( { } , out ) ;
636
636
}
637
637
else if ( node . children . length === 1 ) {
638
638
/*
639
- * If we have only one child element, make a new hash from this element
640
- * plus its x,y,transform
639
+ * If we have only one child element, which is itself hashable, make
640
+ * a new hash from this element plus its x,y,transform
641
641
* These bounding boxes *include* x,y,transform - mostly for use by
642
642
* callers trying to avoid overlaps (ie titles)
643
643
*/
@@ -647,12 +647,12 @@ drawing.bBox = function(node) {
647
647
if ( hash ) {
648
648
var x = + innerNode . getAttribute ( 'x' ) || 0 ;
649
649
var y = + innerNode . getAttribute ( 'y' ) || 0 ;
650
- var transform = innerNode . getAttribute ( 'transform' ) || '' ;
650
+ var transform = innerNode . getAttribute ( 'transform' ) ;
651
651
652
652
if ( ! transform ) {
653
653
// in this case, just varying x and y, don't bother caching
654
- // because the alteration is simple .
655
- var innerBB = drawing . bBox ( innerNode ) ;
654
+ // the final bBox because the alteration is quick .
655
+ var innerBB = drawing . bBox ( innerNode , hash ) ;
656
656
if ( x ) {
657
657
innerBB . left += x ;
658
658
innerBB . right += x ;
0 commit comments