Chromium Code Reviews| Index: Source/core/rendering/RenderBlock.cpp |
| diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp |
| index 3b6d47544e3482ca220adb33a23e07597a35cbcb..36b2b7c3a0cc27b0411271050946ccb59005221e 100644 |
| --- a/Source/core/rendering/RenderBlock.cpp |
| +++ b/Source/core/rendering/RenderBlock.cpp |
| @@ -1714,6 +1714,15 @@ void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeigh |
| setNeedsLayout(false); |
| } |
| +void RenderBlock::addVisualOverflow(const LayoutRect& rect, VisualOverflowClipBehavior clipBehavior) |
| +{ |
| + if (clipBehavior == VisualOverflowClippedByContentsClip && hasOverflowClip() && m_rareData) { |
| + 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.
|
| + return; |
| + } |
| + RenderBox::addVisualOverflow(rect, clipBehavior); |
| +} |
| + |
| void RenderBlock::addOverflowFromChildren() |
| { |
| if (!hasColumns()) { |
| @@ -1726,8 +1735,7 @@ void RenderBlock::addOverflowFromChildren() |
| if (columnCount(colInfo)) { |
| LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1); |
| addLayoutOverflow(lastRect); |
| - if (!hasOverflowClip()) |
| - addVisualOverflow(lastRect); |
| + addVisualOverflow(lastRect, VisualOverflowClippedByContentsClip); |
| } |
| } |
| } |
| @@ -1735,6 +1743,11 @@ void RenderBlock::addOverflowFromChildren() |
| void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats) |
| { |
| m_overflow.clear(); |
| + if (hasOverflowClip()) { |
| + if (!m_rareData) |
| + m_rareData = adoptPtr(new RenderBlockRareData(this)); |
| + 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
|
| + } |
| // Add overflow from children. |
| addOverflowFromChildren(); |
| @@ -1759,13 +1772,13 @@ void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeF |
| if (hasRenderOverflow()) |
| m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); |
| } |
| - |
| + |
| // Allow our overflow to catch cases where the caret in an empty editable element with negative text indent needs to get painted. |
| LayoutUnit textIndent = textIndentOffset(); |
| if (textIndent < 0) { |
| LayoutRect clientRect(clientBoxRect()); |
| - LayoutRect rectToApply = LayoutRect(clientRect.x() + min<LayoutUnit>(0, textIndent), clientRect.y(), clientRect.width() - min<LayoutUnit>(0, 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
|
| - addVisualOverflow(rectToApply); |
| + LayoutRect rectToApply = LayoutRect(clientRect.x() + textIndent, clientRect.y(), clientRect.width() - textIndent, clientRect.height()); |
| + addVisualOverflow(rectToApply, VisualOverflowClippedByContentsClip); |
| } |
| // Add visual overflow from box-shadow and border-image-outset. |
| @@ -1810,14 +1823,10 @@ void RenderBlock::addOverflowFromPositionedObjects() |
| TrackedRendererListHashSet::iterator end = positionedDescendants->end(); |
| for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(); it != end; ++it) { |
| positionedObject = *it; |
| - |
| - // Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content. |
| - if (positionedObject->style()->position() != FixedPosition) { |
|
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.
|
| - LayoutUnit x = positionedObject->x(); |
| - if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| - x -= verticalScrollbarWidth(); |
| - addOverflowFromChild(positionedObject, LayoutSize(x, positionedObject->y())); |
| - } |
| + LayoutUnit x = positionedObject->x(); |
| + if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| + x -= verticalScrollbarWidth(); |
| + addOverflowFromChild(positionedObject, LayoutSize(x, positionedObject->y())); |
| } |
| } |
| @@ -1828,7 +1837,7 @@ void RenderBlock::addVisualOverflowFromTheme() |
| IntRect inflatedRect = pixelSnappedBorderBoxRect(); |
| theme()->adjustRepaintRect(this, inflatedRect); |
| - addVisualOverflow(inflatedRect); |
| + addVisualOverflow(inflatedRect, VisualOverflowNotClipped); |
| } |
| bool RenderBlock::expandsToEncloseOverhangingFloats() const |
| @@ -2897,13 +2906,22 @@ void RenderBlock::repaintOverhangingFloats(bool paintAllDescendants) |
| } |
| } |
| } |
| - |
| + |
| +static bool hasCaret(RenderObject* o) |
| +{ |
| + Frame* frame = o->frame(); |
| + if (frame->selection()->caretRenderer() == o) |
| + return frame->selection()->rendererIsEditable() || (frame->settings() && frame->settings()->caretBrowsingEnabled()); |
| + if (frame->page()->dragCaretController()->caretRenderer() == o) |
| + return frame->page()->dragCaretController()->isContentEditable() || (frame->settings() && frame->settings()->caretBrowsingEnabled()); |
| + return false; |
| +} |
|
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
|
| + |
| void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| { |
| ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
| LayoutPoint adjustedPaintOffset = paintOffset + location(); |
| - |
| PaintPhase phase = paintInfo.phase; |
| // Check if we need to do anything at all. |
| @@ -2918,7 +2936,14 @@ void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| return; |
| } |
| - bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); |
| + const LayoutRect* contentsVisualOverflowRect = 0; |
| + if (m_rareData && !hasControlClip() && !hasCaret(this) && !(shouldPaintSelectionGaps() && phase == PaintPhaseForeground)) { |
| + // Some visual elements clipped by the control clip are not included in m_contentsVisualOverflowRect. |
| + // It is also somewhat complicated to determine whether the caret and selection gaps, if present, would be clipped. |
| + // FIXME: Determine whether these would be clipped instead of indiscriminately bailing out. |
| + contentsVisualOverflowRect = &m_rareData->m_contentsVisualOverflowRect; |
| + } |
| + bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsVisualOverflowRect); |
| paintObject(paintInfo, adjustedPaintOffset); |
| if (pushedClip) |
| popContentsClip(paintInfo, phase, adjustedPaintOffset); |
| @@ -3215,7 +3240,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs |
| // 7. paint caret. |
| // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground, |
| // then paint the caret. |
| - if (paintPhase == PaintPhaseForeground) { |
| + if (paintPhase == PaintPhaseForeground) { |
| paintCaret(paintInfo, paintOffset, CursorCaret); |
| paintCaret(paintInfo, paintOffset, DragCaret); |
| } |