зеркало из https://github.com/mozilla/pjs.git
Bug 412901. getComputedStyle should return actual border widths (i.e. including round-to-device-pixels that happens during style resolution and layout). r+sr=dbaron
This commit is contained in:
Родитель
4176ec707b
Коммит
862a0747a7
|
@ -2861,16 +2861,11 @@ nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
|
|||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nscoord width;
|
||||
const nsStyleDisplay *disp = GetStyleDisplay();
|
||||
if (mFrame && mFrame->IsThemed(disp)) {
|
||||
nsMargin result;
|
||||
nsPresContext *presContext = mFrame->PresContext();
|
||||
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
|
||||
mFrame, disp->mAppearance,
|
||||
&result);
|
||||
width = presContext->DevPixelsToAppUnits(result.side(aSide));
|
||||
if (mFrame) {
|
||||
FlushPendingReflows();
|
||||
width = mFrame->GetUsedBorder().side(aSide);
|
||||
} else {
|
||||
width = GetStyleBorder()->GetComputedBorderWidth(aSide);
|
||||
width = GetStyleBorder()->GetBorderWidth(aSide);
|
||||
}
|
||||
val->SetAppUnits(width);
|
||||
|
||||
|
|
|
@ -389,15 +389,6 @@ struct nsStyleBorder {
|
|||
return mActualBorder.side(aSide);
|
||||
}
|
||||
|
||||
// Get the computed border width for a particular side, in twips. Note that
|
||||
// this is zero if and only if there is no border to be painted for this
|
||||
// side. That is, this value takes into account the border style and the
|
||||
// value is rounded to the nearest device pixel by NS_ROUND_BORDER_TO_PIXELS.
|
||||
nscoord GetComputedBorderWidth(PRUint8 aSide) const
|
||||
{
|
||||
return mActualBorder.side(aSide) ? mBorder.side(aSide) : 0;
|
||||
}
|
||||
|
||||
PRUint8 GetBorderStyle(PRUint8 aSide) const
|
||||
{
|
||||
NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
|
||||
|
|
|
@ -85,6 +85,7 @@ _TEST_FILES = test_bug74880.html \
|
|||
test_bug391221.html \
|
||||
test_bug397427.html \
|
||||
test_bug405818.html \
|
||||
test_bug412901.html \
|
||||
test_compute_data_with_start_struct.html \
|
||||
test_dont_use_document_colors.html \
|
||||
test_inherit_storage.html \
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=412901
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 412901</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=412901">Mozilla Bug 412901</a>
|
||||
<div id="testDiv" style="width:20px; height:20px; border:solid silver; border-left-width:0.2px; border-right-width:0px; border-top-width:2.3px; border-bottom-width:5.5px;">
|
||||
<div id="testDiv2" style="width:20px; height:20px; border:hidden solid silver; border-left-width:0.2px; border-right-width:0px; border-top-width:2.3px; border-bottom-width:5.5px;">
|
||||
<p id="display"></p>
|
||||
</div>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 412901 **/
|
||||
|
||||
var div = document.getElementById("testDiv");
|
||||
var computedStyle = document.defaultView.getComputedStyle(div, "");
|
||||
// we never round down to 0px, very small widths are rounded up to 1px
|
||||
is(computedStyle.borderLeftWidth, "1px");
|
||||
is(computedStyle.borderRightWidth, "0px");
|
||||
is(computedStyle.borderTopWidth, "2px");
|
||||
is(computedStyle.borderBottomWidth, "6px");
|
||||
|
||||
var div2 = document.getElementById("testDiv2");
|
||||
var computedStyle2 = document.defaultView.getComputedStyle(div2, "");
|
||||
is(computedStyle2.borderLeftWidth, "0px");
|
||||
is(computedStyle2.borderRightWidth, "0px");
|
||||
is(computedStyle2.borderTopWidth, "0px");
|
||||
is(computedStyle2.borderBottomWidth, "0px");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче