Bug 970257 - Make <input type=number> handle auto width properly. r=dholbert

This commit is contained in:
Jonathan Watt 2014-02-12 02:54:14 +00:00
parent 2e8e4d644d
commit c3528016ca
5 changed files with 59 additions and 0 deletions

View File

@ -60,6 +60,42 @@ nsNumberControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsContainerFrame::DestroyFrom(aDestructRoot);
}
nscoord
nsNumberControlFrame::GetMinWidth(nsRenderingContext* aRenderingContext)
{
nscoord result;
DISPLAY_MIN_WIDTH(this, result);
nsIFrame* kid = mFrames.FirstChild();
if (kid) { // display:none?
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
kid,
nsLayoutUtils::MIN_WIDTH);
} else {
result = 0;
}
return result;
}
nscoord
nsNumberControlFrame::GetPrefWidth(nsRenderingContext* aRenderingContext)
{
nscoord result;
DISPLAY_PREF_WIDTH(this, result);
nsIFrame* kid = mFrames.FirstChild();
if (kid) { // display:none?
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
kid,
nsLayoutUtils::PREF_WIDTH);
} else {
result = 0;
}
return result;
}
nsresult
nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -50,6 +50,10 @@ public:
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
#endif
virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
virtual nsresult Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<input type="text" style="-moz-appearance:none; width:auto;">
<!-- div to cover spin box area -->
<div style="display:block; position:absolute; background-color:black; width:2000px; height:100px; top:0px; left:100px;">
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<input type="number" style="-moz-appearance:none; width:auto;">
<!-- div to cover spin box area -->
<div style="display:block; position:absolute; background-color:black; width:2000px; height:100px; top:0px; left:100px;">
</body>
</html>

View File

@ -20,6 +20,9 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63
# disabled
== number-disabled.html number-disabled-ref.html
# auto width:
== number-auto-width-1.html number-auto-width-1-ref.html
# min-height/max-height tests:
skip-if(B2G) == number-min-height-1.html number-min-height-1-ref.html
skip-if(B2G) == number-min-height-2.html number-min-height-2-ref.html