commit 83b70e0645d2dfaedd299393da58da55cb7355fe
parent 3a0b29121e2273701a63210a4dc075f1fa60c976
Author: Alice Boxhall <95208+alice@users.noreply.github.com>
Date: Tue, 6 Jan 2026 16:13:54 +0000
Bug 1983766 - Split single element attribute getters into bindings/internals versions. r=dom-core,credential-management-reviewers,webidl,layout-reviewers,smaug,keithamus,jwatt,mtigley
Differential Revision: https://phabricator.services.mozilla.com/D261542
Diffstat:
12 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
@@ -3586,7 +3586,7 @@ nsGenericHTMLElement* nsINode::GetEffectiveCommandForElement() const {
if (const auto* buttonControl = HTMLButtonElement::FromNodeOrNull(this)) {
if (auto* popover = nsGenericHTMLElement::FromNodeOrNull(
- buttonControl->GetCommandForElement())) {
+ buttonControl->GetCommandForElementInternal())) {
if (popover->GetPopoverAttributeState() != PopoverAttributeState::None) {
return popover;
}
@@ -3603,7 +3603,7 @@ nsGenericHTMLElement* nsINode::GetEffectivePopoverTargetElement() const {
return nullptr;
}
if (auto* popover = nsGenericHTMLElement::FromNodeOrNull(
- formControl->GetPopoverTargetElement())) {
+ formControl->GetPopoverTargetElementInternal())) {
if (popover->GetPopoverAttributeState() != PopoverAttributeState::None) {
return popover;
}
diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp
@@ -354,7 +354,7 @@ void HTMLButtonElement::ActivationBehavior(EventChainPostVisitor& aVisitor) {
// 4. Let target be the result of running element's get the
// commandfor-associated element.
- RefPtr<Element> target = GetCommandForElement();
+ RefPtr<Element> target = GetCommandForElementInternal();
// 5. If target is not null:
if (target) {
@@ -611,14 +611,18 @@ Element::Command HTMLButtonElement::GetCommand() const {
return Command::Invalid;
}
-Element* HTMLButtonElement::GetCommandForElement() const {
+Element* HTMLButtonElement::GetCommandForElementForBindings() const {
+ return GetCommandForElementInternal();
+}
+
+Element* HTMLButtonElement::GetCommandForElementInternal() const {
if (StaticPrefs::dom_element_commandfor_enabled()) {
return GetAttrAssociatedElement(nsGkAtoms::commandfor);
}
return nullptr;
}
-void HTMLButtonElement::SetCommandForElement(Element* aElement) {
+void HTMLButtonElement::SetCommandForElementForBindings(Element* aElement) {
ExplicitlySetAttrElement(nsGkAtoms::commandfor, aElement);
}
diff --git a/dom/html/HTMLButtonElement.h b/dom/html/HTMLButtonElement.h
@@ -136,8 +136,9 @@ class HTMLButtonElement final : public nsGenericHTMLFormControlElementWithState,
void SetCustomValidity(const nsAString& aError);
// Command & CommandFor
- Element* GetCommandForElement() const;
- void SetCommandForElement(Element*);
+ Element* GetCommandForElementForBindings() const;
+ Element* GetCommandForElementInternal() const;
+ void SetCommandForElementForBindings(Element*);
void GetCommand(nsAString& aCommand) const;
Element::Command GetCommand() const;
void SetCommand(const nsAString& aValue) {
diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
@@ -754,7 +754,7 @@ static void SerializeColorForHTMLCompatibility(const StyleAbsoluteColor& aColor,
}
nsTArray<nsString> HTMLInputElement::GetColorsFromList() {
- RefPtr<HTMLDataListElement> dataList = GetList();
+ RefPtr<HTMLDataListElement> dataList = GetListInternal();
if (!dataList) {
return {};
}
@@ -1796,7 +1796,11 @@ void HTMLInputElement::SetValue(const nsAString& aValue, CallerType aCallerType,
}
}
-HTMLDataListElement* HTMLInputElement::GetList() const {
+HTMLDataListElement* HTMLInputElement::GetListForBindings() const {
+ return GetListInternal();
+}
+
+HTMLDataListElement* HTMLInputElement::GetListInternal() const {
nsAutoString dataListId;
GetAttr(nsGkAtoms::list, dataListId);
if (dataListId.IsEmpty()) {
@@ -6008,7 +6012,7 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
// I.e. show the autocomplete dropdown based on the list attribute.
// XXX Form-fill support on android is bug 1535985.
if (StaticPrefs::dom_input_showPicker_datalist_enabled() &&
- IsSingleLineTextControl(true) && GetList()) {
+ IsSingleLineTextControl(true) && GetListInternal()) {
if (nsCOMPtr<nsIFormFillController> controller =
do_GetService("@mozilla.org/satchel/form-fill-controller;1")) {
controller->SetControlledElement(this);
diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h
@@ -531,7 +531,8 @@ class HTMLInputElement final : public TextControlElement,
bool IsDraggingRange() const { return mIsDraggingRange; }
void SetIndeterminate(bool aValue);
- HTMLDataListElement* GetList() const;
+ HTMLDataListElement* GetListForBindings() const;
+ HTMLDataListElement* GetListInternal() const;
void GetMax(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::max, aValue); }
void SetMax(const nsAString& aValue, ErrorResult& aRv) {
diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
@@ -2951,12 +2951,19 @@ bool nsGenericHTMLFormControlElementWithState::ParseAttribute(
}
mozilla::dom::Element*
-nsGenericHTMLFormControlElementWithState::GetPopoverTargetElement() const {
+nsGenericHTMLFormControlElementWithState::GetPopoverTargetElementForBindings()
+ const {
+ return GetPopoverTargetElementInternal();
+}
+
+mozilla::dom::Element*
+nsGenericHTMLFormControlElementWithState::GetPopoverTargetElementInternal()
+ const {
return GetAttrAssociatedElement(nsGkAtoms::popovertarget);
}
-void nsGenericHTMLFormControlElementWithState::SetPopoverTargetElement(
- mozilla::dom::Element* aElement) {
+void nsGenericHTMLFormControlElementWithState::
+ SetPopoverTargetElementForBindings(mozilla::dom::Element* aElement) {
ExplicitlySetAttrElement(nsGkAtoms::popovertarget, aElement);
}
diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h
@@ -1279,8 +1279,9 @@ class nsGenericHTMLFormControlElementWithState
nsAttrValue& aResult) override;
// PopoverInvokerElement
- mozilla::dom::Element* GetPopoverTargetElement() const;
- void SetPopoverTargetElement(mozilla::dom::Element*);
+ mozilla::dom::Element* GetPopoverTargetElementForBindings() const;
+ mozilla::dom::Element* GetPopoverTargetElementInternal() const;
+ void SetPopoverTargetElementForBindings(mozilla::dom::Element*);
void GetPopoverTargetAction(nsAString& aValue) const {
GetHTMLEnumAttr(nsGkAtoms::popovertargetaction, aValue);
}
diff --git a/dom/webidl/HTMLButtonElement.webidl b/dom/webidl/HTMLButtonElement.webidl
@@ -46,7 +46,7 @@ interface HTMLButtonElement : HTMLElement {
readonly attribute NodeList labels;
- [Pref="dom.element.commandfor.enabled", CEReactions] attribute Element? commandForElement;
+ [Pref="dom.element.commandfor.enabled", BinaryName="commandForElementForBindings", CEReactions] attribute Element? commandForElement;
[Pref="dom.element.commandfor.enabled", CEReactions] attribute DOMString command;
};
diff --git a/dom/webidl/HTMLInputElement.webidl b/dom/webidl/HTMLInputElement.webidl
@@ -59,7 +59,7 @@ interface HTMLInputElement : HTMLElement {
attribute unsigned long height;
[Pure]
attribute boolean indeterminate;
- [Pure]
+ [Pure, BinaryName=listForBindings]
readonly attribute HTMLDataListElement? list;
[CEReactions, Pure, SetterThrows]
attribute DOMString max;
diff --git a/dom/webidl/PopoverInvokerElement.webidl b/dom/webidl/PopoverInvokerElement.webidl
@@ -8,6 +8,6 @@
*/
interface mixin PopoverInvokerElement {
- [CEReactions] attribute Element? popoverTargetElement;
+ [CEReactions, BinaryName="popoverTargetElementForBindings"] attribute Element? popoverTargetElement;
[CEReactions] attribute DOMString popoverTargetAction;
};
diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp
@@ -409,7 +409,7 @@ void nsRangeFrame::UpdateForValueChange() {
nsTArray<Decimal> nsRangeFrame::TickMarks() {
nsTArray<Decimal> tickMarks;
auto& input = InputElement();
- auto* list = input.GetList();
+ auto* list = input.GetListInternal();
if (!list) {
return tickMarks;
}
diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp
@@ -1265,7 +1265,7 @@ void nsFormFillController::GetValue(mozilla::dom::Element* aElement,
Element* nsFormFillController::GetList(mozilla::dom::Element* aElement) {
if (auto* input = HTMLInputElement::FromNodeOrNull(aElement)) {
- return input->GetList();
+ return input->GetListInternal();
}
return nullptr;
}