Commit 3a343d7d authored by mstensho@opera.com's avatar mstensho@opera.com

[New Multicolumn] Make rounded corners clipping multicol-aware.

R=chrishtr@chromium.org

Review URL: https://codereview.chromium.org/721363002

git-svn-id: svn://svn.chromium.org/blink/trunk@185399 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent df707f95
<!DOCTYPE html>
<p>There should be a box with a rounded border and yellow background below. The start should be in
the first column. The end should be in the third column.</p>
<div style="width:41em; height:10.5em; line-height:2em;">
<div style="float:left; width:13em; height:100%; overflow:hidden;">
<br>
<div style="border-radius:3em; border:1em solid black; padding:0 2em; background:yellow;">
first column<br>
first column<br>
first column<br>
<br>
<br>
</div>
</div>
<div style="float:left; width:1em; height:100%;"></div>
<div style="float:left; width:13em; height:100%; overflow:hidden;">
<div style="margin-top:-7em; border-radius:3em; border:1em solid black; padding:0 2em; background:yellow;">
first column<br>
first column<br>
first column<br>
second column<br>
second column<br>
second column<br>
second column<br>
second column<br>
<br>
<br>
</div>
</div>
<div style="float:left; width:1em; height:100%;"></div>
<div style="float:left; width:13em; height:100%; overflow:hidden;">
<div style="margin-top:-17em; border-radius:3em; border:1em solid black; padding:0 2em; background:yellow;">
first column<br>
first column<br>
first column<br>
second column<br>
second column<br>
second column<br>
second column<br>
second column<br>
third column<br>
</div>
</div>
</div>
<!DOCTYPE html>
<p>The word 'PASS' should be seen below on the right hand side, inside a rounded box with black
border and yellow background.</p>
<div style="line-height:2em;">
<div style="float:right; width:50%;">
<br>
<div style="position:relative; overflow:hidden; border-radius:3em; border:1em solid black; text-align:center; background:yellow;">
PASS
</div>
</div>
</div>
<!DOCTYPE html>
<p>The word 'PASS' should be seen below on the right hand side, inside a rounded box with black
border and yellow background.</p>
<div style="-webkit-columns:2; -webkit-column-gap:0; column-fill:auto; height:10.5em; line-height:2em;">
<br>
<br>
<br>
<br>
<br>
<br>
<div style="position:relative; overflow:hidden; border-radius:3em; border:1em solid black; text-align:center; background:yellow;">
PASS
</div>
</div>
<!DOCTYPE html>
<p>There should be a box with a rounded border and yellow background below. The start should be in
the first column. The end should be in the third column.</p>
<div style="-webkit-columns:3; -webkit-column-gap:1em; column-fill:auto; width:41em; height:10.5em; line-height:2em;">
<br>
<div style="position:relative; overflow:hidden; border-radius:3em; border:1em solid black; padding:0 2em; background:yellow;">
first column<br>
first column<br>
first column<br>
second column<br>
second column<br>
second column<br>
second column<br>
second column<br>
third column<br>
</div>
</div>
...@@ -47,7 +47,7 @@ FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context, ...@@ -47,7 +47,7 @@ FilterPainter::FilterPainter(RenderLayer& renderLayer, GraphicsContext* context,
if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) { if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) {
m_clipRecorder = adoptPtr(new ClipRecorder(renderLayer.renderer(), context, DisplayItem::ClipLayerFilter, clipRect)); m_clipRecorder = adoptPtr(new ClipRecorder(renderLayer.renderer(), context, DisplayItem::ClipLayerFilter, clipRect));
if (clipRect.hasRadius()) if (clipRect.hasRadius())
LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, paintFlags, *m_clipRecorder); LayerPainter::applyRoundedRectClips(renderLayer, paintingInfo, context, LayoutPoint(), paintFlags, *m_clipRecorder);
} }
context->save(); context->save();
......
...@@ -104,7 +104,7 @@ void LayerPainter::paintLayer(GraphicsContext* context, const LayerPaintingInfo& ...@@ -104,7 +104,7 @@ void LayerPainter::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
if (needsToClip(paintingInfo, clipRect)) { if (needsToClip(paintingInfo, clipRect)) {
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()->renderer(), context, DisplayItem::ClipLayerParent, clipRect)); clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()->renderer(), context, DisplayItem::ClipLayerParent, clipRect));
if (clipRect.hasRadius()) if (clipRect.hasRadius())
applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, paintFlags, *clipRecorder); applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, LayoutPoint(), paintFlags, *clipRecorder);
} }
} }
...@@ -375,8 +375,7 @@ bool LayerPainter::needsToClip(const LayerPaintingInfo& localPaintingInfo, const ...@@ -375,8 +375,7 @@ bool LayerPainter::needsToClip(const LayerPaintingInfo& localPaintingInfo, const
return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRadius(); return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRadius();
} }
void LayerPainter::applyRoundedRectClips(RenderLayer& renderLayer, const LayerPaintingInfo& localPaintingInfo, GraphicsContext* context, void LayerPainter::applyRoundedRectClips(RenderLayer& renderLayer, const LayerPaintingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoint& fragmentOffset, PaintLayerFlags paintFlags, ClipRecorder& clipRecorder, BorderRadiusClippingRule rule)
PaintLayerFlags paintFlags, ClipRecorder& clipRecorder, BorderRadiusClippingRule rule)
{ {
// If the clip rect has been tainted by a border radius, then we have to walk up our layer chain applying the clips from // If the clip rect has been tainted by a border radius, then we have to walk up our layer chain applying the clips from
// any layers with overflow. The condition for being able to apply these clips is that the overflow object be in our // any layers with overflow. The condition for being able to apply these clips is that the overflow object be in our
...@@ -390,7 +389,7 @@ void LayerPainter::applyRoundedRectClips(RenderLayer& renderLayer, const LayerPa ...@@ -390,7 +389,7 @@ void LayerPainter::applyRoundedRectClips(RenderLayer& renderLayer, const LayerPa
break; break;
if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) { if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) {
LayoutPoint delta; LayoutPoint delta(fragmentOffset);
layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta);
clipRecorder.addRoundedRectClip(layer->renderer()->style()->getRoundedInnerBorderFor(LayoutRect(delta, layer->size()))); clipRecorder.addRoundedRectClip(layer->renderer()->style()->getRoundedInnerBorderFor(LayoutRect(delta, layer->size())));
} }
...@@ -505,7 +504,7 @@ void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer ...@@ -505,7 +504,7 @@ void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { if (needsToClip(localPaintingInfo, fragment.backgroundRect)) {
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect)); clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect));
if (fragment.backgroundRect.hasRadius()) if (fragment.backgroundRect.hasRadius())
applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder); applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, fragment.paginationOffset, paintFlags, *clipRecorder);
} }
if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea()) if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea())
scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
...@@ -694,7 +693,7 @@ void LayerPainter::paintFragmentWithPhase(PaintPhase phase, const LayerFragment& ...@@ -694,7 +693,7 @@ void LayerPainter::paintFragmentWithPhase(PaintPhase phase, const LayerFragment&
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect)); clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect));
if (clipRect.hasRadius()) if (clipRect.hasRadius())
applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFlags, *clipRecorder, clippingRule); applyRoundedRectClips(m_renderLayer, paintingInfo, context, fragment.paginationOffset, paintFlags, *clipRecorder, clippingRule);
} }
PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, paintBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, paintBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer());
...@@ -721,7 +720,7 @@ void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme ...@@ -721,7 +720,7 @@ void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme
if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) {
clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect)); clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect));
if (layerFragments[0].foregroundRect.hasRadius()) if (layerFragments[0].foregroundRect.hasRadius())
applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, paintFlags, *clipRecorder); applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, layerFragments[0].paginationOffset, paintFlags, *clipRecorder);
clipState = HasClipped; clipState = HasClipped;
} }
......
...@@ -30,7 +30,15 @@ public: ...@@ -30,7 +30,15 @@ public:
void paintOverlayScrollbars(GraphicsContext*, const LayoutRect& damageRect, PaintBehavior, RenderObject* paintingRoot = 0); void paintOverlayScrollbars(GraphicsContext*, const LayoutRect& damageRect, PaintBehavior, RenderObject* paintingRoot = 0);
enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelfForBorderRadius }; enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelfForBorderRadius };
static void applyRoundedRectClips(RenderLayer&, const LayerPaintingInfo&, GraphicsContext*, PaintLayerFlags, ClipRecorder&, BorderRadiusClippingRule = IncludeSelfForBorderRadius);
// Set rounded clip rectangles defined by border radii all the way from the LayerPaintingInfo
// "root" layer down to the specified layer (or the parent of said layer, in case
// BorderRadiusClippingRule says to skip self). fragmentOffset is used for multicol, to specify
// the translation required to get from flow thread coordinates to visual coordinates for a
// certain column.
// FIXME: The BorderRadiusClippingRule parameter is really useless now. If we want to skip self,
// why not just supply the parent layer as the first parameter instead?
static void applyRoundedRectClips(RenderLayer&, const LayerPaintingInfo&, GraphicsContext*, const LayoutPoint& fragmentOffset, PaintLayerFlags, ClipRecorder&, BorderRadiusClippingRule = IncludeSelfForBorderRadius);
private: private:
enum ClipState { HasNotClipped, HasClipped }; enum ClipState { HasNotClipped, HasClipped };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment