Bug 940760 - Make the CSS pseudo-class :focus apply to <input type=number>, fixing B2G forms styling. r=smaug

This commit is contained in:
Jonathan Watt 2013-12-08 21:26:42 +00:00
parent 58d1429d0f
commit 6757d5bd14
4 changed files with 44 additions and 5 deletions

View File

@ -113,8 +113,8 @@ class DOMRectList;
// IID for the dom::Element interface
#define NS_ELEMENT_IID \
{ 0xec962aa7, 0x53ee, 0x46ff, \
{ 0x90, 0x34, 0x68, 0xea, 0x79, 0x9d, 0x7d, 0xf7 } }
{ 0xf7c18f0f, 0xa8fd, 0x4a95, \
{ 0x91, 0x72, 0xd3, 0xa7, 0x4a, 0xb8, 0xc4, 0xbe } }
class Element : public FragmentOrElement
{
@ -385,16 +385,17 @@ private:
// Style state computed from element's state and style locks.
nsEventStates StyleStateFromLocks() const;
protected:
// Methods for the ESM to manage state bits. These will handle
// setting up script blockers when they notify, so no need to do it
// in the callers unless desired.
void AddStates(nsEventStates aStates) {
virtual void AddStates(nsEventStates aStates) {
NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
"Should only be adding ESM-managed states here");
AddStatesSilently(aStates);
NotifyStateChange(aStates);
}
void RemoveStates(nsEventStates aStates) {
virtual void RemoveStates(nsEventStates aStates) {
NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
"Should only be removing ESM-managed states here");
RemoveStatesSilently(aStates);

View File

@ -5732,6 +5732,38 @@ HTMLInputElement::IntrinsicState() const
return state;
}
void
HTMLInputElement::AddStates(nsEventStates aStates)
{
if (mType == NS_FORM_INPUT_TEXT) {
nsEventStates focusStates(aStates & (NS_EVENT_STATE_FOCUS |
NS_EVENT_STATE_FOCUSRING));
if (!focusStates.IsEmpty()) {
HTMLInputElement* ownerNumberControl = GetOwnerNumberControl();
if (ownerNumberControl) {
ownerNumberControl->AddStates(focusStates);
}
}
}
nsGenericHTMLFormElementWithState::AddStates(aStates);
}
void
HTMLInputElement::RemoveStates(nsEventStates aStates)
{
if (mType == NS_FORM_INPUT_TEXT) {
nsEventStates focusStates(aStates & (NS_EVENT_STATE_FOCUS |
NS_EVENT_STATE_FOCUSRING));
if (!focusStates.IsEmpty()) {
HTMLInputElement* ownerNumberControl = GetOwnerNumberControl();
if (ownerNumberControl) {
ownerNumberControl->RemoveStates(focusStates);
}
}
}
nsGenericHTMLFormElementWithState::RemoveStates(aStates);
}
bool
HTMLInputElement::RestoreState(nsPresState* aState)
{

View File

@ -166,6 +166,12 @@ public:
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
// Element
private:
virtual void AddStates(nsEventStates aStates);
virtual void RemoveStates(nsEventStates aStates);
public:
// nsITextControlElement
NS_IMETHOD SetValueChanged(bool aValueChanged) MOZ_OVERRIDE;
NS_IMETHOD_(bool) IsSingleLineTextControl() const MOZ_OVERRIDE;

View File

@ -18,7 +18,7 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63
== show-value.html show-value-ref.html
# focus
fails-if(B2G) needs-focus == focus-handling.html focus-handling-ref.html # bug 940760
needs-focus == focus-handling.html focus-handling-ref.html
# pseudo-elements not usable from content:
== number-pseudo-elements.html number-pseudo-elements-ref.html