Make WeakPtr<Element> possible and deploy it in form associated elements code
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Apr 2019 08:22:39 +0000 (08:22 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Apr 2019 08:22:39 +0000 (08:22 +0000)
commit9bb07a7dd7dc0458e7c6eee19491872d864ba71f
treeeb8d30f08660168ff1fb631a5703978676bc3446
parentb1138d0ee3d10884dbc2cfef6103e92c64ce61cc
Make WeakPtr<Element> possible and deploy it in form associated elements code
https://bugs.webkit.org/show_bug.cgi?id=196626

Reviewed by Antti Koivisto.

Source/WebCore:

Make Element inherit from CanMakeWeakPtr and deploy WeakPtr<*Element> in FormAssociatedElement and HTMLFormElement.

No new tests sine there should be no behavioral change.

* dom/Element.h:
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::FormAssociatedElement):
(WebCore::FormAssociatedElement::insertedIntoAncestor):
(WebCore::FormAssociatedElement::setForm):
(WebCore::FormAssociatedElement::resetFormOwner):
(WebCore::FormAssociatedElement::formAttributeChanged):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::asFormNamedItem):
(WebCore::HTMLElement::asFormAssociatedElement):
* html/HTMLElement.h:
(WebCore::HTMLElement::asFormNamedItem): Deleted.
* html/HTMLFormControlElement.h:
* html/HTMLFormControlsCollection.cpp:
(WebCore::HTMLFormControlsCollection::formImageElements const): Inlined into updateNamedElementCache.
(WebCore::HTMLFormControlsCollection::updateNamedElementCache const):
* html/HTMLFormControlsCollection.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::registerInvalidAssociatedFormControl):
(WebCore::HTMLFormElement::removeInvalidAssociatedFormControlIfNeeded):
(WebCore::HTMLFormElement::registerImgElement):
(WebCore::HTMLFormElement::defaultButton const):
(WebCore::HTMLFormElement::resetDefaultButton):
(WebCore::HTMLFormElement::matchesValidPseudoClass const):
(WebCore::HTMLFormElement::matchesInvalidPseudoClass const):
* html/HTMLFormElement.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::HTMLImageElement):
(WebCore::HTMLImageElement::insertedIntoAncestor):
* html/HTMLImageElement.h:
* html/HTMLInputElement.h:
* html/HTMLMediaElement.h:
* html/HTMLObjectElement.h:
* html/HTMLPictureElement.h:
* html/HTMLSlotElement.h:
* svg/SVGElement.h:

Source/WTF:

Make it possible to call WeakHashSet::remove and WeakHashSet::contains with
a subclass type U of a type T used to define WeakReference<T>.

Also added computesEmpty, which is slightly more efficient than computeSize
when m_set is either empty or when there are non-released weak references in the set.

* wtf/WeakHashSet.h:
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/WeakHashSet.h
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.h
Source/WebCore/html/FormAssociatedElement.cpp
Source/WebCore/html/FormAssociatedElement.h
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLFormControlsCollection.cpp
Source/WebCore/html/HTMLFormControlsCollection.h
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLFormElement.h
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLObjectElement.h
Source/WebCore/html/HTMLPictureElement.h
Source/WebCore/html/HTMLSlotElement.h
Source/WebCore/svg/SVGElement.h