Reviewed by Tim Hatcher.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2007 18:06:06 +0000 (18:06 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2007 18:06:06 +0000 (18:06 +0000)
        - fix http://bugs.webkig.org/show_bug.cgi?id=14981
          DEBUG builds of WebKit hang videwing Yahoo! Mail messages
          with ~5 MB text attachment

        * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::checkConsistency):
        * rendering/RenderFlow.cpp: (WebCore::RenderFlow::checkConsistency):
        * rendering/RenderText.cpp: (WebCore::RenderText::checkConsistency):
        Put the actual consistency check inside an ifdef. If you need it you can
        turn it on. There's still some function call overhead in builds that don't
        have NDEBUG defined, but that's worth it so we can turn this on and off
        without recompiling the world.

        - small code style improvement to recently changed function

        * editing/TextIterator.cpp: (WebCore::plainTextToMallocAllocatedBuffer):
        Use a typedef and make_pair to make the code dealing with the pair simpler to read.

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

WebCore/ChangeLog
WebCore/editing/TextIterator.cpp
WebCore/rendering/InlineFlowBox.cpp
WebCore/rendering/RenderFlow.cpp
WebCore/rendering/RenderText.cpp

index ee63b5c9c43b9bdb66b79576bb1e8b8ff15ab5c3..f25b40d5225e435e9d493e864950faaf4c32083f 100644 (file)
@@ -1,3 +1,24 @@
+2007-08-30  Darin Adler  <darin@apple.com>
+
+        Reviewed by Tim Hatcher.
+
+        - fix http://bugs.webkig.org/show_bug.cgi?id=14981
+          DEBUG builds of WebKit hang videwing Yahoo! Mail messages
+          with ~5 MB text attachment
+
+        * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::checkConsistency):
+        * rendering/RenderFlow.cpp: (WebCore::RenderFlow::checkConsistency):
+        * rendering/RenderText.cpp: (WebCore::RenderText::checkConsistency):
+        Put the actual consistency check inside an ifdef. If you need it you can
+        turn it on. There's still some function call overhead in builds that don't
+        have NDEBUG defined, but that's worth it so we can turn this on and off
+        without recompiling the world.
+
+        - small code style improvement to recently changed function
+
+        * editing/TextIterator.cpp: (WebCore::plainTextToMallocAllocatedBuffer):
+        Use a typedef and make_pair to make the code dealing with the pair simpler to read.
+
 2007-08-30  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Zack.
index ec56e9e30ffe57a9b139e760ca878450af2ac731..7b4a64c05b1f4270aa47797144749d3468498baf 100644 (file)
@@ -1246,7 +1246,8 @@ UChar* plainTextToMallocAllocatedBuffer(const Range* r, unsigned& bufferLength)
     // Use system malloc for buffers since they can consume lots of memory and current TCMalloc is unable return it back to OS.
     static const unsigned cMaxSegmentSize = 1 << 16;
     bufferLength = 0;
-    Vector<pair<UChar*, unsigned> >* textSegments = 0;
+    typedef pair<UChar*, unsigned> TextSegment;
+    Vector<TextSegment>* textSegments = 0;
     Vector<UChar> textBuffer;
     textBuffer.reserveCapacity(cMaxSegmentSize);
     for (TextIterator it(r); !it.atEnd(); it.advance()) {
@@ -1255,10 +1256,9 @@ UChar* plainTextToMallocAllocatedBuffer(const Range* r, unsigned& bufferLength)
             if (!newSegmentBuffer)
                 goto exit;
             memcpy(newSegmentBuffer, textBuffer.data(), textBuffer.size() * sizeof(UChar));
-            pair<UChar*, unsigned> newSegment(newSegmentBuffer, textBuffer.size());
             if (!textSegments)
-                textSegments = new Vector<pair<UChar*, unsigned> >;
-            textSegments->append(newSegment);
+                textSegments = new Vector<TextSegment>;
+            textSegments->append(make_pair(newSegmentBuffer, textBuffer.size()));
             textBuffer.clear();
         }
         textBuffer.append(it.characters(), it.length());
@@ -1278,7 +1278,7 @@ UChar* plainTextToMallocAllocatedBuffer(const Range* r, unsigned& bufferLength)
         if (textSegments) {
             unsigned size = textSegments->size();
             for (unsigned i = 0; i < size; ++i) {
-                const pair<UChar*, unsigned>& segment = textSegments->at(i);
+                const TextSegment& segment = textSegments->at(i);
                 memcpy(resultPos, segment.first, segment.second * sizeof(UChar));
                 resultPos += segment.second;
             }
index bf78d2346a697f4bd9ba89ecc5f348f851bf6255..3554dc28980744eeab7e06e6e27cc8cdacfdd566 100644 (file)
@@ -931,6 +931,7 @@ void InlineFlowBox::clearTruncation()
 
 void InlineFlowBox::checkConsistency() const
 {
+#ifdef CHECK_CONSISTENCY
     ASSERT(!m_hasBadChildList);
     const InlineBox* prev = 0;
     for (const InlineBox* child = m_firstChild; child; child = child->nextOnLine()) {
@@ -939,6 +940,7 @@ void InlineFlowBox::checkConsistency() const
         prev = child;
     }
     ASSERT(prev == m_lastChild);
+#endif
 }
 
 #endif
index 90baabadda22e05abc924bbde93494b44f7eeb3b..eddbf7a15a87b32df62d5c6dc0da571e3d1aa451 100644 (file)
@@ -856,6 +856,7 @@ void RenderFlow::paintOutlineForLine(GraphicsContext* graphicsContext, int tx, i
 
 void RenderFlow::checkConsistency() const
 {
+#ifdef CHECK_CONSISTENCY
     const InlineFlowBox* prev = 0;
     for (const InlineFlowBox* child = m_firstLineBox; child != 0; child = child->nextFlowBox()) {
         ASSERT(child->object() == this);
@@ -863,6 +864,7 @@ void RenderFlow::checkConsistency() const
         prev = child;
     }
     ASSERT(prev == m_lastLineBox);
+#endif
 }
 
 #endif
index 6d90dd87302db80ae65d508c12051b46bc0a34a6..84c6f8a40bffcdd4d02cee492b0319c9937b089c 100644 (file)
@@ -1178,6 +1178,7 @@ InlineBox* RenderText::inlineBox(int offset, EAffinity affinity)
 
 void RenderText::checkConsistency() const
 {
+#ifdef CHECK_CONSISTENCY
     const InlineTextBox* prev = 0;
     for (const InlineTextBox* child = m_firstTextBox; child != 0; child = child->nextTextBox()) {
         ASSERT(child->object() == this);
@@ -1185,6 +1186,7 @@ void RenderText::checkConsistency() const
         prev = child;
     }
     ASSERT(prev == m_lastTextBox);
+#endif
 }
 
 #endif