<rdar://problem/
4002864> REGRESSION(125-146) getElementById in onload fails in a test case involving external resources
Moved management of elementById hashtable from attach/detach to
insertedIntoDocument/removedFromDocument, to avoid being thrown
off by temporary detaches due to style recalcs.
* khtml/xml/dom_elementimpl.cpp:
(ElementImpl::insertedIntoDocument):
(ElementImpl::removedFromDocument):
(ElementImpl::attach):
(ElementImpl::updateId):
* khtml/xml/dom_elementimpl.h:
Make sure that insertedIntoDocument is called before firing any
DOM events.
* khtml/xml/dom_nodeimpl.cpp:
(NodeBaseImpl::dispatchChildInsertedEvents):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8724
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-02-28 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/4002864> REGRESSION(125-146) getElementById in onload fails in a test case involving external resources
+
+ Moved management of elementById hashtable from attach/detach to
+ insertedIntoDocument/removedFromDocument, to avoid being thrown
+ off by temporary detaches due to style recalcs.
+
+ * khtml/xml/dom_elementimpl.cpp:
+ (ElementImpl::insertedIntoDocument):
+ (ElementImpl::removedFromDocument):
+ (ElementImpl::attach):
+ (ElementImpl::updateId):
+ * khtml/xml/dom_elementimpl.h:
+
+ Make sure that insertedIntoDocument is called before firing any
+ DOM events.
+
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeBaseImpl::dispatchChildInsertedEvents):
+
2005-02-28 David Hyatt <hyatt@apple.com>
Fix for 4028999, safari crashes when resetting if mallocsribble is on. Clip rects were being cleared using dead
return RenderObject::createObject(this, style);
}
-void ElementImpl::attach()
+
+void ElementImpl::insertedIntoDocument()
{
-#if SPEED_DEBUG < 1
- createRendererIfNeeded();
-#endif
- NodeBaseImpl::attach();
+ // need to do superclass processing first so inDocument() is true
+ // by the time we reach updateId
+ NodeBaseImpl::insertedIntoDocument();
if (hasID()) {
NamedAttrMapImpl *attrs = attributes(true);
}
}
-void ElementImpl::detach()
+void ElementImpl::removedFromDocument()
{
if (hasID()) {
NamedAttrMapImpl *attrs = attributes(true);
}
}
- NodeBaseImpl::detach();
+ NodeBaseImpl::removedFromDocument();
+}
+
+void ElementImpl::attach()
+{
+#if SPEED_DEBUG < 1
+ createRendererIfNeeded();
+#endif
+ NodeBaseImpl::attach();
}
void ElementImpl::recalcStyle( StyleChange change )
void ElementImpl::updateId(const AtomicString& oldId, const AtomicString& newId)
{
- if (!attached())
+ if (!inDocument())
return;
if (oldId == newId)
virtual NodeImpl *cloneNode ( bool deep );
virtual DOMString nodeName() const;
virtual bool isElementNode() const { return true; }
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
// convenience methods which ignore exceptions
void setAttribute (NodeImpl::Id id, const DOMString &value);
virtual QString state() { return QString::null; }
virtual void attach();
- virtual void detach();
virtual khtml::RenderStyle *styleForRenderer(khtml::RenderObject *parent);
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
virtual void recalcStyle( StyleChange = NoChange );
virtual Node removeNamedItem ( NodeImpl::Id id, int &exceptioncode );
virtual Node setNamedItem ( NodeImpl* arg, int &exceptioncode );
+
virtual AttrImpl *item ( unsigned long index ) const;
unsigned long length() const { return len; }
void NodeBaseImpl::dispatchChildInsertedEvents( NodeImpl *child, int &exceptioncode )
{
+ NodeImpl *p = this;
+ while (p->parentNode())
+ p = p->parentNode();
+
+ if (p->nodeType() == Node::DOCUMENT_NODE) {
+ for (NodeImpl *c = child; c; c = c->traverseNextNode(child)) {
+ c->insertedIntoDocument();
+ }
+ }
+
if (getDocument()->hasListenerType(DocumentImpl::DOMNODEINSERTED_LISTENER)) {
child->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEINSERTED_EVENT,
true,false,this,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
return;
}
- // dispatch the DOMNOdeInsertedInfoDocument event to all descendants
+ // dispatch the DOMNodeInsertedIntoDocument event to all descendants
bool hasInsertedListeners = getDocument()->hasListenerType(DocumentImpl::DOMNODEINSERTEDINTODOCUMENT_LISTENER);
- NodeImpl *p = this;
- while (p->parentNode())
- p = p->parentNode();
- if (p->nodeType() == Node::DOCUMENT_NODE) {
- for (NodeImpl *c = child; c; c = c->traverseNextNode(child)) {
- c->insertedIntoDocument();
- if (hasInsertedListeners) {
- c->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEINSERTEDINTODOCUMENT_EVENT,
- false,false,0,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
- if (exceptioncode)
- return;
- }
+ if (hasInsertedListeners && p->nodeType() == Node::DOCUMENT_NODE) {
+ for (NodeImpl *c = child; c; c = c->traverseNextNode(child)) {
+ c->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEINSERTEDINTODOCUMENT_EVENT,
+ false,false,0,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
+ if (exceptioncode)
+ return;
}
}
}