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

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

Issue 16402019: Remove clips where we can show that they are unnecessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add TestExpectations for layout test changes due to crbug.com/249478 Created 7 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 if (!repaintRect.isEmpty()) { 1707 if (!repaintRect.isEmpty()) {
1708 repaintRectangle(repaintRect); // We need to do a partial repaint of our content. 1708 repaintRectangle(repaintRect); // We need to do a partial repaint of our content.
1709 if (hasReflection()) 1709 if (hasReflection())
1710 repaintRectangle(reflectedRect(repaintRect)); 1710 repaintRectangle(reflectedRect(repaintRect));
1711 } 1711 }
1712 } 1712 }
1713 1713
1714 setNeedsLayout(false); 1714 setNeedsLayout(false);
1715 } 1715 }
1716 1716
1717 void RenderBlock::addVisualOverflow(const LayoutRect& rect, VisualOverflowClipBe havior clipBehavior)
1718 {
1719 if (clipBehavior == VisualOverflowClippedByContentsClip && hasOverflowClip() && m_rareData) {
1720 m_rareData->m_contentsVisualOverflowRect.uniteIfNonZero(rect);
Julien - ping for review 2013/06/19 19:42:58 Why isn't this in RenderOverflow as it is its reas
jbroman 2013/08/02 14:28:17 Moved as requested.
1721 return;
1722 }
1723 RenderBox::addVisualOverflow(rect, clipBehavior);
1724 }
1725
1717 void RenderBlock::addOverflowFromChildren() 1726 void RenderBlock::addOverflowFromChildren()
1718 { 1727 {
1719 if (!hasColumns()) { 1728 if (!hasColumns()) {
1720 if (childrenInline()) 1729 if (childrenInline())
1721 addOverflowFromInlineChildren(); 1730 addOverflowFromInlineChildren();
1722 else 1731 else
1723 addOverflowFromBlockChildren(); 1732 addOverflowFromBlockChildren();
1724 } else { 1733 } else {
1725 ColumnInfo* colInfo = columnInfo(); 1734 ColumnInfo* colInfo = columnInfo();
1726 if (columnCount(colInfo)) { 1735 if (columnCount(colInfo)) {
1727 LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1 ); 1736 LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1 );
1728 addLayoutOverflow(lastRect); 1737 addLayoutOverflow(lastRect);
1729 if (!hasOverflowClip()) 1738 addVisualOverflow(lastRect, VisualOverflowClippedByContentsClip);
1730 addVisualOverflow(lastRect);
1731 } 1739 }
1732 } 1740 }
1733 } 1741 }
1734 1742
1735 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeF loats) 1743 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeF loats)
1736 { 1744 {
1737 m_overflow.clear(); 1745 m_overflow.clear();
1746 if (hasOverflowClip()) {
1747 if (!m_rareData)
1748 m_rareData = adoptPtr(new RenderBlockRareData(this));
1749 m_rareData->m_contentsVisualOverflowRect = LayoutRect();
Julien - ping for review 2013/06/19 19:42:58 You are now forcing all RenderBlocks with an overf
jbroman 2013/08/02 14:28:17 Changed to RenderOverflow. Note that in practice m
1750 }
1738 1751
1739 // Add overflow from children. 1752 // Add overflow from children.
1740 addOverflowFromChildren(); 1753 addOverflowFromChildren();
1741 1754
1742 if (!hasColumns() && (recomputeFloats || isRoot() || expandsToEncloseOverhan gingFloats() || hasSelfPaintingLayer())) 1755 if (!hasColumns() && (recomputeFloats || isRoot() || expandsToEncloseOverhan gingFloats() || hasSelfPaintingLayer()))
1743 addOverflowFromFloats(); 1756 addOverflowFromFloats();
1744 1757
1745 // Add in the overflow from positioned objects. 1758 // Add in the overflow from positioned objects.
1746 addOverflowFromPositionedObjects(); 1759 addOverflowFromPositionedObjects();
1747 1760
1748 if (hasOverflowClip()) { 1761 if (hasOverflowClip()) {
1749 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins 1762 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins
1750 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always 1763 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always
1751 // be considered reachable. 1764 // be considered reachable.
1752 LayoutRect clientRect(clientBoxRect()); 1765 LayoutRect clientRect(clientBoxRect());
1753 LayoutRect rectToApply; 1766 LayoutRect rectToApply;
1754 if (isHorizontalWritingMode()) 1767 if (isHorizontalWritingMode())
1755 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, max<Layo utUnit>(0, oldClientAfterEdge - clientRect.y())); 1768 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, max<Layo utUnit>(0, oldClientAfterEdge - clientRect.y()));
1756 else 1769 else
1757 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), max<LayoutU nit>(0, oldClientAfterEdge - clientRect.x()), 1); 1770 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), max<LayoutU nit>(0, oldClientAfterEdge - clientRect.x()), 1);
1758 addLayoutOverflow(rectToApply); 1771 addLayoutOverflow(rectToApply);
1759 if (hasRenderOverflow()) 1772 if (hasRenderOverflow())
1760 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); 1773 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge);
1761 } 1774 }
1762 1775
1763 // Allow our overflow to catch cases where the caret in an empty editable el ement with negative text indent needs to get painted. 1776 // Allow our overflow to catch cases where the caret in an empty editable el ement with negative text indent needs to get painted.
1764 LayoutUnit textIndent = textIndentOffset(); 1777 LayoutUnit textIndent = textIndentOffset();
1765 if (textIndent < 0) { 1778 if (textIndent < 0) {
1766 LayoutRect clientRect(clientBoxRect()); 1779 LayoutRect clientRect(clientBoxRect());
1767 LayoutRect rectToApply = LayoutRect(clientRect.x() + min<LayoutUnit>(0, textIndent), clientRect.y(), clientRect.width() - min<LayoutUnit>(0, textIndent) , clientRect.height()); 1780 LayoutRect rectToApply = LayoutRect(clientRect.x() + textIndent, clientR ect.y(), clientRect.width() - textIndent, clientRect.height());
Julien - ping for review 2013/06/19 19:42:58 Removing the min seems wrong: textIndent is negati
jbroman 2013/08/02 14:28:17 min returns the lesser of its arguments. If textIn
jbroman 2013/08/02 15:02:20 Err, I meant "is necessarily textIndent". The chan
Julien - ping for review 2013/08/07 00:17:08 Yeah, I misread the condition and your code was ri
1768 addVisualOverflow(rectToApply); 1781 addVisualOverflow(rectToApply, VisualOverflowClippedByContentsClip);
1769 } 1782 }
1770 1783
1771 // Add visual overflow from box-shadow and border-image-outset. 1784 // Add visual overflow from box-shadow and border-image-outset.
1772 addVisualEffectOverflow(); 1785 addVisualEffectOverflow();
1773 1786
1774 // Add visual overflow from theme. 1787 // Add visual overflow from theme.
1775 addVisualOverflowFromTheme(); 1788 addVisualOverflowFromTheme();
1776 1789
1777 if (isRenderFlowThread()) 1790 if (isRenderFlowThread())
1778 toRenderFlowThread(this)->computeOverflowStateForRegions(oldClientAfterE dge); 1791 toRenderFlowThread(this)->computeOverflowStateForRegions(oldClientAfterE dge);
(...skipping 24 matching lines...) Expand all
1803 void RenderBlock::addOverflowFromPositionedObjects() 1816 void RenderBlock::addOverflowFromPositionedObjects()
1804 { 1817 {
1805 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); 1818 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
1806 if (!positionedDescendants) 1819 if (!positionedDescendants)
1807 return; 1820 return;
1808 1821
1809 RenderBox* positionedObject; 1822 RenderBox* positionedObject;
1810 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 1823 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
1811 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) { 1824 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
1812 positionedObject = *it; 1825 positionedObject = *it;
1813 1826 LayoutUnit x = positionedObject->x();
1814 // Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content. 1827 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
1815 if (positionedObject->style()->position() != FixedPosition) { 1828 x -= verticalScrollbarWidth();
Julien - ping for review 2013/06/19 19:42:58 I am not sure I see the point of this change: you
jbroman 2013/08/02 14:28:17 Good point. Reverted.
1816 LayoutUnit x = positionedObject->x(); 1829 addOverflowFromChild(positionedObject, LayoutSize(x, positionedObject->y ()));
1817 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
1818 x -= verticalScrollbarWidth();
1819 addOverflowFromChild(positionedObject, LayoutSize(x, positionedObjec t->y()));
1820 }
1821 } 1830 }
1822 } 1831 }
1823 1832
1824 void RenderBlock::addVisualOverflowFromTheme() 1833 void RenderBlock::addVisualOverflowFromTheme()
1825 { 1834 {
1826 if (!style()->hasAppearance()) 1835 if (!style()->hasAppearance())
1827 return; 1836 return;
1828 1837
1829 IntRect inflatedRect = pixelSnappedBorderBoxRect(); 1838 IntRect inflatedRect = pixelSnappedBorderBoxRect();
1830 theme()->adjustRepaintRect(this, inflatedRect); 1839 theme()->adjustRepaintRect(this, inflatedRect);
1831 addVisualOverflow(inflatedRect); 1840 addVisualOverflow(inflatedRect, VisualOverflowNotClipped);
1832 } 1841 }
1833 1842
1834 bool RenderBlock::expandsToEncloseOverhangingFloats() const 1843 bool RenderBlock::expandsToEncloseOverhangingFloats() const
1835 { 1844 {
1836 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBoxIncludingDeprecated()) 1845 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBoxIncludingDeprecated())
1837 || hasColumns() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() || isRoot(); 1846 || hasColumns() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() || isRoot();
1838 } 1847 }
1839 1848
1840 void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marg inInfo) 1849 void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marg inInfo)
1841 { 1850 {
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 FloatingObject* r = *it; 2899 FloatingObject* r = *it;
2891 // Only repaint the object if it is overhanging, is not in its own layer , and 2900 // Only repaint the object if it is overhanging, is not in its own layer , and
2892 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter 2901 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter
2893 // condition is replaced with being a descendant of us. 2902 // condition is replaced with being a descendant of us.
2894 if (logicalBottomForFloat(r) > logicalHeight() && ((paintAllDescendants && r->m_renderer->isDescendantOf(this)) || r->shouldPaint()) && !r->m_renderer-> hasSelfPaintingLayer()) { 2903 if (logicalBottomForFloat(r) > logicalHeight() && ((paintAllDescendants && r->m_renderer->isDescendantOf(this)) || r->shouldPaint()) && !r->m_renderer-> hasSelfPaintingLayer()) {
2895 r->m_renderer->repaint(); 2904 r->m_renderer->repaint();
2896 r->m_renderer->repaintOverhangingFloats(false); 2905 r->m_renderer->repaintOverhangingFloats(false);
2897 } 2906 }
2898 } 2907 }
2899 } 2908 }
2900 2909
2910 static bool hasCaret(RenderObject* o)
2911 {
2912 Frame* frame = o->frame();
2913 if (frame->selection()->caretRenderer() == o)
2914 return frame->selection()->rendererIsEditable() || (frame->settings() && frame->settings()->caretBrowsingEnabled());
2915 if (frame->page()->dragCaretController()->caretRenderer() == o)
2916 return frame->page()->dragCaretController()->isContentEditable() || (fra me->settings() && frame->settings()->caretBrowsingEnabled());
2917 return false;
2918 }
Julien - ping for review 2013/06/19 19:42:58 This should probably be shared with the logic in R
jbroman 2013/08/02 14:28:17 They diverged and then grew together again. Create
2919
2901 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 2920 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
2902 { 2921 {
2903 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); 2922 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
2904 2923
2905 LayoutPoint adjustedPaintOffset = paintOffset + location(); 2924 LayoutPoint adjustedPaintOffset = paintOffset + location();
2906
2907 PaintPhase phase = paintInfo.phase; 2925 PaintPhase phase = paintInfo.phase;
2908 2926
2909 // Check if we need to do anything at all. 2927 // Check if we need to do anything at all.
2910 // FIXME: Could eliminate the isRoot() check if we fix background painting s o that the RenderView 2928 // FIXME: Could eliminate the isRoot() check if we fix background painting s o that the RenderView
2911 // paints the root's background. 2929 // paints the root's background.
2912 if (!isRoot()) { 2930 if (!isRoot()) {
2913 LayoutRect overflowBox = overflowRectForPaintRejection(); 2931 LayoutRect overflowBox = overflowRectForPaintRejection();
2914 flipForWritingMode(overflowBox); 2932 flipForWritingMode(overflowBox);
2915 overflowBox.inflate(maximalOutlineSize(paintInfo.phase)); 2933 overflowBox.inflate(maximalOutlineSize(paintInfo.phase));
2916 overflowBox.moveBy(adjustedPaintOffset); 2934 overflowBox.moveBy(adjustedPaintOffset);
2917 if (!overflowBox.intersects(paintInfo.rect)) 2935 if (!overflowBox.intersects(paintInfo.rect))
2918 return; 2936 return;
2919 } 2937 }
2920 2938
2921 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); 2939 const LayoutRect* contentsVisualOverflowRect = 0;
2940 if (m_rareData && !hasControlClip() && !hasCaret(this) && !(shouldPaintSelec tionGaps() && phase == PaintPhaseForeground)) {
2941 // Some visual elements clipped by the control clip are not included in m_contentsVisualOverflowRect.
2942 // It is also somewhat complicated to determine whether the caret and se lection gaps, if present, would be clipped.
2943 // FIXME: Determine whether these would be clipped instead of indiscrimi nately bailing out.
2944 contentsVisualOverflowRect = &m_rareData->m_contentsVisualOverflowRect;
2945 }
2946 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsV isualOverflowRect);
2922 paintObject(paintInfo, adjustedPaintOffset); 2947 paintObject(paintInfo, adjustedPaintOffset);
2923 if (pushedClip) 2948 if (pushedClip)
2924 popContentsClip(paintInfo, phase, adjustedPaintOffset); 2949 popContentsClip(paintInfo, phase, adjustedPaintOffset);
2925 2950
2926 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with 2951 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with
2927 // z-index. We paint after we painted the background/border, so that the sc rollbars will 2952 // z-index. We paint after we painted the background/border, so that the sc rollbars will
2928 // sit above the background/border. 2953 // sit above the background/border.
2929 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly()) 2954 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly())
2930 layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjust edPaintOffset), paintInfo.rect); 2955 layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjust edPaintOffset), paintInfo.rect);
2931 } 2956 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
3208 cb->addContinuationWithOutline(inlineRenderer); 3233 cb->addContinuationWithOutline(inlineRenderer);
3209 else if (!inlineRenderer->firstLineBox() || (!inlineEnclosedInSelfPa intingLayer && hasLayer())) 3234 else if (!inlineRenderer->firstLineBox() || (!inlineEnclosedInSelfPa intingLayer && hasLayer()))
3210 inlineRenderer->paintOutline(paintInfo, paintOffset - locationOf fset() + inlineRenderer->containingBlock()->location()); 3235 inlineRenderer->paintOutline(paintInfo, paintOffset - locationOf fset() + inlineRenderer->containingBlock()->location());
3211 } 3236 }
3212 paintContinuationOutlines(paintInfo, paintOffset); 3237 paintContinuationOutlines(paintInfo, paintOffset);
3213 } 3238 }
3214 3239
3215 // 7. paint caret. 3240 // 7. paint caret.
3216 // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground, 3241 // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground,
3217 // then paint the caret. 3242 // then paint the caret.
3218 if (paintPhase == PaintPhaseForeground) { 3243 if (paintPhase == PaintPhaseForeground) {
3219 paintCaret(paintInfo, paintOffset, CursorCaret); 3244 paintCaret(paintInfo, paintOffset, CursorCaret);
3220 paintCaret(paintInfo, paintOffset, DragCaret); 3245 paintCaret(paintInfo, paintOffset, DragCaret);
3221 } 3246 }
3222 } 3247 }
3223 3248
3224 LayoutPoint RenderBlock::flipFloatForWritingModeForChild(const FloatingObject* c hild, const LayoutPoint& point) const 3249 LayoutPoint RenderBlock::flipFloatForWritingModeForChild(const FloatingObject* c hild, const LayoutPoint& point) const
3225 { 3250 {
3226 if (!style()->isFlippedBlocksWritingMode()) 3251 if (!style()->isFlippedBlocksWritingMode())
3227 return point; 3252 return point;
3228 3253
(...skipping 4883 matching lines...) Expand 10 before | Expand all | Expand 10 after
8112 { 8137 {
8113 memoryInstrumentation->addRootObject(gColumnInfoMap, WebCoreMemoryTypes::Ren deringStructures); 8138 memoryInstrumentation->addRootObject(gColumnInfoMap, WebCoreMemoryTypes::Ren deringStructures);
8114 memoryInstrumentation->addRootObject(gPositionedDescendantsMap, WebCoreMemor yTypes::RenderingStructures); 8139 memoryInstrumentation->addRootObject(gPositionedDescendantsMap, WebCoreMemor yTypes::RenderingStructures);
8115 memoryInstrumentation->addRootObject(gPercentHeightDescendantsMap, WebCoreMe moryTypes::RenderingStructures); 8140 memoryInstrumentation->addRootObject(gPercentHeightDescendantsMap, WebCoreMe moryTypes::RenderingStructures);
8116 memoryInstrumentation->addRootObject(gPositionedContainerMap, WebCoreMemoryT ypes::RenderingStructures); 8141 memoryInstrumentation->addRootObject(gPositionedContainerMap, WebCoreMemoryT ypes::RenderingStructures);
8117 memoryInstrumentation->addRootObject(gPercentHeightContainerMap, WebCoreMemo ryTypes::RenderingStructures); 8142 memoryInstrumentation->addRootObject(gPercentHeightContainerMap, WebCoreMemo ryTypes::RenderingStructures);
8118 memoryInstrumentation->addRootObject(gDelayedUpdateScrollInfoSet, WebCoreMem oryTypes::RenderingStructures); 8143 memoryInstrumentation->addRootObject(gDelayedUpdateScrollInfoSet, WebCoreMem oryTypes::RenderingStructures);
8119 } 8144 }
8120 8145
8121 } // namespace WebCore 8146 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698