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

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

Issue 1575983002: Display fixed position objects on every page of paged media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 8 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/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 454
455 ClipRect ancestorBackgroundClipRect; 455 ClipRect ancestorBackgroundClipRect;
456 if (parentLayer) { 456 if (parentLayer) {
457 // Calculate the clip rectangle that the ancestors establish. 457 // Calculate the clip rectangle that the ancestors establish.
458 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver layScrollbarSize); 458 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver layScrollbarSize);
459 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) = = IgnoreOverflowClip) 459 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) = = IgnoreOverflowClip)
460 clipRectsContext.setIgnoreOverflowClip(); 460 clipRectsContext.setIgnoreOverflowClip();
461 ancestorBackgroundClipRect = m_paintLayer.clipper().backgroundClipRect(c lipRectsContext); 461 ancestorBackgroundClipRect = m_paintLayer.clipper().backgroundClipRect(c lipRectsContext);
462 } 462 }
463 463
464 LayoutObject* object = m_paintLayer.layoutObject();
465 LayoutView* view = object->view();
466 bool isFixedPosObjectInPagedMedia = object->style()->position() == FixedPosi tion && object->container() == view && view->pageLogicalHeight();
464 PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); 467 PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer();
465 PaintLayerFragments fragments; 468 PaintLayerFragments fragments;
466 if (paginationLayer) { 469 if (isFixedPosObjectInPagedMedia) {
470 // "For paged media, boxes with fixed positions are repeated on every pa ge."
471 // - https://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#fixed-pos itioning
472 ASSERT(view->firstChild() && view->firstChild()->isLayoutBlock());
473 int pages = toLayoutBlock(view->firstChild())->logicalHeight() / view->p ageLogicalHeight();
474 LayoutPoint paginationOffset;
475 for (int i = 0; i <= pages; i++) {
476 PaintLayerFragment fragment;
477 fragment.backgroundRect = paintingInfo.paintDirtyRect;
478 fragment.paginationOffset = paginationOffset;
479 fragments.append(fragment);
480 paginationOffset += LayoutPoint(0, view->pageLogicalHeight());
481 }
482 } else if (paginationLayer) {
467 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any 483 // 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 484 // issues in it & refactor to make it obvious from code structure what i t does and that it's
469 // correct. 485 // correct.
470 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 486 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
471 ShouldRespectOverflowClipType respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_paintLayer.layoutObject()); 487 ShouldRespectOverflowClipType respectOverflowClip = shouldRespectOverflo wClip(paintFlags, m_paintLayer.layoutObject());
472 // Calculate the transformed bounding box in the current coordinate spac e, to figure out 488 // Calculate the transformed bounding box in the current coordinate spac e, to figure out
473 // which fragmentainers (e.g. columns) we need to visit. 489 // 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()); 490 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. 491 // 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); 492 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, 0, paintingInfo.subPixelAccumulation, &transformedExtent);
477 } else { 493 } else {
478 // We don't need to collect any fragments in the regular way here. We ha ve already 494 // 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 495 // 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 496 // layer is something that can be done further down the path, when the t ransform has
481 // been applied. 497 // been applied.
482 PaintLayerFragment fragment; 498 PaintLayerFragment fragment;
483 fragment.backgroundRect = paintingInfo.paintDirtyRect; 499 fragment.backgroundRect = paintingInfo.paintDirtyRect;
484 fragments.append(fragment); 500 fragments.append(fragment);
485 } 501 }
486 502
487 bool needsScope = fragments.size() > 1; 503 bool needsScope = fragments.size() > 1;
488 PaintResult result = FullyPainted; 504 PaintResult result = FullyPainted;
489 for (const auto& fragment : fragments) { 505 for (const auto& fragment : fragments) {
490 Optional<ScopeRecorder> scopeRecorder; 506 Optional<ScopeRecorder> scopeRecorder;
491 if (needsScope) 507 if (needsScope)
492 scopeRecorder.emplace(context); 508 scopeRecorder.emplace(context);
493 Optional<LayerClipRecorder> clipRecorder; 509 Optional<LayerClipRecorder> clipRecorder;
494 if (parentLayer) { 510 if (parentLayer) {
495 ClipRect clipRectForFragment(ancestorBackgroundClipRect); 511 ClipRect clipRectForFragment(ancestorBackgroundClipRect);
496 clipRectForFragment.moveBy(fragment.paginationOffset); 512 // A fixed-position object is repeated on every page, but if it is c lipped by an ancestor layer then
513 // the repetitions are clipped out.
514 if (!isFixedPosObjectInPagedMedia)
515 clipRectForFragment.moveBy(fragment.paginationOffset);
497 clipRectForFragment.intersect(fragment.backgroundRect); 516 clipRectForFragment.intersect(fragment.backgroundRect);
498 if (clipRectForFragment.isEmpty()) 517 if (clipRectForFragment.isEmpty())
499 continue; 518 continue;
500 if (needsToClip(paintingInfo, clipRectForFragment)) { 519 if (needsToClip(paintingInfo, clipRectForFragment)) {
501 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr agment.isClippedByClipCss()) 520 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr agment.isClippedByClipCss())
502 UseCounter::count(m_paintLayer.layoutObject()->document(), U seCounter::ClipCssOfPositionedElement); 521 UseCounter::count(m_paintLayer.layoutObject()->document(), U seCounter::ClipCssOfPositionedElement);
503 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp layItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginatio nOffset, paintFlags); 522 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp layItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginatio nOffset, paintFlags);
504 } 523 }
505 } 524 }
506 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset) == MayBeClippedByPaintDirtyRect) 525 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset) == MayBeClippedByPaintDirtyRect)
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 793 if (!m_paintLayer.containsDirtyOverlayScrollbars())
775 return; 794 return;
776 795
777 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); 796 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize());
778 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 797 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
779 798
780 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 799 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
781 } 800 }
782 801
783 } // namespace blink 802 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/printing/fixed-positioned-headers-and-footers-larger-than-page-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698