OLD | NEW |
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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated
(); | 792 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated
(); |
793 LineMidpointState& lineMidpointState = resolver.midpointState(); | 793 LineMidpointState& lineMidpointState = resolver.midpointState(); |
794 InlineIterator endOfLine = resolver.position(); | 794 InlineIterator endOfLine = resolver.position(); |
795 bool checkForEndLineMatch = layoutState.endLine(); | 795 bool checkForEndLineMatch = layoutState.endLine(); |
796 RenderTextInfo renderTextInfo; | 796 RenderTextInfo renderTextInfo; |
797 VerticalPositionCache verticalPositionCache; | 797 VerticalPositionCache verticalPositionCache; |
798 | 798 |
799 LineBreaker lineBreaker(this); | 799 LineBreaker lineBreaker(this); |
800 | 800 |
801 while (!endOfLine.atEnd()) { | 801 while (!endOfLine.atEnd()) { |
| 802 bool logicalWidthIsAvailable = false; |
| 803 |
802 // FIXME: Is this check necessary before the first iteration or can it b
e moved to the end? | 804 // FIXME: Is this check necessary before the first iteration or can it b
e moved to the end? |
803 if (checkForEndLineMatch) { | 805 if (checkForEndLineMatch) { |
804 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); | 806 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); |
805 if (layoutState.endLineMatched()) { | 807 if (layoutState.endLineMatched()) { |
806 resolver.setPosition(InlineIterator(resolver.position().root(),
0, 0), 0); | 808 resolver.setPosition(InlineIterator(resolver.position().root(),
0, 0), 0); |
807 break; | 809 break; |
808 } | 810 } |
809 } | 811 } |
810 | 812 |
811 lineMidpointState.reset(); | 813 lineMidpointState.reset(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 if (adjustment) { | 876 if (adjustment) { |
875 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o
ldLogicalHeight, layoutState.lineInfo().isFirstLine()); | 877 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o
ldLogicalHeight, layoutState.lineInfo().isFirstLine()); |
876 lineBox->adjustBlockDirectionPosition(adjustment.toFloat
()); | 878 lineBox->adjustBlockDirectionPosition(adjustment.toFloat
()); |
877 if (layoutState.usesPaintInvalidationBounds()) | 879 if (layoutState.usesPaintInvalidationBounds()) |
878 layoutState.updatePaintInvalidationRangeFromBox(line
Box); | 880 layoutState.updatePaintInvalidationRangeFromBox(line
Box); |
879 | 881 |
880 if (availableLogicalWidthForLine(oldLogicalHeight + adju
stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { | 882 if (availableLogicalWidthForLine(oldLogicalHeight + adju
stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { |
881 // We have to delete this line, remove all floats th
at got added, and let line layout re-run. | 883 // We have to delete this line, remove all floats th
at got added, and let line layout re-run. |
882 lineBox->deleteLine(); | 884 lineBox->deleteLine(); |
883 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog
icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver,
previousEndofLine); | 885 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog
icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver,
previousEndofLine); |
884 continue; | 886 logicalWidthIsAvailable = true; |
| 887 } else { |
| 888 setLogicalHeight(lineBox->lineBottomWithLeading()); |
885 } | 889 } |
886 | |
887 setLogicalHeight(lineBox->lineBottomWithLeading()); | |
888 } | 890 } |
889 } | 891 } |
890 } | 892 } |
891 } | 893 } |
892 | 894 |
893 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) | 895 if (!logicalWidthIsAvailable) { |
894 setStaticPositions(this, lineBreaker.positionedObjects()[i]); | 896 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) |
| 897 setStaticPositions(this, lineBreaker.positionedObjects()[i]); |
895 | 898 |
896 if (!layoutState.lineInfo().isEmpty()) { | 899 if (!layoutState.lineInfo().isEmpty()) { |
897 layoutState.lineInfo().setFirstLine(false); | 900 layoutState.lineInfo().setFirstLine(false); |
898 clearFloats(lineBreaker.clear()); | 901 clearFloats(lineBreaker.clear()); |
899 } | 902 } |
900 | 903 |
901 if (m_floatingObjects && lastRootBox()) { | 904 if (m_floatingObjects && lastRootBox()) { |
902 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(
); | 905 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->
set(); |
903 FloatingObjectSetIterator it = floatingObjectSet.begin(); | 906 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
904 FloatingObjectSetIterator end = floatingObjectSet.end(); | 907 FloatingObjectSetIterator end = floatingObjectSet.end(); |
905 if (layoutState.lastFloat()) { | 908 if (layoutState.lastFloat()) { |
906 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.
find(layoutState.lastFloat()); | 909 FloatingObjectSetIterator lastFloatIterator = floatingObject
Set.find(layoutState.lastFloat()); |
907 ASSERT(lastFloatIterator != end); | 910 ASSERT(lastFloatIterator != end); |
908 ++lastFloatIterator; | 911 ++lastFloatIterator; |
909 it = lastFloatIterator; | 912 it = lastFloatIterator; |
| 913 } |
| 914 for (; it != end; ++it) { |
| 915 FloatingObject* f = it->get(); |
| 916 appendFloatingObjectToLastLine(f); |
| 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. |
| 919 if (layoutState.floats()[layoutState.floatIndex()].rect != f
->frameRect()) |
| 920 checkForEndLineMatch = false; |
| 921 layoutState.setFloatIndex(layoutState.floatIndex() + 1); |
| 922 } |
| 923 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating
ObjectSet.last().get() : 0); |
910 } | 924 } |
911 for (; it != end; ++it) { | |
912 FloatingObject* f = it->get(); | |
913 appendFloatingObjectToLastLine(f); | |
914 ASSERT(f->renderer() == layoutState.floats()[layoutState.floatIn
dex()].object); | |
915 // If a float's geometry has changed, give up on syncing with cl
ean lines. | |
916 if (layoutState.floats()[layoutState.floatIndex()].rect != f->fr
ameRect()) | |
917 checkForEndLineMatch = false; | |
918 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | |
919 } | |
920 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObje
ctSet.last().get() : 0); | |
921 } | 925 } |
922 | 926 |
923 lineMidpointState.reset(); | 927 lineMidpointState.reset(); |
924 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 928 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
925 } | 929 } |
926 | 930 |
927 // In case we already adjusted the line positions during this layout to avoi
d widows | 931 // In case we already adjusted the line positions during this layout to avoi
d widows |
928 // then we need to ignore the possibility of having a new widows situation. | 932 // then we need to ignore the possibility of having a new widows situation. |
929 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. | 933 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. |
930 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ | 934 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2049 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
2046 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2050 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
2047 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2051 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2048 | 2052 |
2049 if (!style()->isLeftToRightDirection()) | 2053 if (!style()->isLeftToRightDirection()) |
2050 return logicalWidth() - logicalLeft; | 2054 return logicalWidth() - logicalLeft; |
2051 return logicalLeft; | 2055 return logicalLeft; |
2052 } | 2056 } |
2053 | 2057 |
2054 } | 2058 } |
OLD | NEW |