diff --git a/tns-core-modules/ui/border/border.ts b/tns-core-modules/ui/border/border.ts index c77fd7e63..0b550dd47 100644 --- a/tns-core-modules/ui/border/border.ts +++ b/tns-core-modules/ui/border/border.ts @@ -14,21 +14,21 @@ export class Border extends ContentView implements BorderDefinition { } public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { - let width = layout.getMeasureSpecSize(widthMeasureSpec); - let widthMode = layout.getMeasureSpecMode(widthMeasureSpec); + const width = layout.getMeasureSpecSize(widthMeasureSpec); + const widthMode = layout.getMeasureSpecMode(widthMeasureSpec); - let height = layout.getMeasureSpecSize(heightMeasureSpec); - let heightMode = layout.getMeasureSpecMode(heightMeasureSpec); + const height = layout.getMeasureSpecSize(heightMeasureSpec); + const heightMode = layout.getMeasureSpecMode(heightMeasureSpec); - let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth; - let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth; + const horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth; + const verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth; - let result = View.measureChild(this, this.layoutView, + const result = View.measureChild(this, this.layoutView, layout.makeMeasureSpec(width - horizontalBorderLength, widthMode), layout.makeMeasureSpec(height - verticalBorderLength, heightMode)); - let widthAndState = View.resolveSizeAndState(result.measuredWidth + horizontalBorderLength, width, widthMode, 0); - let heightAndState = View.resolveSizeAndState(result.measuredHeight + verticalBorderLength, height, heightMode, 0); + const widthAndState = View.resolveSizeAndState(result.measuredWidth + horizontalBorderLength, width, widthMode, 0); + const heightAndState = View.resolveSizeAndState(result.measuredHeight + verticalBorderLength, height, heightMode, 0); this.setMeasuredDimension(widthAndState, heightAndState); } diff --git a/tns-core-modules/ui/content-view/content-view.ts b/tns-core-modules/ui/content-view/content-view.ts index 6fd4a4ced..739fc4ff8 100644 --- a/tns-core-modules/ui/content-view/content-view.ts +++ b/tns-core-modules/ui/content-view/content-view.ts @@ -69,19 +69,19 @@ export class ContentView extends CustomLayoutView implements ContentViewDefiniti // This method won't be called in Android because we use the native android layout. public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { - let result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightMeasureSpec); + const result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightMeasureSpec); - let width = layout.getMeasureSpecSize(widthMeasureSpec); - let widthMode = layout.getMeasureSpecMode(widthMeasureSpec); + const width = layout.getMeasureSpecSize(widthMeasureSpec); + const widthMode = layout.getMeasureSpecMode(widthMeasureSpec); - let height = layout.getMeasureSpecSize(heightMeasureSpec); - let heightMode = layout.getMeasureSpecMode(heightMeasureSpec); + const height = layout.getMeasureSpecSize(heightMeasureSpec); + const heightMode = layout.getMeasureSpecMode(heightMeasureSpec); - let measureWidth = Math.max(result.measuredWidth, this.effectiveMinWidth); - let measureHeight = Math.max(result.measuredHeight, this.effectiveMinHeight); + const measureWidth = Math.max(result.measuredWidth, this.effectiveMinWidth); + const measureHeight = Math.max(result.measuredHeight, this.effectiveMinHeight); - let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0); - let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0); + const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0); + const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0); this.setMeasuredDimension(widthAndState, heightAndState); } diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index b199a10e7..9b96e025c 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -459,21 +459,21 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { let result = size; switch (specMode) { case layout.UNSPECIFIED: - result = size; + result = Math.ceil(size); break; case layout.AT_MOST: if (specSize < size) { - result = Math.round(specSize + 0.499) | layout.MEASURED_STATE_TOO_SMALL; + result = Math.ceil(specSize) | layout.MEASURED_STATE_TOO_SMALL; } break; case layout.EXACTLY: - result = specSize; + result = Math.ceil(specSize); break; } - return Math.round(result + 0.499) | (childMeasuredState & layout.MEASURED_STATE_MASK); + return result | (childMeasuredState & layout.MEASURED_STATE_MASK); } public static combineMeasuredStates(curState: number, newState): number { diff --git a/tns-core-modules/ui/html-view/html-view.ios.ts b/tns-core-modules/ui/html-view/html-view.ios.ts index efc4ee060..58de0f3d6 100644 --- a/tns-core-modules/ui/html-view/html-view.ios.ts +++ b/tns-core-modules/ui/html-view/html-view.ios.ts @@ -29,7 +29,6 @@ export class HtmlView extends HtmlViewBase { public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { var nativeView = this._nativeView; if (nativeView) { - const width = layout.getMeasureSpecSize(widthMeasureSpec); const widthMode = layout.getMeasureSpecMode(widthMeasureSpec); @@ -38,7 +37,7 @@ export class HtmlView extends HtmlViewBase { const desiredSize = layout.measureNativeView(nativeView, width, widthMode, height, heightMode); - const labelWidth = Math.min(desiredSize.width, width); + const labelWidth = widthMode === layout.AT_MOST ? Math.min(desiredSize.width, width) : desiredSize.width; const measureWidth = Math.max(labelWidth, this.effectiveMinWidth); const measureHeight = Math.max(desiredSize.height, this.effectiveMinHeight); diff --git a/tns-core-modules/ui/label/label.ios.ts b/tns-core-modules/ui/label/label.ios.ts index c7dd33b61..e54523393 100644 --- a/tns-core-modules/ui/label/label.ios.ts +++ b/tns-core-modules/ui/label/label.ios.ts @@ -67,11 +67,11 @@ export class Label extends TextBase implements LabelDefinition { public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { let nativeView = this.nativeView; if (nativeView) { - let width = layout.getMeasureSpecSize(widthMeasureSpec); - let widthMode = layout.getMeasureSpecMode(widthMeasureSpec); + const width = layout.getMeasureSpecSize(widthMeasureSpec); + const widthMode = layout.getMeasureSpecMode(widthMeasureSpec); - let height = layout.getMeasureSpecSize(heightMeasureSpec); - let heightMode = layout.getMeasureSpecMode(heightMeasureSpec); + const height = layout.getMeasureSpecSize(heightMeasureSpec); + const heightMode = layout.getMeasureSpecMode(heightMeasureSpec); this._fixedSize = (widthMode === layout.EXACTLY ? FixedSize.WIDTH : FixedSize.NONE) | (heightMode === layout.EXACTLY ? FixedSize.HEIGHT : FixedSize.NONE); @@ -79,15 +79,15 @@ export class Label extends TextBase implements LabelDefinition { const nativeSize = layout.measureNativeView(nativeView, width, widthMode, height, heightMode); let labelWidth = nativeSize.width; - if (this.textWrap) { + if (this.textWrap && widthMode === layout.AT_MOST) { labelWidth = Math.min(labelWidth, width); } - let measureWidth = Math.max(labelWidth, this.effectiveMinWidth); - let measureHeight = Math.max(nativeSize.height, this.effectiveMinHeight); + const measureWidth = Math.max(labelWidth, this.effectiveMinWidth); + const measureHeight = Math.max(nativeSize.height, this.effectiveMinHeight); - let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0); - let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0); + const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0); + const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0); this.setMeasuredDimension(widthAndState, heightAndState); } diff --git a/tns-core-modules/utils/utils.ios.ts b/tns-core-modules/utils/utils.ios.ts index 1439ddca6..7800e5f72 100644 --- a/tns-core-modules/utils/utils.ios.ts +++ b/tns-core-modules/utils/utils.ios.ts @@ -16,7 +16,7 @@ export module layout { var MODE_MASK = 0x3 << MODE_SHIFT; export function makeMeasureSpec(size: number, mode: number): number { - return (Math.round(size) & ~MODE_MASK) | (mode & MODE_MASK); + return (Math.round(Math.max(0, size)) & ~MODE_MASK) | (mode & MODE_MASK); } export function getDisplayDensity(): number {