Skip to content

Commit 858c37b

Browse files
committed
DVF-3144-nodejs-export-server
1 parent e71762c commit 858c37b

File tree

10 files changed

+59
-19
lines changed

10 files changed

+59
-19
lines changed

build.py

100755100644
File mode changed.

src/vector/Clip.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ acgraph.vector.Clip.prototype.addChild = function(child) {
278278
child.remove();
279279
child.setParent(this);
280280
this.needUpdateClip_();
281+
child.notifyPrevParent(true);
281282
return this;
282283
};
283284

@@ -292,6 +293,7 @@ acgraph.vector.Clip.prototype.removeChild = function(element) {
292293
if (dom)
293294
goog.dom.removeNode(dom);
294295
this.needUpdateClip_();
296+
element.notifyPrevParent(false);
295297
return element;
296298
};
297299

src/vector/Defs.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,23 @@ acgraph.vector.Defs.prototype.disposeInternal = function() {
371371
goog.dom.removeNode(this.domElement_);
372372
this.domElement_ = null;
373373

374-
goog.disposeAll(this.linearGradients_);
375-
goog.disposeAll(this.radialGradients_);
376-
goog.disposeAll(this.imageFills_);
377-
// goog.disposeAll(this.hatchFills_);
374+
goog.object.forEach(this.linearGradients_, function(v) {
375+
goog.dispose(v);
376+
});
377+
goog.object.forEach(this.radialGradients_, function(v) {
378+
goog.dispose(v);
379+
});
380+
goog.object.forEach(this.imageFills_, function(v) {
381+
goog.dispose(v);
382+
});
383+
goog.object.forEach(this.hatchFills_, function(v) {
384+
goog.dispose(v);
385+
});
386+
387+
this.linearGradients_ = null;
388+
this.radialGradients_ = null;
389+
this.imageFills_ = null;
390+
this.hatchFills_ = null;
378391

379392
delete this.stage;
380393
};

src/vector/Element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,10 +1724,10 @@ acgraph.vector.Element.prototype.disposeInternal = function() {
17241724
/**
17251725
* Finalizes object removal. If object is in DOM, must be called finilizing any
17261726
* operations with an element.
1727-
* @protected
17281727
*/
17291728
acgraph.vector.Element.prototype.finalizeDisposing = function() {
17301729
goog.dispose(this.handler_);
1730+
17311731
this.handler_ = null;
17321732

17331733
this.setParent(null);

src/vector/HatchFill.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,11 @@ acgraph.vector.HatchFill.prototype.rectHelper_ = function(w, h, opt_l, opt_t) {
369369
* @private
370370
*/
371371
acgraph.vector.HatchFill.prototype.pathHelper_ = function(opt_filled) {
372-
return /** @type {acgraph.vector.Path} */(opt_filled ?
372+
var path = /** @type {acgraph.vector.Path} */(opt_filled ?
373373
this.path().fill(this.color).stroke('none') :
374374
this.path().fill('none').stroke(this.color, this.thickness));
375+
// this.registerDisposable(/** @type {goog.disposable.IDisposable} */(path));
376+
return /** @type {acgraph.vector.Path} */(path);
375377
};
376378

377379

@@ -382,6 +384,7 @@ acgraph.vector.HatchFill.prototype.pathHelper_ = function(opt_filled) {
382384
*/
383385
acgraph.vector.HatchFill.prototype.onePixelRects_ = function(positions, opt_color) {
384386
var path = this.path().fill(opt_color || this.color).stroke('none');
387+
// this.registerDisposable(/** @type {goog.disposable.IDisposable} */(path));
385388
for (var i = 0; i < positions.length; i += 2) {
386389
var x = positions[i];
387390
var y = positions[i + 1];
@@ -427,10 +430,10 @@ acgraph.vector.HatchFill.prototype.getElementTypePrefix = function() {
427430
//----------------------------------------------------------------------------------------------------------------------
428431
/** @inheritDoc */
429432
acgraph.vector.HatchFill.prototype.disposeInternal = function() {
430-
goog.base(this, 'disposeInternal');
431-
432433
if (this.getStage())
433434
this.getStage().getDefs().removeHatchFill(this);
435+
436+
goog.base(this, 'disposeInternal');
434437
};
435438

436439

src/vector/Renderer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,21 @@ acgraph.vector.Renderer.prototype.isImageLoading = function() {
628628
* @return {goog.net.ImageLoader} .
629629
*/
630630
acgraph.vector.Renderer.prototype.getImageLoader = function() {
631-
if (!this.imageLoader_)
631+
if (!this.imageLoader_ || this.imageLoader_.isDisposed())
632632
this.imageLoader_ = new goog.net.ImageLoader(/** @type {Element} */(goog.global['document']['body']));
633633
return this.imageLoader_;
634634
};
635635

636636

637+
/**
638+
* Whether is image loader.
639+
* @return {boolean}
640+
*/
641+
acgraph.vector.Renderer.prototype.isImageLoader = function() {
642+
return !!(this.imageLoader_ && !this.imageLoader_.isDisposed());
643+
};
644+
645+
637646
//region --- Section Transformations ---
638647
//----------------------------------------------------------------------------------------------------------------------
639648
//

src/vector/Stage.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ acgraph.vector.Stage.prototype.checkSize = function(opt_directCall, opt_silent)
897897
if (!opt_silent)
898898
this.dispatchEvent(acgraph.vector.Stage.EventType.STAGE_RESIZE);
899899
}
900-
if (this.container_ && isDynamicSize && !goog.global['isNodeJS']) {
900+
if (this.container_ && isDynamicSize && !goog.global['acgraph']['isNodeJS']) {
901901
this.checkSizeTimer_ = setTimeout(this.checkSize, this.maxResizeDelay_);
902902
}
903903
};
@@ -1207,12 +1207,14 @@ acgraph.vector.Stage.prototype.finishRendering_ = function() {
12071207
var imageLoader = acgraph.getRenderer().getImageLoader();
12081208
var isImageLoading = acgraph.getRenderer().isImageLoading();
12091209
if (imageLoader && isImageLoading) {
1210-
if (!this.imageLoadingListener_)
1211-
this.imageLoadingListener_ = goog.events.listenOnce(imageLoader, goog.net.EventType.COMPLETE, function(e) {
1212-
this.imageLoadingListener_ = null;
1210+
if (!this.imageLoadingListener_) {
1211+
this.imageLoadingListener_ = true;
1212+
goog.events.listenOnce(imageLoader, goog.net.EventType.COMPLETE, function(e) {
1213+
this.imageLoadingListener_ = false;
12131214
if (!this.isRendering_)
12141215
this.dispatchEvent(acgraph.vector.Stage.EventType.STAGE_RENDERED);
12151216
}, false, this);
1217+
}
12161218
} else {
12171219
this.dispatchEvent(acgraph.vector.Stage.EventType.STAGE_RENDERED);
12181220
}
@@ -2168,15 +2170,25 @@ acgraph.vector.Stage.prototype.dispose = function() {
21682170
acgraph.vector.Stage.prototype.disposeInternal = function() {
21692171
acgraph.vector.Stage.base(this, 'disposeInternal');
21702172

2173+
goog.object.forEach(this.charts, function(value, key, arr) {
2174+
value.remove();
2175+
delete arr[value];
2176+
});
2177+
21712178
goog.dispose(this.eventHandler_);
21722179
this.eventHandler_ = null;
21732180

2181+
goog.dispose(this.defs_);
2182+
delete this.defs_;
2183+
21742184
goog.dispose(this.rootLayer_);
21752185
this.renderInternal();
2186+
2187+
this.rootLayer_.finalizeDisposing();
21762188
delete this.rootLayer_;
21772189

2178-
goog.dispose(this.defs_);
2179-
delete this.defs_;
2190+
var id = acgraph.utils.IdGenerator.getInstance().identify(this, acgraph.utils.IdGenerator.ElementTypePrefix.STAGE);
2191+
delete goog.global['acgraph'].stages[id];
21802192

21812193
acgraph.unregister(this);
21822194

src/vector/Text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ acgraph.vector.Text.prototype.htmlText = function(opt_value) {
965965
*/
966966
acgraph.vector.Text.prototype.init_ = function() {
967967
if (this.segments_.length != 0) {
968+
goog.disposeAll(this.segments_, this.textLines_);
968969
this.textLines_ = [];
969970
this.segments_ = [];
970971
}
@@ -1907,7 +1908,6 @@ acgraph.vector.Text.prototype.disposeInternal = function() {
19071908
delete this.segments_;
19081909
delete this.textLines_;
19091910
delete this.bounds;
1910-
delete this.bounds;
19111911
goog.base(this, 'disposeInternal');
19121912
};
19131913

src/vector/svg/Renderer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,10 @@ acgraph.vector.svg.Renderer.prototype.setPathProperties = function(path) {
13571357
* @private
13581358
*/
13591359
acgraph.vector.svg.Renderer.prototype.createClip_ = function(element, clipElement) {
1360+
var stage = element.getStage();
1361+
// stage.registerDisposable(clipElement);
13601362
/** @type {!acgraph.vector.svg.Defs} */
1361-
var defs = /** @type {!acgraph.vector.svg.Defs} */ (element.getStage().getDefs());
1363+
var defs = /** @type {!acgraph.vector.svg.Defs} */ (stage.getDefs());
13621364
/** @type {Element} */
13631365
var clipDomElement = defs.getClipPathElement(clipElement);
13641366
var id = acgraph.utils.IdGenerator.getInstance().identify(clipDomElement, acgraph.utils.IdGenerator.ElementTypePrefix.CLIP);

src/vector/svg/Stage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ goog.require('acgraph.vector.svg.Defs');
1515
acgraph.vector.svg.Stage = function(opt_container, opt_width, opt_height) {
1616
goog.base(this, opt_container, opt_width, opt_height);
1717
};
18-
goog.inherits(acgraph.vector.svg.Stage,
19-
acgraph.vector.Stage);
18+
goog.inherits(acgraph.vector.svg.Stage, acgraph.vector.Stage);
2019

2120

2221
/** @inheritDoc */

0 commit comments

Comments
 (0)