render tree destruction speedup
David Hyatt
hyatt at apple.com
Thu Oct 2 14:40:04 CEST 2003
Taking advantage of the ability to test for document destruction by
querying its renderer to avoid doing some extra work...
Index: khtml/rendering/render_block.cpp
===================================================================
RCS file:
/local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_block.cpp,v
retrieving revision 1.60
diff -u -p -r1.60 khtml/rendering/render_block.cpp
--- khtml/rendering/render_block.cpp 2003/10/01 20:58:55 1.60
+++ khtml/rendering/render_block.cpp 2003/10/02 01:42:38
@@ -319,7 +319,7 @@ void RenderBlock::removeChild(RenderObje
RenderObject* prev = oldChild->previousSibling();
RenderObject* next = oldChild->nextSibling();
bool mergedBlocks = false;
- if (!isInline() && !oldChild->isInline() &&
!oldChild->continuation() &&
+ if (document()->renderer() && !isInline() && !oldChild->isInline()
&& !oldChild->continuation() &&
prev && prev->isAnonymous() && prev->childrenInline() &&
next && next->isAnonymous() && next->childrenInline()) {
// Take all the children out of the |next| block and put them
in
Index: khtml/rendering/render_container.cpp
===================================================================
RCS file:
/local/home/cvs/Labyrinth/WebCore/khtml/rendering/
render_container.cpp,v
retrieving revision 1.41
diff -u -p -r1.41 khtml/rendering/render_container.cpp
--- khtml/rendering/render_container.cpp 2003/10/01 20:58:55 1.41
+++ khtml/rendering/render_container.cpp 2003/10/02 01:42:38
@@ -158,32 +158,34 @@ RenderObject* RenderContainer::removeChi
// So that we'll get the appropriate dirty bit set (either that a
normal flow child got yanked or
// that a positioned child got yanked). We also repaint, so that
the area exposed when the child
// disappears gets repainted properly.
- oldChild->setNeedsLayoutAndMinMaxRecalc();
+ if (document()->renderer()) {
+ oldChild->setNeedsLayoutAndMinMaxRecalc();
#ifdef INCREMENTAL_REPAINTING
- oldChild->repaint();
+ oldChild->repaint();
#endif
+
+ // Keep our layer hierarchy updated.
+ oldChild->removeLayers(enclosingLayer());
- // Keep our layer hierarchy updated.
- oldChild->removeLayers(enclosingLayer());
-
- // if oldChild is the start or end of the selection, then clear
the selection to
- // avoid problems of invalid pointers
-
- // ### This is not the "proper" solution... ideally the selection
should be maintained
- // based on DOM Nodes and a Range, which gets adjusted
appropriately when nodes are
- // deleted/inserted near etc. But this at least prevents crashes
caused when the start
- // or end of the selection is deleted and then accessed when the
user next selects
- // something.
-
- if (oldChild->isSelectionBorder()) {
- RenderObject *root = oldChild;
- while (root && root->parent())
- root = root->parent();
- if (root->isCanvas()) {
- static_cast<RenderCanvas*>(root)->clearSelection();
+ // if oldChild is the start or end of the selection, then
clear the selection to
+ // avoid problems of invalid pointers
+
+ // ### This is not the "proper" solution... ideally the
selection should be maintained
+ // based on DOM Nodes and a Range, which gets adjusted
appropriately when nodes are
+ // deleted/inserted near etc. But this at least prevents
crashes caused when the start
+ // or end of the selection is deleted and then accessed when
the user next selects
+ // something.
+
+ if (oldChild->isSelectionBorder()) {
+ RenderObject *root = oldChild;
+ while (root && root->parent())
+ root = root->parent();
+ if (root->isCanvas()) {
+ static_cast<RenderCanvas*>(root)->clearSelection();
+ }
}
}
-
+
// remove the child
if (oldChild->previousSibling())
oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
More information about the Khtml-devel
mailing list