Commit 07308a5e authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

[LayoutNG] Make offset mapping construction more adapted to fragment painting

The construction of offset mapping used to have some hacks to work around the
LayoutText writeback. The hacks are no longer necessary if fragment painting is
enabled.

This patch makes the hacks disabled when fragment painting is enabled, so that
we can remove the hacks easier in the future.

Bug: 699017
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I57e28f32f318d118e8ebe4a89999e3f07a9a806a
Reviewed-on: https://chromium-review.googlesource.com/777964Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517772}
parent ebc1d8cf
...@@ -228,20 +228,22 @@ template <> ...@@ -228,20 +228,22 @@ template <>
void ClearNeedsLayoutIfUpdatingLayout<NGOffsetMappingBuilder>(LayoutObject*) {} void ClearNeedsLayoutIfUpdatingLayout<NGOffsetMappingBuilder>(LayoutObject*) {}
// Templated helper function for CollectInlinesInternal(). // Templated helper function for CollectInlinesInternal().
// TODO(layout-dev): Remove this function once LayoutNGPaintFragments is enabled
// by default.
template <typename OffsetMappingBuilder> template <typename OffsetMappingBuilder>
String GetTextForInlineCollection(const LayoutText& node) { String GetTextForInlineCollection(const LayoutText& node) {
return node.GetText(); return node.GetText();
} }
// This function is a workaround of writing the whitespace-collapsed string back
// to LayoutText after inline collection, so that we can still recover the
// original text for building offset mapping.
// TODO(xiaochengh): Remove this function once we can:
// - paint inlines directly from the fragment tree, or
// - perform inline collection directly from DOM instead of LayoutText
template <> template <>
String GetTextForInlineCollection<NGOffsetMappingBuilder>( String GetTextForInlineCollection<NGOffsetMappingBuilder>(
const LayoutText& layout_text) { const LayoutText& layout_text) {
if (RuntimeEnabledFeatures::LayoutNGPaintFragmentsEnabled())
return layout_text.GetText();
// The code below is a workaround of writing the whitespace-collapsed string
// back to LayoutText after inline collection, so that we can still recover
// the original text for building offset mapping.
if (layout_text.Style()->TextSecurity() != ETextSecurity::kNone) if (layout_text.Style()->TextSecurity() != ETextSecurity::kNone)
return layout_text.GetText(); return layout_text.GetText();
......
...@@ -138,9 +138,8 @@ void NGOffsetMappingBuilder::Composite(const NGOffsetMappingBuilder& other) { ...@@ -138,9 +138,8 @@ void NGOffsetMappingBuilder::Composite(const NGOffsetMappingBuilder& other) {
} }
void NGOffsetMappingBuilder::SetDestinationString(String string) { void NGOffsetMappingBuilder::SetDestinationString(String string) {
// TODO(xiaochengh): Add the check below when we stop writing back to if (RuntimeEnabledFeatures::LayoutNGPaintFragmentsEnabled())
// LayoutText for inline painting. DCHECK_EQ(mapping_.back(), string.length());
// DCHECK_EQ(mapping_.back(), string.length());
destination_string_ = string; destination_string_ = string;
} }
......
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