mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 948549 - Make <input type=number> behave and look disabled when the 'disabled' attribute is set or it's inside a disabled fieldset. r=smaug
This commit is contained in:
parent
ec7567b01d
commit
25a2974cc7
@ -150,11 +150,24 @@ nsNumberControlFrame::
|
||||
xoffset, yoffset, 0);
|
||||
}
|
||||
|
||||
void
|
||||
nsNumberControlFrame::SyncDisabledState()
|
||||
{
|
||||
nsEventStates eventStates = mContent->AsElement()->State();
|
||||
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
||||
true);
|
||||
} else {
|
||||
mTextField->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
{
|
||||
// nsGkAtoms::disabled is handled by SyncDisabledState
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::placeholder ||
|
||||
aAttribute == nsGkAtoms::readonly ||
|
||||
@ -175,6 +188,14 @@ nsNumberControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||
aModType);
|
||||
}
|
||||
|
||||
void
|
||||
nsNumberControlFrame::ContentStatesChanged(nsEventStates aStates)
|
||||
{
|
||||
if (aStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
nsContentUtils::AddScriptRunner(new SyncDisabledStateEvent(this));
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNumberControlFrame::MakeAnonymousElement(Element** aResult,
|
||||
nsTArray<ContentInfo>& aElements,
|
||||
@ -310,6 +331,9 @@ nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
nsGkAtoms::div,
|
||||
nsCSSPseudoElements::ePseudo_mozNumberSpinDown,
|
||||
spinBoxCI.mStyleContext);
|
||||
|
||||
SyncDisabledState();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
NS_DECL_FRAMEARENA_HELPERS
|
||||
|
||||
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
||||
|
||||
virtual void ContentStatesChanged(nsEventStates aStates);
|
||||
virtual bool IsLeaf() const MOZ_OVERRIDE { return false; }
|
||||
|
||||
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
||||
@ -142,6 +142,34 @@ private:
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsIFrame* aOuterWrapperFrame);
|
||||
|
||||
class SyncDisabledStateEvent;
|
||||
friend class SyncDisabledStateEvent;
|
||||
class SyncDisabledStateEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
SyncDisabledStateEvent(nsNumberControlFrame* aFrame)
|
||||
: mFrame(aFrame)
|
||||
{}
|
||||
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
nsNumberControlFrame* frame =
|
||||
static_cast<nsNumberControlFrame*>(mFrame.GetFrame());
|
||||
NS_ENSURE_STATE(frame);
|
||||
|
||||
frame->SyncDisabledState();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsWeakFrame mFrame;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sync the disabled state of the anonymous children up with our content's.
|
||||
*/
|
||||
void SyncDisabledState();
|
||||
|
||||
/**
|
||||
* The text field used to edit and show the number.
|
||||
* @see nsNumberControlFrame::CreateAnonymousContent.
|
||||
|
@ -5,6 +5,7 @@
|
||||
<input type='file'>
|
||||
<input type='checkbox'>
|
||||
<input type='radio'>
|
||||
<input type='number'>
|
||||
<input>
|
||||
<button>foo</button>
|
||||
<textarea></textarea>
|
||||
|
@ -6,6 +6,7 @@
|
||||
<input type='file'>
|
||||
<input type='checkbox'>
|
||||
<input type='radio'>
|
||||
<input type='number'>
|
||||
<input>
|
||||
<button>foo</button>
|
||||
<textarea></textarea>
|
||||
|
@ -5,6 +5,7 @@
|
||||
<input type='file' disabled>
|
||||
<input type='checkbox' disabled>
|
||||
<input type='radio' disabled>
|
||||
<input type='number' disabled>
|
||||
<input disabled>
|
||||
<button disabled>foo</button>
|
||||
<textarea disabled></textarea>
|
||||
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<input type="text" disabled>
|
||||
<!-- div to cover spin box area -->
|
||||
<div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; left:100px;">
|
||||
</body>
|
||||
</html>
|
8
layout/reftests/forms/input/number/number-disabled.html
Normal file
8
layout/reftests/forms/input/number/number-disabled.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<input type="number" disabled>
|
||||
<!-- div to cover spin box area -->
|
||||
<div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; left:100px;">
|
||||
</body>
|
||||
</html>
|
@ -17,6 +17,9 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63
|
||||
# dynamic value changes:
|
||||
== show-value.html show-value-ref.html
|
||||
|
||||
# disabled
|
||||
== number-disabled.html number-disabled-ref.html
|
||||
|
||||
# focus
|
||||
needs-focus == focus-handling.html focus-handling-ref.html
|
||||
|
||||
|
@ -85,6 +85,14 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame, uint8_t aWidgetType)
|
||||
flags |= NS_EVENT_STATE_FOCUS;
|
||||
}
|
||||
}
|
||||
|
||||
nsNumberControlFrame* numberControlFrame =
|
||||
nsNumberControlFrame::GetNumberControlFrameForSpinButton(aFrame);
|
||||
if (numberControlFrame &&
|
||||
numberControlFrame->GetContent()->AsElement()->State().
|
||||
HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
flags |= NS_EVENT_STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) {
|
||||
|
Loading…
Reference in New Issue
Block a user