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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 3 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 if (r->m_lineLayoutItem.isText()) { 97 if (r->m_lineLayoutItem.isText()) {
98 unsigned opportunitiesInRun = m_runsWithExpansions[i++]; 98 unsigned opportunitiesInRun = m_runsWithExpansions[i++];
99 99
100 RELEASE_ASSERT(opportunitiesInRun <= m_totalOpportunities); 100 RELEASE_ASSERT(opportunitiesInRun <= m_totalOpportunities);
101 101
102 // Don't justify for white-space: pre. 102 // Don't justify for white-space: pre.
103 if (r->m_lineLayoutItem.style()->whiteSpace() != PRE) { 103 if (r->m_lineLayoutItem.style()->whiteSpace() != PRE) {
104 InlineTextBox* textBox = toInlineTextBox(r->m_box); 104 InlineTextBox* textBox = toInlineTextBox(r->m_box);
105 RELEASE_ASSERT(m_totalOpportunities); 105 RELEASE_ASSERT(m_totalOpportunities);
106 int expansion = (availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / m_totalOpportunities; 106 int expansion = ((availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / m_totalOpportunities).toInt();
107 textBox->setExpansion(expansion); 107 textBox->setExpansion(expansion);
108 totalLogicalWidth += expansion; 108 totalLogicalWidth += expansion;
109 } 109 }
110 m_totalOpportunities -= opportunitiesInRun; 110 m_totalOpportunities -= opportunitiesInRun;
111 if (!m_totalOpportunities) 111 if (!m_totalOpportunities)
112 break; 112 break;
113 } 113 }
114 } 114 }
115 } 115 }
116 private: 116 private:
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 deleteLineRange(layoutState, startLine); 774 deleteLineRange(layoutState, startLine);
775 775
776 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); 776 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus);
777 linkToEndLineIfNeeded(layoutState); 777 linkToEndLineIfNeeded(layoutState);
778 markDirtyFloatsForPaintInvalidation(layoutState.floats()); 778 markDirtyFloatsForPaintInvalidation(layoutState.floats());
779 } 779 }
780 780
781 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. 781 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver.
782 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) 782 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d)
783 { 783 {
784 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); 784 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight.toInt ());
785 setLogicalHeight(newLogicalHeight); 785 setLogicalHeight(newLogicalHeight);
786 resolver.setPositionIgnoringNestedIsolates(oldEnd); 786 resolver.setPositionIgnoringNestedIsolates(oldEnd);
787 return oldEnd; 787 return oldEnd;
788 } 788 }
789 789
790 void LayoutBlockFlow::appendFloatsToLastLine(LineLayoutState& layoutState, const InlineIterator& cleanLineStart, const InlineBidiResolver& resolver, const BidiS tatus& cleanLineBidiStatus) 790 void LayoutBlockFlow::appendFloatsToLastLine(LineLayoutState& layoutState, const InlineIterator& cleanLineStart, const InlineBidiResolver& resolver, const BidiS tatus& cleanLineBidiStatus)
791 { 791 {
792 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 792 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
793 FloatingObjectSetIterator it = floatingObjectSet.begin(); 793 FloatingObjectSetIterator it = floatingObjectSet.begin();
794 FloatingObjectSetIterator end = floatingObjectSet.end(); 794 FloatingObjectSetIterator end = floatingObjectSet.end();
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 } 1617 }
1618 1618
1619 layoutRunsAndFloats(layoutState); 1619 layoutRunsAndFloats(layoutState);
1620 } 1620 }
1621 1621
1622 // Expand the last line to accommodate Ruby and emphasis marks. 1622 // Expand the last line to accommodate Ruby and emphasis marks.
1623 int lastLineAnnotationsAdjustment = 0; 1623 int lastLineAnnotationsAdjustment = 0;
1624 if (lastRootBox()) { 1624 if (lastRootBox()) {
1625 LayoutUnit lowestAllowedPosition = std::max(lastRootBox()->lineBottom(), logicalHeight() + paddingAfter()); 1625 LayoutUnit lowestAllowedPosition = std::max(lastRootBox()->lineBottom(), logicalHeight() + paddingAfter());
1626 if (!style()->isFlippedLinesWritingMode()) 1626 if (!style()->isFlippedLinesWritingMode())
1627 lastLineAnnotationsAdjustment = lastRootBox()->computeUnderAnnotatio nAdjustment(lowestAllowedPosition); 1627 lastLineAnnotationsAdjustment = lastRootBox()->computeUnderAnnotatio nAdjustment(lowestAllowedPosition).toInt();
1628 else 1628 else
1629 lastLineAnnotationsAdjustment = lastRootBox()->computeOverAnnotation Adjustment(lowestAllowedPosition); 1629 lastLineAnnotationsAdjustment = lastRootBox()->computeOverAnnotation Adjustment(lowestAllowedPosition).toInt();
1630 } 1630 }
1631 1631
1632 // Now add in the bottom border/padding. 1632 // Now add in the bottom border/padding.
1633 setLogicalHeight(logicalHeight() + lastLineAnnotationsAdjustment + afterEdge ); 1633 setLogicalHeight(logicalHeight() + lastLineAnnotationsAdjustment + afterEdge );
1634 1634
1635 if (!firstLineBox() && hasLineIfEmpty()) 1635 if (!firstLineBox() && hasLineIfEmpty())
1636 setLogicalHeight(logicalHeight() + lineHeight(true, isHorizontalWritingM ode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)); 1636 setLogicalHeight(logicalHeight() + lineHeight(true, isHorizontalWritingM ode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes));
1637 1637
1638 // See if we have any lines that spill out of our block. If we do, then we will possibly need to 1638 // See if we have any lines that spill out of our block. If we do, then we will possibly need to
1639 // truncate text. 1639 // truncate text.
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), ind entText); 1996 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), ind entText);
1997 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; 1997 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft;
1998 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { 1998 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) {
1999 // This line spills out of our box in the appropriate direction. No w we need to see if the line 1999 // This line spills out of our box in the appropriate direction. No w we need to see if the line
2000 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to 2000 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to
2001 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis 2001 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis
2002 // space. 2002 // space.
2003 2003
2004 LayoutUnit width(indentText == IndentText ? firstLineEllipsisWidth : ellipsisWidth); 2004 LayoutUnit width(indentText == IndentText ? firstLineEllipsisWidth : ellipsisWidth);
2005 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; 2005 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge;
2006 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { 2006 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge.toInt(), lineBox Edge.toInt(), width.toInt())) {
2007 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip sisStr, ltr, blockLeftEdge, blockRightEdge, width); 2007 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip sisStr, ltr, blockLeftEdge, blockRightEdge, width);
2008 LayoutUnit logicalLeft; // We are only interested in the delta f rom the base position. 2008 LayoutUnit logicalLeft; // We are only interested in the delta f rom the base position.
2009 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg e; 2009 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg e;
2010 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); 2010 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
2011 if (ltr) 2011 if (ltr)
2012 curr->moveInInlineDirection(logicalLeft); 2012 curr->moveInInlineDirection(logicalLeft);
2013 else 2013 else
2014 curr->moveInInlineDirection(logicalLeft - (availableLogicalW idth - totalLogicalWidth)); 2014 curr->moveInInlineDirection(logicalLeft - (availableLogicalW idth - totalLogicalWidth));
2015 } 2015 }
2016 } 2016 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 2089
2090 PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded(const PaintInva lidationState& paintInvalidationState) 2090 PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded(const PaintInva lidationState& paintInvalidationState)
2091 { 2091 {
2092 if (containsFloats()) 2092 if (containsFloats())
2093 paintInvalidationState.paintingLayer().setNeedsPaintPhaseFloat(); 2093 paintInvalidationState.paintingLayer().setNeedsPaintPhaseFloat();
2094 2094
2095 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 2095 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
2096 } 2096 }
2097 2097
2098 } // namespace blink 2098 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698