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

adele at apple.com adele at apple.com
Wed Dec 22 13:20:10 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 50e3bc2cd105d173de3f8d9c2ed349b49dcaf889
Author: adele at apple.com <adele at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 11 13:20:26 2010 +0000

    Fix for https://bugs.webkit.org/show_bug.cgi?id=45587
    Move line clamp code to its own function.
    
    Reviewed by Sam Weinig.
    
    * rendering/RenderFlexibleBox.cpp:
    (WebCore::RenderFlexibleBox::layoutVerticalBox):
    (WebCore::RenderFlexibleBox::applyLineClamp):
    * rendering/RenderFlexibleBox.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67296 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f527c5f..d4152ae 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-11  Adele Peterson  <adele at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=45587
+        Move line clamp code to its own function.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutVerticalBox):
+        (WebCore::RenderFlexibleBox::applyLineClamp):
+        * rendering/RenderFlexibleBox.h:
+
 2010-09-11  Mihai Parparita  <mihaip at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/rendering/RenderFlexibleBox.cpp b/WebCore/rendering/RenderFlexibleBox.cpp
index 238b16d..c29f736 100644
--- a/WebCore/rendering/RenderFlexibleBox.cpp
+++ b/WebCore/rendering/RenderFlexibleBox.cpp
@@ -646,107 +646,8 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
     // We confine the line clamp ugliness to vertical flexible boxes (thus keeping it out of
     // mainstream block layout); this is not really part of the XUL box model.
     bool haveLineClamp = !style()->lineClamp().isNone();
-    if (haveLineClamp) {
-        int maxLineCount = 0;
-        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();
-                    }
-                }
-                child->layoutIfNeeded();
-                if (child->style()->height().isAuto() && child->isBlockFlow())
-                    maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount());
-            }
-            child = iterator.next();
-        }
-        
-        // Get the # 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->width() + 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->rightOffset(lastVisibleLine->y(), false);
-                int blockLeftEdge = destBlock->leftOffset(lastVisibleLine->y(), false);
-
-                int blockEdge = ltr ? blockRightEdge : blockLeftEdge;
-                if (!lastVisibleLine->canAccommodateEllipsis(ltr, blockEdge,
-                                                             lastVisibleLine->x() + lastVisibleLine->width(),
-                                                             totalWidth))
-                    continue;
-
-                // Let the truncation code kick in.
-                lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, ltr, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
-                destBlock->setHasMarkupTruncation(true);
-            }
-        }
-    }
+    if (haveLineClamp)
+        applyLineClamp(iterator, relayoutChildren);
 
     RenderBlock::startDelayUpdateScrollInfo();
 
@@ -996,6 +897,109 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
         setHeight(oldHeight); 
 }
 
+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();
+                }
+            }
+            child->layoutIfNeeded();
+            if (child->style()->height().isAuto() && child->isBlockFlow())
+                maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount());
+        }
+        child = iterator.next();
+    }
+    
+    // Get the # 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->width() + 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->rightOffset(lastVisibleLine->y(), false);
+            int blockLeftEdge = destBlock->leftOffset(lastVisibleLine->y(), false);
+            
+            int blockEdge = ltr ? blockRightEdge : blockLeftEdge;
+            if (!lastVisibleLine->canAccommodateEllipsis(ltr, blockEdge,
+                                                         lastVisibleLine->x() + lastVisibleLine->width(),
+                                                         totalWidth))
+                continue;
+            
+            // Let the truncation code kick in.
+            lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, ltr, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
+            destBlock->setHasMarkupTruncation(true);
+        }
+    }
+}
+
 void RenderFlexibleBox::placeChild(RenderBox* child, int x, int y)
 {
     IntRect oldRect(child->x(), child->y() , child->width(), child->height());
diff --git a/WebCore/rendering/RenderFlexibleBox.h b/WebCore/rendering/RenderFlexibleBox.h
index a0f84ce..dfd14d9 100644
--- a/WebCore/rendering/RenderFlexibleBox.h
+++ b/WebCore/rendering/RenderFlexibleBox.h
@@ -27,6 +27,8 @@
 
 namespace WebCore {
 
+class FlexBoxIterator;
+
 class RenderFlexibleBox : public RenderBlock {
 public:
     RenderFlexibleBox(Node*);
@@ -59,6 +61,9 @@ protected:
 
     bool m_flexingChildren : 1;
     bool m_stretchingChildren : 1;
+
+private:
+    void applyLineClamp(FlexBoxIterator&, bool relayoutChildren);
 };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list