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

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

Issue 1899193007: Remove special-code for paginating floats followed by lines of text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 lineMidpointState.reset(); 853 lineMidpointState.reset();
854 854
855 layoutState.lineInfo().setEmpty(true); 855 layoutState.lineInfo().setEmpty(true);
856 layoutState.lineInfo().resetRunsFromLeadingWhitespace(); 856 layoutState.lineInfo().resetRunsFromLeadingWhitespace();
857 857
858 const InlineIterator previousEndofLine = endOfLine; 858 const InlineIterator previousEndofLine = endOfLine;
859 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly (); 859 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly ();
860 FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? m_float ingObjects->set().last().get() : 0; 860 FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? m_float ingObjects->set().last().get() : 0;
861 861
862 WordMeasurements wordMeasurements; 862 WordMeasurements wordMeasurements;
863 endOfLine = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), layoutTextInfo, 863 endOfLine = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), layoutTextInfo, wordMeasurements);
864 lastFloatFromPreviousLine, wordMeasurements);
865 layoutTextInfo.m_lineBreakIterator.resetPriorContext(); 864 layoutTextInfo.m_lineBreakIterator.resetPriorContext();
866 if (resolver.position().atEnd()) { 865 if (resolver.position().atEnd()) {
867 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi n with! 866 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi n with!
868 // Once BidiRunList is separated from BidiResolver this will not be needed. 867 // Once BidiRunList is separated from BidiResolver this will not be needed.
869 resolver.runs().deleteRuns(); 868 resolver.runs().deleteRuns();
870 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). 869 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed).
871 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0 ), 0); 870 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0 ), 0);
872 break; 871 break;
873 } 872 }
874 873
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 if (ltr) 1996 if (ltr)
1998 curr->moveInInlineDirection(logicalLeft); 1997 curr->moveInInlineDirection(logicalLeft);
1999 else 1998 else
2000 curr->moveInInlineDirection(logicalLeft - (availableLogicalW idth - totalLogicalWidth)); 1999 curr->moveInInlineDirection(logicalLeft - (availableLogicalW idth - totalLogicalWidth));
2001 } 2000 }
2002 } 2001 }
2003 indentText = DoNotIndentText; 2002 indentText = DoNotIndentText;
2004 } 2003 }
2005 } 2004 }
2006 2005
2007 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject& newFloat, FloatingO bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
2008 {
2009 if (!positionNewFloats(&width))
2010 return false;
2011
2012 // We only connect floats to lines for pagination purposes if the floats occ ur at the start of
2013 // the line and the previous line had a hard break (so this line is either t he first in the block
2014 // or follows a <br>).
2015 if (!newFloat.paginationStrut() || !lineInfo.previousLineBrokeCleanly() || ! lineInfo.isEmpty())
2016 return true;
2017
2018 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2019 ASSERT(floatingObjectSet.last() == &newFloat);
2020
2021 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat);
2022 int paginationStrut = newFloat.paginationStrut();
2023
2024 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag inationStrut())
2025 return true;
2026
2027 FloatingObjectSetIterator it = floatingObjectSet.end();
2028 --it; // Last float is newFloat, skip that one.
2029 FloatingObjectSetIterator begin = floatingObjectSet.begin();
2030 while (it != begin) {
2031 --it;
2032 FloatingObject& floatingObject = *it->get();
2033 if (&floatingObject == lastFloatFromPreviousLine)
2034 break;
2035 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo atPaginationStrut()) {
2036 floatingObject.setPaginationStrut(paginationStrut + floatingObject.p aginationStrut());
2037 LayoutBox* floatBox = floatingObject.layoutObject();
2038 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar ginBeforeForChild(*floatBox) + paginationStrut);
2039 if (floatBox->isLayoutBlock())
2040 floatBox->forceChildLayout();
2041 else
2042 floatBox->layoutIfNeeded();
2043 // Save the old logical top before calling removePlacedObject which will set
2044 // isPlaced to false. Otherwise it will trigger an assert in logical TopForFloat.
2045 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject);
2046 m_floatingObjects->removePlacedObject(floatingObject);
2047 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru t);
2048 m_floatingObjects->addPlacedObject(floatingObject);
2049 }
2050 }
2051
2052 // Just update the line info's pagination strut without altering our logical height yet. If the line ends up containing
2053 // no content, then we don't want to improperly grow the height of the block .
2054 lineInfo.setFloatPaginationStrut(lineInfo.floatPaginationStrut() + paginatio nStrut);
2055 return true;
2056 }
2057
2058 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, Inden tTextOrNot indentText) 2006 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, Inden tTextOrNot indentText)
2059 { 2007 {
2060 ETextAlign textAlign = style()->textAlign(); 2008 ETextAlign textAlign = style()->textAlign();
2061 2009
2062 bool applyIndentText; 2010 bool applyIndentText;
2063 switch (textAlign) { // FIXME: Handle TAEND here 2011 switch (textAlign) { // FIXME: Handle TAEND here
2064 case LEFT: 2012 case LEFT:
2065 case WEBKIT_LEFT: 2013 case WEBKIT_LEFT:
2066 applyIndentText = style()->isLeftToRightDirection(); 2014 applyIndentText = style()->isLeftToRightDirection();
2067 break; 2015 break;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 if (!line || !line->isFirstLineStyle()) 2054 if (!line || !line->isFirstLineStyle())
2107 return reason; 2055 return reason;
2108 // It's the RootInlineBox that paints the ::first-line background. Note that since it may be 2056 // It's the RootInlineBox that paints the ::first-line background. Note that since it may be
2109 // expensive to figure out if the first line is affected by any ::first-line selectors at all, 2057 // expensive to figure out if the first line is affected by any ::first-line selectors at all,
2110 // we just invalidate it unconditionally, since that's typically cheaper. 2058 // we just invalidate it unconditionally, since that's typically cheaper.
2111 invalidateDisplayItemClient(*line); 2059 invalidateDisplayItemClient(*line);
2112 return reason; 2060 return reason;
2113 } 2061 }
2114 2062
2115 } // namespace blink 2063 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698