Skip to content

Commit

Permalink
[inert] Force 'user-modify: none' on inert nodes at used-value time
Browse files Browse the repository at this point in the history
This is done by adding a public ComputedStyle::UsedUserModify() that
returns EUserModify::kNone for inert, and privatizing the existing
ComputedStyle::UserModify() just for friend classes.

Code related to the style resolver, style adjuster, inheritance, etc.
continues using UserModify(), since inert should only change used styles
w3c/csswg-drafts#6685 (comment)

Forcing 'user-modify: none' wasn't explicitly resolved by the CSSWG, but
it solves the inconsistency of editing commands having different
behaviors when executed in a node which is both in inert and editable
subtrees, depending on whether the inert root is a descendant of the
editing root, or an inclusive ancestor.

Forcing 'user-modify: none' is also consistent with Firefox, though it
doesn't have much effect there, it doesn't avoid editability.

Bug: 692360

TEST=external/wpt/inert/inert-and-contenteditable.tentative.html

Change-Id: I4a34b9715272019b0b8daae0fd5ed3e25e38eddf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3486876
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Oriol Brufau <obrufau@igalia.com>
Cr-Commit-Position: refs/heads/main@{#974783}
  • Loading branch information
Loirooriol authored and chromium-wpt-export-bot committed Feb 24, 2022
1 parent 7300d87 commit e451f9e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions inert/inert-and-contenteditable.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Inert and contenteditable</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#inert">
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable">
<meta assert="assert" content="
Executing an editing command in a node marked as both inert and editable
should have the same result regardless of which ancestors trigger each effect.
Only testing for consistency, the exact result is not interoperable.">

<div id="log"></div>

<div class="wrapper" contenteditable inert>
{<p class="target">target</p>}
</div>

<div class="wrapper" contenteditable>
{<p class="target" inert>target</p>}
</div>

<div class="wrapper" inert>
{<p class="target" contenteditable>target</p>}
</div>

<div class="wrapper">
{<p class="target" contenteditable inert>target</p>}
</div>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const results = [];
const textContents = [];
setup(function() {
const selection = getSelection();
for (let wrapper of document.querySelectorAll(".wrapper")) {
const target = wrapper.querySelector(".target");
selection.collapse(target.firstChild, 3);
results.push(document.execCommand("delete"));
textContents.push(wrapper.textContent.trim());
}
});
function testSameValues(array, description) {
test(function() {
assert_greater_than(array.length, 0, "Array shouldn't be empty");
for (let i = 1; i < array.length; ++i) {
assert_equals(array[i], array[0], `${JSON.stringify(array)} at index ${i}`);
}
}, description);
}
testSameValues(results, "execCommand should return the same value");
testSameValues(textContents, "The resulting textContent should be the same value");
</script>

0 comments on commit e451f9e

Please sign in to comment.