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

Side by Side Diff: Source/core/layout/LayoutBlockFlowLine.cpp

Issue 1183003003: Move overflow in InlineTextBox::adjustPosition() if it has glyph overflows (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/layout/LayoutListItem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 if (lineBox) { 860 if (lineBox) {
861 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset() , resolver.status()); 861 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset() , resolver.status());
862 if (layoutState.usesPaintInvalidationBounds()) 862 if (layoutState.usesPaintInvalidationBounds())
863 layoutState.updatePaintInvalidationRangeFromBox(lineBox); 863 layoutState.updatePaintInvalidationRangeFromBox(lineBox);
864 864
865 if (paginated) { 865 if (paginated) {
866 LayoutUnit adjustment = 0; 866 LayoutUnit adjustment = 0;
867 adjustLinePositionForPagination(*lineBox, adjustment, layout State.flowThread()); 867 adjustLinePositionForPagination(*lineBox, adjustment, layout State.flowThread());
868 if (adjustment) { 868 if (adjustment) {
869 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o ldLogicalHeight, layoutState.lineInfo().isFirstLine()); 869 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o ldLogicalHeight, layoutState.lineInfo().isFirstLine());
870 lineBox->adjustBlockDirectionPosition(adjustment.toFloat ()); 870 lineBox->moveInBlockDirection(adjustment.toFloat());
871 if (layoutState.usesPaintInvalidationBounds()) 871 if (layoutState.usesPaintInvalidationBounds())
872 layoutState.updatePaintInvalidationRangeFromBox(line Box); 872 layoutState.updatePaintInvalidationRangeFromBox(line Box);
873 873
874 if (availableLogicalWidthForLine(oldLogicalHeight + adju stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { 874 if (availableLogicalWidthForLine(oldLogicalHeight + adju stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) {
875 // We have to delete this line, remove all floats th at got added, and let line layout re-run. 875 // We have to delete this line, remove all floats th at got added, and let line layout re-run.
876 lineBox->deleteLine(); 876 lineBox->deleteLine();
877 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, previousEndofLine); 877 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, previousEndofLine);
878 logicalWidthIsAvailable = true; 878 logicalWidthIsAvailable = true;
879 } else { 879 } else {
880 setLogicalHeight(lineBox->lineBottomWithLeading()); 880 setLogicalHeight(lineBox->lineBottomWithLeading());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // Attach all the remaining lines, and then adjust their y-positions as needed. 991 // Attach all the remaining lines, and then adjust their y-positions as needed.
992 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ; 992 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ;
993 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) { 993 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) {
994 line->attachLine(); 994 line->attachLine();
995 if (paginated) { 995 if (paginated) {
996 delta -= line->paginationStrut(); 996 delta -= line->paginationStrut();
997 adjustLinePositionForPagination(*line, delta, layoutState.fl owThread()); 997 adjustLinePositionForPagination(*line, delta, layoutState.fl owThread());
998 } 998 }
999 if (delta) { 999 if (delta) {
1000 layoutState.updatePaintInvalidationRangeFromBox(line, delta) ; 1000 layoutState.updatePaintInvalidationRangeFromBox(line, delta) ;
1001 line->adjustBlockDirectionPosition(delta.toFloat()); 1001 line->moveInBlockDirection(delta.toFloat());
1002 } 1002 }
1003 if (Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr()) { 1003 if (Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr()) {
1004 for (auto* box : *cleanLineFloats) { 1004 for (auto* box : *cleanLineFloats) {
1005 FloatingObject* floatingObject = insertFloatingObject(*b ox); 1005 FloatingObject* floatingObject = insertFloatingObject(*b ox);
1006 ASSERT(!floatingObject->originatingLine()); 1006 ASSERT(!floatingObject->originatingLine());
1007 floatingObject->setOriginatingLine(line); 1007 floatingObject->setOriginatingLine(line);
1008 setLogicalHeight(logicalTopForChild(*box) - marginBefore ForChild(*box) + delta); 1008 setLogicalHeight(logicalTopForChild(*box) - marginBefore ForChild(*box) + delta);
1009 positionNewFloats(); 1009 positionNewFloats();
1010 } 1010 }
1011 } 1011 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 paginationDelta -= curr->paginationStrut(); 1659 paginationDelta -= curr->paginationStrut();
1660 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt ate.flowThread()); 1660 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt ate.flowThread());
1661 if (paginationDelta) { 1661 if (paginationDelta) {
1662 if (containsFloats() || !layoutState.floats().isEmpty()) { 1662 if (containsFloats() || !layoutState.floats().isEmpty()) {
1663 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout. 1663 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout.
1664 layoutState.markForFullLayout(); 1664 layoutState.markForFullLayout();
1665 break; 1665 break;
1666 } 1666 }
1667 1667
1668 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta); 1668 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta);
1669 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); 1669 curr->moveInBlockDirection(paginationDelta.toFloat());
1670 } 1670 }
1671 } 1671 }
1672 1672
1673 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. 1673 // If a new float has been inserted before this line or before its l ast known float, just do a full layout.
1674 bool encounteredNewFloat = false; 1674 bool encounteredNewFloat = false;
1675 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); 1675 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat);
1676 if (encounteredNewFloat) 1676 if (encounteredNewFloat)
1677 layoutState.markForFullLayout(); 1677 layoutState.markForFullLayout();
1678 1678
1679 if (dirtiedByFloat || layoutState.isFullLayout()) 1679 if (dirtiedByFloat || layoutState.isFullLayout())
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 1903 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
1904 addLayoutOverflow(curr->paddedLayoutOverflowRect(endPadding)); 1904 addLayoutOverflow(curr->paddedLayoutOverflowRect(endPadding));
1905 LayoutRect visualOverflow = curr->visualOverflowRect(curr->lineTop(), cu rr->lineBottom()); 1905 LayoutRect visualOverflow = curr->visualOverflowRect(curr->lineTop(), cu rr->lineBottom());
1906 addContentsVisualOverflow(visualOverflow); 1906 addContentsVisualOverflow(visualOverflow);
1907 } 1907 }
1908 } 1908 }
1909 1909
1910 void LayoutBlockFlow::deleteEllipsisLineBoxes() 1910 void LayoutBlockFlow::deleteEllipsisLineBoxes()
1911 { 1911 {
1912 ETextAlign textAlign = style()->textAlign(); 1912 ETextAlign textAlign = style()->textAlign();
1913 bool ltr = style()->isLeftToRightDirection();
1914 bool firstLine = true; 1913 bool firstLine = true;
1915 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 1914 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
1916 if (curr->hasEllipsisBox()) { 1915 if (curr->hasEllipsisBox()) {
1917 curr->clearTruncation(); 1916 curr->clearTruncation();
1918 1917
1919 // Shift the line back where it belongs if we cannot accomodate an e llipsis. 1918 // Shift the line back where it belongs if we cannot accomodate an e llipsis.
1920 LayoutUnit logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), f irstLine).toFloat(); 1919 LayoutUnit logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), f irstLine).toFloat();
1921 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(curr->l ineTop(), false) - logicalLeft; 1920 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(curr->l ineTop(), false) - logicalLeft;
1922 LayoutUnit totalLogicalWidth = curr->logicalWidth(); 1921 LayoutUnit totalLogicalWidth = curr->logicalWidth();
1923 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); 1922 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0);
1924 1923
1925 if (ltr) 1924 curr->moveInInlineDirection(logicalLeft - curr->logicalLeft());
1926 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0);
1927 else
1928 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0);
1929 } 1925 }
1930 firstLine = false; 1926 firstLine = false;
1931 } 1927 }
1932 } 1928 }
1933 1929
1934 void LayoutBlockFlow::checkLinesForTextOverflow() 1930 void LayoutBlockFlow::checkLinesForTextOverflow()
1935 { 1931 {
1936 // Determine the width of the ellipsis using the current font. 1932 // Determine the width of the ellipsis using the current font.
1937 const Font& font = style()->font(); 1933 const Font& font = style()->font();
1938 1934
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 // space. 1984 // space.
1989 1985
1990 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; 1986 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h;
1991 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; 1987 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge;
1992 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { 1988 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) {
1993 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip sisStr, ltr, blockLeftEdge, blockRightEdge, width); 1989 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip sisStr, ltr, blockLeftEdge, blockRightEdge, width);
1994 LayoutUnit logicalLeft; // We are only interested in the delta f rom the base position. 1990 LayoutUnit logicalLeft; // We are only interested in the delta f rom the base position.
1995 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg e; 1991 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg e;
1996 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); 1992 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
1997 if (ltr) 1993 if (ltr)
1998 curr->adjustLogicalPosition(logicalLeft, 0); 1994 curr->moveInInlineDirection(logicalLeft);
1999 else 1995 else
2000 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); 1996 curr->moveInInlineDirection(logicalLeft - (availableLogicalW idth - totalLogicalWidth));
2001 } 1997 }
2002 } 1998 }
2003 firstLine = false; 1999 firstLine = false;
2004 } 2000 }
2005 } 2001 }
2006 2002
2007 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject& newFloat, FloatingO bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) 2003 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject& newFloat, FloatingO bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
2008 { 2004 {
2009 if (!positionNewFloats(&width)) 2005 if (!positionNewFloats(&width))
2010 return false; 2006 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2063 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2068 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; 2064 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2069 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2065 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2070 2066
2071 if (!style()->isLeftToRightDirection()) 2067 if (!style()->isLeftToRightDirection())
2072 return logicalWidth() - logicalLeft; 2068 return logicalWidth() - logicalLeft;
2073 return logicalLeft; 2069 return logicalLeft;
2074 } 2070 }
2075 2071
2076 } 2072 }
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/layout/LayoutListItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698