Commit 37254d58 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[rm-for-spv175] Remove old table header/footer and fixed-pos repeating code

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ic7258e4b4e03988344412e2e15893ea30f68ae38
Reviewed-on: https://chromium-review.googlesource.com/1112939Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570097}
parent 5ec1b0db
......@@ -495,17 +495,6 @@ PaintResult PaintLayerPainter::PaintLayerContents(
kIgnorePlatformOverlayScrollbarSize, respect_overflow_clip,
&offset_from_root, local_painting_info.sub_pixel_accumulation);
layer_fragments[0].fragment_data = fragment->fragment_data;
} else if (!RuntimeEnabledFeatures::SlimmingPaintV175Enabled() &&
paint_layer_.GetLayoutObject()
.IsFixedPositionObjectInPagedMedia()) {
PaintLayerFragments single_fragment;
paint_layer_for_fragments->AppendSingleFragmentIgnoringPagination(
single_fragment, local_painting_info.root_layer,
&local_painting_info.paint_dirty_rect,
kIgnorePlatformOverlayScrollbarSize, respect_overflow_clip,
&offset_from_root, local_painting_info.sub_pixel_accumulation);
RepeatFixedPositionObjectInPages(single_fragment[0], painting_info,
layer_fragments);
} else {
paint_layer_for_fragments->CollectFragments(
layer_fragments, local_painting_info.root_layer,
......@@ -725,35 +714,6 @@ bool PaintLayerPainter::AtLeastOneFragmentIntersectsDamageRect(
return false;
}
void PaintLayerPainter::RepeatFixedPositionObjectInPages(
const PaintLayerFragment& single_fragment_ignored_pagination,
const PaintLayerPaintingInfo& painting_info,
PaintLayerFragments& layer_fragments) {
DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV175Enabled());
DCHECK(paint_layer_.GetLayoutObject().IsFixedPositionObjectInPagedMedia());
LayoutView* view = paint_layer_.GetLayoutObject().View();
unsigned pages =
ceilf(view->DocumentRect().Height() / view->PageLogicalHeight());
// The fixed position object is offset from the top of the page, so remove
// any scroll offset.
LayoutPoint offset_from_root;
paint_layer_.ConvertToLayerCoords(painting_info.root_layer, offset_from_root);
LayoutSize offset_adjustment = paint_layer_.Location() - offset_from_root;
layer_fragments.push_back(single_fragment_ignored_pagination);
layer_fragments[0].pagination_offset += offset_adjustment;
layer_fragments[0].layer_bounds.Move(offset_adjustment);
LayoutPoint page_offset(LayoutUnit(), view->PageLogicalHeight());
for (unsigned i = 1; i < pages; i++) {
PaintLayerFragment fragment = layer_fragments[i - 1];
fragment.pagination_offset += page_offset;
fragment.layer_bounds.MoveBy(page_offset);
layer_fragments.push_back(fragment);
}
}
template <typename Function>
static void ForAllFragments(GraphicsContext& context,
const PaintLayerFragments& fragments,
......@@ -783,9 +743,6 @@ PaintResult PaintLayerPainter::PaintLayerWithAdjustedRoot(
PaintResult result = kFullyPainted;
PaintLayerFragments layer_fragments;
bool is_fixed_position_object_in_paged_media =
!RuntimeEnabledFeatures::SlimmingPaintV175Enabled() &&
paint_layer_.GetLayoutObject().IsFixedPositionObjectInPagedMedia();
// This works around a bug in squashed-layer painting.
// Squashed layers paint into a backing in its compositing container's
......@@ -796,7 +753,7 @@ PaintResult PaintLayerPainter::PaintLayerWithAdjustedRoot(
// appropriate ancestor clip for us, so we can simply skip it.
bool is_squashed_layer = painting_info.root_layer == &paint_layer_;
if (is_squashed_layer || is_fixed_position_object_in_paged_media) {
if (is_squashed_layer) {
// We don't need to collect any fragments in the regular way here. We have
// already calculated a clip rectangle for the ancestry if it was needed,
// and clipping this layer is something that can be done further down the
......@@ -804,12 +761,7 @@ PaintResult PaintLayerPainter::PaintLayerWithAdjustedRoot(
PaintLayerFragment fragment;
fragment.background_rect = painting_info.paint_dirty_rect;
fragment.fragment_data = &paint_layer_.GetLayoutObject().FirstFragment();
if (is_fixed_position_object_in_paged_media) {
RepeatFixedPositionObjectInPages(fragment, painting_info,
layer_fragments);
} else {
layer_fragments.push_back(fragment);
}
layer_fragments.push_back(fragment);
} else if (parent_layer) {
ShouldRespectOverflowClipType respect_overflow_clip =
ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject());
......
......@@ -65,16 +65,6 @@ class CORE_EXPORT PaintLayerPainter {
bool ShouldAdjustPaintingRoot(const PaintLayerPaintingInfo& painting_info,
PaintLayerFlags paint_flags);
// "For paged media, boxes with fixed positions are repeated on every page."
// https://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#fixed-positioning
// Repeats singleFragmentIgnoredPagination of the fixed-position object in
// each page, with paginationOffset and layerBounds adjusted for each page.
// TODO(wangxianzhu): Fold this into PaintLayer::collectFragments().
void RepeatFixedPositionObjectInPages(
const PaintLayerFragment& single_fragment_ignored_pagination,
const PaintLayerPaintingInfo&,
PaintLayerFragments&);
PaintResult PaintLayerContentsCompositingAllPhases(
GraphicsContext&,
const PaintLayerPaintingInfo&,
......
......@@ -23,192 +23,34 @@
namespace blink {
void TableSectionPainter::PaintRepeatingHeaderGroup(
const PaintInfo& paint_info,
const LayoutPoint& paint_offset,
ItemToPaint item_to_paint) {
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled())
return;
if (!layout_table_section_.IsRepeatingHeaderGroup())
return;
LayoutTable* table = layout_table_section_.Table();
// TODO(crbug.com/757947): This shouldn't be possible but happens to
// column-spanners in nested multi-col contexts.
if (!table->IsPageLogicalHeightKnown())
return;
// We may paint the header multiple times so can't uniquely identify each
// display item.
DisplayItemCacheSkipper cache_skipper(paint_info.context);
LayoutPoint pagination_offset = paint_offset;
LayoutUnit page_height = table->PageLogicalHeightForOffset(LayoutUnit());
LayoutUnit header_group_offset = table->BlockOffsetToFirstRepeatableHeader();
// The header may have a pagination strut before it so we need to account for
// that when establishing its position.
LayoutUnit strut_on_first_row;
if (LayoutTableRow* row = layout_table_section_.FirstRow())
strut_on_first_row = row->PaginationStrut();
header_group_offset += strut_on_first_row;
LayoutUnit offset_to_next_page =
page_height - IntMod(header_group_offset, page_height);
// Move pagination_offset to the top of the next page.
pagination_offset.Move(LayoutUnit(), offset_to_next_page);
// Now move pagination_offset to the top of the page the cull rect starts on.
if (paint_info.GetCullRect().rect_.Y() > pagination_offset.Y()) {
pagination_offset.Move(LayoutUnit(),
page_height * ((paint_info.GetCullRect().rect_.Y() -
pagination_offset.Y()) /
page_height)
.ToInt());
}
// We only want to consider pages where we going to paint a row, so exclude
// captions and border spacing from the table.
LayoutRect sections_rect(LayoutPoint(), table->Size());
table->SubtractCaptionRect(sections_rect);
LayoutUnit total_height_of_rows =
sections_rect.Height() - table->VBorderSpacing();
LayoutUnit bottom_bound =
std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()),
paint_offset.Y() + total_height_of_rows);
while (pagination_offset.Y() < bottom_bound) {
LayoutPoint nested_offset = pagination_offset;
LayoutUnit height_of_previous_headers =
table->RowOffsetFromRepeatingHeader() -
layout_table_section_.LogicalHeight() + strut_on_first_row;
nested_offset.Move(LayoutUnit(), height_of_previous_headers);
if (item_to_paint == kPaintCollapsedBorders) {
PaintCollapsedSectionBorders(paint_info, nested_offset);
} else {
PaintSection(paint_info, nested_offset);
}
pagination_offset.Move(0, page_height.ToInt());
}
}
void TableSectionPainter::PaintRepeatingFooterGroup(
const PaintInfo& paint_info,
const LayoutPoint& paint_offset,
ItemToPaint item_to_paint) {
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled())
return;
if (!layout_table_section_.IsRepeatingFooterGroup())
return;
// Work out the top position of the table so we can decide
// which page to paint the first footer on.
LayoutTable* table = layout_table_section_.Table();
// TODO(crbug.com/757947): This shouldn't be possible but happens to
// column-spanners in nested multi-col contexts.
if (!table->IsPageLogicalHeightKnown())
return;
// We may paint the footer multiple times so can't uniquely identify each
// display item.
DisplayItemCacheSkipper cache_skipper(paint_info.context);
LayoutRect sections_rect(LayoutPoint(), table->Size());
table->SubtractCaptionRect(sections_rect);
LayoutUnit page_height = table->PageLogicalHeightForOffset(LayoutUnit());
LayoutUnit height_of_previous_footers = table->RowOffsetFromRepeatingFooter();
LayoutUnit offset_for_footer = page_height - height_of_previous_footers;
// TODO: Accounting for the border-spacing here is wrong.
LayoutUnit header_group_offset =
table->BlockOffsetToFirstRepeatableHeader() + table->VBorderSpacing();
// The first row in the table may have a pagination strut before it so we need
// to account for that when establishing its position.
LayoutUnit strut_on_first_row;
LayoutTableSection* top_section = table->TopSection();
if (top_section) {
if (LayoutTableRow* row = top_section->FirstRow())
strut_on_first_row = row->PaginationStrut();
}
header_group_offset += strut_on_first_row;
LayoutUnit total_height_of_rows =
sections_rect.Height() + IntMod(header_group_offset, page_height);
LayoutUnit first_row_strut =
layout_table_section_.FirstRow()
? layout_table_section_.FirstRow()->PaginationStrut()
: LayoutUnit();
total_height_of_rows -=
layout_table_section_.LogicalHeight() - first_row_strut;
// Move the offset to the top of the page the table starts on.
LayoutPoint pagination_offset = paint_offset;
pagination_offset.Move(LayoutUnit(), -total_height_of_rows);
// Paint up to the last page that needs painting.
LayoutUnit bottom_bound =
std::min(LayoutUnit(paint_info.GetCullRect().rect_.MaxY()),
pagination_offset.Y() + total_height_of_rows - page_height);
// If the first row in the table would overlap with the footer on the first
// page then don't repeat the footer there.
if (top_section && top_section->FirstRow() &&
IntMod(header_group_offset, page_height) +
top_section->FirstRow()->LogicalHeight() >
offset_for_footer) {
pagination_offset.Move(LayoutUnit(), page_height);
}
// Paint a footer on each page from first to next-to-last.
while (pagination_offset.Y() < bottom_bound) {
LayoutPoint nested_offset = pagination_offset;
nested_offset.Move(LayoutUnit(), offset_for_footer);
if (item_to_paint == kPaintCollapsedBorders) {
PaintCollapsedSectionBorders(paint_info, nested_offset);
} else {
PaintSection(paint_info, nested_offset);
}
pagination_offset.Move(0, page_height.ToInt());
}
}
void TableSectionPainter::Paint(const PaintInfo& paint_info,
const LayoutPoint& paint_offset) {
// TODO(crbug.com/805514): Paint mask for table section.
if (paint_info.phase == PaintPhase::kMask)
return;
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
// If the section has multiple fragments, it should repeatedly paint the
// fragments by itself if:
// - It's not a self-painting layer (otherwise PaintLayerPainter should
// initiate painting of the multiple fragments);
// - the table doesn't have multiple fragments (otherwise the table's
// containing painting layer should initiate painting of the fragments).
bool should_paint_fragments_by_itself =
layout_table_section_.FirstFragment().NextFragment() &&
!layout_table_section_.HasSelfPaintingLayer() &&
!layout_table_section_.Table()->FirstFragment().NextFragment();
if (!should_paint_fragments_by_itself) {
PaintSection(paint_info, paint_offset);
return;
}
for (const auto* fragment = &layout_table_section_.FirstFragment();
fragment; fragment = fragment->NextFragment()) {
PaintInfo fragment_paint_info = paint_info;
fragment_paint_info.SetFragmentLogicalTopInFlowThread(
fragment->LogicalTopInFlowThread());
PaintSection(fragment_paint_info, paint_offset);
}
// If the section has multiple fragments, it should repeatedly paint the
// fragments by itself if:
// - It's not a self-painting layer (otherwise PaintLayerPainter should
// initiate painting of the multiple fragments);
// - the table doesn't have multiple fragments (otherwise the table's
// containing painting layer should initiate painting of the fragments).
bool should_paint_fragments_by_itself =
layout_table_section_.FirstFragment().NextFragment() &&
!layout_table_section_.HasSelfPaintingLayer() &&
!layout_table_section_.Table()->FirstFragment().NextFragment();
if (!should_paint_fragments_by_itself) {
PaintSection(paint_info, paint_offset);
return;
}
PaintSection(paint_info, paint_offset);
LayoutTable* table = layout_table_section_.Table();
if (table->Header() == layout_table_section_) {
PaintRepeatingHeaderGroup(paint_info, paint_offset, kPaintSection);
} else if (table->Footer() == layout_table_section_) {
PaintRepeatingFooterGroup(paint_info, paint_offset, kPaintSection);
for (const auto* fragment = &layout_table_section_.FirstFragment(); fragment;
fragment = fragment->NextFragment()) {
PaintInfo fragment_paint_info = paint_info;
fragment_paint_info.SetFragmentLogicalTopInFlowThread(
fragment->LogicalTopInFlowThread());
PaintSection(fragment_paint_info, paint_offset);
}
}
......@@ -248,38 +90,27 @@ void TableSectionPainter::PaintSection(const PaintInfo& paint_info,
void TableSectionPainter::PaintCollapsedBorders(
const PaintInfo& paint_info,
const LayoutPoint& paint_offset) {
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
// If the section has multiple fragments, it should repeatedly paint the
// fragments for collapsed borders by itself if the table doesn't have
// multiple fragments (otherwise the table's containing painting layer
// should initiate painting of the fragments). The condition here is
// different from that in Paint() because the table always initiate painting
// of collapsed borders regardless of self-painting status of the section.
bool should_paint_fragments_by_itself =
layout_table_section_.FirstFragment().NextFragment() &&
!layout_table_section_.Table()->FirstFragment().NextFragment();
if (!should_paint_fragments_by_itself) {
PaintCollapsedSectionBorders(paint_info, paint_offset);
return;
}
for (const auto* fragment = &layout_table_section_.FirstFragment();
fragment; fragment = fragment->NextFragment()) {
PaintInfo fragment_paint_info = paint_info;
fragment_paint_info.SetFragmentLogicalTopInFlowThread(
fragment->LogicalTopInFlowThread());
PaintCollapsedSectionBorders(fragment_paint_info, paint_offset);
}
// If the section has multiple fragments, it should repeatedly paint the
// fragments for collapsed borders by itself if the table doesn't have
// multiple fragments (otherwise the table's containing painting layer
// should initiate painting of the fragments). The condition here is
// different from that in Paint() because the table always initiate painting
// of collapsed borders regardless of self-painting status of the section.
bool should_paint_fragments_by_itself =
layout_table_section_.FirstFragment().NextFragment() &&
!layout_table_section_.Table()->FirstFragment().NextFragment();
if (!should_paint_fragments_by_itself) {
PaintCollapsedSectionBorders(paint_info, paint_offset);
return;
}
PaintCollapsedSectionBorders(paint_info, paint_offset);
LayoutTable* table = layout_table_section_.Table();
if (table->Header() == layout_table_section_) {
PaintRepeatingHeaderGroup(paint_info, paint_offset, kPaintCollapsedBorders);
} else if (table->Footer() == layout_table_section_) {
PaintRepeatingFooterGroup(paint_info, paint_offset, kPaintCollapsedBorders);
for (const auto* fragment = &layout_table_section_.FirstFragment(); fragment;
fragment = fragment->NextFragment()) {
PaintInfo fragment_paint_info = paint_info;
fragment_paint_info.SetFragmentLogicalTopInFlowThread(
fragment->LogicalTopInFlowThread());
PaintCollapsedSectionBorders(fragment_paint_info, paint_offset);
}
}
......
......@@ -39,13 +39,6 @@ class TableSectionPainter {
const LayoutPoint&);
void PaintCell(const LayoutTableCell&, const PaintInfo&, const LayoutPoint&);
enum ItemToPaint { kPaintCollapsedBorders, kPaintSection };
void PaintRepeatingHeaderGroup(const PaintInfo&,
const LayoutPoint&,
ItemToPaint);
void PaintRepeatingFooterGroup(const PaintInfo&,
const LayoutPoint&,
ItemToPaint);
void PaintSection(const PaintInfo&, const LayoutPoint&);
void PaintCollapsedSectionBorders(const PaintInfo&, const LayoutPoint&);
......
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