Commit 4809cce0 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[SPv175] Fix printing of subframe and when the frame is scrolled

Set correct property tree state for frame printing.

Skips frame scroll translation because we always print from the origin of
the frame which initiated printing.

We don't need to skip LayoutView scroll translation with RLS because we
print in the LayoutView's container space.

Bug: 808219
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I7d605b7f5e79156829ba861a0a27b8c844892157
Reviewed-on: https://chromium-review.googlesource.com/894486
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533950}
parent 6d10aad7
......@@ -97,8 +97,6 @@ crbug.com/771643 external/wpt/css/css-backgrounds/background-attachment-local/at
crbug.com/771643 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-image-5.html [ Failure ]
# This will pass with --root-layer-scrolls.
crbug.com/771643 scrollbars/custom-scrollbars-paint-outside-iframe.html [ Failure ]
# Others.
crbug.com/771643 virtual/threaded/printing/fixed-positioned-scrolled.html [ Failure ]
# Difficult ancestor clip mask issue.
crbug.com/771643 virtual/prefer_compositing_to_lcd_text/compositing/overflow/nested-border-radius-clipping.html [ Failure ]
......@@ -109,4 +107,4 @@ crbug.com/711468 fast/frames/frame-set-scaling-rotate.html [ Failure ]
crbug.com/711468 fast/frames/frame-set-scaling-skew.html [ Failure ]
crbug.com/711468 fast/sub-pixel/should-not-repaint-subpixel-composited-layer.html [ Failure ]
crbug.com/711468 plugins/webview-plugin-nested-iframe-scroll.html [ Failure ]
crbug.com/711468 svg/hixie/perf/007.xml [ Failure ]
\ No newline at end of file
crbug.com/711468 svg/hixie/perf/007.xml [ Failure ]
......@@ -194,6 +194,7 @@
#include "platform/graphics/paint/ClipRecorder.h"
#include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/PaintRecordBuilder.h"
#include "platform/graphics/paint/ScopedPaintChunkProperties.h"
#include "platform/graphics/skia/SkiaUtils.h"
#include "platform/heap/Handle.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
......@@ -386,16 +387,38 @@ class ChromePrintContext : public PrintContext {
context.ConcatCTM(transform);
context.ClipRect(page_rect);
auto* frame_view = GetFrame()->View();
DCHECK(frame_view);
PropertyTreeState property_tree_state = PropertyTreeState::Root();
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) {
property_tree_state = *frame_view->GetLayoutView()
->FirstFragment()
.LocalBorderBoxProperties();
} else {
property_tree_state = frame_view->PreContentClipProperties();
}
}
PaintRecordBuilder builder(&context.Canvas()->getMetaData(), &context);
GetFrame()->View()->PaintContents(builder.Context(),
kGlobalPaintNormalPhase, page_rect);
frame_view->PaintContents(builder.Context(), kGlobalPaintNormalPhase,
page_rect);
{
Optional<ScopedPaintChunkProperties> scoped_paint_chunk_properties;
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
scoped_paint_chunk_properties.emplace(
builder.Context().GetPaintController(), property_tree_state,
builder, DisplayItem::kPrintedContentDestinationLocations);
}
DrawingRecorder line_boundary_recorder(
builder.Context(), builder,
DisplayItem::kPrintedContentDestinationLocations);
OutputLinkedDestinations(builder.Context(), page_rect);
}
context.DrawRecord(builder.EndRecording());
context.DrawRecord(builder.EndRecording(property_tree_state));
context.Restore();
......
......@@ -48,22 +48,28 @@ PaintPropertyTreeBuilderFragmentContext::
ScrollPaintPropertyNode::Root();
}
static bool NeedsFrameContentClip(const LocalFrame& frame) {
// Returns true if we are printing which was initiated by the frame. We should
// ignore clipping and scroll transform on contents. WebLocalFrameImpl will
// issue artificial page clip for each page, and always print from the origin
// of the contents for which no scroll offset should be applied.
static bool IsPrintingRootFrame(const LocalFrame& frame) {
if (!frame.GetDocument()->Printing())
return true;
return false;
// Don't issue frame content clip the frame is the root frame of printing.
// WebLocalFrameImpl will issue artificial page clip for each page instead.
const auto* parent_frame = frame.Tree().Parent();
if (!parent_frame)
return false;
return true;
// TODO(crbug.com/455764): The local frame may be not the root frame of
// printing when it's printing under a remote frame.
if (!parent_frame->IsLocalFrame())
return false;
return true;
// If the parent frame is printing, this frame should clip normally.
return ToLocalFrame(parent_frame)->GetDocument()->Printing();
return !ToLocalFrame(parent_frame)->GetDocument()->Printing();
}
static bool IsPrintingRootLayoutView(const LayoutObject& object) {
return object.IsLayoutView() && IsPrintingRootFrame(*object.GetFrame());
}
// True if a new property was created, false if an existing one was updated.
......@@ -210,15 +216,17 @@ void FrameViewPaintPropertyTreeBuilder::Update(
bool property_added_or_removed = UpdatePreTranslation(
frame_view, context.current.transform, frame_translate, FloatPoint3D());
bool is_printing_root = IsPrintingRootFrame(frame_view.GetFrame());
FloatRoundedRect content_clip(
NeedsFrameContentClip(frame_view.GetFrame())
? IntRect(IntPoint(), frame_view.VisibleContentSize())
: LayoutRect::InfiniteIntRect());
is_printing_root
? LayoutRect::InfiniteIntRect()
: IntRect(IntPoint(), frame_view.VisibleContentSize()));
property_added_or_removed |= UpdateContentClip(
frame_view, context.current.clip, frame_view.PreTranslation(),
content_clip, full_context.clip_changed);
if (frame_view.IsScrollable()) {
if (!is_printing_root && frame_view.IsScrollable()) {
property_added_or_removed |= UpdateScroll(frame_view, context);
} else if (frame_view.ScrollNode()) {
// Ensure pre-existing properties are cleared if there is no scrolling.
......@@ -229,7 +237,8 @@ void FrameViewPaintPropertyTreeBuilder::Update(
// A scroll translation node is created for static offset (e.g., overflow
// hidden with scroll offset) or cases that scroll and have a scroll node.
ScrollOffset scroll_offset = frame_view.GetScrollOffset();
if (frame_view.IsScrollable() || !scroll_offset.IsZero()) {
if (!is_printing_root &&
(frame_view.IsScrollable() || !scroll_offset.IsZero())) {
TransformationMatrix frame_scroll;
frame_scroll.Translate(-scroll_offset.Width(), -scroll_offset.Height());
property_added_or_removed |=
......@@ -925,8 +934,7 @@ static bool NeedsOverflowClip(const LayoutObject& object) {
return true;
return object.IsBox() && ToLayoutBox(object).ShouldClipOverflow() &&
(!object.IsLayoutView() ||
NeedsFrameContentClip(*ToLayoutView(object).GetFrame()));
!IsPrintingRootLayoutView(object);
}
static bool NeedsOverflowControlsClip(const LayoutObject& object) {
......
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