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

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

Issue 1355003002: Floats on clean lines that are dirtied during layout (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 760
761 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. 761 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver.
762 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) 762 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d)
763 { 763 {
764 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); 764 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight);
765 setLogicalHeight(newLogicalHeight); 765 setLogicalHeight(newLogicalHeight);
766 resolver.setPositionIgnoringNestedIsolates(oldEnd); 766 resolver.setPositionIgnoringNestedIsolates(oldEnd);
767 return oldEnd; 767 return oldEnd;
768 } 768 }
769 769
770 void LayoutBlockFlow::appendFloatsToLastLine(LineLayoutState& layoutState, const InlineIterator& cleanLineStart)
771 {
772 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
773 FloatingObjectSetIterator it = floatingObjectSet.begin();
774 FloatingObjectSetIterator end = floatingObjectSet.end();
775 if (layoutState.lastFloat()) {
776 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lay outState.lastFloat());
777 ASSERT(lastFloatIterator != end);
778 ++lastFloatIterator;
779 it = lastFloatIterator;
780 }
781 for (; it != end; ++it) {
782 FloatingObject& floatingObject = *it->get();
783 // If we've reached the start of clean lines any remaining floating chil dren belong to them.
784 if (floatingObject.layoutObject() == cleanLineStart.object() && layoutSt ate.endLine()) {
785 layoutState.setLastFloat(&floatingObject);
786 return;
787 }
788 appendFloatingObjectToLastLine(floatingObject);
789 ASSERT(floatingObject.layoutObject() == layoutState.floats()[layoutState .floatIndex()].object);
790 // If a float's geometry has changed, give up on syncing with clean line s.
791 if (layoutState.floats()[layoutState.floatIndex()].rect != floatingObjec t.frameRect()) {
792 // Delete all the remaining lines.
793 deleteLineRange(layoutState, layoutState.endLine());
794 layoutState.setEndLine(nullptr);
795 }
796 layoutState.setFloatIndex(layoutState.floatIndex() + 1);
797 }
798 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSet.la st().get() : 0);
799 }
800
770 void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, 801 void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState,
771 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, 802 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart,
772 const BidiStatus& cleanLineBidiStatus) 803 const BidiStatus& cleanLineBidiStatus)
773 { 804 {
774 const ComputedStyle& styleToUse = styleRef(); 805 const ComputedStyle& styleToUse = styleRef();
775 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated (); 806 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated ();
776 LineMidpointState& lineMidpointState = resolver.midpointState(); 807 LineMidpointState& lineMidpointState = resolver.midpointState();
777 InlineIterator endOfLine = resolver.position(); 808 InlineIterator endOfLine = resolver.position();
778 bool checkForEndLineMatch = layoutState.endLine();
779 LayoutTextInfo layoutTextInfo; 809 LayoutTextInfo layoutTextInfo;
780 VerticalPositionCache verticalPositionCache; 810 VerticalPositionCache verticalPositionCache;
781 811
782 LineBreaker lineBreaker(LineLayoutBlockFlow(this)); 812 LineBreaker lineBreaker(LineLayoutBlockFlow(this));
783 813
784 while (!endOfLine.atEnd()) { 814 while (!endOfLine.atEnd()) {
785 bool logicalWidthIsAvailable = false; 815 bool logicalWidthIsAvailable = false;
786 816
787 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end? 817 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end?
788 if (checkForEndLineMatch) { 818 if (layoutState.endLine()) {
789 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus)); 819 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus));
790 if (layoutState.endLineMatched()) { 820 if (layoutState.endLineMatched()) {
791 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0); 821 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);
792 break; 822 break;
793 } 823 }
794 } 824 }
795 825
796 lineMidpointState.reset(); 826 lineMidpointState.reset();
797 827
798 layoutState.lineInfo().setEmpty(true); 828 layoutState.lineInfo().setEmpty(true);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 } 905 }
876 906
877 if (!logicalWidthIsAvailable) { 907 if (!logicalWidthIsAvailable) {
878 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) 908 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i)
879 setStaticPositions(LineLayoutBlockFlow(this), LineLayoutBox(line Breaker.positionedObjects()[i])); 909 setStaticPositions(LineLayoutBlockFlow(this), LineLayoutBox(line Breaker.positionedObjects()[i]));
880 910
881 if (!layoutState.lineInfo().isEmpty()) 911 if (!layoutState.lineInfo().isEmpty())
882 layoutState.lineInfo().setFirstLine(false); 912 layoutState.lineInfo().setFirstLine(false);
883 clearFloats(lineBreaker.clear()); 913 clearFloats(lineBreaker.clear());
884 914
885 if (m_floatingObjects && lastRootBox()) { 915 if (m_floatingObjects && lastRootBox())
886 const FloatingObjectSet& floatingObjectSet = m_floatingObjects-> set(); 916 appendFloatsToLastLine(layoutState, cleanLineStart);
887 FloatingObjectSetIterator it = floatingObjectSet.begin();
888 FloatingObjectSetIterator end = floatingObjectSet.end();
889 if (layoutState.lastFloat()) {
890 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat());
891 ASSERT(lastFloatIterator != end);
892 ++lastFloatIterator;
893 it = lastFloatIterator;
894 }
895 for (; it != end; ++it) {
896 FloatingObject& floatingObject = *it->get();
897 // If we've reached the start of clean lines any remaining f loating children belong to them.
898 // We don't care about the 'last float' mechanism once we're in clean lines so it's ok to let it get set below.
899 if (floatingObject.layoutObject() == cleanLineStart.object() )
900 break;
901 appendFloatingObjectToLastLine(floatingObject);
902 ASSERT(floatingObject.layoutObject() == layoutState.floats() [layoutState.floatIndex()].object);
903 // If a float's geometry has changed, give up on syncing wit h clean lines.
904 if (layoutState.floats()[layoutState.floatIndex()].rect != f loatingObject.frameRect())
905 checkForEndLineMatch = false;
906 layoutState.setFloatIndex(layoutState.floatIndex() + 1);
907 }
908 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating ObjectSet.last().get() : 0);
909 }
910 } 917 }
911 918
912 lineMidpointState.reset(); 919 lineMidpointState.reset();
913 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); 920 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine));
914 } 921 }
915 922
916 // In case we already adjusted the line positions during this layout to avoi d widows 923 // In case we already adjusted the line positions during this layout to avoi d widows
917 // then we need to ignore the possibility of having a new widows situation. 924 // then we need to ignore the possibility of having a new widows situation.
918 // Otherwise, we risk leaving empty containers which is against the block fr agmentation principles. 925 // Otherwise, we risk leaving empty containers which is against the block fr agmentation principles.
919 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow()) { 926 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow()) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } 1010 }
1004 } 1011 }
1005 } 1012 }
1006 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); 1013 setLogicalHeight(lastRootBox()->lineBottomWithLeading());
1007 } else { 1014 } else {
1008 // Delete all the remaining lines. 1015 // Delete all the remaining lines.
1009 deleteLineRange(layoutState, layoutState.endLine()); 1016 deleteLineRange(layoutState, layoutState.endLine());
1010 } 1017 }
1011 } 1018 }
1012 1019
1013 if (positionNewFloats() && lastRootBox()) { 1020 // In case we have a float on the last line, it might not be positioned up t o now.
1014 // In case we have a float on the last line, it might not be positioned up to now. 1021 // This has to be done before adding in the bottom border/padding, or the fl oat will
1015 // This has to be done before adding in the bottom border/padding, or th e float will 1022 // include the padding incorrectly. -dwh
1016 // include the padding incorrectly. -dwh 1023 if (positionNewFloats() && lastRootBox())
1017 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1024 appendFloatsToLastLine(layoutState, InlineIterator());
1018 FloatingObjectSetIterator it = floatingObjectSet.begin();
1019 FloatingObjectSetIterator end = floatingObjectSet.end();
1020 if (layoutState.lastFloat()) {
1021 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find (layoutState.lastFloat());
1022 ASSERT(lastFloatIterator != end);
1023 ++lastFloatIterator;
1024 it = lastFloatIterator;
1025 }
1026 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe t.last().get() : 0);
1027
1028 if (it == end)
1029 return;
1030
1031 for (; it != end; ++it)
1032 appendFloatingObjectToLastLine(*it->get());
1033 }
1034 } 1025 }
1035 1026
1036 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) 1027 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats)
1037 { 1028 {
1038 size_t floatCount = floats.size(); 1029 size_t floatCount = floats.size();
1039 // Floats that did not have layout did not paint invalidations when we laid them out. They would have 1030 // Floats that did not have layout did not paint invalidations when we laid them out. They would have
1040 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be 1031 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be
1041 // painted. 1032 // painted.
1042 for (size_t i = 0; i < floatCount; ++i) { 1033 for (size_t i = 0; i < floatCount; ++i) {
1043 LayoutBox* f = floats[i].object; 1034 LayoutBox* f = floats[i].object;
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2030 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2040 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; 2031 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2041 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2032 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2042 2033
2043 if (!style()->isLeftToRightDirection()) 2034 if (!style()->isLeftToRightDirection())
2044 return logicalWidth() - logicalLeft; 2035 return logicalWidth() - logicalLeft;
2045 return logicalLeft; 2036 return logicalLeft;
2046 } 2037 }
2047 2038
2048 } 2039 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698