Skip to content

Commit 6fc07a3

Browse files
committed
DVF-2444 hidden container problems fixed
1 parent 02c9b30 commit 6fc07a3

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

src/vector/PathBase.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,15 +965,11 @@ acgraph.vector.PathBase.prototype.createDomInternal = function() {
965965
//----------------------------------------------------------------------------------------------------------------------
966966
/** @inheritDoc */
967967
acgraph.vector.PathBase.prototype.renderInternal = function() {
968+
goog.base(this, 'renderInternal');
968969
// If data is unsync - recreate path data attribute
969970
if (this.hasDirtyState(acgraph.vector.Element.DirtyState.DATA)) {
970971
this.renderPath();
971-
if (this.fill() && this.fill()['src']) {
972-
this.setDirtyState(acgraph.vector.Element.DirtyState.FILL);
973-
}
974972
}
975-
976-
goog.base(this, 'renderInternal');
977973
};
978974

979975

src/vector/Shape.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ acgraph.vector.Shape = function() {
2727
*/
2828
this.stroke_ = 'black';
2929

30+
/**
31+
* If the fill or stroke needs update on DATA invalidation.
32+
* 0 - no need, 1 - fill needs to be update, 2 - stroke, 3 - both.
33+
* @type {number}
34+
* @private
35+
*/
36+
this.boundsAffectedColors_ = 0;
37+
3038
goog.base(this);
3139
};
3240
goog.inherits(acgraph.vector.Shape, acgraph.vector.Element);
@@ -73,7 +81,7 @@ acgraph.vector.Shape.prototype.fill = function(opt_fillOrColorOrKeys, opt_opacit
7381
// TODO(Anton Saukh): comparison must be more complex here
7482
if (this.fill_ != newFill) {
7583
this.fill_ = newFill;
76-
// Flag to show that fill changed
84+
this.boundsAffectedColors_ = (this.boundsAffectedColors_ & 2) | !!(newFill['mode'] || newFill['src']);
7785
this.setDirtyState(acgraph.vector.Element.DirtyState.FILL);
7886
}
7987
return this;
@@ -98,7 +106,7 @@ acgraph.vector.Shape.prototype.stroke = function(opt_strokeOrFill, opt_thickness
98106
// TODO(Anton Saukh): comparison must be more complex here
99107
if (this.stroke_ != newStroke) {
100108
this.stroke_ = /** @type {acgraph.vector.Stroke} */(newStroke);
101-
// set flag that stroke has changed
109+
this.boundsAffectedColors_ = (this.boundsAffectedColors_ & 1) | (newStroke['mode'] << 1);
102110
this.setDirtyState(acgraph.vector.Element.DirtyState.STROKE);
103111
}
104112
return this;
@@ -138,6 +146,13 @@ acgraph.vector.Shape.prototype.strokeThickness = function(opt_value) {
138146
//----------------------------------------------------------------------------------------------------------------------
139147
/** @inheritDoc */
140148
acgraph.vector.Shape.prototype.renderInternal = function() {
149+
if (this.boundsAffectedColors_ && this.hasDirtyState(acgraph.vector.Element.DirtyState.DATA)) {
150+
if (!!(this.boundsAffectedColors_ & 1))
151+
this.setDirtyState(acgraph.vector.Element.DirtyState.FILL);
152+
if (!!(this.boundsAffectedColors_ & 2))
153+
this.setDirtyState(acgraph.vector.Element.DirtyState.STROKE);
154+
}
155+
141156
goog.base(this, 'renderInternal');
142157

143158
// Apply stroke and fill settings if they were changed

src/vector/Text.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,11 @@ acgraph.vector.Text.prototype.transformAfterChange = function() {
515515
*/
516516
acgraph.vector.Text.prototype.width = function(opt_value) {
517517
if (goog.isDef(opt_value)) {
518-
if (this.setStyleProperty('width') != opt_value)
519-
this.width_ = opt_value = (Math.max(opt_value, 0) || 0);
518+
if (this.setStyleProperty('width') != opt_value) {
519+
if (!goog.isNull(opt_value))
520+
opt_value = (Math.max(opt_value, 0) || 0);
521+
this.width_ = opt_value;
522+
}
520523
}
521524
return /** @type {number|string|acgraph.vector.Text} */ (this.setStyleProperty('width', opt_value));
522525
};
@@ -532,7 +535,9 @@ acgraph.vector.Text.prototype.width = function(opt_value) {
532535
acgraph.vector.Text.prototype.height = function(opt_value) {
533536
if (goog.isDef(opt_value)) {
534537
if (this.setStyleProperty('height') != opt_value)
535-
this.height_ = opt_value = (Math.max(opt_value, 0) || 0);
538+
if (!goog.isNull(opt_value))
539+
opt_value = (Math.max(opt_value, 0) || 0);
540+
this.height_ = opt_value;
536541
}
537542
return /** @type {number|string|acgraph.vector.Text} */ (this.setStyleProperty('height', opt_value));
538543
};

0 commit comments

Comments
 (0)