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

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: NeedsRebaseline for Mac Created 7 years, 4 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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 if (!hasColumns()) { 1732 if (!hasColumns()) {
1733 if (childrenInline()) 1733 if (childrenInline())
1734 addOverflowFromInlineChildren(); 1734 addOverflowFromInlineChildren();
1735 else 1735 else
1736 addOverflowFromBlockChildren(); 1736 addOverflowFromBlockChildren();
1737 } else { 1737 } else {
1738 ColumnInfo* colInfo = columnInfo(); 1738 ColumnInfo* colInfo = columnInfo();
1739 if (columnCount(colInfo)) { 1739 if (columnCount(colInfo)) {
1740 LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1 ); 1740 LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1 );
1741 addLayoutOverflow(lastRect); 1741 addLayoutOverflow(lastRect);
1742 if (!hasOverflowClip()) 1742 addVisualOverflow(lastRect, VisualOverflowClippedByContentsClip);
1743 addVisualOverflow(lastRect);
1744 } 1743 }
1745 } 1744 }
1746 } 1745 }
1747 1746
1748 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeF loats) 1747 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeF loats)
1749 { 1748 {
1750 m_overflow.clear(); 1749 m_overflow.clear();
1751 1750
1752 // Add overflow from children. 1751 // Add overflow from children.
1753 addOverflowFromChildren(); 1752 addOverflowFromChildren();
(...skipping 17 matching lines...) Expand all
1771 addLayoutOverflow(rectToApply); 1770 addLayoutOverflow(rectToApply);
1772 if (hasRenderOverflow()) 1771 if (hasRenderOverflow())
1773 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); 1772 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge);
1774 } 1773 }
1775 1774
1776 // Allow our overflow to catch cases where the caret in an empty editable el ement with negative text indent needs to get painted. 1775 // Allow our overflow to catch cases where the caret in an empty editable el ement with negative text indent needs to get painted.
1777 LayoutUnit textIndent = textIndentOffset(); 1776 LayoutUnit textIndent = textIndentOffset();
1778 if (textIndent < 0) { 1777 if (textIndent < 0) {
1779 LayoutRect clientRect(noOverflowRect()); 1778 LayoutRect clientRect(noOverflowRect());
1780 LayoutRect rectToApply = LayoutRect(clientRect.x() + min<LayoutUnit>(0, textIndent), clientRect.y(), clientRect.width() - min<LayoutUnit>(0, textIndent) , clientRect.height()); 1779 LayoutRect rectToApply = LayoutRect(clientRect.x() + min<LayoutUnit>(0, textIndent), clientRect.y(), clientRect.width() - min<LayoutUnit>(0, textIndent) , clientRect.height());
1781 addVisualOverflow(rectToApply); 1780 addVisualOverflow(rectToApply, VisualOverflowClippedByContentsClip);
1782 } 1781 }
1783 1782
1784 // Add visual overflow from box-shadow and border-image-outset. 1783 // Add visual overflow from box-shadow and border-image-outset.
1785 addVisualEffectOverflow(); 1784 addVisualEffectOverflow();
1786 1785
1787 // Add visual overflow from theme. 1786 // Add visual overflow from theme.
1788 addVisualOverflowFromTheme(); 1787 addVisualOverflowFromTheme();
1789 1788
1790 if (isRenderNamedFlowThread()) 1789 if (isRenderNamedFlowThread())
1791 toRenderNamedFlowThread(this)->computeOversetStateForRegions(oldClientAf terEdge); 1790 toRenderNamedFlowThread(this)->computeOversetStateForRegions(oldClientAf terEdge);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 } 1834 }
1836 } 1835 }
1837 1836
1838 void RenderBlock::addVisualOverflowFromTheme() 1837 void RenderBlock::addVisualOverflowFromTheme()
1839 { 1838 {
1840 if (!style()->hasAppearance()) 1839 if (!style()->hasAppearance())
1841 return; 1840 return;
1842 1841
1843 IntRect inflatedRect = pixelSnappedBorderBoxRect(); 1842 IntRect inflatedRect = pixelSnappedBorderBoxRect();
1844 theme()->adjustRepaintRect(this, inflatedRect); 1843 theme()->adjustRepaintRect(this, inflatedRect);
1845 addVisualOverflow(inflatedRect); 1844 addVisualOverflow(inflatedRect, VisualOverflowNotClipped);
1846 } 1845 }
1847 1846
1848 bool RenderBlock::expandsToEncloseOverhangingFloats() const 1847 bool RenderBlock::expandsToEncloseOverhangingFloats() const
1849 { 1848 {
1850 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBoxIncludingDeprecated()) 1849 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBoxIncludingDeprecated())
1851 || hasColumns() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() || isRoot(); 1850 || hasColumns() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() || isRoot();
1852 } 1851 }
1853 1852
1854 void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marg inInfo) 1853 void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marg inInfo)
1855 { 1854 {
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 // paints the root's background. 2922 // paints the root's background.
2924 if (!isRoot()) { 2923 if (!isRoot()) {
2925 LayoutRect overflowBox = overflowRectForPaintRejection(); 2924 LayoutRect overflowBox = overflowRectForPaintRejection();
2926 flipForWritingMode(overflowBox); 2925 flipForWritingMode(overflowBox);
2927 overflowBox.inflate(maximalOutlineSize(paintInfo.phase)); 2926 overflowBox.inflate(maximalOutlineSize(paintInfo.phase));
2928 overflowBox.moveBy(adjustedPaintOffset); 2927 overflowBox.moveBy(adjustedPaintOffset);
2929 if (!overflowBox.intersects(paintInfo.rect)) 2928 if (!overflowBox.intersects(paintInfo.rect))
2930 return; 2929 return;
2931 } 2930 }
2932 2931
2933 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); 2932 // There are some cases where not all clipped visual overflow is accounted f or.
2933 // FIXME: reduce the number of such cases.
2934 ContentsClipBehavior contentsClipBehavior = ContentsClipRequired;
2935 if (hasOverflowClip() && !hasControlClip() && !(shouldPaintSelectionGaps() & & phase == PaintPhaseForeground) && !hasCaret())
2936 contentsClipBehavior = ContentsClipAutomatic;
2937
2938 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsC lipBehavior);
2934 paintObject(paintInfo, adjustedPaintOffset); 2939 paintObject(paintInfo, adjustedPaintOffset);
2935 if (pushedClip) 2940 if (pushedClip)
2936 popContentsClip(paintInfo, phase, adjustedPaintOffset); 2941 popContentsClip(paintInfo, phase, adjustedPaintOffset);
2937 2942
2938 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with 2943 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with
2939 // z-index. We paint after we painted the background/border, so that the sc rollbars will 2944 // z-index. We paint after we painted the background/border, so that the sc rollbars will
2940 // sit above the background/border. 2945 // sit above the background/border.
2941 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly()) 2946 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly())
2942 layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjust edPaintOffset), paintInfo.rect); 2947 layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjust edPaintOffset), paintInfo.rect);
2943 } 2948 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 paintChild(child, paintInfo, paintOffset); 3121 paintChild(child, paintInfo, paintOffset);
3117 } 3122 }
3118 3123
3119 void RenderBlock::paintChild(RenderBox* child, PaintInfo& paintInfo, const Layou tPoint& paintOffset) 3124 void RenderBlock::paintChild(RenderBox* child, PaintInfo& paintInfo, const Layou tPoint& paintOffset)
3120 { 3125 {
3121 LayoutPoint childPoint = flipForWritingModeForChild(child, paintOffset); 3126 LayoutPoint childPoint = flipForWritingModeForChild(child, paintOffset);
3122 if (!child->hasSelfPaintingLayer() && !child->isFloating()) 3127 if (!child->hasSelfPaintingLayer() && !child->isFloating())
3123 child->paint(paintInfo, childPoint); 3128 child->paint(paintInfo, childPoint);
3124 } 3129 }
3125 3130
3126 3131 bool RenderBlock::hasCaret(CaretType type)
3127 void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse t, CaretType type)
3128 { 3132 {
3129 // Paint the caret if the FrameSelection says so or if caret browsing is ena bled 3133 // Paint the caret if the FrameSelection says so or if caret browsing is ena bled
3130 bool caretBrowsing = frame()->settings() && frame()->settings()->caretBrowsi ngEnabled(); 3134 bool caretBrowsing = frame()->settings() && frame()->settings()->caretBrowsi ngEnabled();
3131 RenderObject* caretPainter; 3135 RenderObject* caretPainter;
3132 bool isContentEditable; 3136 bool isContentEditable;
3133 if (type == CursorCaret) { 3137 if (type == CursorCaret) {
3134 caretPainter = frame()->selection()->caretRenderer(); 3138 caretPainter = frame()->selection()->caretRenderer();
3135 isContentEditable = frame()->selection()->rendererIsEditable(); 3139 isContentEditable = frame()->selection()->rendererIsEditable();
3136 } else { 3140 } else {
3137 caretPainter = frame()->page()->dragCaretController()->caretRenderer(); 3141 caretPainter = frame()->page()->dragCaretController()->caretRenderer();
3138 isContentEditable = frame()->page()->dragCaretController()->isContentEdi table(); 3142 isContentEditable = frame()->page()->dragCaretController()->isContentEdi table();
3139 } 3143 }
3144 return caretPainter == this && (isContentEditable || caretBrowsing);
3145 }
3140 3146
3141 if (caretPainter == this && (isContentEditable || caretBrowsing)) { 3147 void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse t, CaretType type)
3142 if (type == CursorCaret) 3148 {
3143 frame()->selection()->paintCaret(paintInfo.context, paintOffset, pai ntInfo.rect); 3149 if (!hasCaret(type))
3144 else 3150 return;
3145 frame()->page()->dragCaretController()->paintDragCaret(frame(), pain tInfo.context, paintOffset, paintInfo.rect); 3151
3146 } 3152 if (type == CursorCaret)
3153 frame()->selection()->paintCaret(paintInfo.context, paintOffset, paintIn fo.rect);
3154 else
3155 frame()->page()->dragCaretController()->paintDragCaret(frame(), paintInf o.context, paintOffset, paintInfo.rect);
3147 } 3156 }
3148 3157
3149 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 3158 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
3150 { 3159 {
3151 PaintPhase paintPhase = paintInfo.phase; 3160 PaintPhase paintPhase = paintInfo.phase;
3152 3161
3153 // 1. paint background, borders etc 3162 // 1. paint background, borders etc
3154 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && style()->visibility() == VISIBLE) { 3163 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && style()->visibility() == VISIBLE) {
3155 if (hasBoxDecorations()) 3164 if (hasBoxDecorations())
3156 paintBoxDecorations(paintInfo, paintOffset); 3165 paintBoxDecorations(paintInfo, paintOffset);
(...skipping 5101 matching lines...) Expand 10 before | Expand all | Expand 10 after
8258 } 8267 }
8259 8268
8260 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl oatingObject* floatingObject) 8269 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl oatingObject* floatingObject)
8261 { 8270 {
8262 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped MaxY()); 8271 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped MaxY());
8263 } 8272 }
8264 8273
8265 #endif 8274 #endif
8266 8275
8267 } // namespace WebCore 8276 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698