Skip to content

Commit

Permalink
more null checks for feathers.layout.Measurements
Browse files Browse the repository at this point in the history
It generally shouldn't be an issue because the IMeasureObject check first, but better to be safe and to encourage best practices for those reading the code
  • Loading branch information
joshtynjala committed Feb 23, 2024
1 parent 9b14451 commit a593cff
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 58 deletions.
8 changes: 4 additions & 4 deletions src/feathers/controls/ActivityIndicator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ActivityIndicator extends FeathersControl {
newMinWidth = 0.0;
if (measureSkin != null) {
newMinWidth = Math.max(measureSkin.minWidth, newMinWidth);
} else if (this._activitySkinMeasurements != null) {
} else if (this._activitySkinMeasurements != null && this._activitySkinMeasurements.minWidth != null) {
newMinWidth = Math.max(this._activitySkinMeasurements.minWidth, newMinWidth);
}
}
Expand All @@ -170,15 +170,15 @@ class ActivityIndicator extends FeathersControl {
newMinHeight = 0.0;
if (measureSkin != null) {
newMinHeight = Math.max(measureSkin.minHeight, newMinHeight);
} else if (this._activitySkinMeasurements != null) {
} else if (this._activitySkinMeasurements != null && this._activitySkinMeasurements.minHeight != null) {
newMinHeight = Math.max(this._activitySkinMeasurements.minHeight, newMinHeight);
}
}
var newMaxWidth = this.explicitMaxWidth;
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._activitySkinMeasurements != null) {
} else if (this._activitySkinMeasurements != null && this._activitySkinMeasurements.maxWidth != null) {
newMaxWidth = this._activitySkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -189,7 +189,7 @@ class ActivityIndicator extends FeathersControl {
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._activitySkinMeasurements != null) {
} else if (this._activitySkinMeasurements != null && this._activitySkinMeasurements.maxHeight != null) {
newMaxHeight = this._activitySkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/BasicButton.hx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class BasicButton extends FeathersControl implements ITriggerView implements ISt
if (needsMinWidth) {
if (measureSkin != null) {
newMinWidth = measureSkin.minWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
newMinWidth = this._backgroundSkinMeasurements.minWidth;
} else {
newMinWidth = 0.0;
Expand All @@ -361,7 +361,7 @@ class BasicButton extends FeathersControl implements ITriggerView implements ISt
if (needsMinHeight) {
if (measureSkin != null) {
newMinHeight = measureSkin.minHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
newMinHeight = this._backgroundSkinMeasurements.minHeight;
} else {
newMinHeight = 0.0;
Expand All @@ -372,7 +372,7 @@ class BasicButton extends FeathersControl implements ITriggerView implements ISt
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxWidth != null) {
newMaxWidth = this._backgroundSkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -383,7 +383,7 @@ class BasicButton extends FeathersControl implements ITriggerView implements ISt
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxHeight != null) {
newMaxHeight = this._backgroundSkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/BasicToggleButton.hx
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class BasicToggleButton extends FeathersControl implements ITriggerView implemen
if (needsMinWidth) {
if (measureSkin != null) {
newMinWidth = measureSkin.minWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
newMinWidth = this._backgroundSkinMeasurements.minWidth;
} else {
newMinWidth = 0.0;
Expand All @@ -482,7 +482,7 @@ class BasicToggleButton extends FeathersControl implements ITriggerView implemen
if (needsMinHeight) {
if (measureSkin != null) {
newMinHeight = measureSkin.minHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
newMinHeight = this._backgroundSkinMeasurements.minHeight;
} else {
newMinHeight = 0.0;
Expand All @@ -492,7 +492,7 @@ class BasicToggleButton extends FeathersControl implements ITriggerView implemen
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxWidth != null) {
newMaxWidth = this._backgroundSkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -503,7 +503,7 @@ class BasicToggleButton extends FeathersControl implements ITriggerView implemen
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxHeight != null) {
newMaxHeight = this._backgroundSkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/Button.hx
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class Button extends BasicButton implements ITextControl implements IHTMLTextCon
newMinWidth += this.paddingLeft + this.paddingRight;
if (measureSkin != null) {
newMinWidth = Math.max(measureSkin.minWidth, newMinWidth);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
newMinWidth = Math.max(this._backgroundSkinMeasurements.minWidth, newMinWidth);
}
}
Expand All @@ -843,15 +843,15 @@ class Button extends BasicButton implements ITextControl implements IHTMLTextCon
newMinHeight += this.paddingTop + this.paddingBottom;
if (measureSkin != null) {
newMinHeight = Math.max(measureSkin.minHeight, newMinHeight);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
newMinHeight = Math.max(this._backgroundSkinMeasurements.minHeight, newMinHeight);
}
}
var newMaxWidth = this.explicitMaxWidth;
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxWidth != null) {
newMaxWidth = this._backgroundSkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -862,7 +862,7 @@ class Button extends BasicButton implements ITextControl implements IHTMLTextCon
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxHeight != null) {
newMaxHeight = this._backgroundSkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/Callout.hx
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ class Callout extends FeathersControl {
var contentMinWidth = 0.0;
if (measureContent != null) {
contentMinWidth = measureContent.minWidth;
} else if (this._contentMeasurements != null) {
} else if (this._contentMeasurements != null && this._contentMeasurements.minWidth != null) {
contentMinWidth = this._contentMeasurements.minWidth;
}
if (contentMinWidth < topOrBottomArrowWidth) {
Expand All @@ -1005,7 +1005,7 @@ class Callout extends FeathersControl {
var backgroundMinWidth = 0.0;
if (measureSkin != null) {
backgroundMinWidth = measureSkin.minWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
backgroundMinWidth = this._backgroundSkinMeasurements.minWidth;
}
if (newMinWidth < backgroundMinWidth) {
Expand All @@ -1021,7 +1021,7 @@ class Callout extends FeathersControl {
var contentMinHeight = 0.0;
if (measureContent != null) {
contentMinHeight = measureContent.minWidth;
} else if (this._contentMeasurements != null) {
} else if (this._contentMeasurements != null && this._contentMeasurements.minHeight != null) {
contentMinHeight = this._contentMeasurements.minHeight;
}
if (contentMinHeight < leftOrRightArrowHeight) {
Expand All @@ -1031,7 +1031,7 @@ class Callout extends FeathersControl {
var backgroundMinHeight = 0.0;
if (measureSkin != null) {
backgroundMinHeight = measureSkin.minHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
backgroundMinHeight = this._backgroundSkinMeasurements.minHeight;
}
if (newMinHeight < backgroundMinHeight) {
Expand Down
16 changes: 12 additions & 4 deletions src/feathers/controls/Drawer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -556,32 +556,40 @@ class Drawer extends FeathersControl implements IOpenCloseToggle implements IFoc
if (needsMinWidth) {
if (measureContent != null) {
newMinWidth = measureContent.minWidth;
} else if (this._contentMeasurements != null) {
} else if (this._contentMeasurements != null && this._contentMeasurements.minWidth != null) {
newMinWidth = this._contentMeasurements.minWidth;
} else {
newMinWidth = 0.0;
}
}
var newMinHeight = this.explicitMinHeight;
if (needsMinHeight) {
if (measureContent != null) {
newMinHeight = measureContent.minHeight;
} else if (this._contentMeasurements != null) {
} else if (this._contentMeasurements != null && this._contentMeasurements.minHeight != null) {
newMinHeight = this._contentMeasurements.minHeight;
} else {
newMinHeight = 0.0;
}
}
var newMaxWidth = this.explicitMaxWidth;
if (needsMaxWidth) {
if (measureContent != null) {
newMaxWidth = measureContent.maxWidth;
} else if (this._contentMeasurements != null) {
} else if (this._contentMeasurements != null && this._contentMeasurements.maxWidth != null) {
newMaxWidth = this._contentMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
}
}
var newMaxHeight = this.explicitMaxHeight;
if (needsMaxHeight) {
if (measureContent != null) {
newMaxHeight = measureContent.maxHeight;
} else if (this._contentMeasurements != null) {
} else if (this._contentMeasurements != null && this._contentMeasurements.maxHeight != null) {
newMaxHeight = this._contentMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/FormItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ class FormItem extends FeathersControl implements ITextControl implements IFocus
}
if (measureSkin != null) {
newMinWidth = Math.max(measureSkin.minWidth, newMinWidth);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
newMinWidth = Math.max(this._backgroundSkinMeasurements.minWidth, newMinWidth);
}
}
Expand Down Expand Up @@ -938,15 +938,15 @@ class FormItem extends FeathersControl implements ITextControl implements IFocus
newMinHeight += this.paddingTop + this.paddingBottom;
if (measureSkin != null) {
newMinHeight = Math.max(measureSkin.minHeight, newMinHeight);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
newMinHeight = Math.max(this._backgroundSkinMeasurements.minHeight, newMinHeight);
}
}
var newMaxWidth = this.explicitMaxWidth;
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxWidth != null) {
newMaxWidth = this._backgroundSkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -956,7 +956,7 @@ class FormItem extends FeathersControl implements ITextControl implements IFocus
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxHeight != null) {
newMaxHeight = this._backgroundSkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/Header.hx
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class Header extends FeathersControl implements ITextControl {
}
if (measureSkin != null) {
newMinWidth = Math.max(measureSkin.minWidth, newMinWidth);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
newMinWidth = Math.max(this._backgroundSkinMeasurements.minWidth, newMinWidth);
}
}
Expand All @@ -605,15 +605,15 @@ class Header extends FeathersControl implements ITextControl {
newMinHeight += this.paddingTop + this.paddingBottom;
if (measureSkin != null) {
newMinHeight = Math.max(measureSkin.minHeight, newMinHeight);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
newMinHeight = Math.max(this._backgroundSkinMeasurements.minHeight, newMinHeight);
}
}
var newMaxWidth = this.explicitMaxWidth;
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxWidth != null) {
newMaxWidth = this._backgroundSkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -624,7 +624,7 @@ class Header extends FeathersControl implements ITextControl {
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxHeight != null) {
newMaxHeight = this._backgroundSkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
8 changes: 4 additions & 4 deletions src/feathers/controls/Label.hx
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ class Label extends FeathersControl implements ITextControl implements IHTMLText
newMinWidth = this._textMeasuredWidth + this.paddingLeft + this.paddingRight;
if (measureSkin != null) {
newMinWidth = Math.max(measureSkin.minWidth, newMinWidth);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minWidth != null) {
newMinWidth = Math.max(this._backgroundSkinMeasurements.minWidth, newMinWidth);
}
}
Expand All @@ -649,15 +649,15 @@ class Label extends FeathersControl implements ITextControl implements IHTMLText
newMinHeight = this._textMeasuredHeight + this.paddingTop + this.paddingBottom;
if (measureSkin != null) {
newMinHeight = Math.max(measureSkin.minHeight, newMinHeight);
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.minHeight != null) {
newMinHeight = Math.max(this._backgroundSkinMeasurements.minHeight, newMinHeight);
}
}
var newMaxWidth = this.explicitMaxWidth;
if (needsMaxWidth) {
if (measureSkin != null) {
newMaxWidth = measureSkin.maxWidth;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxWidth != null) {
newMaxWidth = this._backgroundSkinMeasurements.maxWidth;
} else {
newMaxWidth = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand All @@ -668,7 +668,7 @@ class Label extends FeathersControl implements ITextControl implements IHTMLText
if (needsMaxHeight) {
if (measureSkin != null) {
newMaxHeight = measureSkin.maxHeight;
} else if (this._backgroundSkinMeasurements != null) {
} else if (this._backgroundSkinMeasurements != null && this._backgroundSkinMeasurements.maxHeight != null) {
newMaxHeight = this._backgroundSkinMeasurements.maxHeight;
} else {
newMaxHeight = 1.0 / 0.0; // Math.POSITIVE_INFINITY bug workaround for swf
Expand Down
Loading

0 comments on commit a593cff

Please sign in to comment.