Skip to content

Commit 11632dc

Browse files
Alice Boxhallrniwa
Alice Boxhall
authored andcommitted
Add formForBindings() and controlForBindings() methods.
https://bugs.webkit.org/show_bug.cgi?id=287536 Reviewed by Ryosuke Niwa. These methods currently delegate directly to form() and control() respectively, but will later be modified to ensure that nodes don't leak out of shadow roots once referenceTarget is supported. * Source/WebCore/html/FormAssociatedElement.cpp: (WebCore::FormAssociatedElement::formForBindings const): * Source/WebCore/html/FormAssociatedElement.h: * Source/WebCore/html/HTMLButtonElement.idl: * Source/WebCore/html/HTMLFieldSetElement.idl: * Source/WebCore/html/HTMLInputElement.idl: * Source/WebCore/html/HTMLLabelElement.cpp: (WebCore::HTMLLabelElement::controlForBindings const): (WebCore::HTMLLabelElement::formForBindings const): * Source/WebCore/html/HTMLLabelElement.h: * Source/WebCore/html/HTMLLabelElement.idl: * Source/WebCore/html/HTMLLegendElement.cpp: (WebCore::HTMLLegendElement::formForBindings const): * Source/WebCore/html/HTMLLegendElement.h: * Source/WebCore/html/HTMLLegendElement.idl: * Source/WebCore/html/HTMLObjectElement.idl: * Source/WebCore/html/HTMLOptionElement.cpp: (WebCore::HTMLOptionElement::formForBindings const): * Source/WebCore/html/HTMLOptionElement.h: * Source/WebCore/html/HTMLOptionElement.idl: * Source/WebCore/html/HTMLOutputElement.idl: * Source/WebCore/html/HTMLSelectElement.idl: * Source/WebCore/html/HTMLTextAreaElement.idl: Canonical link: https://commits.webkit.org/290323@main
1 parent c268045 commit 11632dc

18 files changed

+41
-11
lines changed

Source/WebCore/html/FormAssociatedElement.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ FormAssociatedElement::FormAssociatedElement(HTMLFormElement* form)
3535
{
3636
}
3737

38+
HTMLFormElement* FormAssociatedElement::formForBindings() const
39+
{
40+
return form();
41+
}
42+
3843
void FormAssociatedElement::setFormInternal(RefPtr<HTMLFormElement>&& newForm)
3944
{
4045
ASSERT(m_form.get() != newForm);

Source/WebCore/html/FormAssociatedElement.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class FormAssociatedElement {
3838
virtual void formWillBeDestroyed() { m_form = nullptr; }
3939

4040
HTMLFormElement* form() const { return m_form.get(); }
41+
virtual HTMLFormElement* formForBindings() const;
4142

4243
void setForm(RefPtr<HTMLFormElement>&&);
4344
virtual void elementInsertedIntoAncestor(Element&, Node::InsertionType);

Source/WebCore/html/HTMLButtonElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Exposed=Window
2323
] interface HTMLButtonElement : HTMLElement {
2424
[CEReactions=NotNeeded, Reflect] attribute boolean disabled;
25-
readonly attribute HTMLFormElement form;
25+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
2626
[CEReactions=NotNeeded] attribute [AtomString] USVString formAction;
2727

2828
[CEReactions=NotNeeded] attribute [AtomString] DOMString formEnctype;

Source/WebCore/html/HTMLFieldSetElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Exposed=Window
2222
] interface HTMLFieldSetElement : HTMLElement {
2323
[CEReactions=Needed, Reflect] attribute boolean disabled;
24-
readonly attribute HTMLFormElement form;
24+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
2525
[CEReactions=NotNeeded, Reflect] attribute DOMString name;
2626

2727
readonly attribute DOMString type;

Source/WebCore/html/HTMLInputElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum AutofillButtonType {
4848
[EnabledBySetting=InputTypeColorEnhancementsEnabled, CEReactions=NotNeeded] attribute [AtomString] DOMString colorSpace;
4949
[CEReactions=NotNeeded, Reflect] attribute DOMString dirName;
5050
[CEReactions=NotNeeded, Reflect] attribute boolean disabled;
51-
readonly attribute HTMLFormElement form;
51+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
5252
[ImplementedAs=filesForBindings] attribute FileList? files;
5353
[CEReactions=NotNeeded] attribute [AtomString] USVString formAction;
5454

Source/WebCore/html/HTMLLabelElement.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ RefPtr<HTMLElement> HTMLLabelElement::control() const
8787
return isConnected() ? firstElementWithIdIfLabelable(treeScope(), controlId) : nullptr;
8888
}
8989

90+
RefPtr<HTMLElement> HTMLLabelElement::controlForBindings() const
91+
{
92+
return control();
93+
}
94+
9095
HTMLFormElement* HTMLLabelElement::form() const
9196
{
9297
if (auto element = control()) {
@@ -96,6 +101,11 @@ HTMLFormElement* HTMLLabelElement::form() const
96101
return nullptr;
97102
}
98103

104+
HTMLFormElement* HTMLLabelElement::formForBindings() const
105+
{
106+
return form();
107+
}
108+
99109
void HTMLLabelElement::setActive(bool down, Style::InvalidationScope invalidationScope)
100110
{
101111
// Update our status first.

Source/WebCore/html/HTMLLabelElement.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class HTMLLabelElement final : public HTMLElement {
3636
static Ref<HTMLLabelElement> create(Document&);
3737

3838
WEBCORE_EXPORT RefPtr<HTMLElement> control() const;
39+
WEBCORE_EXPORT RefPtr<HTMLElement> controlForBindings() const;
3940
WEBCORE_EXPORT HTMLFormElement* form() const;
41+
WEBCORE_EXPORT HTMLFormElement* formForBindings() const;
4042

4143
bool willRespondToMouseClickEventsWithEditability(Editability) const final;
4244
void updateLabel(TreeScope&, const AtomString& oldForAttributeValue, const AtomString& newForAttributeValue);

Source/WebCore/html/HTMLLabelElement.idl

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
[
2222
Exposed=Window
2323
] interface HTMLLabelElement : HTMLElement {
24-
readonly attribute HTMLFormElement form;
24+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
2525
[CEReactions=NotNeeded, Reflect=for] attribute DOMString htmlFor;
26-
readonly attribute HTMLElement control;
26+
[ImplementedAs=controlForBindings] readonly attribute HTMLElement control;
2727
};
2828

Source/WebCore/html/HTMLLegendElement.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,10 @@ HTMLFormElement* HTMLLegendElement::form() const
5555
RefPtr fieldset = dynamicDowncast<HTMLFieldSetElement>(parentNode());
5656
return fieldset ? fieldset->form() : nullptr;
5757
}
58+
59+
HTMLFormElement* HTMLLegendElement::formForBindings() const
60+
{
61+
return form();
62+
}
5863

5964
} // namespace

Source/WebCore/html/HTMLLegendElement.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class HTMLLegendElement final : public HTMLElement {
3535
static Ref<HTMLLegendElement> create(const QualifiedName&, Document&);
3636

3737
WEBCORE_EXPORT HTMLFormElement* form() const;
38+
WEBCORE_EXPORT HTMLFormElement* formForBindings() const;
3839

3940
private:
4041
HTMLLegendElement(const QualifiedName&, Document&);

Source/WebCore/html/HTMLLegendElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[
2222
Exposed=Window
2323
] interface HTMLLegendElement : HTMLElement {
24-
readonly attribute HTMLFormElement form;
24+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
2525
[CEReactions=NotNeeded, Reflect] attribute DOMString align;
2626
};
2727

Source/WebCore/html/HTMLObjectElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Plugin,
2323
Exposed=Window
2424
] interface HTMLObjectElement : HTMLElement {
25-
readonly attribute HTMLFormElement form;
25+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
2626
[CEReactions=NotNeeded, Reflect] attribute DOMString code;
2727
[CEReactions=NotNeeded, Reflect] attribute DOMString align;
2828
[CEReactions=NotNeeded, Reflect] attribute DOMString archive;

Source/WebCore/html/HTMLOptionElement.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ HTMLFormElement* HTMLOptionElement::form() const
145145
return nullptr;
146146
}
147147

148+
HTMLFormElement* HTMLOptionElement::formForBindings() const
149+
{
150+
return form();
151+
}
152+
148153
int HTMLOptionElement::index() const
149154
{
150155
// It would be faster to cache the index, but harder to get it right in all cases.

Source/WebCore/html/HTMLOptionElement.h

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class HTMLOptionElement final : public HTMLElement {
4444
void setText(String&&);
4545

4646
WEBCORE_EXPORT HTMLFormElement* form() const;
47+
WEBCORE_EXPORT HTMLFormElement* formForBindings() const;
4748

4849
WEBCORE_EXPORT int index() const;
4950

Source/WebCore/html/HTMLOptionElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
LegacyFactoryFunction=Option(optional DOMString text = "", optional [AtomString] DOMString value, optional boolean defaultSelected = false, optional boolean selected = false),
2626
] interface HTMLOptionElement : HTMLElement {
2727
[CEReactions=NotNeeded, Reflect] attribute boolean disabled;
28-
readonly attribute HTMLFormElement form;
28+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
2929
[CEReactions=NotNeeded] attribute [AtomString] DOMString label;
3030
[CEReactions=NotNeeded, Reflect=selected] attribute boolean defaultSelected;
3131
attribute boolean selected;

Source/WebCore/html/HTMLOutputElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
[CallWith=CurrentDocument, HTMLConstructor] constructor();
3030

3131
[SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor;
32-
readonly attribute HTMLFormElement? form;
32+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement? form;
3333
[CEReactions=NotNeeded, Reflect] attribute DOMString name;
3434

3535
readonly attribute DOMString type;

Source/WebCore/html/HTMLSelectElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
] interface HTMLSelectElement : HTMLElement {
2626
[CEReactions=NotNeeded] attribute [AtomString] DOMString autocomplete;
2727
[CEReactions=NotNeeded, Reflect] attribute boolean disabled;
28-
readonly attribute HTMLFormElement? form;
28+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement? form;
2929
[CEReactions=NotNeeded, Reflect] attribute boolean multiple;
3030
[CEReactions=NotNeeded, Reflect] attribute DOMString name;
3131
[CEReactions=NotNeeded, Reflect] attribute boolean required;

Source/WebCore/html/HTMLTextAreaElement.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
] interface HTMLTextAreaElement : HTMLElement {
2727
[CEReactions=NotNeeded, Reflect] attribute DOMString dirName;
2828
[CEReactions=NotNeeded, Reflect] attribute boolean disabled;
29-
readonly attribute HTMLFormElement form;
29+
[ImplementedAs=formForBindings] readonly attribute HTMLFormElement form;
3030
[CEReactions=NotNeeded] attribute long minLength;
3131
[CEReactions=NotNeeded] attribute long maxLength;
3232
[CEReactions=NotNeeded, Reflect] attribute DOMString name;

0 commit comments

Comments
 (0)