mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Fix tests to pass on devices with floating density
Floor measure sizes
This commit is contained in:
@ -600,7 +600,7 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
var margins = horizontal ? view.marginLeft + view.marginRight : view.marginTop + view.marginBottom;
|
||||
margins = Math.round(margins * density);
|
||||
margins = Math.floor(margins * density);
|
||||
|
||||
var resultSize = 0;
|
||||
var resultMode = 0;
|
||||
@ -608,7 +608,7 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
var measureLength = Math.max(0, parentLength - margins);
|
||||
|
||||
// Convert to pixels.
|
||||
var childLength = Math.round((horizontal ? view.width : view.height) * density);
|
||||
var childLength = Math.floor((horizontal ? view.width : view.height) * density);
|
||||
|
||||
// We want a specific size... let be it.
|
||||
if (!isNaN(childLength)) {
|
||||
|
@ -236,6 +236,27 @@ export class View extends viewCommon.View {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number {
|
||||
var result = size;
|
||||
switch (specMode) {
|
||||
case utils.layout.UNSPECIFIED:
|
||||
result = size;
|
||||
break;
|
||||
|
||||
case utils.layout.AT_MOST:
|
||||
if (specSize < size) {
|
||||
result = specSize | utils.layout.MEASURED_STATE_TOO_SMALL;
|
||||
}
|
||||
break;
|
||||
|
||||
case utils.layout.EXACTLY:
|
||||
result = specSize;
|
||||
break;
|
||||
}
|
||||
|
||||
return result | (childMeasuredState & utils.layout.MEASURED_STATE_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
export class CustomLayoutView extends View implements viewDefinition.CustomLayoutView {
|
||||
|
Reference in New Issue
Block a user