Diff
Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/ChangeLog 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog 2021-02-24 17:10:07 UTC (rev 273389)
@@ -1,5 +1,67 @@
2021-02-23 Alan Coon <alanc...@apple.com>
+ Cherry-pick r272358. rdar://problem/74622890
+
+ Avoid an ancestor walk in HTMLFormControlElement::computeWillValidate()
+ https://bugs.webkit.org/show_bug.cgi?id=221357
+
+ Reviewed by Ryosuke Niwa.
+
+ HTMLFormControlElement::computeWillValidate() does an ancestor DOM walk to look
+ for enclosing data list elements, but these are fairly uncommon so we can avoid
+ this work if we know the Document has none.
+
+ * dom/Document.h:
+ (WebCore::Document::hasDataListElements const):
+ (WebCore::Document::incrementDataListElementCount):
+ (WebCore::Document::decrementDataListElementCount):
+ * dom/Element.cpp:
+ (WebCore::Element::removedFromAncestor): Avoid fetching the page twice.
+ * html/HTMLDataListElement.cpp:
+ (WebCore::HTMLDataListElement::HTMLDataListElement):
+ (WebCore::HTMLDataListElement::~HTMLDataListElement):
+ (WebCore::HTMLDataListElement::didMoveToNewDocument):
+ * html/HTMLDataListElement.h:
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::computeWillValidate const):
+ * page/PointerLockController.cpp:
+ (WebCore::PointerLockController::elementWasRemoved): Renamed for consistency.
+ (WebCore::PointerLockController::elementRemoved): Deleted.
+ * page/PointerLockController.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-03 Simon Fraser <simon.fra...@apple.com>
+
+ Avoid an ancestor walk in HTMLFormControlElement::computeWillValidate()
+ https://bugs.webkit.org/show_bug.cgi?id=221357
+
+ Reviewed by Ryosuke Niwa.
+
+ HTMLFormControlElement::computeWillValidate() does an ancestor DOM walk to look
+ for enclosing data list elements, but these are fairly uncommon so we can avoid
+ this work if we know the Document has none.
+
+ * dom/Document.h:
+ (WebCore::Document::hasDataListElements const):
+ (WebCore::Document::incrementDataListElementCount):
+ (WebCore::Document::decrementDataListElementCount):
+ * dom/Element.cpp:
+ (WebCore::Element::removedFromAncestor): Avoid fetching the page twice.
+ * html/HTMLDataListElement.cpp:
+ (WebCore::HTMLDataListElement::HTMLDataListElement):
+ (WebCore::HTMLDataListElement::~HTMLDataListElement):
+ (WebCore::HTMLDataListElement::didMoveToNewDocument):
+ * html/HTMLDataListElement.h:
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::computeWillValidate const):
+ * page/PointerLockController.cpp:
+ (WebCore::PointerLockController::elementWasRemoved): Renamed for consistency.
+ (WebCore::PointerLockController::elementRemoved): Deleted.
+ * page/PointerLockController.h:
+
+2021-02-23 Alan Coon <alanc...@apple.com>
+
Cherry-pick r272354. rdar://problem/74622963
Avoid frequent calls to HTMLFormControlElement::updateValidity() when constructing form control elements
Modified: branches/safari-611-branch/Source/WebCore/dom/Document.h (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/dom/Document.h 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/dom/Document.h 2021-02-24 17:10:07 UTC (rev 273389)
@@ -1339,6 +1339,10 @@
void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
+ bool hasDataListElements() const { return m_dataListElementCount; }
+ void incrementDataListElementCount() { ++m_dataListElementCount; }
+ void decrementDataListElementCount() { ASSERT(m_dataListElementCount); --m_dataListElementCount; }
+
void getParserLocation(String& url, unsigned& line, unsigned& column) const;
WEBCORE_EXPORT void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) final;
@@ -2008,6 +2012,8 @@
HashSet<RefPtr<Element>> m_associatedFormControls;
unsigned m_disabledFieldsetElementsCount { 0 };
+ unsigned m_dataListElementCount { 0 };
+
unsigned m_listenerTypes { 0 };
unsigned m_referencingNodeCount { 0 };
int m_loadEventDelayCount { 0 };
Modified: branches/safari-611-branch/Source/WebCore/dom/Element.cpp (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/dom/Element.cpp 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/dom/Element.cpp 2021-02-24 17:10:07 UTC (rev 273389)
@@ -2214,12 +2214,13 @@
if (containsFullScreenElement())
setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
#endif
+
+ if (auto* page = document().page()) {
#if ENABLE(POINTER_LOCK)
- if (document().page())
- document().page()->pointerLockController().elementRemoved(*this);
+ page->pointerLockController().elementWasRemoved(*this);
#endif
- if (document().page())
- document().page()->pointerCaptureController().elementWasRemoved(*this);
+ page->pointerCaptureController().elementWasRemoved(*this);
+ }
setSavedLayerScrollPosition(ScrollPosition());
Modified: branches/safari-611-branch/Source/WebCore/html/HTMLDataListElement.cpp (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/html/HTMLDataListElement.cpp 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/html/HTMLDataListElement.cpp 2021-02-24 17:10:07 UTC (rev 273389)
@@ -49,13 +49,26 @@
inline HTMLDataListElement::HTMLDataListElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
+ document.incrementDataListElementCount();
}
+HTMLDataListElement::~HTMLDataListElement()
+{
+ document().decrementDataListElementCount();
+}
+
Ref<HTMLDataListElement> HTMLDataListElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLDataListElement(tagName, document));
}
+void HTMLDataListElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)
+{
+ oldDocument.decrementDataListElementCount();
+ newDocument.incrementDataListElementCount();
+ HTMLElement::didMoveToNewDocument(oldDocument, newDocument);
+}
+
Ref<HTMLCollection> HTMLDataListElement::options()
{
return ensureRareData().ensureNodeLists().addCachedCollection<GenericCachedHTMLCollection<CollectionTypeTraits<DataListOptions>::traversalType>>(*this, DataListOptions);
Modified: branches/safari-611-branch/Source/WebCore/html/HTMLDataListElement.h (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/html/HTMLDataListElement.h 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/html/HTMLDataListElement.h 2021-02-24 17:10:07 UTC (rev 273389)
@@ -44,6 +44,7 @@
WTF_MAKE_ISO_ALLOCATED(HTMLDataListElement);
public:
static Ref<HTMLDataListElement> create(const QualifiedName&, Document&);
+ ~HTMLDataListElement();
Ref<HTMLCollection> options();
@@ -53,6 +54,8 @@
auto suggestions() const { return filteredDescendants<HTMLOptionElement, isSuggestion>(*this); }
private:
+ void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
+
HTMLDataListElement(const QualifiedName&, Document&);
};
Modified: branches/safari-611-branch/Source/WebCore/html/HTMLFormControlElement.cpp (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/html/HTMLFormControlElement.cpp 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/html/HTMLFormControlElement.cpp 2021-02-24 17:10:07 UTC (rev 273389)
@@ -421,7 +421,7 @@
{
if (m_dataListAncestorState == Unknown) {
#if ENABLE(DATALIST_ELEMENT)
- m_dataListAncestorState = ancestorsOfType<HTMLDataListElement>(*this).first() ? InsideDataList : NotInsideDataList;
+ m_dataListAncestorState = (document().hasDataListElements() && ancestorsOfType<HTMLDataListElement>(*this).first()) ? InsideDataList : NotInsideDataList;
#else
m_dataListAncestorState = NotInsideDataList;
#endif
Modified: branches/safari-611-branch/Source/WebCore/page/PointerLockController.cpp (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/page/PointerLockController.cpp 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/page/PointerLockController.cpp 2021-02-24 17:10:07 UTC (rev 273389)
@@ -103,7 +103,7 @@
m_forceCursorVisibleUponUnlock = true;
}
-void PointerLockController::elementRemoved(Element& element)
+void PointerLockController::elementWasRemoved(Element& element)
{
if (m_element == &element) {
m_documentOfRemovedElementWhileWaitingForUnlock = makeWeakPtr(m_element->document());
Modified: branches/safari-611-branch/Source/WebCore/page/PointerLockController.h (273388 => 273389)
--- branches/safari-611-branch/Source/WebCore/page/PointerLockController.h 2021-02-24 17:10:03 UTC (rev 273388)
+++ branches/safari-611-branch/Source/WebCore/page/PointerLockController.h 2021-02-24 17:10:07 UTC (rev 273389)
@@ -48,7 +48,7 @@
void requestPointerUnlock();
void requestPointerUnlockAndForceCursorVisible();
- void elementRemoved(Element&);
+ void elementWasRemoved(Element&);
void documentDetached(Document&);
bool isLocked() const;
WEBCORE_EXPORT bool lockPending() const;