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

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

Issue 2194273002: Fix border radius on composited children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Super hacky patch 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PaintLayerPainter.h" 5 #include "core/paint/PaintLayerPainter.h"
6 6
7 #include "core/frame/LocalFrame.h" 7 #include "core/frame/LocalFrame.h"
8 #include "core/layout/LayoutInline.h" 8 #include "core/layout/LayoutInline.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/ClipPathClipper.h" 10 #include "core/paint/ClipPathClipper.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()- >isPositioned()) 258 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()- >isPositioned())
259 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C lipPathOfPositionedElement); 259 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C lipPathOfPositionedElement);
260 260
261 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 261 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
262 // so they are nested properly. 262 // so they are nested properly.
263 Optional<ClipPathClipper> clipPathClipper; 263 Optional<ClipPathClipper> clipPathClipper;
264 // Clip-path, like border radius, must not be applied to the contents of a c omposited-scrolling container. 264 // Clip-path, like border radius, must not be applied to the contents of a c omposited-scrolling container.
265 // It must, however, still be applied to the mask layer, so that the composi tor can properly mask the 265 // It must, however, still be applied to the mask layer, so that the composi tor can properly mask the
266 // scrolling contents and scrollbars. 266 // scrolling contents and scrollbars.
267 if (m_paintLayer.layoutObject()->hasClipPath() && (!m_paintLayer.needsCompos itedScrolling() || (paintFlags & PaintLayerPaintingChildClippingMaskPhase))) { 267 if (m_paintLayer.layoutObject()->hasClipPath() && (!m_paintLayer.needsCompos itedScrolling() || (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | Pai ntLayerPaintingAncestorClippingMaskPhase)))) {
268 paintingInfo.ancestorHasClipPathClipping = true; 268 paintingInfo.ancestorHasClipPathClipping = true;
269 269
270 LayoutRect referenceBox(m_paintLayer.boxForClipPath()); 270 LayoutRect referenceBox(m_paintLayer.boxForClipPath());
271 // Note that this isn't going to work correctly if crossing a column bou ndary. The reference box should be 271 // Note that this isn't going to work correctly if crossing a column bou ndary. The reference box should be
272 // determined per-fragment, and hence this ought to be performed after f ragmentation. 272 // determined per-fragment, and hence this ought to be performed after f ragmentation.
273 if (m_paintLayer.enclosingPaginationLayer()) 273 if (m_paintLayer.enclosingPaginationLayer())
274 m_paintLayer.convertFromFlowThreadToVisualBoundingBoxInAncestor(pain tingInfo.rootLayer, referenceBox); 274 m_paintLayer.convertFromFlowThreadToVisualBoundingBoxInAncestor(pain tingInfo.rootLayer, referenceBox);
275 else 275 else
276 referenceBox.moveBy(offsetFromRoot); 276 referenceBox.moveBy(offsetFromRoot);
277 clipPathClipper.emplace( 277 clipPathClipper.emplace(
(...skipping 15 matching lines...) Expand all
293 293
294 PaintLayerPaintingInfo localPaintingInfo(paintingInfo); 294 PaintLayerPaintingInfo localPaintingInfo(paintingInfo);
295 localPaintingInfo.subPixelAccumulation = subpixelAccumulation; 295 localPaintingInfo.subPixelAccumulation = subpixelAccumulation;
296 296
297 PaintLayerFragments layerFragments; 297 PaintLayerFragments layerFragments;
298 if (shouldPaintContent || shouldPaintSelfOutline || isPaintingOverlayScrollb ars) { 298 if (shouldPaintContent || shouldPaintSelfOutline || isPaintingOverlayScrollb ars) {
299 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 299 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
300 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 300 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
301 // TODO(trchen): We haven't decided how to handle visual fragmentation w ith SPv2. 301 // TODO(trchen): We haven't decided how to handle visual fragmentation w ith SPv2.
302 // Related thread https://groups.google.com/a/chromium.org/forum/#!topic /graphics-dev/81XuWFf-mxM 302 // Related thread https://groups.google.com/a/chromium.org/forum/#!topic /graphics-dev/81XuWFf-mxM
303 if (fragmentPolicy == ForceSingleFragment || RuntimeEnabledFeatures::sli mmingPaintV2Enabled()) 303 if (fragmentPolicy == ForceSingleFragment || RuntimeEnabledFeatures::sli mmingPaintV2Enabled()) {
304 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignore OverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.su bPixelAccumulation); 304 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect,
305 else 305 cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, pain tFlags & PaintLayerPaintingAncestorClippingMaskPhase, &offsetFromRoot, localPain tingInfo.subPixelAccumulation);
306 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 306 } else {
307 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect,
308 cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, pain tFlags & PaintLayerPaintingAncestorClippingMaskPhase,
309 &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
310 }
307 311
308 // TODO(trchen): Needs to adjust cull rect between transform spaces. htt ps://crbug.com/593596 312 // TODO(trchen): Needs to adjust cull rect between transform spaces. htt ps://crbug.com/593596
309 // Disables layer culling for SPv2 for now because the space of the cull rect doesn't match 313 // Disables layer culling for SPv2 for now because the space of the cull rect doesn't match
310 // the space we paint in. Clipping will still be done by clip nodes, so this won't cause 314 // the space we paint in. Clipping will still be done by clip nodes, so this won't cause
311 // rendering issues, only performance. 315 // rendering issues, only performance.
312 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 316 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
313 layerFragments[0].backgroundRect = LayoutRect(LayoutRect::infiniteIn tRect()); 317 layerFragments[0].backgroundRect = LayoutRect(LayoutRect::infiniteIn tRect());
314 layerFragments[0].foregroundRect = LayoutRect(LayoutRect::infiniteIn tRect()); 318 layerFragments[0].foregroundRect = LayoutRect(LayoutRect::infiniteIn tRect());
315 } 319 }
316 320
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (shouldPaintNormalFlowAndPosZOrderLists) { 374 if (shouldPaintNormalFlowAndPosZOrderLists) {
371 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte xt, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect) 375 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte xt, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect)
372 result = MayBeClippedByPaintDirtyRect; 376 result = MayBeClippedByPaintDirtyRect;
373 } 377 }
374 378
375 if (shouldPaintOverlayScrollbars) 379 if (shouldPaintOverlayScrollbars)
376 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags); 380 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags);
377 } // FilterPainter block 381 } // FilterPainter block
378 382
379 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; 383 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly;
380 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 384 bool shouldPaintClippingMask = (paintFlags & (PaintLayerPaintingChildClippin gMaskPhase | PaintLayerPaintingAncestorClippingMaskPhase)) && shouldPaintContent && !selectionOnly;
381 385
382 if (shouldPaintMask) 386 if (shouldPaintMask)
383 paintMaskForFragments(layerFragments, context, localPaintingInfo, paintF lags); 387 paintMaskForFragments(layerFragments, context, localPaintingInfo, paintF lags);
384 if (shouldPaintClippingMask) { 388 if (shouldPaintClippingMask) {
385 // Paint the border radius mask for the fragments. 389 // Paint the border radius mask for the fragments.
386 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintFlags); 390 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintFlags);
387 } 391 }
388 392
389 if (subsequenceRecorder) 393 if (subsequenceRecorder)
390 m_paintLayer.setPreviousPaintResult(result); 394 m_paintLayer.setPreviousPaintResult(result);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } else if (paginationLayer) { 470 } else if (paginationLayer) {
467 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any 471 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any
468 // issues in it & refactor to make it obvious from code structure what i t does and that it's 472 // issues in it & refactor to make it obvious from code structure what i t does and that it's
469 // correct. 473 // correct.
470 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 474 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
471 ShouldRespectOverflowClipType respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_paintLayer.layoutObject()); 475 ShouldRespectOverflowClipType respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_paintLayer.layoutObject());
472 // Calculate the transformed bounding box in the current coordinate spac e, to figure out 476 // Calculate the transformed bounding box in the current coordinate spac e, to figure out
473 // which fragmentainers (e.g. columns) we need to visit. 477 // which fragmentainers (e.g. columns) we need to visit.
474 LayoutRect transformedExtent = PaintLayer::transparencyClipBox(&m_paintL ayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, PaintLayer::Root OfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.getGlobal PaintFlags()); 478 LayoutRect transformedExtent = PaintLayer::transparencyClipBox(&m_paintL ayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, PaintLayer::Root OfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.getGlobal PaintFlags());
475 // FIXME: we don't check if paginationLayer is within paintingInfo.rootL ayer here. 479 // FIXME: we don't check if paginationLayer is within paintingInfo.rootL ayer here.
476 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, 0, paintingInfo.subPixelAccumulation, &transformedExtent); 480 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, false, 0, paintingInfo.subPixelAccumulation, &transformedExtent);
477 } else { 481 } else {
478 // We don't need to collect any fragments in the regular way here. We ha ve already 482 // We don't need to collect any fragments in the regular way here. We ha ve already
479 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this 483 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this
480 // layer is something that can be done further down the path, when the t ransform has 484 // layer is something that can be done further down the path, when the t ransform has
481 // been applied. 485 // been applied.
482 PaintLayerFragment fragment; 486 PaintLayerFragment fragment;
483 fragment.backgroundRect = paintingInfo.paintDirtyRect; 487 fragment.backgroundRect = paintingInfo.paintDirtyRect;
484 fragments.append(fragment); 488 fragments.append(fragment);
485 } 489 }
486 490
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 switch (phase) { 644 switch (phase) {
641 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self. 645 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self.
642 case PaintPhaseSelfOutlineOnly: 646 case PaintPhaseSelfOutlineOnly:
643 case PaintPhaseMask: // Mask painting will handle clipping to self. 647 case PaintPhaseMask: // Mask painting will handle clipping to self.
644 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 648 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
645 break; 649 break;
646 default: 650 default:
647 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 651 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
648 break; 652 break;
649 } 653 }
650
651 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); 654 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule);
652 } 655 }
653 656
654 LayoutRect newCullRect(clipRect.rect()); 657 LayoutRect newCullRect(clipRect.rect());
655 Optional<ScrollRecorder> scrollRecorder; 658 Optional<ScrollRecorder> scrollRecorder;
656 LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation(); 659 LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation();
657 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 660 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
658 const ObjectPaintProperties* objectPaintProperties = m_paintLayer.layout Object()->objectPaintProperties(); 661 const ObjectPaintProperties* objectPaintProperties = m_paintLayer.layout Object()->objectPaintProperties();
659 ASSERT(objectPaintProperties && objectPaintProperties->localBorderBoxPro perties()); 662 ASSERT(objectPaintProperties && objectPaintProperties->localBorderBoxPro perties());
660 paintOffset += toSize(objectPaintProperties->localBorderBoxProperties()- >paintOffset); 663 paintOffset += toSize(objectPaintProperties->localBorderBoxProperties()- >paintOffset);
661 } else { 664 } else {
662 paintOffset += toSize(fragment.layerBounds.location()); 665 paintOffset += toSize(fragment.layerBounds.location());
663 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { 666 if (!paintingInfo.scrollOffsetAccumulation.isZero()) {
664 // As a descendant of the root layer, m_paintLayer's painting is not controlled by the ScrollRecorders 667 // As a descendant of the root layer, m_paintLayer's painting is not controlled by the ScrollRecorders
665 // created by BlockPainter of the ancestor layers up to the root lay er, so we need to issue ScrollRecorder 668 // created by BlockPainter of the ancestor layers up to the root lay er, so we need to issue ScrollRecorder
666 // for this layer seperately, with the scroll offset accumulated fro m the root layer to the parent of this 669 // for this layer seperately, with the scroll offset accumulated fro m the root layer to the parent of this
667 // layer, to get the same result as ScrollRecorder in BlockPainter. 670 // layer, to get the same result as ScrollRecorder in BlockPainter.
668 paintOffset += paintingInfo.scrollOffsetAccumulation; 671 paintOffset += paintingInfo.scrollOffsetAccumulation;
669 672
670 newCullRect.move(paintingInfo.scrollOffsetAccumulation); 673 newCullRect.move(paintingInfo.scrollOffsetAccumulation);
671 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, paintingInfo.scrollOffsetAccumulation); 674 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, paintingInfo.scrollOffsetAccumulation);
672 } 675 }
673 } 676 }
674 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, 677 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase,
675 paintingInfo.getGlobalPaintFlags(), paintFlags, paintingInfo.rootLayer-> layoutObject()); 678 paintingInfo.getGlobalPaintFlags(), paintFlags, paintingInfo.rootLayer-> layoutObject());
676 679
680 // TODO(schenney): This is the wrong object for painting AncestorClippingMas k.
677 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 681 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
678 } 682 }
679 683
680 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, 684 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments,
681 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, 685 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
682 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 686 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
683 { 687 {
684 Optional<DisplayItemCacheSkipper> cacheSkipper; 688 Optional<DisplayItemCacheSkipper> cacheSkipper;
685 if (layerFragments.size() > 1) 689 if (layerFragments.size() > 1)
686 cacheSkipper.emplace(context); 690 cacheSkipper.emplace(context);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 798 if (!m_paintLayer.containsDirtyOverlayScrollbars())
795 return; 799 return;
796 800
797 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); 801 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize());
798 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 802 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
799 803
800 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 804 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
801 } 805 }
802 806
803 } // namespace blink 807 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698