[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/khtml/xml
From: Germain Garand <germain () ebooksfrance ! com>
Date: 2007-10-22 16:35:01
Message-ID: 1193070901.438432.26315.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 728184 by ggarand:
Cache the document element: now that we have comments in dom,
it can be slow to walk the tree each and every time.
Adapted from similar change in WC r15247
by Timothy Hatcher <timothy@apple.com>
M +25 -4 dom_docimpl.cpp
M +3 -0 dom_docimpl.h
--- trunk/KDE/kdelibs/khtml/xml/dom_docimpl.cpp #728183:728184
@@ -376,6 +376,7 @@
m_docLoading = false;
m_inSyncLoad = false;
m_loadingXMLDoc = 0;
+ m_documentElement = 0;
m_cssTarget = 0;
m_dynamicDomRestyler = new khtml::DynamicDomRestyler();
}
@@ -420,6 +421,11 @@
m_activeNode->deref();
m_activeNode = 0;
}
+
+ if (m_documentElement) {
+ m_documentElement->deref();
+ m_documentElement = 0;
+ }
removeChildren();
@@ -468,6 +474,8 @@
m_hoverNode->deref();
if (m_activeNode)
m_activeNode->deref();
+ if (m_documentElement)
+ m_documentElement->deref();
m_renderArena.reset();
@@ -485,12 +493,25 @@
return m_implementation;
}
+void DocumentImpl::childrenChanged()
+{
+ // invalidate the document element we have cached in case it was replaced
+ if (m_documentElement)
+ m_documentElement->deref();
+ m_documentElement = 0;
+}
+
ElementImpl *DocumentImpl::documentElement() const
{
- NodeImpl *n = firstChild();
- while (n && n->nodeType() != Node::ELEMENT_NODE)
- n = n->nextSibling();
- return static_cast<ElementImpl*>(n);
+ if (!m_documentElement) {
+ NodeImpl* n = firstChild();
+ while (n && n->nodeType() != Node::ELEMENT_NODE)
+ n = n->nextSibling();
+ m_documentElement = static_cast<ElementImpl*>(n);
+ if (m_documentElement)
+ m_documentElement->ref();
+ }
+ return m_documentElement;
}
ElementImpl *DocumentImpl::createElement( const DOMString &name, int* pExceptioncode )
--- trunk/KDE/kdelibs/khtml/xml/dom_docimpl.h #728183:728184
@@ -190,6 +190,7 @@
DOMImplementationImpl *implementation() const;
ElementImpl *documentElement() const;
+ virtual void childrenChanged();
virtual ElementImpl *createElement ( const DOMString &tagName, int* pExceptioncode = 0 );
virtual AttrImpl *createAttribute( const DOMString &tagName, int* pExceptioncode = 0 );
DocumentFragmentImpl *createDocumentFragment ();
@@ -650,6 +651,8 @@
DOMString m_title;
DOMString m_preferredStylesheetSet;
khtml::CachedCSSStyleSheet *m_loadingXMLDoc;
+
+ mutable ElementImpl* m_documentElement;
//int m_decoderMibEnum;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic