提交 9cfa175b 编写于 作者: P prr

8048583: CustomMediaSizeName class matching to standard media is too loose

Reviewed-by: bae, jgodinez
上级 879eac46
...@@ -67,6 +67,22 @@ class CustomMediaSizeName extends MediaSizeName { ...@@ -67,6 +67,22 @@ class CustomMediaSizeName extends MediaSizeName {
MediaSize.INCH); MediaSize.INCH);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
} }
// The public API method finds a closest match even if it not
// all that close. Here we want to be sure its *really* close.
if (mediaName != null) {
MediaSize sz = MediaSize.getMediaSizeForName(mediaName);
if (sz == null) {
mediaName = null;
} else {
float w = sz.getX(MediaSize.INCH);
float h = sz.getY(MediaSize.INCH);
float dw = Math.abs(w - width);
float dh = Math.abs(h - length);
if (dw > 0.1 || dh > 0.1) {
mediaName = null;
}
}
}
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册