Bug 1373798 part 1. Stop calling SetHasDirAuto/ClearHasDirAuto in input element code. r=mystor

The old setup unset the HasDirAuto flag when changing the "dir" attr away from
the value "auto", and reset it when setting it to "auto", before calling
SetDirectionalityFromValue.  But SetDirectionalityFromValue doesn't depend on
the HasDirAuto flag, and that flag is set correctly for us by nsGenericElement,
so we don't have to manage it ourselves at all.

The callers outside BeforeSetAttr/AfterSetAttr just preserved the flag value, so
there's no behavior change at all for them.

MozReview-Commit-ID: AC8uV3cOtH2
This commit is contained in:
Boris Zbarsky 2017-06-19 23:24:59 -04:00
Родитель 3b61cf8d3e
Коммит e925cebd5b
2 изменённых файлов: 11 добавлений и 18 удалений

Просмотреть файл

@ -1371,10 +1371,6 @@ HTMLInputElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
} else if (aNotify && aName == nsGkAtoms::disabled) {
mDisabledChanged = true;
} else if (aName == nsGkAtoms::dir &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
nsGkAtoms::_auto, eIgnoreCase)) {
SetDirectionIfAuto(false, aNotify);
} else if (mType == NS_FORM_INPUT_RADIO && aName == nsGkAtoms::required) {
nsCOMPtr<nsIRadioGroupContainer> container = GetRadioGroupContainer();
@ -1502,7 +1498,7 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
"HTML5 spec does not allow underflow for type=range");
} else if (aName == nsGkAtoms::dir &&
aValue && aValue->Equals(nsGkAtoms::_auto, eIgnoreCase)) {
SetDirectionIfAuto(true, aNotify);
SetDirectionFromValue(aNotify);
} else if (aName == nsGkAtoms::lang) {
if (mType == NS_FORM_INPUT_NUMBER) {
// Update the value that is displayed to the user to the new locale:
@ -4887,7 +4883,9 @@ HTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
}
// Set direction based on value if dir=auto
SetDirectionIfAuto(HasDirAuto(), false);
if (HasDirAuto()) {
SetDirectionFromValue(false);
}
// An element can't suffer from value missing if it is not in a document.
// We have to check if we suffer from that as we are now in a document.
@ -6325,17 +6323,12 @@ HTMLInputElement::SetDefaultValueAsValue()
}
void
HTMLInputElement::SetDirectionIfAuto(bool aAuto, bool aNotify)
HTMLInputElement::SetDirectionFromValue(bool aNotify)
{
if (aAuto) {
SetHasDirAuto();
if (IsSingleLineTextControl(true)) {
nsAutoString value;
GetValue(value, CallerType::System);
SetDirectionalityFromValue(this, value, aNotify);
}
} else {
ClearHasDirAuto();
if (IsSingleLineTextControl(true)) {
nsAutoString value;
GetValue(value, CallerType::System);
SetDirectionalityFromValue(this, value, aNotify);
}
}
@ -7775,7 +7768,7 @@ HTMLInputElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange)
UpdateAllValidityStates(aNotify);
if (HasDirAuto()) {
SetDirectionIfAuto(true, aNotify);
SetDirectionFromValue(aNotify);
}
// :placeholder-shown pseudo-class may change when the value changes.

Просмотреть файл

@ -1145,7 +1145,7 @@ protected:
*/
nsresult SetDefaultValueAsValue();
virtual void SetDirectionIfAuto(bool aAuto, bool aNotify);
void SetDirectionFromValue(bool aNotify);
/**
* Return if an element should have a specific validity UI