Bug 1876163 - Part 5: Consider input / textarea children of dir=auto slot. r=smaug

This patch implements step 2.3.2 from https://html.spec.whatwg.org/#auto-directionality for the special case where the child is an auto-directionality form-associated element according to step 1 of the algorithm.

Depends on D208339

Differential Revision: https://phabricator.services.mozilla.com/D208340
This commit is contained in:
Vincent Hilla
2024-07-09 08:00:35 +00:00
parent c50c1c0cc9
commit 2ddf8f16af
8 changed files with 105 additions and 94 deletions

View File

@@ -650,6 +650,10 @@ class HTMLInputElement final : public TextControlElement,
ErrorResult& aRv);
void GetValue(nsAString& aValue, CallerType aCallerType);
// Generic getter for the value that doesn't do experimental control type
// sanitization.
void GetValueInternal(nsAString& aValue, CallerType aCallerType) const;
void GetValueAsDate(JSContext* aCx, JS::MutableHandle<JSObject*> aObj,
ErrorResult& aRv);
@@ -872,6 +876,13 @@ class HTMLInputElement final : public TextControlElement,
// Parse a simple (hex) color.
static mozilla::Maybe<nscolor> ParseSimpleColor(const nsAString& aColor);
/**
* https://html.spec.whatwg.org/#auto-directionality-form-associated-elements
*/
bool IsAutoDirectionalityAssociated() const {
return IsAutoDirectionalityAssociated(mType);
}
protected:
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual ~HTMLInputElement();
@@ -940,10 +951,6 @@ class HTMLInputElement final : public TextControlElement,
return SetValueInternal(aValue, nullptr, aOptions);
}
// Generic getter for the value that doesn't do experimental control type
// sanitization.
void GetValueInternal(nsAString& aValue, CallerType aCallerType) const;
// A getter for callers that know we're not dealing with a file input, so they
// don't have to think about the caller type.
void GetNonFileValueInternal(nsAString& aValue) const;
@@ -1108,13 +1115,6 @@ class HTMLInputElement final : public TextControlElement,
MOZ_CAN_RUN_SCRIPT
nsresult SetDefaultValueAsValue();
/**
* Sets the direction from the input value. if aKnownValue is provided, it
* saves a GetValue call.
*/
void SetAutoDirectionality(bool aNotify,
const nsAString* aKnownValue = nullptr);
/**
* Returns the radio group container within the DOM tree that the element
* is currently a member of, if one exists.
@@ -1582,10 +1582,6 @@ class HTMLInputElement final : public TextControlElement,
}
}
bool IsAutoDirectionalityAssociated() const {
return IsAutoDirectionalityAssociated(mType);
}
static bool CreatesDateTimeWidget(FormControlType aType) {
return aType == FormControlType::InputDate ||
aType == FormControlType::InputTime ||