Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 17e31b8

Browse files
mstenshoCommit bot
mstensho
authored and
Commit bot
committed
Display -webkit-filter objects in any column (instead of only in the first one).
Most of our painting-related operations take place after fragmentation, i.e. via PaintLayerPainter::paintFragmentWithPhase(). All such operations can just sit back and relax and not worry about fragmentation, since translation and clipping for a given fragmentainer (column) has already taken place. This is not the case for filters, though. They are set up before fragmentation. Therefore, we need to make the bounding box of the layer visual (convert out of the flow thread coordinate space) on our own. We now do this specifically for filters, or we'd upset other parts of the code, such as clip path. BUG=530074 [email protected] Review URL: https://codereview.chromium.org/1645583002 Cr-Commit-Position: refs/heads/master@{#371808}
1 parent 8665451 commit 17e31b8

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!DOCTYPE html>
2+
<p>The word "PASS" should be seen below.</p>
3+
<div style="margin-left:5em; -webkit-filter:grayscale(90%);">PASS</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<p>The word "PASS" should be seen below.</p>
3+
<div style="-webkit-columns:2; -webkit-column-gap:0; width:10em;">
4+
<br>
5+
<div style="-webkit-filter:grayscale(90%);">PASS</div>
6+
</div>

third_party/WebKit/Source/core/paint/FilterPainter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ FilterPainter::FilterPainter(PaintLayer& layer, GraphicsContext& context, const
6969
// the layer's filter. See crbug.com/502026.
7070
if (webFilterOperations->isEmpty())
7171
return;
72-
context.paintController().createAndAppend<BeginFilterDisplayItem>(*m_layoutObject, imageFilter, FloatRect(rootRelativeBounds), webFilterOperations.release());
72+
LayoutRect visualBounds(rootRelativeBounds);
73+
if (layer.enclosingPaginationLayer()) {
74+
// Filters are set up before pagination, so we need to make the bounding box visual on our own.
75+
visualBounds.moveBy(-offsetFromRoot);
76+
layer.convertFromFlowThreadToVisualBoundingBoxInAncestor(paintingInfo.rootLayer, visualBounds);
77+
}
78+
context.paintController().createAndAppend<BeginFilterDisplayItem>(*m_layoutObject, imageFilter, FloatRect(visualBounds), webFilterOperations.release());
7379
}
7480

7581
m_filterInProgress = true;

third_party/WebKit/Source/core/paint/PaintLayer.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,15 @@ TransformationMatrix PaintLayer::renderableTransform(GlobalPaintFlags globalPain
436436
return *m_transform;
437437
}
438438

439-
// Convert a bounding box from flow thread coordinates, relative to |layer|, to visual coordinates, relative to |ancestorLayer|.
440-
// See http://www.chromium.org/developers/design-documents/multi-column-layout for more info on these coordinate types.
441-
static void convertFromFlowThreadToVisualBoundingBoxInAncestor(const PaintLayer* layer, const PaintLayer* ancestorLayer, LayoutRect& rect)
439+
void PaintLayer::convertFromFlowThreadToVisualBoundingBoxInAncestor(const PaintLayer* ancestorLayer, LayoutRect& rect) const
442440
{
443-
PaintLayer* paginationLayer = layer->enclosingPaginationLayer();
441+
PaintLayer* paginationLayer = enclosingPaginationLayer();
444442
ASSERT(paginationLayer);
445443
LayoutFlowThread* flowThread = toLayoutFlowThread(paginationLayer->layoutObject());
446444

447445
// First make the flow thread rectangle relative to the flow thread, not to |layer|.
448446
LayoutPoint offsetWithinPaginationLayer;
449-
layer->convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer);
447+
convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer);
450448
rect.moveBy(offsetWithinPaginationLayer);
451449

452450
// Then make the rectangle visual, relative to the fragmentation context. Split our box up into
@@ -2155,7 +2153,7 @@ LayoutRect PaintLayer::fragmentsBoundingBox(const PaintLayer* ancestorLayer) con
21552153
return physicalBoundingBox(ancestorLayer);
21562154

21572155
LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutObject());
2158-
convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, result);
2156+
convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result);
21592157
return result;
21602158
}
21612159

@@ -2255,7 +2253,7 @@ LayoutRect PaintLayer::boundingBoxForCompositing(const PaintLayer* ancestorLayer
22552253
result = transform()->mapRect(result);
22562254

22572255
if (enclosingPaginationLayer()) {
2258-
convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, result);
2256+
convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result);
22592257
return result;
22602258
}
22612259
LayoutPoint delta;

third_party/WebKit/Source/core/paint/PaintLayer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
300300
// http://www.chromium.org/developers/design-documents/multi-column-layout for more info.
301301
LayoutPoint visualOffsetFromAncestor(const PaintLayer* ancestorLayer) const;
302302

303+
// Convert a bounding box from flow thread coordinates, relative to |this|, to visual coordinates, relative to |ancestorLayer|.
304+
// See http://www.chromium.org/developers/design-documents/multi-column-layout for more info on these coordinate types.
305+
// This method requires this layer to be paginated; i.e. it must have an enclosingPaginationLayer().
306+
void convertFromFlowThreadToVisualBoundingBoxInAncestor(const PaintLayer* ancestorLayer, LayoutRect&) const;
307+
303308
// The hitTest() method looks for mouse events by walking layers that intersect the point from front to back.
304309
bool hitTest(HitTestResult&);
305310

0 commit comments

Comments
 (0)