mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
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:
parent
57fa4cd151
commit
2851981a72
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user