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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp

Issue 2781863005: Account for filter bounds for backgroundRect during PaintLayer painting (Closed)
Patch Set: none Created 3 years, 8 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 layers.push(layer); 195 layers.push(layer);
196 } 196 }
197 } 197 }
198 198
199 LayoutRect PaintLayerClipper::localClipRect( 199 LayoutRect PaintLayerClipper::localClipRect(
200 const PaintLayer& clippingRootLayer) const { 200 const PaintLayer& clippingRootLayer) const {
201 ClipRectsContext context(&clippingRootLayer, PaintingClipRects); 201 ClipRectsContext context(&clippingRootLayer, PaintingClipRects);
202 if (m_geometryMapper) { 202 if (m_geometryMapper) {
203 ClipRect clipRect; 203 ClipRect clipRect;
204 calculateClipRectWithGeometryMapper(context, false, clipRect); 204 calculateClipRectWithGeometryMapper(context, false, clipRect);
205 applyOverflowClipToBackgroundRectWithGeometryMapper(context, clipRect); 205 applyVisualOverflowClipToBackgroundRectWithGeometryMapper(context,
206 clipRect);
trchen 2017/03/29 23:50:08 Why is this line needed? The only caller of PLC::l
chrishtr 2017/03/30 04:35:26 There is not really any point, but if I remove thi
206 LayoutRect premappedRect = clipRect.rect(); 207 LayoutRect premappedRect = clipRect.rect();
207 208
208 // The rect now needs to be transformed to the local space of this 209 // The rect now needs to be transformed to the local space of this
209 // PaintLayer. 210 // PaintLayer.
210 premappedRect.moveBy(context.rootLayer->layoutObject().paintOffset()); 211 premappedRect.moveBy(context.rootLayer->layoutObject().paintOffset());
211 212
212 const auto* clipRootLayerTransform = clippingRootLayer.layoutObject() 213 const auto* clipRootLayerTransform = clippingRootLayer.layoutObject()
213 .paintProperties() 214 .paintProperties()
214 ->localBorderBoxProperties() 215 ->localBorderBoxProperties()
215 ->transform(); 216 ->transform();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // TODO(chrishtr): fix the underlying bug that causes this situation. 292 // TODO(chrishtr): fix the underlying bug that causes this situation.
292 if (!properties) { 293 if (!properties) {
293 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); 294 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
294 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); 295 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
295 } else { 296 } else {
296 calculateClipRectWithGeometryMapper(context, false, backgroundRect); 297 calculateClipRectWithGeometryMapper(context, false, backgroundRect);
297 298
298 backgroundRect.move(context.subPixelAccumulation); 299 backgroundRect.move(context.subPixelAccumulation);
299 backgroundRect.intersect(paintDirtyRect); 300 backgroundRect.intersect(paintDirtyRect);
300 301
301 applyOverflowClipToBackgroundRectWithGeometryMapper(context, 302 applyVisualOverflowClipToBackgroundRectWithGeometryMapper(context,
302 backgroundRect); 303 backgroundRect);
303 304
304 calculateClipRectWithGeometryMapper(context, true, foregroundRect); 305 calculateClipRectWithGeometryMapper(context, true, foregroundRect);
305 foregroundRect.move(context.subPixelAccumulation); 306 foregroundRect.move(context.subPixelAccumulation);
306 foregroundRect.intersect(paintDirtyRect); 307 foregroundRect.intersect(paintDirtyRect);
307 } 308 }
308 LayoutPoint offset; 309 LayoutPoint offset;
309 if (offsetFromRoot) 310 if (offsetFromRoot)
310 offset = *offsetFromRoot; 311 offset = *offsetFromRoot;
311 else 312 else
312 m_layer.convertToLayerCoords(context.rootLayer, offset); 313 m_layer.convertToLayerCoords(context.rootLayer, offset);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 373
373 // The LayoutView is special since its overflow clipping rect may be larger 374 // The LayoutView is special since its overflow clipping rect may be larger
374 // than its box rect (crbug.com/492871). 375 // than its box rect (crbug.com/492871).
375 LayoutRect layerBoundsWithVisualOverflow = 376 LayoutRect layerBoundsWithVisualOverflow =
376 layoutObject.isLayoutView() 377 layoutObject.isLayoutView()
377 ? toLayoutView(layoutObject).viewRect() 378 ? toLayoutView(layoutObject).viewRect()
378 : toLayoutBox(layoutObject).visualOverflowRect(); 379 : toLayoutBox(layoutObject).visualOverflowRect();
379 // PaintLayer are in physical coordinates, so the overflow has to be 380 // PaintLayer are in physical coordinates, so the overflow has to be
380 // flipped. 381 // flipped.
381 toLayoutBox(layoutObject).flipForWritingMode(layerBoundsWithVisualOverflow); 382 toLayoutBox(layoutObject).flipForWritingMode(layerBoundsWithVisualOverflow);
383 if (m_layer.paintsWithFilters()) {
384 layerBoundsWithVisualOverflow =
385 m_layer.mapLayoutRectForFilter(layerBoundsWithVisualOverflow);
386 }
382 layerBoundsWithVisualOverflow.moveBy(offset); 387 layerBoundsWithVisualOverflow.moveBy(offset);
383 backgroundRect.intersect(layerBoundsWithVisualOverflow); 388 backgroundRect.intersect(layerBoundsWithVisualOverflow);
384 } 389 }
385 390
386 // CSS clip (different than clipping due to overflow) can clip to any box, 391 // CSS clip (different than clipping due to overflow) can clip to any box,
387 // even if it falls outside of the border box. 392 // even if it falls outside of the border box.
388 if (layoutObject.hasClip()) { 393 if (layoutObject.hasClip()) {
389 // Clip applies to *us* as well, so go ahead and update the damageRect. 394 // Clip applies to *us* as well, so go ahead and update the damageRect.
390 LayoutRect newPosClip = toLayoutBox(layoutObject).clipRect(offset); 395 LayoutRect newPosClip = toLayoutBox(layoutObject).clipRect(offset);
391 backgroundRect.intersect(newPosClip); 396 backgroundRect.intersect(newPosClip);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 490 }
486 491
487 const FloatClipRect& clippedRectInRootLayerSpace = 492 const FloatClipRect& clippedRectInRootLayerSpace =
488 m_geometryMapper->sourceToDestinationClipRect( 493 m_geometryMapper->sourceToDestinationClipRect(
489 propertyTreeState, destinationPropertyTreeState); 494 propertyTreeState, destinationPropertyTreeState);
490 output.setRect(clippedRectInRootLayerSpace); 495 output.setRect(clippedRectInRootLayerSpace);
491 496
492 output.moveBy(-context.rootLayer->layoutObject().paintOffset()); 497 output.moveBy(-context.rootLayer->layoutObject().paintOffset());
493 } 498 }
494 499
495 void PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper( 500 void PaintLayerClipper::
496 const ClipRectsContext& context, 501 applyVisualOverflowClipToBackgroundRectWithGeometryMapper(
497 ClipRect& clip) const { 502 const ClipRectsContext& context,
503 ClipRect& clip) const {
trchen 2017/03/29 23:50:08 The name doesn't seem to match the implementation.
chrishtr 2017/03/30 04:35:26 Method is now deleted.
498 const LayoutObject& layoutObject = m_layer.layoutObject(); 504 const LayoutObject& layoutObject = m_layer.layoutObject();
499 if (!shouldClipOverflow(context)) 505 if (!shouldClipOverflow(context))
500 return; 506 return;
501 LayoutRect layerBoundsWithVisualOverflow = 507 LayoutRect layerBoundsWithVisualOverflow =
502 layoutObject.isLayoutView() 508 layoutObject.isLayoutView()
503 ? toLayoutView(layoutObject).viewRect() 509 ? toLayoutView(layoutObject).viewRect()
504 : toLayoutBox(layoutObject).visualOverflowRect(); 510 : toLayoutBox(layoutObject).visualOverflowRect();
505 toLayoutBox(layoutObject) 511 toLayoutBox(layoutObject)
506 .flipForWritingMode( 512 .flipForWritingMode(
507 // PaintLayer are in physical coordinates, so the overflow has to be 513 // PaintLayer are in physical coordinates, so the overflow has to be
508 // flipped. 514 // flipped.
509 layerBoundsWithVisualOverflow); 515 layerBoundsWithVisualOverflow);
516 if (m_layer.paintsWithFilters()) {
517 layerBoundsWithVisualOverflow =
518 m_layer.mapLayoutRectForFilter(layerBoundsWithVisualOverflow);
519 }
520
trchen 2017/03/29 23:50:08 Is it possible to make it a geometry mapper helper
chrishtr 2017/03/30 04:35:26 That's a great observation. In fact it led me to r
510 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); 521 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow);
511 clip.intersect(layerBoundsWithVisualOverflow); 522 clip.intersect(layerBoundsWithVisualOverflow);
512 } 523 }
513 524
514 void PaintLayerClipper::calculateBackgroundClipRect( 525 void PaintLayerClipper::calculateBackgroundClipRect(
515 const ClipRectsContext& context, 526 const ClipRectsContext& context,
516 ClipRect& output) const { 527 ClipRect& output) const {
517 if (m_geometryMapper) { 528 if (m_geometryMapper) {
518 // TODO(chrishtr): fix the underlying bug that causes this situation. 529 // TODO(chrishtr): fix the underlying bug that causes this situation.
519 if (!m_layer.layoutObject().paintProperties()) { 530 if (!m_layer.layoutObject().paintProperties()) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 DCHECK(!m_geometryMapper); 607 DCHECK(!m_geometryMapper);
597 ClipRectsContext context(rootLayer, PaintingClipRects, 608 ClipRectsContext context(rootLayer, PaintingClipRects,
598 IgnorePlatformOverlayScrollbarSize, 609 IgnorePlatformOverlayScrollbarSize,
599 subpixelAccumulation); 610 subpixelAccumulation);
600 if (respectOverflowClip == IgnoreOverflowClip) 611 if (respectOverflowClip == IgnoreOverflowClip)
601 context.setIgnoreOverflowClip(); 612 context.setIgnoreOverflowClip();
602 return getClipRects(context); 613 return getClipRects(context);
603 } 614 }
604 615
605 } // namespace blink 616 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698