Commit 302e6c7c authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

[LayoutNG] Change how content editable forces legacy layout

This patch changes how editing forces legacy layout to the one
added for form controls[1] to use legacy layout tree for nested editable, e.g.
  <div contenteditable>
  legacy layout tree
    <div contenteditable=false>
      non-editable block in editable block should be legacy
    </div>
  </div>

This patch continues http://crrev.com/c/880542

[1] http://crrev.com/c/875511 Change form controls not to use LayoutNG

Bug: 714962
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I78d44fc82b3de5e647b67ee6aa7733db62e344b8
Reviewed-on: https://chromium-review.googlesource.com/880530
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531861}
parent bde15e9c
......@@ -640,19 +640,21 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
}
}
if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
if (RuntimeEnabledFeatures::LayoutNGEnabled() && !style.ForceLegacyLayout()) {
// Form controls are not supported yet.
if (!style.ForceLegacyLayout() && element &&
element->ShouldForceLegacyLayout()) {
if (element && element->ShouldForceLegacyLayout()) {
style.SetForceLegacyLayout(true);
}
// TODO(layout-dev): Once LayoutNG handles inline content editable, we
// should get rid of following code fragment.
else if (style.UserModify() != EUserModify::kReadOnly &&
style.Display() == EDisplay::kInline &&
parent_style.UserModify() == EUserModify::kReadOnly) {
style.SetDisplay(EDisplay::kInlineBlock);
else if (style.UserModify() != EUserModify::kReadOnly) {
style.SetForceLegacyLayout(true);
if (style.Display() == EDisplay::kInline &&
parent_style.UserModify() == EUserModify::kReadOnly) {
style.SetDisplay(EDisplay::kInlineBlock);
}
}
}
}
......
......@@ -820,6 +820,7 @@ TEST_F(NGLayoutSelectionTest, MixedBlockFlowsAsSibling) {
}
TEST_F(NGLayoutSelectionTest, MixedBlockFlowsAnscestor) {
// Both "foo" and "bar" for DIV elements should be legacy LayoutBlock.
const SelectionInDOMTree& selection = SetSelectionTextToBody(
"<div contenteditable>f^oo"
"<div contenteditable=false>ba|r</div></div>");
......@@ -829,19 +830,10 @@ TEST_F(NGLayoutSelectionTest, MixedBlockFlowsAnscestor) {
TEST_NEXT(IsLegacyBlockFlow, kContain, NotInvalidate);
TEST_NEXT(IsLayoutNGBlockFlow, kContain, NotInvalidate);
TEST_NEXT("foo", kStart, ShouldInvalidate);
TEST_NEXT(IsLayoutNGBlockFlow, kContain, NotInvalidate);
TEST_NEXT(IsLegacyBlockFlow, kContain, NotInvalidate);
TEST_NEXT("bar", kEnd, ShouldInvalidate);
TEST_NO_NEXT_LAYOUT_OBJECT();
EXPECT_EQ(1u, Selection().LayoutSelectionStart().value());
LayoutObject* const bar = GetDocument()
.body()
->firstChild()
->firstChild()
->nextSibling()
->firstChild()
->GetLayoutObject();
EXPECT_EQ(std::make_pair(0u, 2u), Selection().LayoutSelectionStartEndForNG(
GetNGPhysicalTextFragment(bar)));
}
TEST_F(NGLayoutSelectionTest, MixedBlockFlowsDecendant) {
......
......@@ -113,8 +113,7 @@ static bool g_modify_layout_tree_structure_any_state = false;
inline bool ShouldUseNewLayout(const ComputedStyle& style) {
return RuntimeEnabledFeatures::LayoutNGEnabled() &&
!style.ForceLegacyLayout() &&
style.UserModify() == EUserModify::kReadOnly;
!style.ForceLegacyLayout();
}
template <typename Predicate>
......
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