Commit 73dff2a0 authored by cathiechen's avatar cathiechen Committed by Commit Bot

Fix the nested layer of counter uncorrected when display changed

In order to update counter-reset correctly, MoveNonResetSiblingsToChildOf
is called, so the non-reset sibling will become the child of this reset
CounterNode. If this reset node is nested inside another CounterNode,
the sibling's nested layer won't be correct. So we should skip calling
MoveNonResetSiblingsToChildOf() in the nested case.

Bug: 849107
Change-Id: I8c59e18785dfec18c4bc2053e9c01041c23e4183
Reviewed-on: https://chromium-review.googlesource.com/1098867Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: cathie chen <cathiechen@tencent.com>
Cr-Commit-Position: refs/heads/master@{#567103}
parent a7fac6f2
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nested counter with display change to none and restore</title>
<link rel="help" href="https://drafts.csswg.org/css-lists/#counters-without-boxes">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
ol {
list-style-type: none;
counter-reset: count;
}
li { counter-increment: count; }
li::before {
content: counters(count, ".");
margin-right: 0.5em;
font-weight: bold;
color: seagreen;
}
</style>
<ol>
<li>
<span>Item 1</span>
<ol id="target">
<li>Item 1.1</li>
</ol>
</li>
<li id="item2">Item 2</li>
</ol>
<script>
test(function() {
document.body.offsetTop; // force layout
assert_equals(window.internals.counterValue(item2), '2');
document.getElementById("target").style="display:none";
document.body.offsetTop; // force layout
assert_equals(window.internals.counterValue(item2), '2');
document.getElementById("target").style="display:block";
document.body.offsetTop; // force layout
assert_equals(window.internals.counterValue(item2), '2');
}, "nested counter with display changed");
</script>
......@@ -399,11 +399,13 @@ static CounterNode* MakeCounterNodeIfNeeded(LayoutObject& object,
scoped_refptr<CounterNode> old_previous_sibling = nullptr;
if (FindPlaceForCounter(object, identifier, false, old_parent,
old_previous_sibling)) {
CounterNode* first_node_to_move =
old_previous_sibling ? old_previous_sibling->NextSibling()
: old_parent->FirstChild();
CounterNode::MoveNonResetSiblingsToChildOf(first_node_to_move, *new_node,
identifier);
if (!object.IsDescendantOf(&old_parent->Owner())) {
CounterNode* first_node_to_move =
old_previous_sibling ? old_previous_sibling->NextSibling()
: old_parent->FirstChild();
CounterNode::MoveNonResetSiblingsToChildOf(first_node_to_move,
*new_node, identifier);
}
}
}
......
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