Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1039)

Unified Diff: Source/core/rendering/RenderDeprecatedFlexibleBox.cpp

Issue 26588002: Remove support for -webkit-line-clamp Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Base files missing... Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderDeprecatedFlexibleBox.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderDeprecatedFlexibleBox.cpp
diff --git a/Source/core/rendering/RenderDeprecatedFlexibleBox.cpp b/Source/core/rendering/RenderDeprecatedFlexibleBox.cpp
index ee4d483f6e1f0845dbda12e3c6475e355198ec41..a4d691950d32443479500d1e38011e5bcec3811c 100644
--- a/Source/core/rendering/RenderDeprecatedFlexibleBox.cpp
+++ b/Source/core/rendering/RenderDeprecatedFlexibleBox.cpp
@@ -182,15 +182,6 @@ static LayoutUnit contentHeightForChild(RenderBox* child)
return child->logicalHeight() - child->borderAndPaddingLogicalHeight();
}
-void RenderDeprecatedFlexibleBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
-{
- RenderStyle* oldStyle = style();
- if (oldStyle && !oldStyle->lineClamp().isNone() && newStyle->lineClamp().isNone())
- clearLineClamp();
-
- RenderBlock::styleWillChange(diff, newStyle);
-}
-
void RenderDeprecatedFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
if (hasMultipleLines() || isVertical()) {
@@ -644,12 +635,6 @@ void RenderDeprecatedFlexibleBox::layoutVerticalBox(bool relayoutChildren)
bool haveFlex = false, flexingChildren = false;
gatherFlexChildrenInfo(iterator, relayoutChildren, highestFlexGroup, lowestFlexGroup, haveFlex);
- // 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)
- applyLineClamp(iterator, relayoutChildren);
-
RenderBlock::startDelayUpdateScrollInfo();
// We do 2 passes. The first pass is simply to lay everyone out at
@@ -674,7 +659,7 @@ void RenderDeprecatedFlexibleBox::layoutVerticalBox(bool relayoutChildren)
}
SubtreeLayoutScope layoutScope(child);
- if (!haveLineClamp && (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent()))))
+ if (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent())))
layoutScope.setChildNeedsLayout(child);
if (child->style()->visibility() == COLLAPSE) {
@@ -878,126 +863,6 @@ void RenderDeprecatedFlexibleBox::layoutVerticalBox(bool relayoutChildren)
setHeight(oldHeight);
}
-void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren)
-{
- UseCounter::count(&document(), UseCounter::LineClamp);
-
- int maxLineCount = 0;
- for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
- if (childDoesNotAffectWidthOrFlexing(child))
- continue;
-
- child->clearOverrideSize();
- if (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent()))
- || (child->style()->height().isAuto() && child->isRenderBlock())) {
- child->setChildNeedsLayout(MarkOnlyThis);
-
- // Dirty all the positioned objects.
- if (child->isRenderBlock()) {
- toRenderBlock(child)->markPositionedObjectsForLayout();
- toRenderBlock(child)->clearTruncation();
- }
- }
- child->layoutIfNeeded();
- if (child->style()->height().isAuto() && child->isRenderBlock())
- maxLineCount = max(maxLineCount, toRenderBlock(child)->lineCount());
- }
-
- // 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)
- return;
-
- for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
- if (childDoesNotAffectWidthOrFlexing(child) || !child->style()->height().isAuto() || !child->isRenderBlock())
- continue;
-
- RenderBlock* blockChild = toRenderBlock(child);
- int lineCount = blockChild->lineCount();
- if (lineCount <= numVisibleLines)
- continue;
-
- LayoutUnit newHeight = blockChild->heightForLineCount(numVisibleLines);
- if (newHeight == child->height())
- continue;
-
- child->setOverrideLogicalContentHeight(newHeight - child->borderAndPaddingHeight());
- child->forceChildLayout();
-
- // 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
- LayoutUnit totalWidth;
- InlineBox* anchorBox = lastLine->lastChild();
- if (anchorBox && anchorBox->renderer()->style()->isLink())
- totalWidth = anchorBox->logicalWidth() + font.width(constructTextRun(this, font, ellipsisAndSpace, 2, style()));
- else {
- anchorBox = 0;
- totalWidth = font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style()));
- }
-
- // 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;
-
- LayoutUnit blockRightEdge = destBlock->logicalRightOffsetForLine(lastVisibleLine->y(), false);
- if (!lastVisibleLine->lineCanAccommodateEllipsis(leftToRight, blockRightEdge, lastVisibleLine->x() + lastVisibleLine->logicalWidth(), totalWidth))
- continue;
-
- // Let the truncation code kick in.
- // FIXME: the text alignment should be recomputed after the width changes due to truncation.
- LayoutUnit blockLeftEdge = destBlock->logicalLeftOffsetForLine(lastVisibleLine->y(), false);
- lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, leftToRight, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
- destBlock->setHasMarkupTruncation(true);
- }
-}
-
-void RenderDeprecatedFlexibleBox::clearLineClamp()
-{
- FlexBoxIterator iterator(this);
- for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
- if (childDoesNotAffectWidthOrFlexing(child))
- continue;
-
- child->clearOverrideSize();
- if ((child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent()))
- || (child->style()->height().isAuto() && child->isRenderBlock())) {
- child->setChildNeedsLayout();
-
- if (child->isRenderBlock()) {
- toRenderBlock(child)->markPositionedObjectsForLayout();
- toRenderBlock(child)->clearTruncation();
- }
- }
- }
-}
-
void RenderDeprecatedFlexibleBox::placeChild(RenderBox* child, const LayoutPoint& location)
{
LayoutRect oldRect = child->frameRect();
« no previous file with comments | « Source/core/rendering/RenderDeprecatedFlexibleBox.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698