Commit 064f56b2 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Make TextOffsetMapping skip anonymous block flow wrappers for pseudo elements

In some cases, we create anonymous block flow wrappers for float pseudo
elements. Such wrappers should be skipped by TextOffsetMapping.

Bug: 900906
Change-Id: I7f9ce5906ed8b2daaff3b0c9310e639d932ae5d0
Reviewed-on: https://chromium-review.googlesource.com/c/1315701
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605262}
parent b3f3eefb
......@@ -103,9 +103,10 @@ const LayoutBlockFlow* ComputeInlineContentsAsBlockFlow(
block_flow.IsFloatingOrOutOfFlowPositioned()) {
const LayoutBlockFlow& root_block_flow =
RootInlineContentsContainerOf(block_flow);
DCHECK(CanBeInlineContentsContainer(root_block_flow))
<< layout_object << " block_flow=" << block_flow
<< " root_block_flow=" << root_block_flow;
// Skip |root_block_flow| if it's an anonymous wrapper created for
// pseudo elements. See test AnonymousBlockFlowWrapperForFloatPseudo.
if (!CanBeInlineContentsContainer(root_block_flow))
return nullptr;
return &root_block_flow;
}
if (!CanBeInlineContentsContainer(block_flow))
......
......@@ -230,6 +230,20 @@ TEST_P(ParameterizedTextOffsetMappingTest, RangeOfEmptyBlock) {
TextOffsetMapping::FindBackwardInlineContents(position));
}
// http://crbug.com/900906
TEST_P(ParameterizedTextOffsetMappingTest,
AnonymousBlockFlowWrapperForFloatPseudo) {
InsertStyleElement("table::after{content:close-quote;float:right;}");
const PositionInFlatTree position =
ToPositionInFlatTree(SetCaretTextToBody("<table></table>|foo"));
const TextOffsetMapping::InlineContents inline_contents =
TextOffsetMapping::FindBackwardInlineContents(position);
ASSERT_TRUE(inline_contents.IsNotNull());
const TextOffsetMapping::InlineContents previous_contents =
TextOffsetMapping::InlineContents::PreviousOf(inline_contents);
EXPECT_TRUE(previous_contents.IsNull());
}
// http://crbug.com/832497
TEST_P(ParameterizedTextOffsetMappingTest, RangeWithCollapsedWhitespace) {
// Whitespaces after <div> is collapsed.
......
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