| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/rendering/RenderParagraph.h" | 6 #include "sky/engine/core/rendering/RenderParagraph.h" |
| 7 | 7 |
| 8 #include "sky/engine/core/rendering/BidiRunForLine.h" | 8 #include "sky/engine/core/rendering/BidiRunForLine.h" |
| 9 #include "sky/engine/core/rendering/InlineIterator.h" | 9 #include "sky/engine/core/rendering/InlineIterator.h" |
| 10 #include "sky/engine/core/rendering/RenderLayer.h" | 10 #include "sky/engine/core/rendering/RenderLayer.h" |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 return -1; | 1243 return -1; |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 void RenderParagraph::layoutChildren(bool relayoutChildren, SubtreeLayoutScope&
layoutScope, LayoutUnit& paintInvalidationLogicalTop, LayoutUnit& paintInvalidat
ionLogicalBottom, LayoutUnit beforeEdge, LayoutUnit afterEdge) | 1246 void RenderParagraph::layoutChildren(bool relayoutChildren, SubtreeLayoutScope&
layoutScope, LayoutUnit& paintInvalidationLogicalTop, LayoutUnit& paintInvalidat
ionLogicalBottom, LayoutUnit beforeEdge, LayoutUnit afterEdge) |
| 1247 { | 1247 { |
| 1248 // Figure out if we should clear out our line boxes. | 1248 // Figure out if we should clear out our line boxes. |
| 1249 // FIXME: Handle resize eventually! | 1249 // FIXME: Handle resize eventually! |
| 1250 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren
; | 1250 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren
; |
| 1251 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint
InvalidationLogicalBottom); | 1251 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint
InvalidationLogicalBottom); |
| 1252 | 1252 |
| 1253 if (isFullLayout) { | 1253 if (isFullLayout) |
| 1254 // Ensure the old line boxes will be erased. | |
| 1255 if (firstLineBox()) | |
| 1256 setShouldDoFullPaintInvalidation(true); | |
| 1257 lineBoxes()->deleteLineBoxes(); | 1254 lineBoxes()->deleteLineBoxes(); |
| 1258 } | |
| 1259 | 1255 |
| 1260 // Text truncation kicks in in two cases: | 1256 // Text truncation kicks in in two cases: |
| 1261 // 1) If your overflow isn't visible and your text-overflow-mode isn't c
lip. | 1257 // 1) If your overflow isn't visible and your text-overflow-mode isn't c
lip. |
| 1262 // 2) If you're an anonymous paragraph with a parent that satisfies #1. | 1258 // 2) If you're an anonymous paragraph with a parent that satisfies #1. |
| 1263 // FIXME: CSS3 says that descendants that are clipped must also know how to
truncate. This is insanely | 1259 // FIXME: CSS3 says that descendants that are clipped must also know how to
truncate. This is insanely |
| 1264 // difficult to figure out in general (especially in the middle of doing lay
out), so we only handle the | 1260 // difficult to figure out in general (especially in the middle of doing lay
out), so we only handle the |
| 1265 // simple case of an anonymous block truncating when it's parent is clipped. | 1261 // simple case of an anonymous block truncating when it's parent is clipped. |
| 1266 bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip()) | 1262 bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip()) |
| 1267 || (isAnonymousBlock() && parent() && parent()->style()->textOverflow()
&& parent()->hasOverflowClip()); | 1263 || (isAnonymousBlock() && parent() && parent()->style()->textOverflow()
&& parent()->hasOverflowClip()); |
| 1268 | 1264 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 // Now add in the bottom border/padding. | 1319 // Now add in the bottom border/padding. |
| 1324 setLogicalHeight(logicalHeight() + lastLineAnnotationsAdjustment + afterEdge
); | 1320 setLogicalHeight(logicalHeight() + lastLineAnnotationsAdjustment + afterEdge
); |
| 1325 | 1321 |
| 1326 if (!firstLineBox() && hasLineIfEmpty()) | 1322 if (!firstLineBox() && hasLineIfEmpty()) |
| 1327 setLogicalHeight(logicalHeight() + lineHeight(true, HorizontalLine, Posi
tionOfInteriorLineBoxes)); | 1323 setLogicalHeight(logicalHeight() + lineHeight(true, HorizontalLine, Posi
tionOfInteriorLineBoxes)); |
| 1328 | 1324 |
| 1329 // See if we have any lines that spill out of our block. If we do, then we
will possibly need to | 1325 // See if we have any lines that spill out of our block. If we do, then we
will possibly need to |
| 1330 // truncate text. | 1326 // truncate text. |
| 1331 if (hasTextOverflow) | 1327 if (hasTextOverflow) |
| 1332 checkLinesForTextOverflow(); | 1328 checkLinesForTextOverflow(); |
| 1333 | |
| 1334 // Ensure the new line boxes will be painted. | |
| 1335 if (isFullLayout && firstLineBox()) | |
| 1336 setShouldDoFullPaintInvalidation(true); | |
| 1337 } | 1329 } |
| 1338 | 1330 |
| 1339 void RenderParagraph::checkFloatsInCleanLine(RootInlineBox* line, Vector<FloatWi
thRect>& floats, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByF
loat) | 1331 void RenderParagraph::checkFloatsInCleanLine(RootInlineBox* line, Vector<FloatWi
thRect>& floats, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByF
loat) |
| 1340 { | 1332 { |
| 1341 Vector<RenderBox*>* cleanLineFloats = line->floatsPtr(); | 1333 Vector<RenderBox*>* cleanLineFloats = line->floatsPtr(); |
| 1342 if (!cleanLineFloats) | 1334 if (!cleanLineFloats) |
| 1343 return; | 1335 return; |
| 1344 | 1336 |
| 1345 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); | 1337 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); |
| 1346 for (Vector<RenderBox*>::iterator it = cleanLineFloats->begin(); it != end;
++it) { | 1338 for (Vector<RenderBox*>::iterator it = cleanLineFloats->begin(); it != end;
++it) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 } | 1378 } |
| 1387 // Check if a new float has been inserted after the last known float. | 1379 // Check if a new float has been inserted after the last known float. |
| 1388 if (!curr && floatIndex < layoutState.floats().size()) | 1380 if (!curr && floatIndex < layoutState.floats().size()) |
| 1389 layoutState.markForFullLayout(); | 1381 layoutState.markForFullLayout(); |
| 1390 } | 1382 } |
| 1391 | 1383 |
| 1392 if (layoutState.isFullLayout()) { | 1384 if (layoutState.isFullLayout()) { |
| 1393 // If we encountered a new float and have inline children, mark ourself
to force us to issue paint invalidations. | 1385 // If we encountered a new float and have inline children, mark ourself
to force us to issue paint invalidations. |
| 1394 if (layoutState.hasInlineChild() && !selfNeedsLayout()) { | 1386 if (layoutState.hasInlineChild() && !selfNeedsLayout()) { |
| 1395 setNeedsLayoutAndFullPaintInvalidation(MarkOnlyThis); | 1387 setNeedsLayoutAndFullPaintInvalidation(MarkOnlyThis); |
| 1396 setShouldDoFullPaintInvalidation(true); | |
| 1397 } | 1388 } |
| 1398 | 1389 |
| 1399 // FIXME: This should just call deleteLineBoxTree, but that causes | 1390 // FIXME: This should just call deleteLineBoxTree, but that causes |
| 1400 // crashes for fast/repaint tests. | 1391 // crashes for fast/repaint tests. |
| 1401 curr = firstRootBox(); | 1392 curr = firstRootBox(); |
| 1402 while (curr) { | 1393 while (curr) { |
| 1403 // Note: This uses nextRootBox() insted of nextLineBox() like delete
LineBoxTree does. | 1394 // Note: This uses nextRootBox() insted of nextLineBox() like delete
LineBoxTree does. |
| 1404 RootInlineBox* next = curr->nextRootBox(); | 1395 RootInlineBox* next = curr->nextRootBox(); |
| 1405 curr->deleteLine(); | 1396 curr->deleteLine(); |
| 1406 curr = next; | 1397 curr = next; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 curr->adjustLogicalPosition(logicalLeft, 0); | 1582 curr->adjustLogicalPosition(logicalLeft, 0); |
| 1592 else | 1583 else |
| 1593 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); | 1584 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); |
| 1594 } | 1585 } |
| 1595 } | 1586 } |
| 1596 firstLine = false; | 1587 firstLine = false; |
| 1597 } | 1588 } |
| 1598 } | 1589 } |
| 1599 | 1590 |
| 1600 } // namespace blink | 1591 } // namespace blink |
| OLD | NEW |