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

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

Issue 2400063002: Don't clip contain:paint when requested to ignore clip (Closed)
Patch Set: Rebase Created 4 years, 2 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 foregroundRect = backgroundRect; 337 foregroundRect = backgroundRect;
338 338
339 LayoutPoint offset; 339 LayoutPoint offset;
340 if (offsetFromRoot) 340 if (offsetFromRoot)
341 offset = *offsetFromRoot; 341 offset = *offsetFromRoot;
342 else 342 else
343 m_layer.convertToLayerCoords(context.rootLayer, offset); 343 m_layer.convertToLayerCoords(context.rootLayer, offset);
344 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); 344 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size()));
345 345
346 // Update the clip rects that will be passed to child layers. 346 // Update the clip rects that will be passed to child layers.
347 if ((layoutObject.hasOverflowClip() || 347 if (shouldClipOverflow(context)) {
348 layoutObject.styleRef().containsPaint()) &&
349 shouldRespectOverflowClip(context)) {
350 foregroundRect.intersect( 348 foregroundRect.intersect(
351 toLayoutBox(layoutObject) 349 toLayoutBox(layoutObject)
352 .overflowClipRect(offset, context.overlayScrollbarClipBehavior)); 350 .overflowClipRect(offset, context.overlayScrollbarClipBehavior));
353 if (layoutObject.styleRef().hasBorderRadius()) 351 if (layoutObject.styleRef().hasBorderRadius())
354 foregroundRect.setHasRadius(true); 352 foregroundRect.setHasRadius(true);
355 353
356 // FIXME: Does not do the right thing with columns yet, since we don't yet 354 // FIXME: Does not do the right thing with columns yet, since we don't yet
357 // factor in the individual column boxes as overflow. 355 // factor in the individual column boxes as overflow.
358 356
359 // The LayoutView is special since its overflow clipping rect may be larger 357 // The LayoutView is special since its overflow clipping rect may be larger
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // Ensure that our parent's clip has been calculated so that we can examine 398 // Ensure that our parent's clip has been calculated so that we can examine
401 // the values. 399 // the values.
402 if (parentLayer) { 400 if (parentLayer) {
403 parentLayer->clipper().getOrCalculateClipRects(context, clipRects); 401 parentLayer->clipper().getOrCalculateClipRects(context, clipRects);
404 } else { 402 } else {
405 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); 403 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
406 } 404 }
407 405
408 adjustClipRectsForChildren(layoutObject, clipRects); 406 adjustClipRectsForChildren(layoutObject, clipRects);
409 407
410 if ((layoutObject.hasOverflowClip() && shouldRespectOverflowClip(context)) || 408 if (shouldClipOverflow(context) || layoutObject.hasClip() ||
411 (layoutObject.isSVGRoot() && 409 (layoutObject.isSVGRoot() &&
412 toLayoutSVGRoot(&layoutObject)->shouldApplyViewportClip()) || 410 toLayoutSVGRoot(&layoutObject)->shouldApplyViewportClip())) {
413 layoutObject.hasClip() || layoutObject.styleRef().containsPaint()) {
414 // This offset cannot use convertToLayerCoords, because sometimes our 411 // This offset cannot use convertToLayerCoords, because sometimes our
415 // rootLayer may be across some transformed layer boundary, for example, in 412 // rootLayer may be across some transformed layer boundary, for example, in
416 // the PaintLayerCompositor overlapMap, where clipRects are needed in view 413 // the PaintLayerCompositor overlapMap, where clipRects are needed in view
417 // space. 414 // space.
418 applyClipRects(context, layoutObject, 415 applyClipRects(context, layoutObject,
419 roundedLayoutPoint(layoutObject.localToAncestorPoint( 416 roundedLayoutPoint(layoutObject.localToAncestorPoint(
420 FloatPoint(), context.rootLayer->layoutObject())), 417 FloatPoint(), context.rootLayer->layoutObject())),
421 clipRects); 418 clipRects);
422 } 419 }
423 } 420 }
(...skipping 16 matching lines...) Expand all
440 LayoutRect source(LayoutRect::infiniteIntRect()); 437 LayoutRect source(LayoutRect::infiniteIntRect());
441 bool success = false; 438 bool success = false;
442 const ObjectPaintProperties* properties = 439 const ObjectPaintProperties* properties =
443 m_layer.layoutObject()->objectPaintProperties(); 440 m_layer.layoutObject()->objectPaintProperties();
444 PropertyTreeState propertyTreeState = 441 PropertyTreeState propertyTreeState =
445 properties->localBorderBoxProperties()->propertyTreeState; 442 properties->localBorderBoxProperties()->propertyTreeState;
446 443
447 if (properties->cssClip()) 444 if (properties->cssClip())
448 propertyTreeState.setClip(properties->cssClip()); 445 propertyTreeState.setClip(properties->cssClip());
449 446
450 const LayoutObject& layoutObject = *m_layer.layoutObject(); 447 if (isForeground && shouldClipOverflow(context) && properties->overflowClip())
451 if (shouldRespectOverflowClip(context) && isForeground && 448 propertyTreeState.setClip(properties->overflowClip());
452 (layoutObject.hasOverflowClip() ||
453 layoutObject.styleRef().containsPaint())) {
454 if (properties->overflowClip())
455 propertyTreeState.setClip(properties->overflowClip());
456 }
457 449
458 const ObjectPaintProperties* ancestorProperties = 450 const ObjectPaintProperties* ancestorProperties =
459 context.rootLayer->layoutObject()->objectPaintProperties(); 451 context.rootLayer->layoutObject()->objectPaintProperties();
460 PropertyTreeState destinationPropertyTreeState = 452 PropertyTreeState destinationPropertyTreeState =
461 ancestorProperties->localBorderBoxProperties()->propertyTreeState; 453 ancestorProperties->localBorderBoxProperties()->propertyTreeState;
462 if (!context.rootLayer->clipper().shouldRespectOverflowClip(context)) { 454 if (!context.rootLayer->clipper().shouldRespectOverflowClip(context)) {
463 if (ancestorProperties->overflowClip()) 455 if (ancestorProperties->overflowClip())
464 destinationPropertyTreeState.setClip(ancestorProperties->overflowClip()); 456 destinationPropertyTreeState.setClip(ancestorProperties->overflowClip());
465 } 457 }
466 FloatRect clippedRectInRootLayerSpace = 458 FloatRect clippedRectInRootLayerSpace =
467 m_geometryMapper->mapToVisualRectInDestinationSpace( 459 m_geometryMapper->mapToVisualRectInDestinationSpace(
468 FloatRect(source), propertyTreeState, destinationPropertyTreeState, 460 FloatRect(source), propertyTreeState, destinationPropertyTreeState,
469 success); 461 success);
470 DCHECK(success); 462 DCHECK(success);
471 return ClipRect(LayoutRect(clippedRectInRootLayerSpace)); 463 return ClipRect(LayoutRect(clippedRectInRootLayerSpace));
472 } 464 }
473 465
474 ClipRect PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper( 466 ClipRect PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper(
475 const ClipRectsContext& context, 467 const ClipRectsContext& context,
476 const ClipRect& clip) const { 468 const ClipRect& clip) const {
477 const LayoutObject& layoutObject = *m_layer.layoutObject(); 469 const LayoutObject& layoutObject = *m_layer.layoutObject();
478 FloatRect clipRect(clip.rect()); 470 FloatRect clipRect(clip.rect());
479 if ((layoutObject.hasOverflowClip() || 471 if (shouldClipOverflow(context)) {
480 layoutObject.styleRef().containsPaint()) &&
481 shouldRespectOverflowClip(context)) {
482 LayoutRect layerBoundsWithVisualOverflow = 472 LayoutRect layerBoundsWithVisualOverflow =
483 layoutObject.isLayoutView() 473 layoutObject.isLayoutView()
484 ? toLayoutView(layoutObject).viewRect() 474 ? toLayoutView(layoutObject).viewRect()
485 : toLayoutBox(layoutObject).visualOverflowRect(); 475 : toLayoutBox(layoutObject).visualOverflowRect();
486 toLayoutBox(layoutObject) 476 toLayoutBox(layoutObject)
487 .flipForWritingMode( 477 .flipForWritingMode(
488 // PaintLayer are in physical coordinates, so the overflow has to be 478 // PaintLayer are in physical coordinates, so the overflow has to be
489 // flipped. 479 // flipped.
490 layerBoundsWithVisualOverflow); 480 layerBoundsWithVisualOverflow);
491 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); 481 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 521 }
532 522
533 void PaintLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context, 523 void PaintLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context,
534 ClipRects& clipRects) const { 524 ClipRects& clipRects) const {
535 if (context.usesCache()) 525 if (context.usesCache())
536 clipRects = getClipRects(context); 526 clipRects = getClipRects(context);
537 else 527 else
538 calculateClipRects(context, clipRects); 528 calculateClipRects(context, clipRects);
539 } 529 }
540 530
531 bool PaintLayerClipper::shouldClipOverflow(
532 const ClipRectsContext& context) const {
533 return (m_layer.layoutObject()->hasOverflowClip() ||
534 m_layer.layoutObject()->styleRef().containsPaint()) &&
535 shouldRespectOverflowClip(context);
536 }
537
541 bool PaintLayerClipper::shouldRespectOverflowClip( 538 bool PaintLayerClipper::shouldRespectOverflowClip(
542 const ClipRectsContext& context) const { 539 const ClipRectsContext& context) const {
543 if (&m_layer != context.rootLayer) 540 if (&m_layer != context.rootLayer)
544 return true; 541 return true;
545 542
546 if (context.respectOverflowClip == IgnoreOverflowClip) 543 if (context.respectOverflowClip == IgnoreOverflowClip)
547 return false; 544 return false;
548 545
549 if (m_layer.isRootLayer() && 546 if (m_layer.isRootLayer() &&
550 context.respectOverflowClipForViewport == IgnoreOverflowClip) 547 context.respectOverflowClipForViewport == IgnoreOverflowClip)
551 return false; 548 return false;
552 549
553 return true; 550 return true;
554 } 551 }
555 552
556 ClipRects& PaintLayerClipper::paintingClipRects( 553 ClipRects& PaintLayerClipper::paintingClipRects(
557 const PaintLayer* rootLayer, 554 const PaintLayer* rootLayer,
558 ShouldRespectOverflowClipType respectOverflowClip, 555 ShouldRespectOverflowClipType respectOverflowClip,
559 const LayoutSize& subpixelAccumulation) const { 556 const LayoutSize& subpixelAccumulation) const {
560 DCHECK(!m_geometryMapper); 557 DCHECK(!m_geometryMapper);
561 ClipRectsContext context(rootLayer, PaintingClipRects, 558 ClipRectsContext context(rootLayer, PaintingClipRects,
562 IgnoreOverlayScrollbarSize, subpixelAccumulation); 559 IgnoreOverlayScrollbarSize, subpixelAccumulation);
563 if (respectOverflowClip == IgnoreOverflowClip) 560 if (respectOverflowClip == IgnoreOverflowClip)
564 context.setIgnoreOverflowClip(); 561 context.setIgnoreOverflowClip();
565 return getClipRects(context); 562 return getClipRects(context);
566 } 563 }
567 564
568 } // namespace blink 565 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698