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

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

Issue 145083009: Remove unnecessary repaint from line layout and cleanup logic (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/line/LineLayoutState.h » ('j') | 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 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 while (boxToDelete && boxToDelete != stopLine) { 937 while (boxToDelete && boxToDelete != stopLine) {
938 layoutState.updateRepaintRangeFromBox(boxToDelete); 938 layoutState.updateRepaintRangeFromBox(boxToDelete);
939 // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineB oxTree(). 939 // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineB oxTree().
940 // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when tr aversing. 940 // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when tr aversing.
941 RootInlineBox* next = boxToDelete->nextRootBox(); 941 RootInlineBox* next = boxToDelete->nextRootBox();
942 boxToDelete->deleteLine(); 942 boxToDelete->deleteLine();
943 boxToDelete = next; 943 boxToDelete = next;
944 } 944 }
945 } 945 }
946 946
947 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState, bool has InlineChild) 947 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState)
948 { 948 {
949 // We want to skip ahead to the first dirty line 949 // We want to skip ahead to the first dirty line
950 InlineBidiResolver resolver; 950 InlineBidiResolver resolver;
951 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); 951 RootInlineBox* startLine = determineStartPosition(layoutState, resolver);
952 952
953 unsigned consecutiveHyphenatedLines = 0; 953 unsigned consecutiveHyphenatedLines = 0;
954 if (startLine) { 954 if (startLine) {
955 for (RootInlineBox* line = startLine->prevRootBox(); line && line->isHyp henated(); line = line->prevRootBox()) 955 for (RootInlineBox* line = startLine->prevRootBox(); line && line->isHyp henated(); line = line->prevRootBox())
956 consecutiveHyphenatedLines++; 956 consecutiveHyphenatedLines++;
957 } 957 }
958 958
959 // FIXME: This would make more sense outside of this function, but since
960 // determineStartPosition can change the fullLayout flag we have to do this here. Failure to call
961 // determineStartPosition first will break fast/repaint/line-flow-with-float s-9.html.
962 if (layoutState.isFullLayout() && hasInlineChild && !selfNeedsLayout()) {
963 // Mark as needing a full layout to force us to repaint. Allow regions
964 // to reflow as needed.
965 setNeedsLayout(MarkOnlyThis);
966
967 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
968 setShouldDoFullRepaintAfterLayout(true);
969 } else {
970 RenderView* v = view();
971 if (v && !v->doingFullRepaint() && hasLayer()) {
972 // Because we waited until we were already inside layout to disc over
973 // that the block really needed a full layout, we missed our cha nce to repaint the layer
974 // before layout started. Luckily the layer has cached the repai nt rect for its original
975 // position and size, and so we can use that to make a repaint h appen now.
976 repaintUsingContainer(containerForRepaint(), pixelSnappedIntRect (layer()->repainter().repaintRect()));
977 }
978 }
979 }
980
981 if (containsFloats()) 959 if (containsFloats())
982 layoutState.setLastFloat(m_floatingObjects->set().last()); 960 layoutState.setLastFloat(m_floatingObjects->set().last());
983 961
984 // We also find the first clean line and extract these lines. We will add t hem back 962 // We also find the first clean line and extract these lines. We will add t hem back
985 // if we determine that we're able to synchronize after handling all our dir ty lines. 963 // if we determine that we're able to synchronize after handling all our dir ty lines.
986 InlineIterator cleanLineStart; 964 InlineIterator cleanLineStart;
987 BidiStatus cleanLineBidiStatus; 965 BidiStatus cleanLineBidiStatus;
988 if (!layoutState.isFullLayout() && startLine) 966 if (!layoutState.isFullLayout() && startLine)
989 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); 967 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus);
990 968
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 // Walk all the lines and delete our ellipsis line boxes if they exist. 1526 // Walk all the lines and delete our ellipsis line boxes if they exist.
1549 if (hasTextOverflow) 1527 if (hasTextOverflow)
1550 deleteEllipsisLineBoxes(); 1528 deleteEllipsisLineBoxes();
1551 1529
1552 if (firstChild()) { 1530 if (firstChild()) {
1553 // In full layout mode, clear the line boxes of children upfront. Otherw ise, 1531 // In full layout mode, clear the line boxes of children upfront. Otherw ise,
1554 // siblings can run into stale root lineboxes during layout. Then layout 1532 // siblings can run into stale root lineboxes during layout. Then layout
1555 // the replaced elements later. In partial layout mode, line boxes are n ot 1533 // the replaced elements later. In partial layout mode, line boxes are n ot
1556 // deleted and only dirtied. In that case, we can layout the replaced 1534 // deleted and only dirtied. In that case, we can layout the replaced
1557 // elements at the same time. 1535 // elements at the same time.
1558 bool hasInlineChild = false;
1559 Vector<RenderBox*> replacedChildren; 1536 Vector<RenderBox*> replacedChildren;
1560 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { 1537 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) {
1561 RenderObject* o = walker.current(); 1538 RenderObject* o = walker.current();
1562 1539
1563 LayoutRectRecorder recorder(*o, !o->isText()); 1540 LayoutRectRecorder recorder(*o, !o->isText());
1564 1541
1565 if (!hasInlineChild && o->isInline()) 1542 if (!layoutState.hasInlineChild() && o->isInline())
1566 hasInlineChild = true; 1543 layoutState.setHasInlineChild(true);
1567 1544
1568 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned() ) { 1545 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned() ) {
1569 RenderBox* box = toRenderBox(o); 1546 RenderBox* box = toRenderBox(o);
1570 1547
1571 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, box); 1548 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, box);
1572 1549
1573 if (o->isOutOfFlowPositioned()) 1550 if (o->isOutOfFlowPositioned())
1574 o->containingBlock()->insertPositionedObject(box); 1551 o->containingBlock()->insertPositionedObject(box);
1575 else if (o->isFloating()) 1552 else if (o->isFloating())
1576 layoutState.floats().append(FloatWithRect(box)); 1553 layoutState.floats().append(FloatWithRect(box));
(...skipping 10 matching lines...) Expand all
1587 toRenderInline(o)->updateAlwaysCreateLineBoxes(layoutState.i sFullLayout()); 1564 toRenderInline(o)->updateAlwaysCreateLineBoxes(layoutState.i sFullLayout());
1588 if (layoutState.isFullLayout() || o->selfNeedsLayout()) 1565 if (layoutState.isFullLayout() || o->selfNeedsLayout())
1589 dirtyLineBoxesForRenderer(o, layoutState.isFullLayout()); 1566 dirtyLineBoxesForRenderer(o, layoutState.isFullLayout());
1590 o->clearNeedsLayout(); 1567 o->clearNeedsLayout();
1591 } 1568 }
1592 } 1569 }
1593 1570
1594 for (size_t i = 0; i < replacedChildren.size(); i++) 1571 for (size_t i = 0; i < replacedChildren.size(); i++)
1595 replacedChildren[i]->layoutIfNeeded(); 1572 replacedChildren[i]->layoutIfNeeded();
1596 1573
1597 layoutRunsAndFloats(layoutState, hasInlineChild); 1574 layoutRunsAndFloats(layoutState);
1598 } 1575 }
1599 1576
1600 // Expand the last line to accommodate Ruby and emphasis marks. 1577 // Expand the last line to accommodate Ruby and emphasis marks.
1601 int lastLineAnnotationsAdjustment = 0; 1578 int lastLineAnnotationsAdjustment = 0;
1602 if (lastRootBox()) { 1579 if (lastRootBox()) {
1603 LayoutUnit lowestAllowedPosition = max(lastRootBox()->lineBottom(), logi calHeight() + paddingAfter()); 1580 LayoutUnit lowestAllowedPosition = max(lastRootBox()->lineBottom(), logi calHeight() + paddingAfter());
1604 if (!style()->isFlippedLinesWritingMode()) 1581 if (!style()->isFlippedLinesWritingMode())
1605 lastLineAnnotationsAdjustment = lastRootBox()->computeUnderAnnotatio nAdjustment(lowestAllowedPosition); 1582 lastLineAnnotationsAdjustment = lastRootBox()->computeUnderAnnotatio nAdjustment(lowestAllowedPosition);
1606 else 1583 else
1607 lastLineAnnotationsAdjustment = lastRootBox()->computeOverAnnotation Adjustment(lowestAllowedPosition); 1584 lastLineAnnotationsAdjustment = lastRootBox()->computeOverAnnotation Adjustment(lowestAllowedPosition);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 1668
1692 if (dirtiedByFloat || layoutState.isFullLayout()) 1669 if (dirtiedByFloat || layoutState.isFullLayout())
1693 break; 1670 break;
1694 } 1671 }
1695 // Check if a new float has been inserted after the last known float. 1672 // Check if a new float has been inserted after the last known float.
1696 if (!curr && floatIndex < layoutState.floats().size()) 1673 if (!curr && floatIndex < layoutState.floats().size())
1697 layoutState.markForFullLayout(); 1674 layoutState.markForFullLayout();
1698 } 1675 }
1699 1676
1700 if (layoutState.isFullLayout()) { 1677 if (layoutState.isFullLayout()) {
1678 // If we encountered a new float and have inline children, mark ourself to force us to repaint.
1679 if (layoutState.hasInlineChild() && !selfNeedsLayout())
1680 setNeedsLayout(MarkOnlyThis);
ojan 2014/01/28 20:55:23 Why do this instead of calling repaint directly? D
leviw_travelin_and_unemployed 2014/01/28 21:42:31 Perhaps this can be further optimized, but this is
1681
1701 // FIXME: This should just call deleteLineBoxTree, but that causes 1682 // FIXME: This should just call deleteLineBoxTree, but that causes
1702 // crashes for fast/repaint tests. 1683 // crashes for fast/repaint tests.
1703 curr = firstRootBox(); 1684 curr = firstRootBox();
1704 while (curr) { 1685 while (curr) {
1705 // Note: This uses nextRootBox() insted of nextLineBox() like delete LineBoxTree does. 1686 // Note: This uses nextRootBox() insted of nextLineBox() like delete LineBoxTree does.
1706 RootInlineBox* next = curr->nextRootBox(); 1687 RootInlineBox* next = curr->nextRootBox();
1707 curr->deleteLine(); 1688 curr->deleteLine();
1708 curr = next; 1689 curr = next;
1709 } 1690 }
1710 ASSERT(!firstLineBox() && !lastLineBox()); 1691 ASSERT(!firstLineBox() && !lastLineBox());
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 2058 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
2078 2059
2079 setLineGridBox(lineGridBox); 2060 setLineGridBox(lineGridBox);
2080 2061
2081 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 2062 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
2082 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 2063 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
2083 // to this grid. 2064 // to this grid.
2084 } 2065 }
2085 2066
2086 } 2067 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/line/LineLayoutState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698