Commit 1c61e650 authored by Kent Tamura's avatar Kent Tamura Committed by Chromium LUCI CQ

css-lists: counter-* properties update should invalidate ListItemOrdinals

Since r835809, list-items respect to counter-* properties, but we didn't
invalidate list-items on updating the properties.

LayoutCounter::LayoutObjectStyleChanged(), which is called whenever
counter-* properties are changed, invalidates ListItemOrdinal too.

* LayoutCounter::LayoutObjectStyleChanged() calls new function
  ListItemOrdinal::ItemCounterStyleUpdated()

* ListItemOrdinal::ItemInsertedOrRemoved() is renamed to ItemUpdated(),
  and it adds support of inclusive invalidation.

* ListItemOrdinal::ItemInsertedOrRemoved() and
  ItemCounterStyleUpdated() call ItemUpdated().

* counter-set-002.html
 - Fix the flakiness
 - Add list-items before/after the updated node

Bug: 1157854
Change-Id: I669c2c70f87473d5d863f5f02208eb7fe1a41a55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586455Reviewed-by: default avatarOriol Brufau <obrufau@igalia.com>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836962}
parent 04d941be
......@@ -258,8 +258,8 @@ void ListItemOrdinal::InvalidateAllItemsForOrderedList(
// TODO(layout-dev): We should use layout tree traversal instead of flat tree
// traversal to invalidate ordinal number cache since lite items in unassigned
// slots don't have cached value. See http://crbug.com/844277 for details.
void ListItemOrdinal::ItemInsertedOrRemoved(
const LayoutObject* layout_list_item) {
void ListItemOrdinal::ItemUpdated(const LayoutObject* layout_list_item,
UpdateType type) {
// If distribution recalc is needed, updateListMarkerNumber will be re-invoked
// after distribution is calculated.
const Node* item_node = layout_list_item->GetNode();
......@@ -273,7 +273,8 @@ void ListItemOrdinal::ItemInsertedOrRemoved(
bool is_list_reversed = false;
if (auto* o_list_element = DynamicTo<HTMLOListElement>(list_node)) {
o_list_element->ItemCountChanged();
if (type == kInsertedOrRemoved)
o_list_element->ItemCountChanged();
is_list_reversed = o_list_element->IsReversed();
}
......@@ -285,7 +286,22 @@ void ListItemOrdinal::ItemInsertedOrRemoved(
if (list_node->NeedsReattachLayoutTree())
return;
if (type == kCounterStyle) {
ListItemOrdinal* ordinal = Get(*item_node);
DCHECK(ordinal);
ordinal->InvalidateSelf(*item_node);
}
InvalidateOrdinalsAfter(is_list_reversed, list_node, item_node);
}
void ListItemOrdinal::ItemInsertedOrRemoved(
const LayoutObject* layout_list_item) {
ItemUpdated(layout_list_item, kInsertedOrRemoved);
}
void ListItemOrdinal::ItemCounterStyleUpdated(
const LayoutObject& layout_list_item) {
ItemUpdated(&layout_list_item, kCounterStyle);
}
} // namespace blink
......@@ -51,6 +51,8 @@ class CORE_EXPORT ListItemOrdinal {
// Invalidate items that are affected by an insertion or a removal.
static void ItemInsertedOrRemoved(const LayoutObject*);
// Invalidate items that are affected by counter style update.
static void ItemCounterStyleUpdated(const LayoutObject&);
private:
enum ValueType { kNeedsUpdate, kUpdated, kExplicit };
......@@ -82,6 +84,8 @@ class CORE_EXPORT ListItemOrdinal {
static void InvalidateOrdinalsAfter(bool is_reversed,
const Node* list_node,
const Node* item_node);
enum UpdateType { kInsertedOrRemoved, kCounterStyle };
static void ItemUpdated(const LayoutObject*, UpdateType type);
mutable int value_ = 0;
mutable unsigned type_ : 2; // ValueType
......
......@@ -765,6 +765,8 @@ void LayoutCounter::LayoutObjectSubtreeAttached(LayoutObject* layout_object) {
void LayoutCounter::LayoutObjectStyleChanged(LayoutObject& layout_object,
const ComputedStyle* old_style,
const ComputedStyle& new_style) {
if (layout_object.IsListItemIncludingNG())
ListItemOrdinal::ItemCounterStyleUpdated(layout_object);
Node* node = layout_object.GeneratingNode();
if (!node || node->NeedsReattachLayoutTree())
return; // cannot have generated content or if it can have, it will be
......
......@@ -807,7 +807,6 @@ crbug.com/470421 external/wpt/css/css-sizing/aspect-ratio/flex-aspect-ratio-022.
# [css-lists]
crbug.com/1123457 external/wpt/css/css-lists/counter-list-item-2.html [ Failure ]
crbug.com/1157854 external/wpt/css/css-lists/counter-set-002.html [ Failure ]
crbug.com/1066577 external/wpt/css/css-lists/li-value-reversed-005.html [ Failure ]
crbug.com/1066577 external/wpt/css/css-lists/li-value-reversed-004.html [ Failure ]
......
......@@ -9,6 +9,12 @@
<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.org">
</head>
<body>
<ol><li></li></ol>
<ol>
<li></li>
<li></li>
<li></li>
<fieldset style="display:list-item"></fieldset>
<li></li>
</ol>
</body>
</html>
......@@ -10,8 +10,25 @@
<link rel="help" href="https://drafts.csswg.org/css-lists/#propdef-counter-set">
<link rel="match" href="counter-set-002-ref.html">
</head>
<body onload="document.getElementById('item').style=''">
<body>
<noscript>Test not run - javascript required.</noscript>
<ol><li id="item" style="counter-increment: list-item 3"></li></ol>
<ol>
<li></li>
<li id="item" style="counter-increment: list-item 3"></li>
<li></li>
<style>
.f {
display: list-item;
}
</style>
<fieldset id="item4" class="f" style="counter-set: list-item 42"></fieldset>
<li></li>
</ol>
<script>
document.body.offsetTop;
document.getElementById('item').style= '';
document.getElementById('item4').style= '';
</script>
</body>
</html>
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