From d6ed23984b193705b3c22df2b8f2087f431103af Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Tue, 5 Jun 2012 22:15:46 +0200 Subject: [PATCH] Bug 686886 - Port bug 680747 and bug 680518 to nsMeterFrame. r=roc --- layout/forms/nsMeterFrame.cpp | 25 ++++++++++++++++++- layout/forms/nsMeterFrame.h | 3 +++ .../forms/meter/block-invalidate-ref.html | 10 ++++++++ .../forms/meter/block-invalidate.html | 19 ++++++++++++++ layout/reftests/forms/meter/in-cells-ref.html | 22 ++++++++++++++++ layout/reftests/forms/meter/in-cells.html | 21 ++++++++++++++++ layout/reftests/forms/meter/reftest.list | 4 +++ .../reftests/forms/progress/in-cells-ref.html | 4 +-- layout/reftests/forms/progress/in-cells.html | 4 +-- 9 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 layout/reftests/forms/meter/block-invalidate-ref.html create mode 100644 layout/reftests/forms/meter/block-invalidate.html create mode 100644 layout/reftests/forms/meter/in-cells-ref.html create mode 100644 layout/reftests/forms/meter/in-cells.html diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index 4c66ae2a30a5..8d675c43cbca 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -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 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 { diff --git a/layout/forms/nsMeterFrame.h b/layout/forms/nsMeterFrame.h index c2f3f555770a..d3bc6316eede 100644 --- a/layout/forms/nsMeterFrame.h +++ b/layout/forms/nsMeterFrame.h @@ -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 & diff --git a/layout/reftests/forms/meter/block-invalidate-ref.html b/layout/reftests/forms/meter/block-invalidate-ref.html new file mode 100644 index 000000000000..3208c43ef6b7 --- /dev/null +++ b/layout/reftests/forms/meter/block-invalidate-ref.html @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/layout/reftests/forms/meter/block-invalidate.html b/layout/reftests/forms/meter/block-invalidate.html new file mode 100644 index 000000000000..abc98f7f7a6c --- /dev/null +++ b/layout/reftests/forms/meter/block-invalidate.html @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/layout/reftests/forms/meter/in-cells-ref.html b/layout/reftests/forms/meter/in-cells-ref.html new file mode 100644 index 000000000000..aa81938a3df7 --- /dev/null +++ b/layout/reftests/forms/meter/in-cells-ref.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + +
foobar
foobar
+ + diff --git a/layout/reftests/forms/meter/in-cells.html b/layout/reftests/forms/meter/in-cells.html new file mode 100644 index 000000000000..c62510433aed --- /dev/null +++ b/layout/reftests/forms/meter/in-cells.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + +
foobar
foobar
+ + diff --git a/layout/reftests/forms/meter/reftest.list b/layout/reftests/forms/meter/reftest.list index b3dafe4ae2d9..39c77431b33c 100644 --- a/layout/reftests/forms/meter/reftest.list +++ b/layout/reftests/forms/meter/reftest.list @@ -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 diff --git a/layout/reftests/forms/progress/in-cells-ref.html b/layout/reftests/forms/progress/in-cells-ref.html index 5dac7b0fda2c..7002706218f4 100644 --- a/layout/reftests/forms/progress/in-cells-ref.html +++ b/layout/reftests/forms/progress/in-cells-ref.html @@ -9,12 +9,12 @@ - + - +
foo bar
foo bar
diff --git a/layout/reftests/forms/progress/in-cells.html b/layout/reftests/forms/progress/in-cells.html index acfad3c6a44a..fc3614347a73 100644 --- a/layout/reftests/forms/progress/in-cells.html +++ b/layout/reftests/forms/progress/in-cells.html @@ -8,12 +8,12 @@ - + - +
foo bar
foo bar