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

Commit 1d27087

Browse files
author
Morten Stenshorne
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} (cherry picked from commit 17e31b8) Review URL: https://codereview.chromium.org/1656213002 . Cr-Commit-Position: refs/branch-heads/2623@{#235} Cr-Branched-From: 92d7753-refs/heads/master@{#369907}
1 parent 3f1b97b commit 1d27087

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
@@ -435,17 +435,15 @@ TransformationMatrix PaintLayer::renderableTransform(GlobalPaintFlags globalPain
435435
return *m_transform;
436436
}
437437

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

446444
// First make the flow thread rectangle relative to the flow thread, not to |layer|.
447445
LayoutPoint offsetWithinPaginationLayer;
448-
layer->convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer);
446+
convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer);
449447
rect.moveBy(offsetWithinPaginationLayer);
450448

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

21562154
LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutObject());
2157-
convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, result);
2155+
convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result);
21582156
return result;
21592157
}
21602158

@@ -2253,7 +2251,7 @@ LayoutRect PaintLayer::boundingBoxForCompositing(const PaintLayer* ancestorLayer
22532251
result = transform()->mapRect(result);
22542252

22552253
if (enclosingPaginationLayer()) {
2256-
convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, result);
2254+
convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result);
22572255
return result;
22582256
}
22592257
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)