Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/DeprecatedPaintLayerPainter.h" | 6 #include "core/paint/DeprecatedPaintLayerPainter.h" |
| 7 | 7 |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/layout/ClipPathOperation.h" | 9 #include "core/layout/ClipPathOperation.h" |
| 10 #include "core/layout/LayoutBlock.h" | 10 #include "core/layout/LayoutBlock.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 | 416 |
| 417 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags) | 417 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags) |
| 418 { | 418 { |
| 419 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) | 419 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) |
| 420 return; | 420 return; |
| 421 | 421 |
| 422 #if ENABLE(ASSERT) | 422 #if ENABLE(ASSERT) |
| 423 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); | 423 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); |
| 424 #endif | 424 #endif |
| 425 | 425 |
| 426 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; | |
| 427 if (m_paintLayer.layoutObject()->hasOverflowClip()) | |
| 428 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set(); | |
| 429 | |
| 426 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); | 430 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); |
| 427 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { | 431 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { |
| 428 DeprecatedPaintLayerPainter childPainter(*child->layer()); | 432 DeprecatedPaintLayerPainter childPainter(*child->layer()); |
| 429 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() | 433 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() |
| 430 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). | 434 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). |
| 431 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo, paintFlag s)) | 435 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo, paintFlag s)) |
| 432 continue; | 436 continue; |
| 433 | 437 |
| 438 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; | |
| 439 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; | |
| 440 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer. | |
| 441 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { | |
| 442 if (parentLayer->layoutObject()->hasOverflowClip()) | |
| 443 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset(); | |
| 444 } | |
| 445 | |
| 434 if (!child->layer()->isPaginated()) | 446 if (!child->layer()->isPaginated()) |
| 435 childPainter.paintLayer(context, paintingInfo, paintFlags); | 447 childPainter.paintLayer(context, childPaintingInfo, paintFlags); |
| 436 else | 448 else |
| 437 childPainter.paintPaginatedChildLayer(context, paintingInfo, paintFl ags); | 449 childPainter.paintPaginatedChildLayer(context, childPaintingInfo, pa intFlags); |
| 438 } | 450 } |
| 439 } | 451 } |
| 440 | 452 |
| 441 // FIXME: inline this. | 453 // FIXME: inline this. |
| 442 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) | 454 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) |
| 443 { | 455 { |
| 444 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); | 456 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); |
| 445 } | 457 } |
| 446 | 458 |
| 447 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const Deprecate dPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 459 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const Deprecate dPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; | 638 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; |
| 627 break; | 639 break; |
| 628 } | 640 } |
| 629 | 641 |
| 630 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), clipType, c lipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); | 642 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), clipType, c lipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); |
| 631 } | 643 } |
| 632 | 644 |
| 633 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForLayoutObject, 0, paintingInfo.rootLayer->layoutObjec t()); | 645 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForLayoutObject, 0, paintingInfo.rootLayer->layoutObjec t()); |
| 634 OwnPtr<ScrollRecorder> scrollRecorder; | 646 OwnPtr<ScrollRecorder> scrollRecorder; |
| 635 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation()); | 647 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation()); |
| 636 if (&m_paintLayer != paintingInfo.rootLayer && paintingInfo.rootLayer->layou tObject()->hasOverflowClip()) { | 648 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { |
|
chrishtr
2015/06/03 18:46:08
Can you explain more why we need to do this accumu
Xianzhu
2015/06/03 19:06:59
This is covered by existing tests. Previously the
Xianzhu
2015/06/03 19:42:41
Done.
| |
| 637 // As a sublayer of the root layer, m_paintLayer's painting is not contr olled by the ScrollRecorder | 649 paintOffset += paintingInfo.scrollOffsetAccumulation; |
| 638 // created by BlockPainter of the root layer, so we need to issue Scroll Recorder for them separately. | 650 paintInfo.rect.move(paintingInfo.scrollOffsetAccumulation); |
| 639 // FIXME: This doesn't apply in slimming paint phase 2. | 651 scrollRecorder = adoptPtr(new ScrollRecorder(*paintInfo.context, *m_pain tLayer.layoutObject(), paintInfo.phase, paintingInfo.scrollOffsetAccumulation)); |
| 640 IntSize scrollOffset = paintingInfo.rootLayer->layoutBox()->scrolledCont entOffset(); | |
| 641 if (paintingInfo.rootLayer->scrollsOverflow() || !scrollOffset.isZero()) { | |
| 642 paintOffset += scrollOffset; | |
| 643 paintInfo.rect.move(scrollOffset); | |
| 644 scrollRecorder = adoptPtr(new ScrollRecorder(*paintInfo.context, *m_ paintLayer.layoutObject(), paintInfo.phase, scrollOffset)); | |
| 645 } | |
| 646 } | 652 } |
| 647 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); | 653 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); |
| 648 } | 654 } |
| 649 | 655 |
| 650 void DeprecatedPaintLayerPainter::paintBackgroundForFragments(const DeprecatedPa intLayerFragments& layerFragments, GraphicsContext* context, | 656 void DeprecatedPaintLayerPainter::paintBackgroundForFragments(const DeprecatedPa intLayerFragments& layerFragments, GraphicsContext* context, |
| 651 const LayoutRect& transparencyPaintDirtyRect, const DeprecatedPaintLayerPain tingInfo& localPaintingInfo, PaintBehavior paintBehavior, | 657 const LayoutRect& transparencyPaintDirtyRect, const DeprecatedPaintLayerPain tingInfo& localPaintingInfo, PaintBehavior paintBehavior, |
| 652 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) | 658 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) |
| 653 { | 659 { |
| 654 bool needsScope = layerFragments.size() > 1; | 660 bool needsScope = layerFragments.size() > 1; |
| 655 for (auto& fragment : layerFragments) { | 661 for (auto& fragment : layerFragments) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 748 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
| 743 return; | 749 return; |
| 744 | 750 |
| 745 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot); | 751 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot); |
| 746 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 752 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 747 | 753 |
| 748 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 754 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 749 } | 755 } |
| 750 | 756 |
| 751 } // namespace blink | 757 } // namespace blink |
| OLD | NEW |