Commit e8bad1ec authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CompositeAfterPaint] Fix cull rect in printing

Change-Id: If25a2df97a3bf5a322c02d650eb5aaeff86f7722
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2258423Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781356}
parent 1ac62546
...@@ -233,12 +233,6 @@ void PaintLayerPainter::AdjustForPaintProperties( ...@@ -233,12 +233,6 @@ void PaintLayerPainter::AdjustForPaintProperties(
painting_info.root_layer->GetLayoutObject().FirstFragment(); painting_info.root_layer->GetLayoutObject().FirstFragment();
const auto* source_transform = const auto* source_transform =
&first_root_fragment.LocalBorderBoxProperties().Transform(); &first_root_fragment.LocalBorderBoxProperties().Transform();
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() &&
IsMainFrameNotClippingContents(*painting_info.root_layer)) {
// Use PostScrollTranslation as the source transform to avoid clipping of
// the scrolling contents in CullRect::ApplyTransforms().
source_transform = &first_root_fragment.PostScrollTranslation();
}
const auto& destination_transform = const auto& destination_transform =
first_fragment.LocalBorderBoxProperties().Transform(); first_fragment.LocalBorderBoxProperties().Transform();
if (source_transform == &destination_transform) if (source_transform == &destination_transform)
...@@ -255,14 +249,18 @@ void PaintLayerPainter::AdjustForPaintProperties( ...@@ -255,14 +249,18 @@ void PaintLayerPainter::AdjustForPaintProperties(
// Convert old_cull_rect into the layer's transform space. // Convert old_cull_rect into the layer's transform space.
old_cull_rect->MoveBy(RoundedIntPoint(first_fragment.PaintOffset())); old_cull_rect->MoveBy(RoundedIntPoint(first_fragment.PaintOffset()));
} }
if (paint_flags & kPaintLayerPaintingOverflowContents) {
// Don't clip to the view scrolling container when printing because we // Use PostScrollTranslation as the source transform to avoid clipping
// need to print the whole document. // of the scrolling contents in CullRect::ApplyTransforms().
bool clip_to_scroll_container = source_transform = &first_root_fragment.PostScrollTranslation();
!(context.Printing() && // Map cull_rect into scrolling contents space (i.e. source_transform).
(paint_flags & kPaintLayerPaintingOverflowContents)); if (const auto* properties = first_root_fragment.PaintProperties()) {
if (const auto* scroll_translation = properties->ScrollTranslation())
cull_rect.Move(-scroll_translation->Translation2D());
}
}
cull_rect.ApplyTransforms(*source_transform, destination_transform, cull_rect.ApplyTransforms(*source_transform, destination_transform,
old_cull_rect, clip_to_scroll_container); old_cull_rect);
// Convert cull_rect from the layer's transform space to the layer's local // Convert cull_rect from the layer's transform space to the layer's local
// space. // space.
cull_rect.MoveBy(-RoundedIntPoint(first_fragment.PaintOffset())); cull_rect.MoveBy(-RoundedIntPoint(first_fragment.PaintOffset()));
......
...@@ -51,6 +51,15 @@ void CullRect::Move(const IntSize& offset) { ...@@ -51,6 +51,15 @@ void CullRect::Move(const IntSize& offset) {
rect_.Move(offset); rect_.Move(offset);
} }
void CullRect::Move(const FloatSize& offset) {
if (IsInfinite())
return;
FloatRect float_rect(rect_);
float_rect.Move(offset);
rect_ = EnclosingIntRect(float_rect);
}
static void MapRect(const TransformPaintPropertyNode& transform, static void MapRect(const TransformPaintPropertyNode& transform,
IntRect& rect) { IntRect& rect) {
if (transform.IsIdentityOr2DTranslation()) { if (transform.IsIdentityOr2DTranslation()) {
...@@ -63,15 +72,12 @@ static void MapRect(const TransformPaintPropertyNode& transform, ...@@ -63,15 +72,12 @@ static void MapRect(const TransformPaintPropertyNode& transform,
} }
CullRect::ApplyTransformResult CullRect::ApplyTransformInternal( CullRect::ApplyTransformResult CullRect::ApplyTransformInternal(
const TransformPaintPropertyNode& transform, const TransformPaintPropertyNode& transform) {
bool clip_to_scroll_container) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
if (const auto* scroll = transform.ScrollNode()) { if (const auto* scroll = transform.ScrollNode()) {
if (clip_to_scroll_container) {
rect_.Intersect(scroll->ContainerRect()); rect_.Intersect(scroll->ContainerRect());
if (rect_.IsEmpty()) if (rect_.IsEmpty())
return kNotExpanded; return kNotExpanded;
}
MapRect(transform, rect_); MapRect(transform, rect_);
...@@ -103,8 +109,7 @@ CullRect::ApplyTransformResult CullRect::ApplyTransformInternal( ...@@ -103,8 +109,7 @@ CullRect::ApplyTransformResult CullRect::ApplyTransformInternal(
void CullRect::ApplyTransforms(const TransformPaintPropertyNode& source, void CullRect::ApplyTransforms(const TransformPaintPropertyNode& source,
const TransformPaintPropertyNode& destination, const TransformPaintPropertyNode& destination,
const base::Optional<CullRect>& old_cull_rect, const base::Optional<CullRect>& old_cull_rect) {
bool clip_to_scroll_container) {
DCHECK(RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); DCHECK(RuntimeEnabledFeatures::CompositeAfterPaintEnabled());
Vector<const TransformPaintPropertyNode*> scroll_translations; Vector<const TransformPaintPropertyNode*> scroll_translations;
...@@ -130,7 +135,7 @@ void CullRect::ApplyTransforms(const TransformPaintPropertyNode& source, ...@@ -130,7 +135,7 @@ void CullRect::ApplyTransforms(const TransformPaintPropertyNode& source,
*last_transform, *scroll_translation->Parent(), rect_); *last_transform, *scroll_translation->Parent(), rect_);
} }
last_scroll_translation_result = last_scroll_translation_result =
ApplyTransformInternal(*scroll_translation, clip_to_scroll_container); ApplyTransformInternal(*scroll_translation);
last_transform = scroll_translation; last_transform = scroll_translation;
} }
......
...@@ -40,13 +40,13 @@ class PLATFORM_EXPORT CullRect { ...@@ -40,13 +40,13 @@ class PLATFORM_EXPORT CullRect {
void MoveBy(const IntPoint& offset); void MoveBy(const IntPoint& offset);
void Move(const IntSize& offset); void Move(const IntSize& offset);
void Move(const FloatSize& offset);
// Applies one transform to the cull rect. Before this function is called, // Applies one transform to the cull rect. Before this function is called,
// the cull rect is in the space of the parent the transform node. // the cull rect is in the space of the parent the transform node.
// For CompositeAfterPaint, when the transform is a scroll translation, the // For CompositeAfterPaint, when the transform is a scroll translation, the
// cull rect is converted in the following steps: // cull rect is converted in the following steps:
// 1. it's clipped by the container rect if |clip_to_scroll_container| is // 1. it's clipped by the container rect,
// true,
// 2. transformed by inverse of the scroll translation, // 2. transformed by inverse of the scroll translation,
// 3. expanded by thousands of pixels for composited scrolling. // 3. expanded by thousands of pixels for composited scrolling.
void ApplyTransform(const TransformPaintPropertyNode& transform) { void ApplyTransform(const TransformPaintPropertyNode& transform) {
...@@ -62,8 +62,7 @@ class PLATFORM_EXPORT CullRect { ...@@ -62,8 +62,7 @@ class PLATFORM_EXPORT CullRect {
// will be set to |old_cull_rect| to avoid repaint on each composited scroll. // will be set to |old_cull_rect| to avoid repaint on each composited scroll.
void ApplyTransforms(const TransformPaintPropertyNode& source, void ApplyTransforms(const TransformPaintPropertyNode& source,
const TransformPaintPropertyNode& destination, const TransformPaintPropertyNode& destination,
const base::Optional<CullRect>& old_cull_rect, const base::Optional<CullRect>& old_cull_rect);
bool clip_to_scroll_container = true);
const IntRect& Rect() const { return rect_; } const IntRect& Rect() const { return rect_; }
...@@ -86,8 +85,7 @@ class PLATFORM_EXPORT CullRect { ...@@ -86,8 +85,7 @@ class PLATFORM_EXPORT CullRect {
kExpandedForPartialScrollingContents, kExpandedForPartialScrollingContents,
}; };
ApplyTransformResult ApplyTransformInternal( ApplyTransformResult ApplyTransformInternal(
const TransformPaintPropertyNode&, const TransformPaintPropertyNode&);
bool clip_to_scroll_container = true);
bool ChangedEnough(const CullRect& old_cull_rect) const; bool ChangedEnough(const CullRect& old_cull_rect) const;
......
...@@ -48,9 +48,6 @@ crbug.com/957674 virtual/scalefactor200/external/wpt/largest-contentful-paint/in ...@@ -48,9 +48,6 @@ crbug.com/957674 virtual/scalefactor200/external/wpt/largest-contentful-paint/in
external/wpt/css/css-transforms/transform3d-backface-visibility-006.html [ Failure ] external/wpt/css/css-transforms/transform3d-backface-visibility-006.html [ Failure ]
printing/fixed-positioned-headers-and-footers-absolute-covering-some-pages.html [ Failure ]
printing/fixed-positioned-headers-and-footers-larger-than-page.html [ Failure ]
transforms/3d/general/background-visibility-layers.html [ Failure ] transforms/3d/general/background-visibility-layers.html [ Failure ]
# Raster invalidation doesn't work for huge layers. # Raster invalidation doesn't work for huge layers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment