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 "core/paint/PaintLayerPainter.h" | 5 #include "core/paint/PaintLayerPainter.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 | 447 |
| 448 ClipRect ancestorBackgroundClipRect; | 448 ClipRect ancestorBackgroundClipRect; |
| 449 if (parentLayer) { | 449 if (parentLayer) { |
| 450 // Calculate the clip rectangle that the ancestors establish. | 450 // Calculate the clip rectangle that the ancestors establish. |
| 451 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver layScrollbarSize); | 451 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver layScrollbarSize); |
| 452 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) = = IgnoreOverflowClip) | 452 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) = = IgnoreOverflowClip) |
| 453 clipRectsContext.setIgnoreOverflowClip(); | 453 clipRectsContext.setIgnoreOverflowClip(); |
| 454 ancestorBackgroundClipRect = m_paintLayer.clipper().backgroundClipRect(c lipRectsContext); | 454 ancestorBackgroundClipRect = m_paintLayer.clipper().backgroundClipRect(c lipRectsContext); |
| 455 } | 455 } |
| 456 | 456 |
| 457 LayoutObject* object = m_paintLayer.layoutObject(); | |
| 458 LayoutView* view = object->view(); | |
| 459 bool isFixedPosObjectInPagedMedia = object->style()->position() == FixedPosi tion && view->pageLogicalHeight(); | |
|
Xianzhu
2016/03/21 19:37:18
We should exclude the case that the view is not th
| |
| 457 PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); | 460 PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); |
| 458 PaintLayerFragments fragments; | 461 PaintLayerFragments fragments; |
| 459 if (paginationLayer) { | 462 if (isFixedPosObjectInPagedMedia) { |
| 463 // "For paged media, boxes with fixed positions are repeated on every pa ge." | |
|
Xianzhu
2016/03/21 19:37:18
Nit: include the link of source of the above state
| |
| 464 ASSERT(view->firstChild() && view->firstChild()->isLayoutBlock()); | |
| 465 int pages = toLayoutBlock(view->firstChild())->logicalHeight() / view->p ageLogicalHeight(); | |
| 466 LayoutPoint paginationOffset; | |
| 467 for (int i = 0; i <= pages; i++) { | |
| 468 PaintLayerFragment fragment; | |
| 469 fragment.paginationOffset = paginationOffset; | |
| 470 fragments.append(fragment); | |
| 471 paginationOffset += LayoutPoint(0, view->pageLogicalHeight()); | |
| 472 } | |
| 473 } else if (paginationLayer) { | |
| 460 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any | 474 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any |
| 461 // issues in it & refactor to make it obvious from code structure what i t does and that it's | 475 // issues in it & refactor to make it obvious from code structure what i t does and that it's |
| 462 // correct. | 476 // correct. |
| 463 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; | 477 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; |
| 464 ShouldRespectOverflowClipType respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_paintLayer.layoutObject()); | 478 ShouldRespectOverflowClipType respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_paintLayer.layoutObject()); |
| 465 // Calculate the transformed bounding box in the current coordinate spac e, to figure out | 479 // Calculate the transformed bounding box in the current coordinate spac e, to figure out |
| 466 // which fragmentainers (e.g. columns) we need to visit. | 480 // which fragmentainers (e.g. columns) we need to visit. |
| 467 LayoutRect transformedExtent = PaintLayer::transparencyClipBox(&m_paintL ayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, PaintLayer::Root OfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.getGlobal PaintFlags()); | 481 LayoutRect transformedExtent = PaintLayer::transparencyClipBox(&m_paintL ayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, PaintLayer::Root OfTransparencyClipBox, paintingInfo.subPixelAccumulation, paintingInfo.getGlobal PaintFlags()); |
| 468 // FIXME: we don't check if paginationLayer is within paintingInfo.rootL ayer here. | 482 // FIXME: we don't check if paginationLayer is within paintingInfo.rootL ayer here. |
| 469 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, 0, paintingInfo.subPixelAccumulation, &transformedExtent); | 483 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, 0, paintingInfo.subPixelAccumulation, &transformedExtent); |
| 470 } else { | 484 } else { |
| 471 // We don't need to collect any fragments in the regular way here. We ha ve already | 485 // We don't need to collect any fragments in the regular way here. We ha ve already |
| 472 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this | 486 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this |
| 473 // layer is something that can be done further down the path, when the t ransform has | 487 // layer is something that can be done further down the path, when the t ransform has |
| 474 // been applied. | 488 // been applied. |
| 475 PaintLayerFragment fragment; | 489 PaintLayerFragment fragment; |
| 476 fragment.backgroundRect = paintingInfo.paintDirtyRect; | 490 fragment.backgroundRect = paintingInfo.paintDirtyRect; |
| 477 fragments.append(fragment); | 491 fragments.append(fragment); |
| 478 } | 492 } |
| 479 | 493 |
| 480 bool needsScope = fragments.size() > 1; | 494 bool needsScope = fragments.size() > 1; |
| 481 PaintResult result = FullyPainted; | 495 PaintResult result = FullyPainted; |
| 482 for (const auto& fragment : fragments) { | 496 for (const auto& fragment : fragments) { |
| 483 Optional<ScopeRecorder> scopeRecorder; | 497 Optional<ScopeRecorder> scopeRecorder; |
| 484 if (needsScope) | 498 if (needsScope) |
| 485 scopeRecorder.emplace(context); | 499 scopeRecorder.emplace(context); |
| 486 Optional<LayerClipRecorder> clipRecorder; | 500 Optional<LayerClipRecorder> clipRecorder; |
| 487 if (parentLayer) { | 501 if (parentLayer && !isFixedPosObjectInPagedMedia) { |
|
Xianzhu
2016/03/21 19:37:18
I think we should still clip (especially css clip)
| |
| 488 ClipRect clipRectForFragment(ancestorBackgroundClipRect); | 502 ClipRect clipRectForFragment(ancestorBackgroundClipRect); |
| 489 clipRectForFragment.moveBy(fragment.paginationOffset); | 503 clipRectForFragment.moveBy(fragment.paginationOffset); |
| 490 clipRectForFragment.intersect(fragment.backgroundRect); | 504 clipRectForFragment.intersect(fragment.backgroundRect); |
| 491 if (clipRectForFragment.isEmpty()) | 505 if (clipRectForFragment.isEmpty()) |
| 492 continue; | 506 continue; |
| 493 if (needsToClip(paintingInfo, clipRectForFragment)) { | 507 if (needsToClip(paintingInfo, clipRectForFragment)) { |
| 494 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr agment.isClippedByClipCss()) | 508 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr agment.isClippedByClipCss()) |
| 495 UseCounter::count(m_paintLayer.layoutObject()->document(), U seCounter::ClipCssOfPositionedElement); | 509 UseCounter::count(m_paintLayer.layoutObject()->document(), U seCounter::ClipCssOfPositionedElement); |
| 496 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp layItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginatio nOffset, paintFlags); | 510 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp layItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginatio nOffset, paintFlags); |
| 497 } | 511 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 781 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
| 768 return; | 782 return; |
| 769 | 783 |
| 770 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); | 784 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); |
| 771 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 785 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 772 | 786 |
| 773 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 787 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 774 } | 788 } |
| 775 | 789 |
| 776 } // namespace blink | 790 } // namespace blink |
| OLD | NEW |