| 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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 | 858 |
| 859 RenderObject* next(); | 859 RenderObject* next(); |
| 860 }; | 860 }; |
| 861 | 861 |
| 862 RenderObject* InlineMinMaxIterator::next() | 862 RenderObject* InlineMinMaxIterator::next() |
| 863 { | 863 { |
| 864 RenderObject* result = 0; | 864 RenderObject* result = 0; |
| 865 bool oldEndOfInline = endOfInline; | 865 bool oldEndOfInline = endOfInline; |
| 866 endOfInline = false; | 866 endOfInline = false; |
| 867 while (current || current == parent) { | 867 while (current || current == parent) { |
| 868 if (!oldEndOfInline && (current == parent || (!current->isFloating() &&
!current->isReplaced() && !current->isOutOfFlowPositioned()))) | 868 if (!oldEndOfInline && (current == parent || (!current->isReplaced() &&
!current->isOutOfFlowPositioned()))) |
| 869 result = current->slowFirstChild(); | 869 result = current->slowFirstChild(); |
| 870 | 870 |
| 871 if (!result) { | 871 if (!result) { |
| 872 // We hit the end of our inline. (It was empty, e.g., <span></span>.
) | 872 // We hit the end of our inline. (It was empty, e.g., <span></span>.
) |
| 873 if (!oldEndOfInline && current->isRenderInline()) { | 873 if (!oldEndOfInline && current->isRenderInline()) { |
| 874 result = current; | 874 result = current; |
| 875 endOfInline = true; | 875 endOfInline = true; |
| 876 break; | 876 break; |
| 877 } | 877 } |
| 878 | 878 |
| 879 while (current && current != parent) { | 879 while (current && current != parent) { |
| 880 result = current->nextSibling(); | 880 result = current->nextSibling(); |
| 881 if (result) | 881 if (result) |
| 882 break; | 882 break; |
| 883 current = current->parent(); | 883 current = current->parent(); |
| 884 if (current && current != parent && current->isRenderInline()) { | 884 if (current && current != parent && current->isRenderInline()) { |
| 885 result = current; | 885 result = current; |
| 886 endOfInline = true; | 886 endOfInline = true; |
| 887 break; | 887 break; |
| 888 } | 888 } |
| 889 } | 889 } |
| 890 } | 890 } |
| 891 | 891 |
| 892 if (!result) | 892 if (!result) |
| 893 break; | 893 break; |
| 894 | 894 |
| 895 if (!result->isOutOfFlowPositioned() && (result->isText() || result->isF
loating() || result->isReplaced() || result->isRenderInline())) | 895 if (!result->isOutOfFlowPositioned() && (result->isText() || result->isR
eplaced() || result->isRenderInline())) |
| 896 break; | 896 break; |
| 897 | 897 |
| 898 current = result; | 898 current = result; |
| 899 result = 0; | 899 result = 0; |
| 900 } | 900 } |
| 901 | 901 |
| 902 // Update our position. | 902 // Update our position. |
| 903 current = result; | 903 current = result; |
| 904 return current; | 904 return current; |
| 905 } | 905 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 autoWrap = oldAutoWrap = styleToUse->autoWrap(); | 973 autoWrap = oldAutoWrap = styleToUse->autoWrap(); |
| 974 | 974 |
| 975 InlineMinMaxIterator childIterator(this); | 975 InlineMinMaxIterator childIterator(this); |
| 976 | 976 |
| 977 // Only gets added to the max preffered width once. | 977 // Only gets added to the max preffered width once. |
| 978 bool addedTextIndent = false; | 978 bool addedTextIndent = false; |
| 979 // Signals the text indent was more negative than the min preferred width | 979 // Signals the text indent was more negative than the min preferred width |
| 980 bool hasRemainingNegativeTextIndent = false; | 980 bool hasRemainingNegativeTextIndent = false; |
| 981 | 981 |
| 982 LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw); | 982 LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw); |
| 983 RenderObject* prevFloat = 0; | |
| 984 bool isPrevChildInlineFlow = false; | 983 bool isPrevChildInlineFlow = false; |
| 985 bool shouldBreakLineAfterText = false; | 984 bool shouldBreakLineAfterText = false; |
| 986 while (RenderObject* child = childIterator.next()) { | 985 while (RenderObject* child = childIterator.next()) { |
| 987 autoWrap = child->isReplaced() ? child->parent()->style()->autoWrap() : | 986 autoWrap = child->isReplaced() ? child->parent()->style()->autoWrap() : |
| 988 child->style()->autoWrap(); | 987 child->style()->autoWrap(); |
| 989 | 988 |
| 990 // Step One: determine whether or not we need to go ahead and | 989 // Step One: determine whether or not we need to go ahead and |
| 991 // terminate our current line. Each discrete chunk can become | 990 // terminate our current line. Each discrete chunk can become |
| 992 // the new min-width, if it is the widest chunk seen so far, and | 991 // the new min-width, if it is the widest chunk seen so far, and |
| 993 // it can also become the max-width. | 992 // it can also become the max-width. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 | 1054 |
| 1056 if (!child->isRenderInline() && !child->isText()) { | 1055 if (!child->isRenderInline() && !child->isText()) { |
| 1057 // Case (2). Inline replaced elements and floats. | 1056 // Case (2). Inline replaced elements and floats. |
| 1058 // Go ahead and terminate the current line as far as | 1057 // Go ahead and terminate the current line as far as |
| 1059 // minwidth is concerned. | 1058 // minwidth is concerned. |
| 1060 LayoutUnit childMinPreferredLogicalWidth = child->minPreferredLogica
lWidth(); | 1059 LayoutUnit childMinPreferredLogicalWidth = child->minPreferredLogica
lWidth(); |
| 1061 LayoutUnit childMaxPreferredLogicalWidth = child->maxPreferredLogica
lWidth(); | 1060 LayoutUnit childMaxPreferredLogicalWidth = child->maxPreferredLogica
lWidth(); |
| 1062 childMin += childMinPreferredLogicalWidth.ceilToFloat(); | 1061 childMin += childMinPreferredLogicalWidth.ceilToFloat(); |
| 1063 childMax += childMaxPreferredLogicalWidth.ceilToFloat(); | 1062 childMax += childMaxPreferredLogicalWidth.ceilToFloat(); |
| 1064 | 1063 |
| 1065 bool clearPreviousFloat; | |
| 1066 if (child->isFloating()) { | |
| 1067 clearPreviousFloat = (prevFloat | |
| 1068 && ((prevFloat->style()->floating() == LeftFloat && (childSt
yle->clear() & CLEFT)) | |
| 1069 || (prevFloat->style()->floating() == RightFloat && (chi
ldStyle->clear() & CRIGHT)))); | |
| 1070 prevFloat = child; | |
| 1071 } else { | |
| 1072 clearPreviousFloat = false; | |
| 1073 } | |
| 1074 | |
| 1075 bool canBreakReplacedElement = true; | 1064 bool canBreakReplacedElement = true; |
| 1076 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!isPre
vChildInlineFlow || shouldBreakLineAfterText)) || clearPreviousFloat) { | 1065 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!isPre
vChildInlineFlow || shouldBreakLineAfterText))) { |
| 1077 updatePreferredWidth(minLogicalWidth, inlineMin); | 1066 updatePreferredWidth(minLogicalWidth, inlineMin); |
| 1078 inlineMin = 0; | 1067 inlineMin = 0; |
| 1079 } | 1068 } |
| 1080 | 1069 |
| 1081 // If we're supposed to clear the previous float, then terminate max
width as well. | |
| 1082 if (clearPreviousFloat) { | |
| 1083 updatePreferredWidth(maxLogicalWidth, inlineMax); | |
| 1084 inlineMax = 0; | |
| 1085 } | |
| 1086 | |
| 1087 // Add in text-indent. This is added in only once. | 1070 // Add in text-indent. This is added in only once. |
| 1088 if (!addedTextIndent && !child->isFloating()) { | 1071 if (!addedTextIndent) { |
| 1089 float ceiledTextIndent = textIndent.ceilToFloat(); | 1072 float ceiledTextIndent = textIndent.ceilToFloat(); |
| 1090 childMin += ceiledTextIndent; | 1073 childMin += ceiledTextIndent; |
| 1091 childMax += ceiledTextIndent; | 1074 childMax += ceiledTextIndent; |
| 1092 | 1075 |
| 1093 if (childMin < 0) | 1076 if (childMin < 0) |
| 1094 textIndent = adjustFloatForSubPixelLayout(childMin); | 1077 textIndent = adjustFloatForSubPixelLayout(childMin); |
| 1095 else | 1078 else |
| 1096 addedTextIndent = true; | 1079 addedTextIndent = true; |
| 1097 } | 1080 } |
| 1098 | 1081 |
| 1099 // Add our width to the max. | 1082 // Add our width to the max. |
| 1100 inlineMax += std::max<float>(0, childMax); | 1083 inlineMax += std::max<float>(0, childMax); |
| 1101 | 1084 |
| 1102 if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineFlow
&& !shouldBreakLineAfterText)) { | 1085 if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineFlow
&& !shouldBreakLineAfterText)) { |
| 1103 if (child->isFloating()) | 1086 inlineMin += childMin; |
| 1104 updatePreferredWidth(minLogicalWidth, childMin); | |
| 1105 else | |
| 1106 inlineMin += childMin; | |
| 1107 } else { | 1087 } else { |
| 1108 // Now check our line. | 1088 // Now check our line. |
| 1109 updatePreferredWidth(minLogicalWidth, childMin); | 1089 updatePreferredWidth(minLogicalWidth, childMin); |
| 1110 | 1090 |
| 1111 // Now start a new line. | 1091 // Now start a new line. |
| 1112 inlineMin = 0; | 1092 inlineMin = 0; |
| 1113 } | 1093 } |
| 1114 | 1094 |
| 1115 if (autoWrap && canBreakReplacedElement && isPrevChildInlineFlow) { | 1095 if (autoWrap && canBreakReplacedElement && isPrevChildInlineFlow) { |
| 1116 updatePreferredWidth(minLogicalWidth, inlineMin); | 1096 updatePreferredWidth(minLogicalWidth, inlineMin); |
| 1117 inlineMin = 0; | 1097 inlineMin = 0; |
| 1118 } | 1098 } |
| 1119 | 1099 |
| 1120 // We are no longer stripping whitespace at the start of | 1100 // We are no longer stripping whitespace at the start of |
| 1121 // a line. | 1101 // a line. |
| 1122 if (!child->isFloating()) { | 1102 stripFrontSpaces = false; |
| 1123 stripFrontSpaces = false; | 1103 trailingSpaceChild = 0; |
| 1124 trailingSpaceChild = 0; | |
| 1125 } | |
| 1126 } else if (child->isText()) { | 1104 } else if (child->isText()) { |
| 1127 // Case (3). Text. | 1105 // Case (3). Text. |
| 1128 RenderText* t = toRenderText(child); | 1106 RenderText* t = toRenderText(child); |
| 1129 | 1107 |
| 1130 // Determine if we have a breakable character. Pass in | 1108 // Determine if we have a breakable character. Pass in |
| 1131 // whether or not we should ignore any spaces at the front | 1109 // whether or not we should ignore any spaces at the front |
| 1132 // of the string. If those are going to be stripped out, | 1110 // of the string. If those are going to be stripped out, |
| 1133 // then they shouldn't be considered in the breakable char | 1111 // then they shouldn't be considered in the breakable char |
| 1134 // check. | 1112 // check. |
| 1135 bool hasBreakableChar, hasBreak; | 1113 bool hasBreakableChar, hasBreak; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 // the replaced elements later. In partial layout mode, line boxes are n
ot | 1244 // the replaced elements later. In partial layout mode, line boxes are n
ot |
| 1267 // deleted and only dirtied. In that case, we can layout the replaced | 1245 // deleted and only dirtied. In that case, we can layout the replaced |
| 1268 // elements at the same time. | 1246 // elements at the same time. |
| 1269 Vector<RenderBox*> replacedChildren; | 1247 Vector<RenderBox*> replacedChildren; |
| 1270 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | 1248 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
| 1271 RenderObject* o = walker.current(); | 1249 RenderObject* o = walker.current(); |
| 1272 | 1250 |
| 1273 if (!layoutState.hasInlineChild() && o->isInline()) | 1251 if (!layoutState.hasInlineChild() && o->isInline()) |
| 1274 layoutState.setHasInlineChild(true); | 1252 layoutState.setHasInlineChild(true); |
| 1275 | 1253 |
| 1276 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned()
) { | 1254 if (o->isReplaced() || o->isOutOfFlowPositioned()) { |
| 1277 RenderBox* box = toRenderBox(o); | 1255 RenderBox* box = toRenderBox(o); |
| 1278 | 1256 |
| 1279 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, box); | 1257 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, box); |
| 1280 | 1258 |
| 1281 if (o->isOutOfFlowPositioned()) | 1259 if (o->isOutOfFlowPositioned()) { |
| 1282 o->containingBlock()->insertPositionedObject(box); | 1260 o->containingBlock()->insertPositionedObject(box); |
| 1283 else if (o->isFloating()) | 1261 } else if (isFullLayout || o->needsLayout()) { |
| 1284 layoutState.floats().append(FloatWithRect(box)); | |
| 1285 else if (isFullLayout || o->needsLayout()) { | |
| 1286 // Replaced element. | 1262 // Replaced element. |
| 1287 box->dirtyLineBoxes(isFullLayout); | 1263 box->dirtyLineBoxes(isFullLayout); |
| 1288 if (isFullLayout) | 1264 if (isFullLayout) |
| 1289 replacedChildren.append(box); | 1265 replacedChildren.append(box); |
| 1290 else | 1266 else |
| 1291 o->layoutIfNeeded(); | 1267 o->layoutIfNeeded(); |
| 1292 } | 1268 } |
| 1293 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInl
ine())) { | 1269 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInl
ine())) { |
| 1294 if (!o->isText()) | 1270 if (!o->isText()) |
| 1295 toRenderInline(o)->updateAlwaysCreateLineBoxes(layoutState.i
sFullLayout()); | 1271 toRenderInline(o)->updateAlwaysCreateLineBoxes(layoutState.i
sFullLayout()); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 1604 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
| 1629 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 1605 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
| 1630 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 1606 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 1631 | 1607 |
| 1632 if (!style()->isLeftToRightDirection()) | 1608 if (!style()->isLeftToRightDirection()) |
| 1633 return logicalWidth() - logicalLeft; | 1609 return logicalWidth() - logicalLeft; |
| 1634 return logicalLeft; | 1610 return logicalLeft; |
| 1635 } | 1611 } |
| 1636 | 1612 |
| 1637 } | 1613 } |
| OLD | NEW |