Convert selectionRect() from using a list to a dict and patch it to be like setSelec...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Oct 2004 20:15:08 +0000 (20:15 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Oct 2004 20:15:08 +0000 (20:15 +0000)
to use the old dirty bit optimization (which had been removed), and so it was pathologically slow on large documents.

        Reviewed by kocienda

        * khtml/rendering/render_canvas.cpp:
        (RenderCanvas::selectionRect):
        * khtml/rendering/render_object.h:
        (khtml::RenderObject::hasSelectedChildren):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7899 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_canvas.cpp
WebCore/khtml/rendering/render_object.h

index 1d02af106cc2fa8fa4060b9635a247a3b7b50ef1..f60e5bbad303c7a0ab8ad12d3b1988b41a0faef5 100644 (file)
@@ -1,3 +1,15 @@
+2004-10-26  David Hyatt  <hyatt@apple.com>
+
+       Convert selectionRect() from using a list to a dict and patch it to be like setSelection.  It was still trying
+       to use the old dirty bit optimization (which had been removed), and so it was pathologically slow on large documents.
+       
+        Reviewed by kocienda
+
+        * khtml/rendering/render_canvas.cpp:
+        (RenderCanvas::selectionRect):
+        * khtml/rendering/render_object.h:
+        (khtml::RenderObject::hasSelectedChildren):
+
 2004-10-26  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Hyatt
index 9455042113a6461175dd1365dbc280b65cf4303f..fe90a49be0daabc7ca96ff6a2385c1f907116ec6 100644 (file)
@@ -305,7 +305,8 @@ void RenderCanvas::absoluteRects(QValueList<QRect>& rects, int _tx, int _ty)
 
 QRect RenderCanvas::selectionRect() const
 {
-    QValueList<SelectionInfo> selectedObjects;
+    QPtrDict<SelectionInfo> selectedObjects;
+    selectedObjects.setAutoDelete(true);
     RenderObject* os = m_selectionStart;
     while (os) {
         RenderObject* no = 0;
@@ -321,29 +322,26 @@ QRect RenderCanvas::selectionRect() const
             }
         }
         
-        if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) &&
-            os->selectionState() != SelectionNone) {
+        if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
             // Blocks are responsible for painting line gaps and margin gaps.  They must be examined as well.
-            selectedObjects.append(SelectionInfo(os));
+            selectedObjects.insert(os, new SelectionInfo(os));
             RenderBlock* cb = os->containingBlock();
-            while (cb && !cb->hasDirtySelectionState() && cb->hasSelectedChildren()) {
-                selectedObjects.append(SelectionInfo(cb));
-                cb->setHasDirtySelectionState(true);
+            while (cb && !cb->isCanvas()) {
+                SelectionInfo* blockInfo = selectedObjects.find(cb);
+                if (blockInfo) break;
+                selectedObjects.insert(cb, new SelectionInfo(cb));
                 cb = cb->containingBlock();
             }
         }
-
+        
         os = no;
     }
 
     // Now create a single bounding box rect that encloses the whole selection.
     QRect selRect;
-    QValueListConstIterator<SelectionInfo> it;
-    for (it = selectedObjects.begin(); it != selectedObjects.end(); ++it) {
-        (*it).object()->setHasDirtySelectionState(false);
-        selRect = selRect.unite((*it).rect());
-    }
-
+    QPtrDictIterator<SelectionInfo> objects(selectedObjects);
+    for (objects.toFirst(); objects.current(); ++objects)
+        selRect = selRect.unite(objects.current()->rect());
     return selRect;
 }
 
index 5a378bc4a440b0920c5608b3595f315915208eb2..0474a0336a1af4e74ace544292543ed96be11051 100644 (file)
@@ -741,10 +741,6 @@ public:
 
     // Whether or not a block has selected children.
     virtual bool hasSelectedChildren() const { return false; }
-    
-    // A dirty bit used when determining the correct selection state of blocks.  Used to avoid repeatedly examining the same blocks.
-    virtual bool hasDirtySelectionState() const { return false; }
-    virtual void setHasDirtySelectionState(bool b) {}
 
     // Whether or not a selection can be attempted on this object.  Should only be called right before actually beginning a selection,
     // since it fires the selectstart DOM event.