Bug 947728 part 2 - Make |-moz-appearance:number-input| the UA style sheet default for <input type=number>, and make the value 'textfield' hide the spinner. r=roc

This commit is contained in:
Jonathan Watt 2013-12-08 23:26:07 +00:00
parent 57fa4cd151
commit 2851981a72
3 changed files with 33 additions and 0 deletions

View File

@ -280,6 +280,12 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
fm->SetFocus(element, 0);
}
if (StyleDisplay()->mAppearance == NS_THEME_TEXTFIELD) {
// The author has elected to hide the spinner by setting this
// -moz-appearance. We will reframe if it changes.
return rv;
}
// Create the ::-moz-number-spin-box pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
outerWrapperCI.mChildren,
@ -368,6 +374,10 @@ nsNumberControlFrame::GetSpinButtonForPointerEvent(WidgetGUIEvent* aEvent) const
MOZ_ASSERT(aEvent->eventStructType == NS_MOUSE_EVENT,
"Unexpected event type");
if (!mSpinBox) {
// we don't have a spinner
return eSpinButtonNone;
}
if (aEvent->originalTarget == mSpinUp) {
return eSpinButtonUp;
}
@ -398,6 +408,9 @@ nsNumberControlFrame::GetSpinButtonForPointerEvent(WidgetGUIEvent* aEvent) const
void
nsNumberControlFrame::SpinnerStateChanged() const
{
MOZ_ASSERT(mSpinUp && mSpinDown,
"We should not be called when we have no spinner");
nsIFrame* spinUpFrame = mSpinUp->GetPrimaryFrame();
if (spinUpFrame && spinUpFrame->IsThemed()) {
spinUpFrame->InvalidateFrame();
@ -449,6 +462,9 @@ nsNumberControlFrame::HandleFocusEvent(WidgetEvent* aEvent)
bool
nsNumberControlFrame::ShouldUseNativeStyleForSpinner() const
{
MOZ_ASSERT(mSpinUp && mSpinDown,
"We should not be called when we have no spinner");
nsIFrame* spinUpFrame = mSpinUp->GetPrimaryFrame();
nsIFrame* spinDownFrame = mSpinDown->GetPrimaryFrame();
@ -504,14 +520,17 @@ nsNumberControlFrame::GetPseudoElement(nsCSSPseudoElements::Type aType)
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberSpinBox) {
MOZ_ASSERT(mSpinBox);
return mSpinBox;
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp) {
MOZ_ASSERT(mSpinUp);
return mSpinUp;
}
if (aType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown) {
MOZ_ASSERT(mSpinDown);
return mSpinDown;
}

View File

@ -887,6 +887,7 @@ input[type=range]::-moz-range-thumb {
}
input[type="number"] {
-moz-appearance: number-input;
/* Has to revert some properties applied by the generic input rule. */
-moz-binding: none;
width: 149px; /* to match type=text */

View File

@ -2420,6 +2420,19 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
|| mResize != aOther.mResize)
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
if ((mAppearance == NS_THEME_TEXTFIELD &&
aOther.mAppearance != NS_THEME_TEXTFIELD) ||
(mAppearance != NS_THEME_TEXTFIELD &&
aOther.mAppearance == NS_THEME_TEXTFIELD)) {
// This is for <input type=number> where we allow authors to specify a
// |-moz-appearance:textfield| to get a control without a spinner. (The
// spinner is present for |-moz-appearance:number-input| but also other
// values such as 'none'.) We need to reframe since we want to use
// nsTextControlFrame instead of nsNumberControlFrame if the author
// specifies 'textfield'.
return nsChangeHint_ReconstructFrame;
}
if (mFloats != aOther.mFloats) {
// Changing which side we float on doesn't affect descendants directly
NS_UpdateHint(hint,