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

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

Issue 1610063002: Revert of Remove PaintInfo's paintingRoot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/layout/ClipPathOperation.h" 8 #include "core/layout/ClipPathOperation.h"
9 #include "core/layout/LayoutBlock.h" 9 #include "core/layout/LayoutBlock.h"
10 #include "core/layout/LayoutFrame.h" 10 #include "core/layout/LayoutFrame.h"
(...skipping 29 matching lines...) Expand all
40 { 40 {
41 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 41 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
42 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 42 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
43 // will do a full paintInvalidationForWholeLayoutObject(). 43 // will do a full paintInvalidationForWholeLayoutObject().
44 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement()) 44 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
45 return true; 45 return true;
46 46
47 return false; 47 return false;
48 } 48 }
49 49
50 void PaintLayerPainter::paint(GraphicsContext& context, const LayoutRect& damage Rect, const GlobalPaintFlags globalPaintFlags, PaintLayerFlags paintFlags) 50 void PaintLayerPainter::paint(GraphicsContext& context, const LayoutRect& damage Rect, const GlobalPaintFlags globalPaintFlags, LayoutObject* paintingRoot, Paint LayerFlags paintFlags)
51 { 51 {
52 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), globalPaintFlags, LayoutSize()); 52 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), globalPaintFlags, LayoutSize(), paintingRoot);
53 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) 53 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags))
54 paintLayer(context, paintingInfo, paintFlags); 54 paintLayer(context, paintingInfo, paintFlags);
55 } 55 }
56 56
57 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject) 57 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject)
58 { 58 {
59 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip; 59 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip;
60 } 60 }
61 61
62 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext& co ntext, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 62 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext& co ntext, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 332 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
333 if (shouldPaintContent) { 333 if (shouldPaintContent) {
334 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi lar optimization for slimming paint v2. 334 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi lar optimization for slimming paint v2.
335 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); 335 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot);
336 if (!shouldPaintContent) 336 if (!shouldPaintContent)
337 result = MayBeClippedByPaintDirtyRect; 337 result = MayBeClippedByPaintDirtyRect;
338 } 338 }
339 } 339 }
340 340
341 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly; 341 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly;
342 // If this layer's layoutObject is a child of the paintingRoot, we paint unc onditionally, which
343 // is done by passing a nil paintingRoot down to our layoutObject (as if no paintingRoot was ever set).
344 // Else, our layout tree may or may not contain the painting root, so we pas s that root along
345 // so it will be tested against as we descend through the layoutObjects.
346 LayoutObject* paintingRootForLayoutObject = 0;
347 if (localPaintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescen dantOf(localPaintingInfo.paintingRoot))
348 paintingRootForLayoutObject = localPaintingInfo.paintingRoot;
342 349
343 { // Begin block for the lifetime of any filter. 350 { // Begin block for the lifetime of any filter.
344 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags, 351 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags,
345 rootRelativeBounds, rootRelativeBoundsComputed); 352 rootRelativeBounds, rootRelativeBoundsComputed);
346 353
347 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; 354 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
348 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 355 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
349 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) { 356 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) {
350 PaintChunkProperties properties(context.paintController().curren tPaintChunkProperties()); 357 PaintChunkProperties properties(context.paintController().curren tPaintChunkProperties());
351 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents()) 358 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents())
352 properties.transform = transform; 359 properties.transform = transform;
353 if (EffectPaintPropertyNode* effect = objectProperties->effect() ) 360 if (EffectPaintPropertyNode* effect = objectProperties->effect() )
354 properties.effect = effect; 361 properties.effect = effect;
355 scopedPaintChunkProperties.emplace(context.paintController(), pr operties); 362 scopedPaintChunkProperties.emplace(context.paintController(), pr operties);
356 } 363 }
357 } 364 }
358 365
359 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 366 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
360 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 367 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
361 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent; 368 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent;
362 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound; 369 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound;
363 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; 370 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
364 371
365 if (shouldPaintBackground) { 372 if (shouldPaintBackground) {
366 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 373 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect,
367 localPaintingInfo, paintFlags); 374 localPaintingInfo, paintingRootForLayoutObject, paintFlags);
368 } 375 }
369 376
370 if (shouldPaintNegZOrderList) { 377 if (shouldPaintNegZOrderList) {
371 if (paintChildren(NegativeZOrderChildren, context, paintingInfo, pai ntFlags) == MayBeClippedByPaintDirtyRect) 378 if (paintChildren(NegativeZOrderChildren, context, paintingInfo, pai ntFlags) == MayBeClippedByPaintDirtyRect)
372 result = MayBeClippedByPaintDirtyRect; 379 result = MayBeClippedByPaintDirtyRect;
373 } 380 }
374 381
375 if (shouldPaintOwnContents) { 382 if (shouldPaintOwnContents) {
376 paintForegroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 383 paintForegroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect,
377 localPaintingInfo, selectionOnly, paintFlags); 384 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p aintFlags);
378 } 385 }
379 386
380 if (shouldPaintOutline) 387 if (shouldPaintOutline)
381 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintFlags); 388 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags);
382 389
383 if (shouldPaintNormalFlowAndPosZOrderLists) { 390 if (shouldPaintNormalFlowAndPosZOrderLists) {
384 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte xt, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect) 391 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte xt, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect)
385 result = MayBeClippedByPaintDirtyRect; 392 result = MayBeClippedByPaintDirtyRect;
386 } 393 }
387 394
388 if (shouldPaintOverlayScrollbars) 395 if (shouldPaintOverlayScrollbars)
389 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags); 396 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags);
390 } // FilterPainter block 397 } // FilterPainter block
391 398
392 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; 399 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly;
393 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 400 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly;
394 401
395 if (shouldPaintMask) 402 if (shouldPaintMask)
396 paintMaskForFragments(layerFragments, context, localPaintingInfo, paintF lags); 403 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags);
397 if (shouldPaintClippingMask) { 404 if (shouldPaintClippingMask) {
398 // Paint the border radius mask for the fragments. 405 // Paint the border radius mask for the fragments.
399 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintFlags); 406 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags);
400 } 407 }
401 408
402 if (subsequenceRecorder) 409 if (subsequenceRecorder)
403 m_paintLayer.setPreviousPaintResult(result); 410 m_paintLayer.setPreviousPaintResult(result);
404 return result; 411 return result;
405 } 412 }
406 413
407 bool PaintLayerPainter::needsToClip(const PaintLayerPaintingInfo& localPaintingI nfo, const ClipRect& clipRect) 414 bool PaintLayerPainter::needsToClip(const PaintLayerPaintingInfo& localPaintingI nfo, const ClipRect& clipRect)
408 { 415 {
409 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); 416 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 transform.translateRight(roundedDelta.x(), roundedDelta.y()); 517 transform.translateRight(roundedDelta.x(), roundedDelta.y());
511 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); 518 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta);
512 519
513 // TODO(jbroman): Put the real transform origin here, instead of using a 520 // TODO(jbroman): Put the real transform origin here, instead of using a
514 // matrix with the origin baked in. 521 // matrix with the origin baked in.
515 FloatPoint3D transformOrigin; 522 FloatPoint3D transformOrigin;
516 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject( ), DisplayItem::Transform3DElementTransform, transform, transformOrigin); 523 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject( ), DisplayItem::Transform3DElementTransform, transform, transformOrigin);
517 524
518 // Now do a paint with the root layer shifted to be us. 525 // Now do a paint with the root layer shifted to be us.
519 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti ngInfo.globalPaintFlags(), 526 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti ngInfo.globalPaintFlags(),
520 adjustedSubPixelAccumulation); 527 adjustedSubPixelAccumulation, paintingInfo.paintingRoot);
521 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH asClipPathClipping; 528 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH asClipPathClipping;
522 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai ntFlags, ForceSingleFragment); 529 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai ntFlags, ForceSingleFragment);
523 } 530 }
524 531
525 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre nToVisit, GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 532 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre nToVisit, GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
526 { 533 {
527 PaintResult result = FullyPainted; 534 PaintResult result = FullyPainted;
528 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 535 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
529 return result; 536 return result;
530 537
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 598
592 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) 599 if (needsToClip(localPaintingInfo, fragment.backgroundRect))
593 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags); 600 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags);
594 if (PaintLayerScrollableArea* scrollableArea = m_paintLayer.scrollableAr ea()) { 601 if (PaintLayerScrollableArea* scrollableArea = m_paintLayer.scrollableAr ea()) {
595 CullRect cullRect(pixelSnappedIntRect(fragment.backgroundRect.rect() )); 602 CullRect cullRect(pixelSnappedIntRect(fragment.backgroundRect.rect() ));
596 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), cullRect, true); 603 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), cullRect, true);
597 } 604 }
598 } 605 }
599 } 606 }
600 607
601 void PaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const PaintLaye rFragment& fragment, GraphicsContext& context, const ClipRect& clipRect, const P aintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, ClipState clipS tate) 608 void PaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const PaintLaye rFragment& fragment, GraphicsContext& context, const ClipRect& clipRect, const P aintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
602 { 609 {
603 ASSERT(m_paintLayer.isSelfPaintingLayer()); 610 ASSERT(m_paintLayer.isSelfPaintingLayer());
604 611
605 Optional<LayerClipRecorder> clipRecorder; 612 Optional<LayerClipRecorder> clipRecorder;
606 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 613 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
607 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 614 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
608 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 615 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
609 switch (phase) { 616 switch (phase) {
610 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self. 617 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self.
611 case PaintPhaseSelfOutlineOnly: 618 case PaintPhaseSelfOutlineOnly:
(...skipping 14 matching lines...) Expand all
626 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { 633 if (!paintingInfo.scrollOffsetAccumulation.isZero()) {
627 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders 634 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders
628 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder 635 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder
629 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this 636 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this
630 // layer, to get the same result as ScrollRecorder in BlockPainter. 637 // layer, to get the same result as ScrollRecorder in BlockPainter.
631 paintOffset += paintingInfo.scrollOffsetAccumulation; 638 paintOffset += paintingInfo.scrollOffsetAccumulation;
632 639
633 newCullRect.move(paintingInfo.scrollOffsetAccumulation); 640 newCullRect.move(paintingInfo.scrollOffsetAccumulation);
634 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, pai ntingInfo.scrollOffsetAccumulation); 641 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, pai ntingInfo.scrollOffsetAccumulation);
635 } 642 }
636 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, 643 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, painti ngInfo.globalPaintFlags(), paintFlags,
637 paintingInfo.globalPaintFlags(), paintFlags, paintingInfo.rootLayer->lay outObject()); 644 paintingRootForLayoutObject, paintingInfo.rootLayer->layoutObject());
638 645
639 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 646 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
640 } 647 }
641 648
642 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, 649 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context,
643 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, 650 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo,
644 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 651 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
645 { 652 {
646 bool needsScope = layerFragments.size() > 1; 653 bool needsScope = layerFragments.size() > 1;
647 for (auto& fragment : layerFragments) { 654 for (auto& fragment : layerFragments) {
648 Optional<ScopeRecorder> scopeRecorder; 655 Optional<ScopeRecorder> scopeRecorder;
649 if (needsScope) 656 if (needsScope)
650 scopeRecorder.emplace(context); 657 scopeRecorder.emplace(context);
651 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped); 658 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, pa intFlags, HasNotClipped);
652 } 659 }
653 } 660 }
654 661
655 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, 662 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context,
656 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, 663 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo,
657 const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLa yerFlags paintFlags) 664 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags)
658 { 665 {
659 // Optimize clipping for the single fragment case. 666 // Optimize clipping for the single fragment case.
660 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 667 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
661 ClipState clipState = HasNotClipped; 668 ClipState clipState = HasNotClipped;
662 Optional<LayerClipRecorder> clipRecorder; 669 Optional<LayerClipRecorder> clipRecorder;
663 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 670 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
664 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags); 671 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags);
665 clipState = HasClipped; 672 clipState = HasClipped;
666 } 673 }
667 674
668 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 675 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
669 // interleaving of the fragments to work properly. 676 // interleaving of the fragments to work properly.
670 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseDescendantBlockBackgroundsOnly, 677 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseDescendantBlockBackgroundsOnly, layerFragments,
671 layerFragments, context, localPaintingInfo, paintFlags, clipState); 678 context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, cli pState);
672 679
673 if (!selectionOnly) { 680 if (!selectionOnly) {
674 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintFlags, clipState); 681 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState);
675 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintFlags, clipState); 682 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipStat e);
676 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnly, l ayerFragments, context, localPaintingInfo, paintFlags, clipState); 683 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnly, l ayerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFla gs, clipState);
677 } 684 }
678 } 685 }
679 686
680 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, 687 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, c onst PaintLayerFragments& layerFragments, GraphicsContext& context,
681 const PaintLayerFragments& layerFragments, GraphicsContext& context, 688 const PaintLayerPaintingInfo& localPaintingInfo, LayoutObject* paintingRootF orLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
682 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags, ClipState clipState)
683 { 689 {
684 bool needsScope = layerFragments.size() > 1; 690 bool needsScope = layerFragments.size() > 1;
685 for (auto& fragment : layerFragments) { 691 for (auto& fragment : layerFragments) {
686 if (!fragment.foregroundRect.isEmpty()) { 692 if (!fragment.foregroundRect.isEmpty()) {
687 Optional<ScopeRecorder> scopeRecorder; 693 Optional<ScopeRecorder> scopeRecorder;
688 if (needsScope) 694 if (needsScope)
689 scopeRecorder.emplace(context); 695 scopeRecorder.emplace(context);
690 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintFlags, clipState); 696 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState);
691 } 697 }
692 } 698 }
693 } 699 }
694 700
695 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, 701 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintin gInfo,
696 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags) 702 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
697 { 703 {
698 bool needsScope = layerFragments.size() > 1; 704 bool needsScope = layerFragments.size() > 1;
699 for (auto& fragment : layerFragments) { 705 for (auto& fragment : layerFragments) {
700 if (!fragment.backgroundRect.isEmpty()) { 706 if (!fragment.backgroundRect.isEmpty()) {
701 Optional<ScopeRecorder> scopeRecorder; 707 Optional<ScopeRecorder> scopeRecorder;
702 if (needsScope) 708 if (needsScope)
703 scopeRecorder.emplace(context); 709 scopeRecorder.emplace(context);
704 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped); 710 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintF lags, HasNotClipped);
705 } 711 }
706 } 712 }
707 } 713 }
708 714
709 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, 715 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingIn fo,
710 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags) 716 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
711 { 717 {
712 bool needsScope = layerFragments.size() > 1; 718 bool needsScope = layerFragments.size() > 1;
713 for (auto& fragment : layerFragments) { 719 for (auto& fragment : layerFragments) {
714 Optional<ScopeRecorder> scopeRecorder; 720 Optional<ScopeRecorder> scopeRecorder;
715 if (needsScope) 721 if (needsScope)
716 scopeRecorder.emplace(context); 722 scopeRecorder.emplace(context);
717 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintFlags, HasNotClipped); 723 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, HasNotCli pped);
718 } 724 }
719 } 725 }
720 726
721 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments, 727 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& lo calPaintingInfo,
722 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags) 728 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
723 { 729 {
724 bool needsScope = layerFragments.size() > 1; 730 bool needsScope = layerFragments.size() > 1;
725 for (auto& fragment: layerFragments) { 731 for (auto& fragment: layerFragments) {
726 Optional<ScopeRecorder> scopeRecorder; 732 Optional<ScopeRecorder> scopeRecorder;
727 if (needsScope) 733 if (needsScope)
728 scopeRecorder.emplace(context); 734 scopeRecorder.emplace(context);
729 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintFlags, HasNotClipped); 735 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, H asNotClipped);
730 } 736 }
731 } 737 }
732 738
733 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags) 739 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags, LayoutObject* painting Root)
734 { 740 {
735 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 741 if (!m_paintLayer.containsDirtyOverlayScrollbars())
736 return; 742 return;
737 743
738 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); 744 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize(), paintingRoot);
739 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 745 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
740 746
741 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 747 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
742 } 748 }
743 749
744 } // namespace blink 750 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.h ('k') | third_party/WebKit/Source/core/paint/ReplacedPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698