Commit 80b2218c authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

[PaintTouchActionRects] Support scrolling LayoutView touch action rects

This patch is a followup to [1] and paints the LayoutView hit test
rects into the scrolling contents layer, like the background does. This
improves performance because the hit test rect does not need to be
repainted on every scroll change.

With this patch we no longer regress raster in the rendering.desktop
touch_handler_scrolling benchmark.

[1] https://crrev.com/603335

Bug: 888269
Change-Id: I27864ed6d612c26f2258b60805778b2c6f894d62
Reviewed-on: https://chromium-review.googlesource.com/c/1303868
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarXianda Sun <sunxd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604342}
parent d02c1ea9
This tests verifies the hit test regions given to the compositor in the simple case where touch handles cover (or nearly cover) the entire document. It can only be run in DumpRenderTree.
document: #document scrolling (0, 0, 800, 600)
document: #document scrolling (0, 600, 785, 1400)
document: #document scrolling (0, 0, 785, 2000)
html: #document scrolling (0, 0, 785, 2000)
......
......@@ -330,7 +330,9 @@ TEST_F(BlockPainterTestWithPaintTouchAction, TouchActionRectScrollingContents) {
ElementsAre(IsSameId(&scroller->GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient(),
kBackgroundType),
IsSameId(scroller, DisplayItem::kHitTest),
IsSameId(&scroller->GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient(),
DisplayItem::kHitTest),
IsSameId(child, DisplayItem::kHitTest)));
EXPECT_THAT(non_scroller_paint_controller.GetDisplayItemList(),
ElementsAre(IsSameId(&root_client, kDocumentBackgroundType)));
......
......@@ -54,6 +54,7 @@ void BoxPainter::PaintChildren(const PaintInfo& paint_info) {
void BoxPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info,
const LayoutPoint& paint_offset) {
LayoutRect paint_rect;
const DisplayItemClient* background_client = nullptr;
base::Optional<ScopedBoxContentsPaintState> contents_paint_state;
if (BoxModelObjectPainter::
IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
......@@ -70,9 +71,13 @@ void BoxPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info,
// paint_rect so we expand the paint_rect by the border size when painting
// the background into the scrolling contents layer.
paint_rect.Expand(layout_box_.BorderBoxOutsets());
background_client = &layout_box_.GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient();
} else {
paint_rect = layout_box_.BorderBoxRect();
paint_rect.MoveBy(paint_offset);
background_client = &layout_box_;
}
// Paint the background if we're visible and this block has a box decoration
......@@ -83,11 +88,11 @@ void BoxPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info,
PaintBoxDecorationBackgroundWithRect(
contents_paint_state ? contents_paint_state->GetPaintInfo()
: paint_info,
paint_rect);
paint_rect, *background_client);
}
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled())
RecordHitTestData(paint_info, paint_offset, paint_rect);
RecordHitTestData(paint_info, paint_offset, paint_rect, *background_client);
}
bool BoxPainter::BackgroundIsKnownToBeOpaque(const PaintInfo& paint_info) {
......@@ -102,7 +107,8 @@ bool BoxPainter::BackgroundIsKnownToBeOpaque(const PaintInfo& paint_info) {
void BoxPainter::PaintBoxDecorationBackgroundWithRect(
const PaintInfo& paint_info,
const LayoutRect& paint_rect) {
const LayoutRect& paint_rect,
const DisplayItemClient& background_client) {
bool painting_overflow_contents = BoxModelObjectPainter::
IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
&layout_box_, paint_info);
......@@ -121,17 +127,12 @@ void BoxPainter::PaintBoxDecorationBackgroundWithRect(
cache_skipper.emplace(paint_info.context);
}
const DisplayItemClient& display_item_client =
painting_overflow_contents
? layout_box_.GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient()
: layout_box_;
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, display_item_client,
paint_info.context, background_client,
DisplayItem::kBoxDecorationBackground))
return;
DrawingRecorder recorder(paint_info.context, display_item_client,
DrawingRecorder recorder(paint_info.context, background_client,
DisplayItem::kBoxDecorationBackground);
BoxDecorationData box_decoration_data(layout_box_);
GraphicsContextStateSaver state_saver(paint_info.context, false);
......@@ -255,7 +256,8 @@ void BoxPainter::PaintMaskImages(const PaintInfo& paint_info,
void BoxPainter::RecordHitTestData(const PaintInfo& paint_info,
const LayoutPoint& paint_offset,
const LayoutRect& paint_rect) {
const LayoutRect& paint_rect,
const DisplayItemClient& background_client) {
// TODO(sunxd): ReplacedPainter only record hit test data for svg root which
// skips clip. We should move the conditions and ReplacedPainter's
// RecordHitTestData here.
......@@ -275,7 +277,7 @@ void BoxPainter::RecordHitTestData(const PaintInfo& paint_info,
if (touch_action == TouchAction::kTouchActionAuto)
return;
HitTestData::RecordHitTestRect(paint_info.context, layout_box_,
HitTestData::RecordHitTestRect(paint_info.context, background_client,
HitTestRect(paint_rect, touch_action));
}
......
......@@ -15,6 +15,7 @@ namespace blink {
struct PaintInfo;
class Color;
class DisplayItemClient;
class LayoutBox;
class LayoutPoint;
class LayoutRect;
......@@ -32,15 +33,18 @@ class BoxPainter {
void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset);
void PaintMaskImages(const PaintInfo&, const LayoutRect&);
void PaintBoxDecorationBackgroundWithRect(const PaintInfo&,
const LayoutRect&);
void PaintBoxDecorationBackgroundWithRect(
const PaintInfo&,
const LayoutRect&,
const DisplayItemClient& background_client);
// Paint a hit test display item and record hit test data. This should be
// called in the background paint phase even if there is no other painted
// content.
void RecordHitTestData(const PaintInfo&,
const LayoutPoint& paint_offset,
const LayoutRect& paint_rect);
const LayoutRect& paint_rect,
const DisplayItemClient& background_client);
private:
bool BackgroundIsKnownToBeOpaque(const PaintInfo&);
......
......@@ -81,7 +81,8 @@ void FieldsetPainter::PaintBoxDecorationBackground(
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()) {
BoxPainter(layout_fieldset_)
.RecordHitTestData(paint_info, paint_offset, paint_rect);
.RecordHitTestData(paint_info, paint_offset, paint_rect,
layout_fieldset_);
}
}
......
......@@ -120,7 +120,7 @@ void TableCellPainter::PaintBoxDecorationBackground(
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()) {
LayoutRect rect = PaintRectNotIncludingVisualOverflow(paint_offset);
BoxPainter(layout_table_cell_)
.RecordHitTestData(paint_info, paint_offset, rect);
.RecordHitTestData(paint_info, paint_offset, rect, layout_table_cell_);
}
}
......
......@@ -61,11 +61,12 @@ void TablePainter::PaintBoxDecorationBackground(
if (layout_table_.HasBoxDecorationBackground() &&
layout_table_.StyleRef().Visibility() == EVisibility::kVisible) {
BoxPainter(layout_table_)
.PaintBoxDecorationBackgroundWithRect(paint_info, rect);
.PaintBoxDecorationBackgroundWithRect(paint_info, rect, layout_table_);
}
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()) {
BoxPainter(layout_table_).RecordHitTestData(paint_info, paint_offset, rect);
BoxPainter(layout_table_)
.RecordHitTestData(paint_info, paint_offset, rect, layout_table_);
}
}
......
......@@ -32,42 +32,16 @@ void ViewPainter::Paint(const PaintInfo& paint_info) {
}
void ViewPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info) {
PaintBoxDecorationBackgroundInternal(paint_info);
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()) {
BoxPainter(layout_view_)
.RecordHitTestData(paint_info, LayoutPoint(),
layout_view_.BorderBoxRect());
}
}
void ViewPainter::PaintBoxDecorationBackgroundInternal(
const PaintInfo& paint_info) {
// Paint the background if we're visible and this block has a box decoration
// (background, border, appearance, or box shadow).
const ComputedStyle& style = layout_view_.StyleRef();
if (style.Visibility() != EVisibility::kVisible ||
!layout_view_.HasBoxDecorationBackground()) {
if (layout_view_.StyleRef().Visibility() != EVisibility::kVisible)
return;
}
if (paint_info.SkipRootBackground())
bool has_touch_action_rect =
RuntimeEnabledFeatures::PaintTouchActionRectsEnabled() &&
(layout_view_.EffectiveWhitelistedTouchAction() !=
TouchAction::kTouchActionAuto);
if (!layout_view_.HasBoxDecorationBackground() && !has_touch_action_rect)
return;
// This function overrides background painting for the LayoutView.
// View background painting is special in the following ways:
// 1. The view paints background for the root element, the background
// positioning respects the positioning and transformation of the root
// element.
// 2. CSS background-clip is ignored, the background layers always expand to
// cover the whole canvas. None of the stacking context effects (except
// transformation) on the root element affects the background.
// 3. The main frame is also responsible for painting the user-agent-defined
// base background color. Conceptually it should be painted by the embedder
// but painting it here allows culling and pre-blending optimization when
// possible.
GraphicsContext& context = paint_info.context;
// The background rect always includes at least the visible content size.
IntRect background_rect(PixelSnappedIntRect(layout_view_.BackgroundRect()));
......@@ -75,7 +49,7 @@ void ViewPainter::PaintBoxDecorationBackgroundInternal(
if (paint_info.IsPrinting())
background_rect.Unite(layout_view_.DocumentRect());
const DisplayItemClient* display_item_client = &layout_view_;
const DisplayItemClient* background_client = &layout_view_;
base::Optional<ScopedPaintChunkProperties> scoped_scroll_property;
if (BoxModelObjectPainter::
......@@ -88,27 +62,57 @@ void ViewPainter::PaintBoxDecorationBackgroundInternal(
// object_paint_properties.h for details.
document_rect.MoveBy(layout_view_.ScrollOrigin());
background_rect.Unite(document_rect);
display_item_client = &layout_view_.GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient();
background_client = &layout_view_.GetScrollableArea()
->GetScrollingBackgroundDisplayItemClient();
scoped_scroll_property.emplace(
paint_info.context.GetPaintController(),
layout_view_.FirstFragment().ContentsProperties(), *display_item_client,
layout_view_.FirstFragment().ContentsProperties(), *background_client,
DisplayItem::kDocumentBackground);
}
if (layout_view_.HasBoxDecorationBackground()) {
PaintBoxDecorationBackgroundInternal(paint_info, background_rect,
*background_client);
}
if (has_touch_action_rect) {
BoxPainter(layout_view_)
.RecordHitTestData(paint_info, LayoutPoint(),
LayoutRect(background_rect), *background_client);
}
}
// This function handles background painting for the LayoutView.
// View background painting is special in the following ways:
// 1. The view paints background for the root element, the background
// positioning respects the positioning and transformation of the root
// element.
// 2. CSS background-clip is ignored, the background layers always expand to
// cover the whole canvas. None of the stacking context effects (except
// transformation) on the root element affects the background.
// 3. The main frame is also responsible for painting the user-agent-defined
// base background color. Conceptually it should be painted by the embedder
// but painting it here allows culling and pre-blending optimization when
// possible.
void ViewPainter::PaintBoxDecorationBackgroundInternal(
const PaintInfo& paint_info,
const IntRect& background_rect,
const DisplayItemClient& background_client) {
// TODO(pdr): Can this check be removed? It is not hit in any test.
if (paint_info.SkipRootBackground())
return;
GraphicsContext& context = paint_info.context;
if (DrawingRecorder::UseCachedDrawingIfPossible(
context, *display_item_client, DisplayItem::kDocumentBackground))
context, background_client, DisplayItem::kDocumentBackground)) {
return;
}
DrawingRecorder recorder(context, background_client,
DisplayItem::kDocumentBackground);
const Document& document = layout_view_.GetDocument();
const LocalFrameView& frame_view = *layout_view_.GetFrameView();
bool is_main_frame = document.IsInMainFrame();
bool paints_base_background =
is_main_frame && (frame_view.BaseBackgroundColor().Alpha() > 0);
bool should_clear_canvas =
paints_base_background &&
(document.GetSettings() &&
document.GetSettings()->GetShouldClearDocumentBackground());
bool paints_base_background = document.IsInMainFrame() &&
(frame_view.BaseBackgroundColor().Alpha() > 0);
Color base_background_color =
paints_base_background ? frame_view.BaseBackgroundColor() : Color();
Color root_background_color = layout_view_.StyleRef().VisitedDependentColor(
......@@ -117,9 +121,6 @@ void ViewPainter::PaintBoxDecorationBackgroundInternal(
document.documentElement() ? document.documentElement()->GetLayoutObject()
: nullptr;
DrawingRecorder recorder(context, *display_item_client,
DisplayItem::kDocumentBackground);
// Special handling for print economy mode.
bool force_background_to_white =
BoxModelObjectPainter::ShouldForceWhiteBackgroundForPrintEconomy(
......@@ -174,6 +175,10 @@ void ViewPainter::PaintBoxDecorationBackgroundInternal(
}
}
bool should_clear_canvas =
paints_base_background &&
(document.GetSettings() &&
document.GetSettings()->GetShouldClearDocumentBackground());
if (!background_renderable) {
if (base_background_color.Alpha()) {
context.FillRect(
......
......@@ -10,6 +10,8 @@
namespace blink {
struct PaintInfo;
class DisplayItemClient;
class IntRect;
class LayoutView;
class ViewPainter {
......@@ -24,7 +26,10 @@ class ViewPainter {
private:
const LayoutView& layout_view_;
void PaintBoxDecorationBackgroundInternal(const PaintInfo&);
void PaintBoxDecorationBackgroundInternal(
const PaintInfo&,
const IntRect& background_rect,
const DisplayItemClient& background_client);
};
} // namespace blink
......
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/paint/view_painter.h"
#include <gtest/gtest.h>
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h"
#include "third_party/blink/renderer/core/paint/paint_controller_paint_test.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_display_item.h"
......@@ -107,7 +108,7 @@ TEST_P(ViewPainterTest, DocumentBackgroundWithScroll) {
ElementsAre(IsSameId(&ViewScrollingBackgroundClient(),
kDocumentBackgroundType)));
const auto& chunks = RootPaintController().GetPaintArtifact().PaintChunks();
const auto& chunks = RootPaintController().PaintChunks();
EXPECT_EQ(1u, chunks.size());
const auto& chunk = chunks[0];
EXPECT_EQ(&ViewScrollingBackgroundClient(), &chunk.id.client);
......@@ -119,4 +120,127 @@ TEST_P(ViewPainterTest, DocumentBackgroundWithScroll) {
EXPECT_EQ(properties->OverflowClip(), tree_state.Clip());
}
class ViewPainterTestWithPaintTouchAction
: public ViewPainterTest,
private ScopedPaintTouchActionRectsForTest {
public:
ViewPainterTestWithPaintTouchAction()
: ViewPainterTest(), ScopedPaintTouchActionRectsForTest(true) {}
void SetUp() override {
ViewPainterTest::SetUp();
Settings* settings = GetDocument().GetFrame()->GetSettings();
settings->SetPreferCompositingToLCDTextEnabled(true);
}
};
INSTANTIATE_PAINT_TEST_CASE_P(ViewPainterTestWithPaintTouchAction);
TEST_P(ViewPainterTestWithPaintTouchAction, TouchActionRectScrollingContents) {
// TODO(crbug.com/732611): We do not yet draw the background into the
// scrolling contents layer with SPV2.
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled())
return;
SetBodyInnerHTML(R"HTML(
<style>
::-webkit-scrollbar { display: none; }
html {
background: lightblue;
touch-action: none;
}
body {
margin: 0;
}
</style>
<div id='forcescroll' style='width: 0; height: 3000px;'></div>
)HTML");
GetFrame().DomWindow()->scrollBy(0, 100);
GetDocument().View()->UpdateAllLifecyclePhases();
const auto& scrolling_client = ViewScrollingBackgroundClient();
auto scrolling_properties =
GetLayoutView().FirstFragment().ContentsProperties();
HitTestData view_hit_test_data;
view_hit_test_data.touch_action_rects.emplace_back(
LayoutRect(0, 0, 800, 3000));
auto* html =
ToLayoutBlock(GetDocument().documentElement()->GetLayoutObject());
HitTestData html_hit_test_data;
html_hit_test_data.touch_action_rects.emplace_back(
LayoutRect(0, 0, 800, 3000));
html_hit_test_data.touch_action_rects.emplace_back(
LayoutRect(0, 0, 800, 3000));
EXPECT_THAT(
RootPaintController().PaintChunks(),
ElementsAre(
IsPaintChunk(
0, 2, PaintChunk::Id(scrolling_client, kDocumentBackgroundType),
scrolling_properties, view_hit_test_data),
IsPaintChunk(
2, 5,
PaintChunk::Id(*html->Layer(), kNonScrollingBackgroundChunkType),
scrolling_properties, html_hit_test_data)));
}
TEST_P(ViewPainterTestWithPaintTouchAction,
TouchActionRectNonScrollingContents) {
// TODO(crbug.com/732611): We do not yet draw the background into the
// scrolling contents layer with SPV2.
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled())
return;
SetBodyInnerHTML(R"HTML(
<style>
::-webkit-scrollbar { display: none; }
html {
background: radial-gradient(
circle at 100px 100px, blue, transparent 200px) fixed;
touch-action: none;
}
body {
margin: 0;
}
</style>
<div id='forcescroll' style='width: 0; height: 3000px;'></div>
)HTML");
GetFrame().DomWindow()->scrollBy(0, 100);
GetDocument().View()->UpdateAllLifecyclePhases();
auto* view = &GetLayoutView();
auto& non_scrolling_paint_controller = view->GetScrollableArea()
->Layer()
->GraphicsLayerBacking(view)
->GetPaintController();
auto properties = view->FirstFragment().LocalBorderBoxProperties();
HitTestData view_hit_test_data;
view_hit_test_data.touch_action_rects.emplace_back(
LayoutRect(0, 0, 800, 600));
EXPECT_THAT(
non_scrolling_paint_controller.PaintChunks(),
ElementsAre(IsPaintChunk(
0, 2,
PaintChunk::Id(*view->Layer(), kNonScrollingBackgroundChunkType),
properties, view_hit_test_data)));
auto* html =
ToLayoutBlock(GetDocument().documentElement()->GetLayoutObject());
auto scrolling_properties = view->FirstFragment().ContentsProperties();
HitTestData scrolling_hit_test_data;
scrolling_hit_test_data.touch_action_rects.emplace_back(
LayoutRect(0, 0, 800, 3000));
scrolling_hit_test_data.touch_action_rects.emplace_back(
LayoutRect(0, 0, 800, 3000));
EXPECT_THAT(
RootPaintController().PaintChunks(),
ElementsAre(IsPaintChunk(
0, 3,
PaintChunk::Id(*html->Layer(), kNonScrollingBackgroundChunkType),
scrolling_properties, scrolling_hit_test_data)));
}
} // namespace blink
......@@ -7,6 +7,7 @@
#include "base/containers/flat_map.h"
#include "cc/base/region.h"
#include "cc/layers/touch_action_region.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......@@ -34,4 +35,13 @@ LayoutRect HitTestRect::GetBounds(const Vector<HitTestRect>& hit_test_rects) {
return LayoutRect(IntRect(rect));
}
String HitTestRect::ToString() const {
// TODO(pdr): Print the value of |whitelisted_touch_action|.
return rect.ToString();
}
std::ostream& operator<<(std::ostream& os, const HitTestRect& hit_test_rect) {
return os << hit_test_rect.ToString();
}
} // namespace blink
......@@ -40,10 +40,14 @@ struct PLATFORM_EXPORT HitTestRect {
}
bool operator!=(const HitTestRect& rhs) const { return !(*this == rhs); }
String ToString() const;
};
using LayerHitTestRects = WTF::HashMap<const PaintLayer*, Vector<HitTestRect>>;
PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const HitTestRect&);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_HIT_TEST_RECT_H_
......@@ -7,6 +7,8 @@
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/drawing_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......@@ -32,4 +34,56 @@ void HitTestData::RecordHitTestRect(GraphicsContext& context,
chunk.EnsureHitTestData().touch_action_rects.push_back(action);
}
static String HitTestRectsAsString(HitTestRects rects) {
StringBuilder sb;
sb.Append("[");
bool first = true;
for (const auto& rect : rects) {
if (!first)
sb.Append(", ");
first = false;
sb.Append("(");
sb.Append(rect.ToString());
sb.Append(")");
}
sb.Append("]");
return sb.ToString();
}
String HitTestData::ToString() const {
StringBuilder sb;
sb.Append("{");
bool printed_top_level_field = false;
if (!touch_action_rects.IsEmpty()) {
sb.Append("touch_action_rects: ");
sb.Append(HitTestRectsAsString(touch_action_rects));
printed_top_level_field = true;
}
if (!wheel_event_handler_region.IsEmpty()) {
if (printed_top_level_field)
sb.Append(", ");
sb.Append("wheel_event_handler_region: ");
sb.Append(HitTestRectsAsString(wheel_event_handler_region));
printed_top_level_field = true;
}
if (!non_fast_scrollable_region.IsEmpty()) {
if (printed_top_level_field)
sb.Append(", ");
sb.Append("non_fast_scrollable_region: ");
sb.Append(HitTestRectsAsString(non_fast_scrollable_region));
printed_top_level_field = true;
}
sb.Append("}");
return sb.ToString();
}
std::ostream& operator<<(std::ostream& os, const HitTestData& data) {
return os << data.ToString().Utf8().data();
}
} // namespace blink
......@@ -41,8 +41,12 @@ struct PLATFORM_EXPORT HitTestData {
static void RecordHitTestRect(GraphicsContext&,
const DisplayItemClient&,
const HitTestRect&);
String ToString() const;
};
PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const HitTestData&);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_HIT_TEST_DATA_H_
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/platform/graphics/paint/paint_chunk.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......@@ -23,36 +24,20 @@ static_assert(sizeof(PaintChunk) == sizeof(SameSizeAsPaintChunk),
"PaintChunk should stay small");
String PaintChunk::ToString() const {
String ret_val = String::Format(
"PaintChunk(begin=%zu, end=%zu, id=%s cacheable=%d props=(%s) bounds=%s "
StringBuilder sb;
sb.Append("PaintChunk(");
sb.Append(String::Format(
"begin=%zu, end=%zu, id=%s cacheable=%d props=(%s) bounds=%s "
"known_to_be_opaque=%d",
begin_index, end_index, id.ToString().Utf8().data(), is_cacheable,
properties.ToString().Utf8().data(), bounds.ToString().Utf8().data(),
known_to_be_opaque);
known_to_be_opaque));
if (hit_test_data) {
ret_val.append(String::Format(
", touch_action_rects=(rects: %u, bounds: %s), "
"wheel_event_handler_region=(rects: %u, bounds: %s), "
"non_fast_scrollable_region=(rects: %u, bounds: %s))",
hit_test_data->touch_action_rects.size(),
HitTestRect::GetBounds(hit_test_data->touch_action_rects)
.ToString()
.Utf8()
.data(),
hit_test_data->wheel_event_handler_region.size(),
HitTestRect::GetBounds(hit_test_data->wheel_event_handler_region)
.ToString()
.Utf8()
.data(),
hit_test_data->non_fast_scrollable_region.size(),
HitTestRect::GetBounds(hit_test_data->non_fast_scrollable_region)
.ToString()
.Utf8()
.data()));
} else {
ret_val.append(")");
sb.Append(", hit_test_data=");
sb.Append(hit_test_data->ToString());
}
return ret_val;
sb.Append(")");
return sb.ToString();
}
std::ostream& operator<<(std::ostream& os, const PaintChunk& chunk) {
......
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