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

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 763173003: Convert RenderBlockFlow code to use FloatingObject references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 662
663 // Position is used to properly position both replaced elements and 663 // Position is used to properly position both replaced elements and
664 // to update the static normal flow x/y of positioned elements. 664 // to update the static normal flow x/y of positioned elements.
665 if (r->m_object->isText()) 665 if (r->m_object->isText())
666 toRenderText(r->m_object)->positionLineBox(r->m_box); 666 toRenderText(r->m_object)->positionLineBox(r->m_box);
667 else if (r->m_object->isBox()) 667 else if (r->m_object->isBox())
668 toRenderBox(r->m_object)->positionLineBox(r->m_box); 668 toRenderBox(r->m_object)->positionLineBox(r->m_box);
669 } 669 }
670 } 670 }
671 671
672 void RenderBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj ect) 672 void RenderBlockFlow::appendFloatingObjectToLastLine(FloatingObject& floatingObj ect)
673 { 673 {
674 ASSERT(!floatingObject->originatingLine()); 674 ASSERT(!floatingObject.originatingLine());
675 floatingObject->setOriginatingLine(lastRootBox()); 675 floatingObject.setOriginatingLine(lastRootBox());
676 lastRootBox()->appendFloat(floatingObject->renderer()); 676 lastRootBox()->appendFloat(floatingObject.renderer());
677 } 677 }
678 678
679 // This function constructs line boxes for all of the text runs in the resolver and computes their position. 679 // This function constructs line boxes for all of the text runs in the resolver and computes their position.
680 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas urements& wordMeasurements) 680 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas urements& wordMeasurements)
681 { 681 {
682 if (!bidiRuns.runCount()) 682 if (!bidiRuns.runCount())
683 return 0; 683 return 0;
684 684
685 // FIXME: Why is this only done when we had runs? 685 // FIXME: Why is this only done when we had runs?
686 lineInfo.setLastLine(!end.object()); 686 lineInfo.setLastLine(!end.object());
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 FloatingObjectSetIterator it = floatingObjectSet.begin(); 906 FloatingObjectSetIterator it = floatingObjectSet.begin();
907 FloatingObjectSetIterator end = floatingObjectSet.end(); 907 FloatingObjectSetIterator end = floatingObjectSet.end();
908 if (layoutState.lastFloat()) { 908 if (layoutState.lastFloat()) {
909 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat()); 909 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat());
910 ASSERT(lastFloatIterator != end); 910 ASSERT(lastFloatIterator != end);
911 ++lastFloatIterator; 911 ++lastFloatIterator;
912 it = lastFloatIterator; 912 it = lastFloatIterator;
913 } 913 }
914 for (; it != end; ++it) { 914 for (; it != end; ++it) {
915 FloatingObject* f = it->get(); 915 FloatingObject* f = it->get();
916 appendFloatingObjectToLastLine(f); 916 appendFloatingObjectToLastLine(*f);
917 ASSERT(f->renderer() == layoutState.floats()[layoutState.flo atIndex()].object); 917 ASSERT(f->renderer() == layoutState.floats()[layoutState.flo atIndex()].object);
918 // If a float's geometry has changed, give up on syncing wit h clean lines. 918 // If a float's geometry has changed, give up on syncing wit h clean lines.
919 if (layoutState.floats()[layoutState.floatIndex()].rect != f ->frameRect()) 919 if (layoutState.floats()[layoutState.floatIndex()].rect != f ->frameRect())
920 checkForEndLineMatch = false; 920 checkForEndLineMatch = false;
921 layoutState.setFloatIndex(layoutState.floatIndex() + 1); 921 layoutState.setFloatIndex(layoutState.floatIndex() + 1);
922 } 922 }
923 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating ObjectSet.last().get() : 0); 923 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating ObjectSet.last().get() : 0);
924 } 924 }
925 } 925 }
926 926
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 VerticalPositionCache verticalPositionCache; 1054 VerticalPositionCache verticalPositionCache;
1055 LayoutUnit blockLogicalHeight = logicalHeight(); 1055 LayoutUnit blockLogicalHeight = logicalHeight();
1056 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache); 1056 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache);
1057 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); 1057 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight);
1058 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight); 1058 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight);
1059 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight); 1059 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight);
1060 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom()); 1060 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom());
1061 } 1061 }
1062 1062
1063 for (; it != end; ++it) 1063 for (; it != end; ++it)
1064 appendFloatingObjectToLastLine(it->get()); 1064 appendFloatingObjectToLastLine(*it->get());
1065 } 1065 }
1066 } 1066 }
1067 1067
1068 void RenderBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) 1068 void RenderBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats)
1069 { 1069 {
1070 size_t floatCount = floats.size(); 1070 size_t floatCount = floats.size();
1071 // Floats that did not have layout did not paint invalidations when we laid them out. They would have 1071 // Floats that did not have layout did not paint invalidations when we laid them out. They would have
1072 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be 1072 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be
1073 // painted. 1073 // painted.
1074 for (size_t i = 0; i < floatCount; ++i) { 1074 for (size_t i = 0; i < floatCount; ++i) {
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 RootInlineBox* lastLine = layoutState.endLine(); 1835 RootInlineBox* lastLine = layoutState.endLine();
1836 while (RootInlineBox* nextLine = lastLine->nextRootBox()) 1836 while (RootInlineBox* nextLine = lastLine->nextRootBox())
1837 lastLine = nextLine; 1837 lastLine = nextLine;
1838 1838
1839 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue (lineDelta); 1839 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue (lineDelta);
1840 1840
1841 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1841 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1842 FloatingObjectSetIterator end = floatingObjectSet.end(); 1842 FloatingObjectSetIterator end = floatingObjectSet.end();
1843 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { 1843 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) {
1844 FloatingObject* floatingObject = it->get(); 1844 FloatingObject* floatingObject = it->get();
1845 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom ForFloat(floatingObject) < logicalBottom) 1845 if (logicalBottomForFloat(*floatingObject) >= logicalTop && logicalBotto mForFloat(*floatingObject) < logicalBottom)
1846 return false; 1846 return false;
1847 } 1847 }
1848 1848
1849 return true; 1849 return true;
1850 } 1850 }
1851 1851
1852 bool RenderBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) 1852 bool RenderBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus)
1853 { 1853 {
1854 if (resolver.position() == endLineStart) { 1854 if (resolver.position() == endLineStart) {
1855 if (resolver.status() != endLineStatus) 1855 if (resolver.status() != endLineStatus)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 1993
1994 // We only connect floats to lines for pagination purposes if the floats occ ur at the start of 1994 // We only connect floats to lines for pagination purposes if the floats occ ur at the start of
1995 // the line and the previous line had a hard break (so this line is either t he first in the block 1995 // the line and the previous line had a hard break (so this line is either t he first in the block
1996 // or follows a <br>). 1996 // or follows a <br>).
1997 if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty()) 1997 if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
1998 return true; 1998 return true;
1999 1999
2000 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2000 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2001 ASSERT(floatingObjectSet.last() == newFloat); 2001 ASSERT(floatingObjectSet.last() == newFloat);
2002 2002
2003 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); 2003 LayoutUnit floatLogicalTop = logicalTopForFloat(*newFloat);
2004 int paginationStrut = newFloat->paginationStrut(); 2004 int paginationStrut = newFloat->paginationStrut();
2005 2005
2006 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag inationStrut()) 2006 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag inationStrut())
2007 return true; 2007 return true;
2008 2008
2009 FloatingObjectSetIterator it = floatingObjectSet.end(); 2009 FloatingObjectSetIterator it = floatingObjectSet.end();
2010 --it; // Last float is newFloat, skip that one. 2010 --it; // Last float is newFloat, skip that one.
2011 FloatingObjectSetIterator begin = floatingObjectSet.begin(); 2011 FloatingObjectSetIterator begin = floatingObjectSet.begin();
2012 while (it != begin) { 2012 while (it != begin) {
2013 --it; 2013 --it;
2014 FloatingObject* floatingObject = it->get(); 2014 FloatingObject* floatingObject = it->get();
2015 if (floatingObject == lastFloatFromPreviousLine) 2015 if (floatingObject == lastFloatFromPreviousLine)
2016 break; 2016 break;
2017 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo atPaginationStrut()) { 2017 if (logicalTopForFloat(*floatingObject) == logicalHeight() + lineInfo.fl oatPaginationStrut()) {
2018 floatingObject->setPaginationStrut(paginationStrut + floatingObject- >paginationStrut()); 2018 floatingObject->setPaginationStrut(paginationStrut + floatingObject- >paginationStrut());
2019 RenderBox* floatBox = floatingObject->renderer(); 2019 RenderBox* floatBox = floatingObject->renderer();
2020 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar ginBeforeForChild(*floatBox) + paginationStrut); 2020 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar ginBeforeForChild(*floatBox) + paginationStrut);
2021 if (floatBox->isRenderBlock()) 2021 if (floatBox->isRenderBlock())
2022 floatBox->forceChildLayout(); 2022 floatBox->forceChildLayout();
2023 else 2023 else
2024 floatBox->layoutIfNeeded(); 2024 floatBox->layoutIfNeeded();
2025 // Save the old logical top before calling removePlacedObject which will set 2025 // Save the old logical top before calling removePlacedObject which will set
2026 // isPlaced to false. Otherwise it will trigger an assert in logical TopForFloat. 2026 // isPlaced to false. Otherwise it will trigger an assert in logical TopForFloat.
2027 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject); 2027 LayoutUnit oldLogicalTop = logicalTopForFloat(*floatingObject);
2028 m_floatingObjects->removePlacedObject(floatingObject); 2028 m_floatingObjects->removePlacedObject(floatingObject);
2029 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru t); 2029 setLogicalTopForFloat(*floatingObject, oldLogicalTop + paginationStr ut);
2030 m_floatingObjects->addPlacedObject(floatingObject); 2030 m_floatingObjects->addPlacedObject(floatingObject);
2031 } 2031 }
2032 } 2032 }
2033 2033
2034 // Just update the line info's pagination strut without altering our logical height yet. If the line ends up containing 2034 // Just update the line info's pagination strut without altering our logical height yet. If the line ends up containing
2035 // no content, then we don't want to improperly grow the height of the block . 2035 // no content, then we don't want to improperly grow the height of the block .
2036 lineInfo.setFloatPaginationStrut(lineInfo.floatPaginationStrut() + paginatio nStrut); 2036 lineInfo.setFloatPaginationStrut(lineInfo.floatPaginationStrut() + paginatio nStrut);
2037 return true; 2037 return true;
2038 } 2038 }
2039 2039
2040 LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine) 2040 LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine)
2041 { 2041 {
2042 ETextAlign textAlign = style()->textAlign(); 2042 ETextAlign textAlign = style()->textAlign();
2043 2043
2044 if (textAlign == TASTART) // FIXME: Handle TAEND here 2044 if (textAlign == TASTART) // FIXME: Handle TAEND here
2045 return startOffsetForLine(position, firstLine); 2045 return startOffsetForLine(position, firstLine);
2046 2046
2047 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here 2047 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here
2048 float totalLogicalWidth = 0; 2048 float totalLogicalWidth = 0;
2049 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); 2049 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat ();
2050 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2050 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft;
2051 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2051 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2052 2052
2053 if (!style()->isLeftToRightDirection()) 2053 if (!style()->isLeftToRightDirection())
2054 return logicalWidth() - logicalLeft; 2054 return logicalWidth() - logicalLeft;
2055 return logicalLeft; 2055 return logicalLeft;
2056 } 2056 }
2057 2057
2058 } 2058 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698