Changeset 121085 in webkit
- Timestamp:
- Jun 22, 2012 7:02:28 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 16 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r121083 r121085 1 2012-06-22 Benjamin Poulain <bpoulain@apple.com> 2 3 Text with text-overflow:ellipsis and text-align:right is left aligned 4 https://bugs.webkit.org/show_bug.cgi?id=88705 5 6 Reviewed by Dan Bernstein. 7 8 * fast/css/text-overflow-ellipsis-text-align-center.html: Added. 9 * fast/css/text-overflow-ellipsis-text-align-justify.html: Added. 10 * fast/css/text-overflow-ellipsis-text-align-left.html: Added. 11 * fast/css/text-overflow-ellipsis-text-align-right.html: Added. 12 * fast/css/vertical-text-overflow-ellipsis-text-align-center.html: Added. 13 * fast/css/vertical-text-overflow-ellipsis-text-align-justify.html: Added. 14 * fast/css/vertical-text-overflow-ellipsis-text-align-left.html: Added. 15 * fast/css/vertical-text-overflow-ellipsis-text-align-right.html: Added. 16 The vertical-text tests are incorrect due to other bugs. Add they to track regressions/progressions 17 going forward. 18 19 * platform/chromium/TestExpectations: The tests need platform specific results. 20 * platform/mac/fast/css/text-overflow-ellipsis-text-align-center-expected.txt: Added. 21 * platform/mac/fast/css/text-overflow-ellipsis-text-align-justify-expected.txt: Added. 22 * platform/mac/fast/css/text-overflow-ellipsis-text-align-left-expected.txt: Added. 23 * platform/mac/fast/css/text-overflow-ellipsis-text-align-right-expected.txt: Added. 24 * platform/mac/fast/css/text-overflow-ellipsis-text-align-center-expected.txt: Added. 25 * platform/mac/fast/css/text-overflow-ellipsis-text-align-justify-expected.txt: Added. 26 * platform/mac/fast/css/text-overflow-ellipsis-text-align-left-expected.txt: Added. 27 * platform/mac/fast/css/text-overflow-ellipsis-text-align-right-expected.txt: Added. 28 1 29 2012-06-22 Alexandru Chiculita <achicu@adobe.com> 2 30 -
trunk/LayoutTests/platform/chromium/TestExpectations
r121080 r121085 3671 3671 BUGWK87653 : compositing/geometry/composited-in-columns.html = IMAGE+TEXT 3672 3672 3673 // Needs Rebaseline. 3674 BUGWK88705 : fast/css/text-overflow-ellipsis-text-align-center-expected.txt = TEXT 3675 BUGWK88705 : fast/css/text-overflow-ellipsis-text-align-justify-expected.txt = TEXT 3676 BUGWK88705 : fast/css/text-overflow-ellipsis-text-align-left-expected.txt = TEXT 3677 BUGWK88705 : fast/css/text-overflow-ellipsis-text-align-right-expected.txt = TEXT 3678 BUGWK88705 : fast/css/vertical-text-overflow-ellipsis-text-align-center.html = TEXT 3679 BUGWK88705 : fast/css/vertical-text-overflow-ellipsis-text-align-justify.html = TEXT 3680 BUGWK88705 : fast/css/vertical-text-overflow-ellipsis-text-align-left.html = TEXT 3681 BUGWK88705 : fast/css/vertical-text-overflow-ellipsis-text-align-right.html = TEXT 3682 3673 3683 // Fails with a mismatch in $("menulist").selectedIndex 3674 3684 BUGWK87748 MAC : fast/forms/select/optgroup-clicking.html = TEXT -
trunk/Source/WebCore/ChangeLog
r121084 r121085 1 2012-06-22 Benjamin Poulain <bpoulain@apple.com> 2 3 Text with text-overflow:ellipsis and text-align:right is left aligned 4 https://bugs.webkit.org/show_bug.cgi?id=88705 5 6 Reviewed by Dan Bernstein. 7 8 When building the line of a text with overflow, we do not know if we can place 9 an ellipsis and where it should be. Because of that, text is laid out as if it does 10 not have text-overflow: ellipsis. 11 12 This causes problems with text-alignement right in LTR and left in RTL. The shortened text 13 did not follow the allignment. 14 15 This patch changes the position of lines with ellipsis after layout to follow the allignment. 16 In RenderBlock::checkLinesForTextOverflow(), the call to RootInlineBox::placeEllipsis() now 17 also gives the width of the truncated text. We use this width to re-compute the alignement and 18 shift the box if necessary. 19 20 In RenderBlock::deleteEllipsisLineBoxes() we revert the text to the position computed with the 21 total width. This way all layout computation is done as usual. 22 23 Tests: fast/css/text-overflow-ellipsis-text-align-left.html 24 fast/css/text-overflow-ellipsis-text-align-right.html 25 26 * rendering/InlineBox.cpp: 27 (WebCore::InlineBox::canAccommodateEllipsis): Make the method const for readability, truncating is 28 done later in placeEllipsisBox(). 29 (WebCore::InlineBox::placeEllipsisBox): Add an output argument, truncatedWidth, giving the width 30 of the text + ellipsis after truncation (if any truncation can be done). 31 * rendering/InlineBox.h: 32 (InlineBox): 33 * rendering/InlineFlowBox.cpp: 34 (WebCore::InlineBox::adjustLogicalPosition): adjustPosition() logical coordinates. 35 (WebCore::InlineFlowBox::canAccommodateEllipsis): 36 (WebCore::InlineFlowBox::placeEllipsisBox): 37 * rendering/InlineFlowBox.h: 38 (InlineFlowBox): 39 * rendering/InlineTextBox.cpp: 40 (WebCore::InlineTextBox::placeEllipsisBox): 41 * rendering/InlineTextBox.h: 42 (InlineTextBox): 43 * rendering/RenderBlockLineLayout.cpp: 44 (WebCore::RenderBlock::deleteEllipsisLineBoxes): In addition to removing the truncation, we 45 need to revert the shift introduced by checkLinesForTextOverflow(). This restore the lines 46 to its original, untruncated position in order to layout the block correctly in RenderBlock::layoutInlineChildren(). 47 (WebCore::RenderBlock::checkLinesForTextOverflow): After we truncate the text, we now recompute the shift we need 48 for alignment, and move the line accordingly. 49 * rendering/RenderDeprecatedFlexibleBox.cpp: 50 (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): 51 * rendering/RootInlineBox.cpp: 52 (WebCore::RootInlineBox::placeEllipsis): Return the width of the truncated text + the width of the ellipsis. 53 (WebCore::RootInlineBox::placeEllipsisBox): 54 (WebCore::RootInlineBox::adjustPosition): 55 * rendering/RootInlineBox.h: 56 (RootInlineBox): 57 1 58 2012-06-22 Eugene Klyuchnikov <eustas.big@gmail.com> 2 59 -
trunk/Source/WebCore/rendering/InlineBox.cpp
r120824 r121085 323 323 } 324 324 325 bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) 325 bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const 326 326 { 327 327 // Non-replaced elements can always accommodate an ellipsis. … … 334 334 } 335 335 336 float InlineBox::placeEllipsisBox(bool, float, float, float, bool&)336 float InlineBox::placeEllipsisBox(bool, float, float, float, float& truncatedWidth, bool&) 337 337 { 338 338 // Use -1 to mean "we didn't set the position." 339 truncatedWidth += logicalWidth(); 339 340 return -1; 340 341 } -
trunk/Source/WebCore/rendering/InlineBox.h
r120824 r121085 73 73 74 74 virtual void adjustPosition(float dx, float dy); 75 void adjustLogicalPosition(float deltaLogicalLeft, float deltaLogicalTop) 76 { 77 if (isHorizontal()) 78 adjustPosition(deltaLogicalLeft, deltaLogicalTop); 79 else 80 adjustPosition(deltaLogicalTop, deltaLogicalLeft); 81 } 75 82 void adjustLineDirectionPosition(float delta) 76 83 { … … 262 269 virtual RenderObject::SelectionState selectionState(); 263 270 264 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) ;271 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const; 265 272 // visibleLeftEdge, visibleRightEdge are in the parent's coordinate system. 266 virtual float placeEllipsisBox(bool ltr, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, bool&);273 virtual float placeEllipsisBox(bool ltr, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool&); 267 274 268 275 #ifndef NDEBUG -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r120835 r121085 1381 1381 } 1382 1382 1383 bool InlineFlowBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) 1383 bool InlineFlowBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const 1384 1384 { 1385 1385 for (InlineBox *box = firstChild(); box; box = box->nextOnLine()) { … … 1390 1390 } 1391 1391 1392 float InlineFlowBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, bool& foundBox)1392 float InlineFlowBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) 1393 1393 { 1394 1394 float result = -1; … … 1404 1404 1405 1405 while (box) { 1406 int currResult = box->placeEllipsisBox(ltr, visibleLeftEdge, visibleRightEdge, ellipsisWidth, foundBox);1406 int currResult = box->placeEllipsisBox(ltr, visibleLeftEdge, visibleRightEdge, ellipsisWidth, truncatedWidth, foundBox); 1407 1407 if (currResult != -1 && result == -1) 1408 1408 result = currResult; -
trunk/Source/WebCore/rendering/InlineFlowBox.h
r120824 r121085 103 103 virtual void removeLineBoxFromRenderObject(); 104 104 105 virtual void clearTruncation() ;105 virtual void clearTruncation() OVERRIDE; 106 106 107 107 IntRect roundedFrameRect() const; … … 190 190 virtual RenderObject::SelectionState selectionState(); 191 191 192 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) ;193 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, bool&);192 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const OVERRIDE; 193 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool&) OVERRIDE; 194 194 195 195 bool hasTextChildren() const { return m_hasTextChildren; } -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r120824 r121085 234 234 } 235 235 236 float InlineTextBox::placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, bool& foundBox)236 float InlineTextBox::placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) 237 237 { 238 238 if (foundBox) { … … 276 276 // and the ellipsis edge. 277 277 m_truncation = cFullTruncation; 278 truncatedWidth += ellipsisWidth; 278 279 return min(ellipsisX, x()); 279 280 } … … 291 292 // e.g. In the case of an LTR inline box truncated in an RTL flow then we can 292 293 // have a situation such as |Hello| -> |...He| 294 truncatedWidth += widthOfVisibleText + ellipsisWidth; 293 295 if (flowIsLTR) 294 296 return left() + widthOfVisibleText; … … 296 298 return right() - widthOfVisibleText - ellipsisWidth; 297 299 } 300 truncatedWidth += logicalWidth(); 298 301 return -1; 299 302 } -
trunk/Source/WebCore/rendering/InlineTextBox.h
r120824 r121085 131 131 private: 132 132 virtual void clearTruncation() { m_truncation = cNoTruncation; } 133 virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, bool& foundBox);133 virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE; 134 134 135 135 public: -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r120495 r121085 2676 2676 void RenderBlock::deleteEllipsisLineBoxes() 2677 2677 { 2678 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) 2679 curr->clearTruncation(); 2678 ETextAlign textAlign = style()->textAlign(); 2679 bool ltr = style()->isLeftToRightDirection(); 2680 bool firstLine = true; 2681 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 2682 if (curr->hasEllipsisBox()) { 2683 curr->clearTruncation(); 2684 2685 // Shift the line back where it belongs if we cannot accomodate an ellipsis. 2686 float logicalLeft = pixelSnappedLogicalLeftOffsetForLine(curr->lineTop(), firstLine); 2687 float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTop(), false) - logicalLeft; 2688 float totalLogicalWidth = curr->logicalWidth(); 2689 updateLogicalWidthForAlignment(textAlign, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); 2690 2691 if (ltr) 2692 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); 2693 else 2694 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft), 0); 2695 } 2696 firstLine = false; 2697 } 2680 2698 } 2681 2699 … … 2695 2713 // Include the scrollbar for overflow blocks, which means we want to use "contentWidth()" 2696 2714 bool ltr = style()->isLeftToRightDirection(); 2715 ETextAlign textAlign = style()->textAlign(); 2716 bool firstLine = true; 2697 2717 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 2698 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr-> y(), curr == firstRootBox());2699 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr-> y(), curr == firstRootBox());2718 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), firstLine); 2719 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), firstLine); 2700 2720 LayoutUnit lineBoxEdge = ltr ? curr->x() + curr->logicalWidth() : curr->x(); 2701 2721 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < blockLeftEdge)) { … … 2704 2724 // accommodate our truncation string, and no replaced elements (images, tables) can overlap the ellipsis 2705 2725 // space. 2706 LayoutUnit width = curr == firstRootBox() ? firstLineEllipsisWidth : ellipsisWidth; 2726 2727 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidth; 2707 2728 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; 2708 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, width)) 2709 curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width); 2710 } 2729 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, width)) { 2730 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width); 2731 2732 float logicalLeft = 0; // We are only intersted in the delta from the base position. 2733 float truncatedWidth = pixelSnappedLogicalRightOffsetForLine(curr->lineTop(), firstLine); 2734 updateLogicalWidthForAlignment(textAlign, 0, logicalLeft, totalLogicalWidth, truncatedWidth, 0); 2735 if (ltr) 2736 curr->adjustLogicalPosition(logicalLeft, 0); 2737 else 2738 curr->adjustLogicalPosition(-(truncatedWidth - (logicalLeft + totalLogicalWidth)), 0); 2739 } 2740 } 2741 firstLine = false; 2711 2742 } 2712 2743 } … … 2777 2808 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) - logicalLeft; 2778 2809 float totalLogicalWidth = logicalWidthForChild(child); 2779 updateLogicalWidthForAlignment(textAlign, 0 l, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);2810 updateLogicalWidthForAlignment(textAlign, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); 2780 2811 2781 2812 if (!style()->isLeftToRightDirection()) -
trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp
r119507 r121085 980 980 981 981 // Let the truncation code kick in. 982 // FIXME: the text alignment should be recomputed after the width changes due to truncation. 982 983 lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, leftToRight, blockLeftEdge, blockRightEdge, totalWidth, anchorBox); 983 984 destBlock->setHasMarkupTruncation(true); -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r120824 r121085 123 123 } 124 124 125 voidRootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth,125 float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, 126 126 InlineBox* markupBox) 127 127 { … … 139 139 if (ltr && (x() + logicalWidth() + ellipsisWidth) <= blockRightEdge) { 140 140 ellipsisBox->setX(x() + logicalWidth()); 141 return ;141 return logicalWidth() + ellipsisWidth; 142 142 } 143 143 … … 146 146 // truncated). 147 147 bool foundBox = false; 148 ellipsisBox->setX(placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, foundBox)); 149 } 150 151 float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, bool& foundBox) 152 { 153 float result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, foundBox); 154 if (result == -1) 148 float truncatedWidth = 0; 149 float position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox); 150 ellipsisBox->setX(position); 151 return truncatedWidth; 152 } 153 154 float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) 155 { 156 float result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox); 157 if (result == -1) { 155 158 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; 159 truncatedWidth = blockRightEdge - blockLeftEdge; 160 } 156 161 return result; 157 162 } … … 232 237 m_lineTopWithLeading += blockDirectionDelta; 233 238 m_lineBottomWithLeading += blockDirectionDelta; 239 if (hasEllipsisBox()) 240 ellipsisBox()->adjustPosition(dx, dy); 234 241 } 235 242 -
trunk/Source/WebCore/rendering/RootInlineBox.h
r120824 r121085 93 93 94 94 bool lineCanAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth); 95 void placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox = 0); 96 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, bool& foundBox); 95 // Return the truncatedWidth, the width of the truncated text + ellipsis. 96 float placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox = 0); 97 // Return the position of the EllipsisBox or -1. 98 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE; 97 99 98 100 using InlineBox::hasEllipsisBox; … … 101 103 void paintEllipsisBox(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) const; 102 104 103 virtual void clearTruncation() ;105 virtual void clearTruncation() OVERRIDE; 104 106 105 107 bool isHyphenated() const; … … 185 187 #endif 186 188 private: 187 188 189 LayoutUnit lineSnapAdjustment(LayoutUnit delta = 0) const; 189 190
Note: See TracChangeset
for help on using the changeset viewer.