Bug 686886 - Port bug 680747 and bug 680518 to nsMeterFrame. r=roc

This commit is contained in:
Mounir Lamouri 2012-06-05 22:15:46 +02:00
parent 57ef1552f9
commit b4ff41189c
9 changed files with 107 additions and 5 deletions

View File

@ -245,6 +245,7 @@ nsMeterFrame::AttributeChanged(PRInt32 aNameSpaceID,
PresContext()->PresShell()->FrameNeedsReflow(barFrame,
nsIPresShell::eResize,
NS_FRAME_IS_DIRTY);
Invalidate(GetVisualOverflowRectRelativeToSelf());
}
return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute,
@ -270,10 +271,32 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
} else {
autoSize.width *= 5; // 5em
}
return autoSize;
}
nscoord
nsMeterFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
{
nsRefPtr<nsFontMetrics> fontMet;
NS_ENSURE_SUCCESS(
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), 0);
nscoord minWidth = fontMet->Font().size; // 1em
if (GetStyleDisplay()->mOrient == NS_STYLE_ORIENT_HORIZONTAL) {
minWidth *= 5; // 5em
}
return minWidth;
}
nscoord
nsMeterFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
{
return GetMinWidth(aRenderingContext);
}
bool
nsMeterFrame::ShouldUseNativeStyle() const
{

View File

@ -85,6 +85,9 @@ public:
nsSize aMargin, nsSize aBorder,
nsSize aPadding, bool aShrinkWrap);
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
virtual bool IsFrameOfType(PRUint32 aFlags) const
{
return nsContainerFrame::IsFrameOfType(aFlags &

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<link rel='stylesheet' type='text/css' href='style.css'>
<style>
meter { display: block; }
</style>
<body>
<meter value='0.5'></meter>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html class='reftest-wait'>
<link rel='stylesheet' type='text/css' href='style.css'>
<style>
meter { display: block; }
</style>
<script>
function loadHandler() {
setTimeout(function() {
var p = document.getElementsByTagName('meter')[0];
p.value = '0.5';
document.documentElement.className = '';
}, 0);
}
</script>
<body onload="loadHandler();">
<meter value='0'></meter>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<link rel='stylesheet' type='text/css' href='style.css'>
<style>
meter { width: 5em; height: 1em; }
meter.vertical { -moz-orient: vertical; width: 1em; height: 5em; }
</style>
<body>
<table>
<tr>
<td>foo</td>
<td><meter value='0.5'></meter></td>
<td>bar</td>
</tr>
<tr>
<td>foo</td>
<td><meter class='vertical' value='0.5'></meter></td>
<td>bar</td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<link rel='stylesheet' type='text/css' href='style.css'>
<style>
meter.vertical { -moz-orient: vertical; }
</style>
<body>
<table>
<tr>
<td>foo</td>
<td><meter value='0.5'></meter></td>
<td>bar</td>
</tr>
<tr>
<td>foo</td>
<td><meter class='vertical' value='0.5'></meter></td>
<td>bar</td>
</tr>
</table>
</body>
</html>

View File

@ -20,3 +20,7 @@
# default style
include default-style/reftest.list
# Tests for bugs:
== block-invalidate.html block-invalidate-ref.html
== in-cells.html in-cells-ref.html

View File

@ -9,12 +9,12 @@
<table>
<tr>
<td>foo</td>
<td><progress value='0.5'></td>
<td><progress value='0.5'></progress></td>
<td>bar</td>
</tr>
<tr>
<td>foo</td>
<td><progress class='vertical' value='0.5'></td>
<td><progress class='vertical' value='0.5'></progress></td>
<td>bar</td>
</tr>
</table>

View File

@ -8,12 +8,12 @@
<table>
<tr>
<td>foo</td>
<td><progress value='0.5'></td>
<td><progress value='0.5'></progress></td>
<td>bar</td>
</tr>
<tr>
<td>foo</td>
<td><progress class='vertical' value='0.5'></td>
<td><progress class='vertical' value='0.5'></progress></td>
<td>bar</td>
</tr>
</table>