Commit e0980d3c authored by ggaren@apple.com's avatar ggaren@apple.com

Removed the notion of "disconnected nodes with event listeners" because

it was vestigial. The reference cycle it tried to solve was solved another
way in https://bugs.webkit.org/show_bug.cgi?id=21260.

Patch by Geoffrey Garen <ggaren@apple.com> on 2009-09-15
Reviewed by Sam Weinig.

* dom/Document.cpp:
(WebCore::Document::removeAllEventListeners):
* dom/Document.h:
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::insertedIntoDocument):
(WebCore::Node::removedFromDocument):
(WebCore::Node::willMoveToNewOwnerDocument):
(WebCore::Node::didMoveToNewOwnerDocument):
(WebCore::Node::addEventListener):
(WebCore::Node::removeEventListener):
(WebCore::Node::clearAttributeEventListener):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8ccd5aae
2009-09-15 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
Removed the notion of "disconnected nodes with event listeners" because
it was vestigial. The reference cycle it tried to solve was solved another
way in https://bugs.webkit.org/show_bug.cgi?id=21260.
* dom/Document.cpp:
(WebCore::Document::removeAllEventListeners):
* dom/Document.h:
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::insertedIntoDocument):
(WebCore::Node::removedFromDocument):
(WebCore::Node::willMoveToNewOwnerDocument):
(WebCore::Node::didMoveToNewOwnerDocument):
(WebCore::Node::addEventListener):
(WebCore::Node::removeEventListener):
(WebCore::Node::clearAttributeEventListener):
2009-09-15 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
......@@ -1458,29 +1458,10 @@ void Document::removeAllEventListeners()
{
if (DOMWindow* domWindow = this->domWindow())
domWindow->removeAllEventListeners();
removeAllDisconnectedNodeEventListeners();
for (Node* node = this; node; node = node->traverseNextNode())
node->removeAllEventListeners();
}
void Document::registerDisconnectedNodeWithEventListeners(Node* node)
{
m_disconnectedNodesWithEventListeners.add(node);
}
void Document::unregisterDisconnectedNodeWithEventListeners(Node* node)
{
m_disconnectedNodesWithEventListeners.remove(node);
}
void Document::removeAllDisconnectedNodeEventListeners()
{
HashSet<Node*>::iterator end = m_disconnectedNodesWithEventListeners.end();
for (HashSet<Node*>::iterator i = m_disconnectedNodesWithEventListeners.begin(); i != end; ++i)
(*i)->removeAllEventListeners();
m_disconnectedNodesWithEventListeners.clear();
}
RenderView* Document::renderView() const
{
return toRenderView(renderer());
......
......@@ -812,9 +812,6 @@ public:
void removeAllEventListeners();
void registerDisconnectedNodeWithEventListeners(Node*);
void unregisterDisconnectedNodeWithEventListeners(Node*);
CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
#if ENABLE(SVG)
......@@ -884,7 +881,6 @@ private:
void executeScriptSoonTimerFired(Timer<Document>*);
void updateTitle();
void removeAllDisconnectedNodeEventListeners();
void updateFocusAppearanceTimerFired(Timer<Document>*);
void updateBaseURL();
......@@ -1026,8 +1022,6 @@ private:
typedef HashMap<AtomicStringImpl*, HTMLMapElement*> ImageMapsByName;
ImageMapsByName m_imageMapsByName;
HashSet<Node*> m_disconnectedNodesWithEventListeners;
int m_docID; // A unique document identifier used for things like document-specific mapped attributes.
String m_xmlEncoding;
......
......@@ -452,9 +452,6 @@ Node::~Node()
liveNodeSet.remove(this);
#endif
if (!eventListeners().isEmpty() && !inDocument())
document()->unregisterDisconnectedNodeWithEventListeners(this);
if (!hasRareData())
ASSERT(!NodeRareData::rareDataMap().contains(this));
else {
......@@ -2357,34 +2354,22 @@ const RegisteredEventListenerVector& Node::eventListeners() const
void Node::insertedIntoDocument()
{
if (!eventListeners().isEmpty())
document()->unregisterDisconnectedNodeWithEventListeners(this);
setInDocument(true);
}
void Node::removedFromDocument()
{
if (!eventListeners().isEmpty())
document()->registerDisconnectedNodeWithEventListeners(this);
setInDocument(false);
}
void Node::willMoveToNewOwnerDocument()
{
if (!eventListeners().isEmpty())
document()->unregisterDisconnectedNodeWithEventListeners(this);
ASSERT(!willMoveToNewOwnerDocumentWasCalled);
setWillMoveToNewOwnerDocumentWasCalled(true);
}
void Node::didMoveToNewOwnerDocument()
{
if (!eventListeners().isEmpty())
document()->registerDisconnectedNodeWithEventListeners(this);
ASSERT(!didMoveToNewOwnerDocumentWasCalled);
setDidMoveToNewOwnerDocumentWasCalled(true);
}
......@@ -2428,10 +2413,6 @@ void Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
// The DOM2 spec says that "duplicate instances are discarded" in this case.
removeEventListener(eventType, listener.get(), useCapture);
// adding the first one
if (listeners.isEmpty() && !inDocument())
document->registerDisconnectedNodeWithEventListeners(this);
listeners.append(RegisteredEventListener::create(eventType, listener, useCapture));
updateSVGElementInstancesAfterEventListenerChange(this);
}
......@@ -2452,10 +2433,6 @@ void Node::removeEventListener(const AtomicString& eventType, EventListener* lis
r.setRemoved(true);
listeners->remove(i);
// removed last
if (listeners->isEmpty() && !inDocument())
document()->unregisterDisconnectedNodeWithEventListeners(this);
updateSVGElementInstancesAfterEventListenerChange(this);
return;
}
......@@ -2952,10 +2929,6 @@ void Node::clearAttributeEventListener(const AtomicString& eventType)
r.setRemoved(true);
listeners->remove(i);
// removed last
if (listeners->isEmpty() && !inDocument())
document()->unregisterDisconnectedNodeWithEventListeners(this);
updateSVGElementInstancesAfterEventListenerChange(this);
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment