[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:25:13 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 85586afb9e496bbbc883b001ae8171cdcd51e354
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 19 23:22:42 2003 +0000

    	Make the BidiIterator midpoints use an array instead of a list.
    
            Reviewed by kocienda
    
    	* khtml/rendering/bidi.h
            * khtml/rendering/bidi.cpp:
            * khtml/rendering/render_block.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3672 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index e22f105..2ac93e9 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,13 @@
+2003-02-19  David Hyatt  <hyatt at apple.com>
+
+	Make the BidiIterator midpoints use an array instead of a list.
+	
+        Reviewed by kocienda
+
+	* khtml/rendering/bidi.h
+        * khtml/rendering/bidi.cpp:
+        * khtml/rendering/render_block.h:
+
 2003-02-18  Maciej Stachowiak  <mjs at apple.com
 
 	Reviewed by Chris.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index e22f105..2ac93e9 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,13 @@
+2003-02-19  David Hyatt  <hyatt at apple.com>
+
+	Make the BidiIterator midpoints use an array instead of a list.
+	
+        Reviewed by kocienda
+
+	* khtml/rendering/bidi.h
+        * khtml/rendering/bidi.cpp:
+        * khtml/rendering/render_block.h:
+
 2003-02-18  Maciej Stachowiak  <mjs at apple.com
 
 	Reviewed by Chris.
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index da12568..bdf80d2 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -43,8 +43,15 @@ static BidiIterator current;
 static BidiContext *context;
 static BidiStatus status;
 static QPtrList<BidiRun> *sruns = 0;
-static QPtrList<BidiIterator> *smidpoints = 0;
+
+// Midpoint globals.  The goal is not to do any allocation when dealing with
+// these midpoints, so we just keep an array around and never clear it.  We track
+// the number of items and position using the two other variables.
+static QMemArray<BidiIterator> *smidpoints = 0;
+static uint sNumMidpoints = 0;
+static uint sCurrMidpoint = 0;
 static bool betweenMidpoints = false;
+
 static bool isLineEmpty = true;
 static QChar::Direction dir;
 static bool adjustEmbeddding = false;
@@ -92,37 +99,6 @@ static int inlineWidth(RenderObject* child, bool start = true, bool end = true)
 }
 
 #ifndef NDEBUG
-static bool inBidiIteratorDetach;
-#endif
-
-void BidiIterator::detach(RenderArena* renderArena)
-{
-#ifndef NDEBUG
-    inBidiIteratorDetach = true;
-#endif
-    delete this;
-#ifndef NDEBUG
-    inBidiIteratorDetach = false;
-#endif
-    
-    // Recover the size left there for us by operator delete and free the memory.
-    renderArena->free(*(size_t *)this, this);
-}
-
-void* BidiIterator::operator new(size_t sz, RenderArena* renderArena) throw()
-{
-    return renderArena->allocate(sz);
-}
-
-void BidiIterator::operator delete(void* ptr, size_t sz)
-{
-    assert(inBidiIteratorDetach);
-
-    // Stash size where detach can find it.
-    *(size_t*)ptr = sz;
-}
-
-#ifndef NDEBUG
 static bool inBidiRunDetach;
 #endif
 
@@ -370,39 +346,52 @@ inline QChar::Direction BidiIterator::direction() const
 
 // -------------------------------------------------------------------------------------------------
 
+static void addMidpoint(const BidiIterator& midpoint)
+{
+    if (!smidpoints)
+        return;
+
+    if (smidpoints->size() <= sNumMidpoints)
+        smidpoints->resize(sNumMidpoints+10);
+
+    BidiIterator* midpoints = smidpoints->data();
+    midpoints[sNumMidpoints++] = midpoint;
+}
+
 static void appendRunsForObject(int start, int end, RenderObject* obj)
 {
     if (start > end || obj->isSpecial())
         return;
-        
-    BidiIterator* nextMidpoint = (smidpoints && smidpoints->count()) ? smidpoints->at(0) : 0;
+
+    bool haveNextMidpoint = (smidpoints && sCurrMidpoint < sNumMidpoints);
+    BidiIterator nextMidpoint;
+    if (haveNextMidpoint)
+        nextMidpoint = smidpoints->at(sCurrMidpoint);
     if (betweenMidpoints) {
-        if (!(nextMidpoint && nextMidpoint->obj == obj))
+        if (!(haveNextMidpoint && nextMidpoint.obj == obj))
             return;
         // This is a new start point. Stop ignoring objects and 
         // adjust our start.
         betweenMidpoints = false;
-        start = nextMidpoint->pos;
-        smidpoints->removeFirst(); // Delete the midpoint.
-        nextMidpoint->detach(obj->renderArena());
+        start = nextMidpoint.pos;
+        sCurrMidpoint++;
         if (start < end)
             return appendRunsForObject(start, end, obj);
     }
     else {
-        if (!smidpoints || !nextMidpoint || (obj != nextMidpoint->obj)) {
+        if (!smidpoints || !haveNextMidpoint || (obj != nextMidpoint.obj)) {
             sruns->append( new (obj->renderArena()) BidiRun(start, end, obj, context, dir) );
             return;
         }
         
         // An end midpoint has been encounted within our object.  We
         // need to go ahead and append a run with our endpoint.
-        if (int(nextMidpoint->pos+1) <= end) {
+        if (int(nextMidpoint.pos+1) <= end) {
             sruns->append( new (obj->renderArena())
-                                BidiRun(start, nextMidpoint->pos+1, obj, context, dir) );
+                                BidiRun(start, nextMidpoint.pos+1, obj, context, dir) );
             betweenMidpoints = true;
-            int nextPos = nextMidpoint->pos+1;
-            smidpoints->removeFirst();
-            nextMidpoint->detach(obj->renderArena());
+            int nextPos = nextMidpoint.pos+1;
+            sCurrMidpoint++;
             return appendRunsForObject(nextPos, end, obj);
         }
         else
@@ -1154,21 +1143,6 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator
     sruns = 0;
 }
 
-
-static void deleteMidpoints(RenderArena* arena, QPtrList<BidiIterator>* midpoints)
-{
-    if (!midpoints)
-        return;
-        
-    unsigned int len = midpoints->count();
-    for(unsigned int i=0; i < len; i++) {
-        BidiIterator* s = midpoints->at(i);
-        if (s)
-            s->detach(arena);
-    }
-    midpoints->clear();
-}
-
 void RenderBlock::layoutInlineChildren(bool relayoutChildren)
 {
     m_overflowHeight = 0;
@@ -1231,16 +1205,17 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren)
 
         m_firstLine = true;
         
-        if (!smidpoints) {
-            smidpoints = new QPtrList<BidiIterator>;
-            smidpoints->setAutoDelete(false);
-        }
-                
+        if (!smidpoints)
+            smidpoints = new QMemArray<BidiIterator>;
+
+        sNumMidpoints = 0;
+        sCurrMidpoint = 0;
+        
         while( !end.atEnd() ) {
             start = end;
             betweenMidpoints = false;
             isLineEmpty = true;
-            end = findNextLineBreak(start, *smidpoints);
+            end = findNextLineBreak(start);
             if( start.atEnd() ) break;
             if (!isLineEmpty) {
                 bidiReorderLine(start, end);
@@ -1258,13 +1233,16 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren)
                 m_firstLine = false;
                 newLine();
             }
-            deleteMidpoints(renderArena(), smidpoints);
+
+            sNumMidpoints = 0;
+            sCurrMidpoint = 0;
         }
         startEmbed->deref();
         //embed->deref();
     }
-    
-    deleteMidpoints(renderArena(), smidpoints);
+
+    sNumMidpoints = 0;
+    sCurrMidpoint = 0;
 
     // Now add in the bottom border/padding.
     m_height += toAdd;
@@ -1283,7 +1261,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren)
     //kdDebug(6040) << "height = " << m_height <<endl;
 }
 
-BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIterator>& midpoints)
+BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start)
 {
     int width = lineWidth(m_height);
     int w = 0;
@@ -1400,10 +1378,10 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIt
 
             tmpW += o->width()+o->marginLeft()+o->marginRight()+inlineWidth(o);
             if (ignoringSpaces) {
-                BidiIterator* startMid = new (o->renderArena()) BidiIterator();
-                startMid->obj = o;
-                startMid->pos = 0;
-                midpoints.append(startMid);
+                BidiIterator startMid;
+                startMid.obj = o;
+                startMid.pos = 0;
+                addMidpoint(startMid);
             }
             isLineEmpty = false;
             ignoringSpaces = false;
@@ -1424,10 +1402,10 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIt
                       static_cast<RenderText*>(next)->text()[0] == '\n')) {
                     currentCharacterIsSpace = true;
                     ignoringSpaces = true;
-                    BidiIterator* endMid = new (o->renderArena()) BidiIterator();
-                    endMid->obj = o;
-                    endMid->pos = 0;
-                    midpoints.append(endMid);
+                    BidiIterator endMid;
+                    endMid.obj = o;
+                    endMid.pos = 0;
+                    addMidpoint(endMid);
                 }
             }
         } else if ( o->isText() ) {
@@ -1465,10 +1443,10 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIt
                         if (!currentCharacterIsSpace) {
                             // Stop ignoring spaces and begin at this
                             // new point.
-                            BidiIterator* startMid = new (o->renderArena()) BidiIterator();
-                            startMid->obj = o;
-                            startMid->pos = pos;
-                            midpoints.append(startMid);
+                            BidiIterator startMid;
+                            startMid.obj = o;
+                            startMid.pos = pos;
+                            addMidpoint(startMid);
                             ignoringSpaces = false;
                         }
                         else {
@@ -1543,14 +1521,13 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIt
                             // We just entered a mode where we are ignoring
                             // spaces. Create a midpoint to terminate the run
                             // before the second space. 
-                            BidiIterator* endMid = new (o->renderArena()) BidiIterator();
-                            if (trailingSpaceObject) {
-                                endMid->obj = trailingSpaceObject;
-                            }
+                            BidiIterator endMid;
+                            if (trailingSpaceObject)
+                                endMid.obj = trailingSpaceObject;
                             else
-                                endMid->obj = o;
-                            endMid->pos = lastSpacePos;
-                            midpoints.append(endMid);
+                                endMid.obj = o;
+                            endMid.pos = lastSpacePos;
+                            addMidpoint(endMid);
                             lastSpace = pos;
                         }
                     }
@@ -1561,10 +1538,10 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIt
                     ignoringSpaces = false;
                     lastSpacePos = 0;
                     lastSpace = pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
-                    BidiIterator* startMid = new (o->renderArena()) BidiIterator();
-                    startMid->obj = o;
-                    startMid->pos = pos;
-                    midpoints.append(startMid);
+                    BidiIterator startMid;
+                    startMid.obj = o;
+                    startMid.pos = pos;
+                    addMidpoint(startMid);
                 }
                 
                 if (!isPre && currentCharacterIsSpace && !ignoringSpaces)
@@ -1714,20 +1691,19 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, QPtrList<BidiIt
         // This object is either going to be part of the last midpoint, or it is going
         // to be the actual endpoint.  In both cases we just decrease our pos by 1 level to
         // exclude the space, allowing it to - in effect - collapse into the newline.
-        int count = midpoints.count();
-        if (count%2==1) {
-            BidiIterator* lastEndPoint = midpoints.at(count-1);
-            lastEndPoint->pos--;
+        if (sNumMidpoints%2==1) {
+            BidiIterator* midpoints = smidpoints->data();
+            midpoints[sNumMidpoints-1].pos--;
         }
         //else if (lBreak.pos > 0)
         //    lBreak.pos--;
         else if (lBreak.obj == 0 && trailingSpaceObject->isText()) {
             // Add a new end midpoint that stops right at the very end.
-            BidiIterator* endMid = new (trailingSpaceObject->renderArena()) BidiIterator();
-            endMid->obj = trailingSpaceObject;
+            BidiIterator endMid;
+            endMid.obj = trailingSpaceObject;
             RenderText* text = static_cast<RenderText *>(trailingSpaceObject);
-            endMid->pos = text->length() >=2 ? text->length() - 2 : 0;
-            midpoints.append(endMid);
+            endMid.pos = text->length() >=2 ? text->length() - 2 : 0;
+            addMidpoint(endMid);
         }
     }
 
diff --git a/WebCore/khtml/rendering/bidi.h b/WebCore/khtml/rendering/bidi.h
index 6d73a99..eb49a87 100644
--- a/WebCore/khtml/rendering/bidi.h
+++ b/WebCore/khtml/rendering/bidi.h
@@ -113,19 +113,6 @@ public:
 	const QChar &current() const;
 	QChar::Direction direction() const;
 
-    void detach(RenderArena* renderArena);
-    
-    // Overloaded new operator.  Derived classes must override operator new
-    // in order to allocate out of the RenderArena.
-    void* operator new(size_t sz, RenderArena* renderArena) throw();    
-
-    // Overridden to prevent the normal delete from being called.
-    void operator delete(void* ptr, size_t sz);
-        
-private:
-    // The normal operator new is disallowed.
-    void* operator new(size_t sz) throw();
-
 public:
 	RenderBlock *par;
 	RenderObject *obj;
diff --git a/WebCore/khtml/rendering/render_block.h b/WebCore/khtml/rendering/render_block.h
index fd18d60..712365c 100644
--- a/WebCore/khtml/rendering/render_block.h
+++ b/WebCore/khtml/rendering/render_block.h
@@ -92,7 +92,7 @@ public:
 
     // the implementation of the following functions is in bidi.cpp
     void bidiReorderLine(const BidiIterator &start, const BidiIterator &end);
-    BidiIterator findNextLineBreak(BidiIterator &start, QPtrList<BidiIterator>& midpoints);
+    BidiIterator findNextLineBreak(BidiIterator &start);
     InlineFlowBox* constructLine(QPtrList<BidiRun>& runs, const BidiIterator& start,
                                  const BidiIterator& end);
     InlineFlowBox* createLineBoxes(RenderObject* obj);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list