Commit 7aeceb41 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Fix regression that ComputeInlineBoxPosition no longer enters inline blocks

Previous CL crrev.com/c/775550 was supposed to be pure refactoring, but
changed behavior that ComputeInlineBoxPosition no longer enters inline
blocks, because the CL moved the branch handling atomic inlines above the
branch that moves input position into inline blocks.

This patch fixes the regression by moving the branches back to their old
positions.

Bug: 856417
Change-Id: I94a22259f723af11b701d3a1078e68b5729bb0d0
Reviewed-on: https://chromium-review.googlesource.com/1116357Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570791}
parent 09c2c541
...@@ -393,6 +393,7 @@ jumbo_source_set("unit_tests") { ...@@ -393,6 +393,7 @@ jumbo_source_set("unit_tests") {
"selection_controller_test.cc", "selection_controller_test.cc",
"selection_modifier_character_test.cc", "selection_modifier_character_test.cc",
"selection_modifier_test.cc", "selection_modifier_test.cc",
"selection_modifier_word_test.cc",
"selection_template_test.cc", "selection_template_test.cc",
"serializers/styled_markup_serializer_test.cc", "serializers/styled_markup_serializer_test.cc",
"set_selection_options_test.cc", "set_selection_options_test.cc",
......
...@@ -227,18 +227,19 @@ PositionWithAffinityTemplate<Strategy> ComputeInlineAdjustedPositionAlgorithm( ...@@ -227,18 +227,19 @@ PositionWithAffinityTemplate<Strategy> ComputeInlineAdjustedPositionAlgorithm(
if (layout_object.IsText()) if (layout_object.IsText())
return position; return position;
if (layout_object.IsAtomicInlineLevel()) { // We perform block flow adjustment first, so that we can move into an inline
// TODO(crbug.com/567964): Change the following branch to DCHECK once fixed. // block when needed instead of stopping at its boundary as if it is a
if (!layout_object.IsInline()) // replaced element.
return PositionWithAffinityTemplate<Strategy>(); if (layout_object.IsLayoutBlockFlow() &&
return position; CanHaveChildrenForEditing(position.AnchorNode()) &&
HasRenderedNonAnonymousDescendantsWithHeight(&layout_object)) {
return AdjustBlockFlowPositionToInline(position.GetPosition());
} }
if (!layout_object.IsLayoutBlockFlow() || // TODO(crbug.com/567964): Change the second operand to DCHECK once fixed.
!CanHaveChildrenForEditing(position.AnchorNode()) || if (!layout_object.IsAtomicInlineLevel() || !layout_object.IsInline())
!HasRenderedNonAnonymousDescendantsWithHeight(&layout_object))
return PositionWithAffinityTemplate<Strategy>(); return PositionWithAffinityTemplate<Strategy>();
return AdjustBlockFlowPositionToInline(position.GetPosition()); return position;
} }
// Returns true if |layout_object| and |offset| points after line end. // Returns true if |layout_object| and |offset| points after line end.
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/editing/selection_modifier.h"
#include "third_party/blink/renderer/core/editing/testing/editing_test_base.h"
namespace blink {
class SelectionModifierWordTest : public EditingTestBase {};
// Regression test for crbug.com/856417
TEST_F(SelectionModifierWordTest, MoveIntoInlineBlockWithBidiNoHang) {
const SelectionInDOMTree selection = SetSelectionTextToBody(
"<div contenteditable>"
"<span>&#x05D0;|&#x05D1;&#x05D2;</span>"
"<span style=\"display: inline-block\">foo</span>"
"</div>");
SelectionModifier modifier(GetFrame(), selection);
modifier.Modify(SelectionModifyAlteration::kMove,
SelectionModifyDirection::kRight, TextGranularity::kWord);
// Shouldn't hang here.
EXPECT_EQ(
"<div contenteditable>"
"<span>\xD7\x90\xD7\x91\xD7\x92</span>"
"<span style=\"display: inline-block\">foo|</span>"
"</div>",
GetSelectionTextFromBody(modifier.Selection().AsSelection()));
}
} // namespace blink
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