1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Bug 1373798 - Move HTML dir attribute state into event state flags

* Stop calling SetHasDirAuto/ClearHasDirAuto in input element code
* Introduce event state flags that track the state of an element's dir attribute
* Rewrite our existing checks for the state of the dir attr on top of the new event state flags
* Add pseudo-classes for matching on the dir attribute states
* Use the new dir attribute pseudoclasses in html.css

Tag #1375
This commit is contained in:
Matt A. Tobin
2020-04-17 05:50:47 -04:00
committed by Roy Tam
parent 4e14355697
commit 3b2a22f085
11 changed files with 142 additions and 75 deletions
+10 -17
View File
@@ -1264,10 +1264,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();
@@ -1419,7 +1415,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:
@@ -4975,7 +4971,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.
@@ -6693,17 +6691,12 @@ HTMLInputElement::SetDefaultValueAsValue()
}
void
HTMLInputElement::SetDirectionIfAuto(bool aAuto, bool aNotify)
HTMLInputElement::SetDirectionFromValue(bool aNotify)
{
if (aAuto) {
SetHasDirAuto();
if (IsSingleLineTextControl(true)) {
nsAutoString value;
GetValue(value);
SetDirectionalityFromValue(this, value, aNotify);
}
} else {
ClearHasDirAuto();
if (IsSingleLineTextControl(true)) {
nsAutoString value;
GetValue(value);
SetDirectionalityFromValue(this, value, aNotify);
}
}
@@ -8480,7 +8473,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.