Commit 10813f31 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Re-enable position cache on Android

This patch re-enables position cache on Android when
|NGFragmentItem| is enabled.

It was disabled by r660251 crrev.com/c/1614133 to reduce
memory usage on Android, but hinders the layout performance
in some cases.

As |NGFragmentItem| saves memory on text-heavy pages, we
should have a room to re-enable the position cache.

Bug: 982194, 1042604
Change-Id: Ib4b0543f181024f0b825d4a378e0a3aa92109368
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226579Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774479}
parent 26a626b9
......@@ -1292,16 +1292,20 @@ scoped_refptr<const NGLayoutResult> NGInlineNode::Layout(
auto layout_result = algorithm.Layout();
#if defined(OS_ANDROID)
// Cached position data is crucial for line breaking performance and is
// preserved across layouts to speed up subsequent layout passes due to
// reflow, page zoom, window resize, etc. On Android though reflows are less
// common, page zoom isn't used (instead uses pinch-zoom), and the window
// typically can't be resized (apart from rotation). To reduce memory usage
// discard the cached position data after layout.
NGInlineNodeData* data = MutableData();
for (auto& item : data->items) {
if (item.shape_result_)
item.shape_result_->DiscardPositionData();
if (!RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) {
// Cached position data is crucial for line breaking performance and is
// preserved across layouts to speed up subsequent layout passes due to
// reflow, page zoom, window resize, etc. On Android though reflows are less
// common, page zoom isn't used (instead uses pinch-zoom), and the window
// typically can't be resized (apart from rotation). To reduce memory usage
// discard the cached position data after layout.
// TODO(crbug.com/1042604): FragmentItem should save memory enough to re-
// enable the position cache.
NGInlineNodeData* data = MutableData();
for (auto& item : data->items) {
if (item.shape_result_)
item.shape_result_->DiscardPositionData();
}
}
#endif // defined(OS_ANDROID)
......
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