[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mitz at apple.com mitz at apple.com
Wed Dec 22 14:41:16 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6d1003805a8331923bd296fccba8355200ebffeb
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 15 22:27:52 2010 +0000

    Clean up RenderFlexibleBox::applyLineClamp()
    https://bugs.webkit.org/show_bug.cgi?id=47743
    
    Reviewed by Adele Peterson.
    
    * rendering/RenderFlexibleBox.cpp:
    (WebCore::RenderFlexibleBox::applyLineClamp):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69890 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5c09d65..86aa30a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-15  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Clean up RenderFlexibleBox::applyLineClamp()
+        https://bugs.webkit.org/show_bug.cgi?id=47743
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::applyLineClamp):
+
 2010-10-15  Alexey Proskuryakov  <ap at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/rendering/RenderFlexibleBox.cpp b/WebCore/rendering/RenderFlexibleBox.cpp
index de6ef40..38454fa 100644
--- a/WebCore/rendering/RenderFlexibleBox.cpp
+++ b/WebCore/rendering/RenderFlexibleBox.cpp
@@ -913,103 +913,102 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
 void RenderFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren)
 {
     int maxLineCount = 0;
-    RenderBox* child = iterator.first();
-    while (child) {
-        if (!child->isPositioned()) {
-            if (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent())) ||
-                (child->style()->height().isAuto() && child->isBlockFlow() && !child->needsLayout())) {
-                child->setChildNeedsLayout(true, false);
-                
-                // Dirty all the positioned objects.
-                if (child->isRenderBlock()) {
-                    toRenderBlock(child)->markPositionedObjectsForLayout();
-                    toRenderBlock(child)->clearTruncation();
-                }
+    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
+        if (child->isPositioned())
+            continue;
+
+        if (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent()))
+            || (child->style()->height().isAuto() && child->isBlockFlow() && !child->needsLayout())) {
+            child->setChildNeedsLayout(true, false);
+
+            // Dirty all the positioned objects.
+            if (child->isRenderBlock()) {
+                toRenderBlock(child)->markPositionedObjectsForLayout();
+                toRenderBlock(child)->clearTruncation();
             }
-            child->layoutIfNeeded();
-            if (child->style()->height().isAuto() && child->isBlockFlow())
-                maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount());
         }
-        child = iterator.next();
+        child->layoutIfNeeded();
+        if (child->style()->height().isAuto() && child->isBlockFlow())
+            maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount());
     }
-    
-    // Get the # of lines and then alter all block flow children with auto height to use the
+
+    // Get the number of lines and then alter all block flow children with auto height to use the
     // specified height. We always try to leave room for at least one line.
     LineClampValue lineClamp = style()->lineClamp();
     int numVisibleLines = lineClamp.isPercentage() ? max(1, (maxLineCount + 1) * lineClamp.value() / 100) : lineClamp.value();
-    if (numVisibleLines < maxLineCount) {
-        for (child = iterator.first(); child; child = iterator.next()) {
-            if (child->isPositioned() || !child->style()->height().isAuto() || !child->isBlockFlow())
-                continue;
-            
-            RenderBlock* blockChild = toRenderBlock(child);
-            int lineCount = blockChild->lineCount();
-            if (lineCount <= numVisibleLines)
-                continue;
-            
-            int newHeight = blockChild->heightForLineCount(numVisibleLines);
-            if (newHeight == child->height())
-                continue;
-            
-            child->setChildNeedsLayout(true, false);
-            child->setOverrideSize(newHeight);
-            m_flexingChildren = true;
-            child->layoutIfNeeded();
-            m_flexingChildren = false;
-            child->setOverrideSize(-1);
-            
-            // FIXME: For now don't support RTL.
-            if (style()->direction() != LTR)
-                continue;
-            
-            // Get the last line
-            RootInlineBox* lastLine = blockChild->lineAtIndex(lineCount-1);
-            if (!lastLine)
-                continue;
-            
-            RootInlineBox* lastVisibleLine = blockChild->lineAtIndex(numVisibleLines-1);
-            if (!lastVisibleLine)
-                continue;
-            
-            const UChar ellipsisAndSpace[2] = { horizontalEllipsis, ' ' };
-            DEFINE_STATIC_LOCAL(AtomicString, ellipsisAndSpaceStr, (ellipsisAndSpace, 2));
-            DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1));
-            const Font& font = style(numVisibleLines == 1)->font();
-            
-            // Get ellipsis width, and if the last child is an anchor, it will go after the ellipsis, so add in a space and the anchor width too 
-            int totalWidth;
-            InlineBox* anchorBox = lastLine->lastChild();
-            if (anchorBox && anchorBox->renderer()->node() && anchorBox->renderer()->node()->isLink())
-                totalWidth = anchorBox->logicalWidth() + font.width(TextRun(ellipsisAndSpace, 2));
-            else {
-                anchorBox = 0;
-                totalWidth = font.width(TextRun(&horizontalEllipsis, 1));
-            }
-            
-            // See if this width can be accommodated on the last visible line
-            RenderBlock* destBlock = toRenderBlock(lastVisibleLine->renderer());
-            RenderBlock* srcBlock = toRenderBlock(lastLine->renderer());
-            
-            // FIXME: Directions of src/destBlock could be different from our direction and from one another.
-            if (srcBlock->style()->direction() != LTR)
-                continue;
-            if (destBlock->style()->direction() != LTR)
-                continue;
-            int ltr = true;
-            
-            int blockRightEdge = destBlock->logicalRightOffsetForLine(lastVisibleLine->y(), false);
-            int blockLeftEdge = destBlock->logicalLeftOffsetForLine(lastVisibleLine->y(), false);
-            
-            int blockEdge = ltr ? blockRightEdge : blockLeftEdge;
-            if (!lastVisibleLine->canAccommodateEllipsis(ltr, blockEdge,
-                                                         lastVisibleLine->x() + lastVisibleLine->logicalWidth(),
-                                                         totalWidth))
-                continue;
-            
-            // Let the truncation code kick in.
-            lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, ltr, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
-            destBlock->setHasMarkupTruncation(true);
+    if (numVisibleLines >= maxLineCount)
+        return;
+
+    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
+        if (child->isPositioned() || !child->style()->height().isAuto() || !child->isBlockFlow())
+            continue;
+        
+        RenderBlock* blockChild = toRenderBlock(child);
+        int lineCount = blockChild->lineCount();
+        if (lineCount <= numVisibleLines)
+            continue;
+        
+        int newHeight = blockChild->heightForLineCount(numVisibleLines);
+        if (newHeight == child->height())
+            continue;
+        
+        child->setChildNeedsLayout(true, false);
+        child->setOverrideSize(newHeight);
+        m_flexingChildren = true;
+        child->layoutIfNeeded();
+        m_flexingChildren = false;
+        child->setOverrideSize(-1);
+
+        // FIXME: For now don't support RTL.
+        if (style()->direction() != LTR)
+            continue;
+
+        // Get the last line
+        RootInlineBox* lastLine = blockChild->lineAtIndex(lineCount-1);
+        if (!lastLine)
+            continue;
+
+        RootInlineBox* lastVisibleLine = blockChild->lineAtIndex(numVisibleLines-1);
+        if (!lastVisibleLine)
+            continue;
+
+        const UChar ellipsisAndSpace[2] = { horizontalEllipsis, ' ' };
+        DEFINE_STATIC_LOCAL(AtomicString, ellipsisAndSpaceStr, (ellipsisAndSpace, 2));
+        DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1));
+        const Font& font = style(numVisibleLines == 1)->font();
+
+        // Get ellipsis width, and if the last child is an anchor, it will go after the ellipsis, so add in a space and the anchor width too 
+        int totalWidth;
+        InlineBox* anchorBox = lastLine->lastChild();
+        if (anchorBox && anchorBox->renderer()->node() && anchorBox->renderer()->node()->isLink())
+            totalWidth = anchorBox->logicalWidth() + font.width(TextRun(ellipsisAndSpace, 2));
+        else {
+            anchorBox = 0;
+            totalWidth = font.width(TextRun(&horizontalEllipsis, 1));
         }
+
+        // See if this width can be accommodated on the last visible line
+        RenderBlock* destBlock = toRenderBlock(lastVisibleLine->renderer());
+        RenderBlock* srcBlock = toRenderBlock(lastLine->renderer());
+        
+        // FIXME: Directions of src/destBlock could be different from our direction and from one another.
+        if (!srcBlock->style()->isLeftToRightDirection())
+            continue;
+
+        bool leftToRight = destBlock->style()->isLeftToRightDirection();
+        if (!leftToRight)
+            continue;
+
+        int blockRightEdge = destBlock->logicalRightOffsetForLine(lastVisibleLine->y(), false);
+        int blockLeftEdge = destBlock->logicalLeftOffsetForLine(lastVisibleLine->y(), false);
+
+        int blockEdge = leftToRight ? blockRightEdge : blockLeftEdge;
+        if (!lastVisibleLine->canAccommodateEllipsis(leftToRight, blockEdge, lastVisibleLine->x() + lastVisibleLine->logicalWidth(), totalWidth))
+            continue;
+
+        // Let the truncation code kick in.
+        lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, leftToRight, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
+        destBlock->setHasMarkupTruncation(true);
     }
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list