Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-15099] use default unit for border radius #5310

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,32 @@ protected double getPixels(View parent)
}
return -1;
}

/**
* Calculate and return the number of pixels based on the type
* without rounding or type casting.
* @param parent the parent view used for calculation.
* @return the number of pixels.
*/
public double getPixelsRaw(View parent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is a duplicate of getPixels(View parent). Couldn't we have just just made that method public?

{
switch (units) {
case TypedValue.COMPLEX_UNIT_PX:
case COMPLEX_UNIT_UNDEFINED:
return this.value;
case COMPLEX_UNIT_PERCENT:
return getPercentPixels(parent);
case TypedValue.COMPLEX_UNIT_DIP:
case TypedValue.COMPLEX_UNIT_SP:
return getScaledPixels(parent);
case TypedValue.COMPLEX_UNIT_PT:
case TypedValue.COMPLEX_UNIT_MM:
case COMPLEX_UNIT_CM:
case TypedValue.COMPLEX_UNIT_IN:
return getSizePixels(parent);
}
return -1;
}

/**
* Calculates and returns the number of pixels, depending on the type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,9 @@ private void initializeBorder(KrollDict d, Integer bgColor)
}

if (d.containsKey(TiC.PROPERTY_BORDER_RADIUS)) {
float radius = TiConvert.toFloat(d, TiC.PROPERTY_BORDER_RADIUS, 0f);
TiDimension radiusDim = TiConvert.toTiDimension(d.get(TiC.PROPERTY_BORDER_RADIUS),
TiDimension.TYPE_WIDTH);
float radius = (float) radiusDim.getPixelsRaw(getNativeView());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to be exact about borderRadius why not about borderWidth. Either both values get rounded or neither. Please be consistent. For reference iOS does not round off either values

if (radius > 0f && HONEYCOMB_OR_GREATER) {
disableHWAcceleration();
}
Expand Down