Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
isContentEditable returns false for
display:none
contenteditable el…
…ements, but true for children https://bugs.webkit.org/show_bug.cgi?id=240834 Reviewed by Ryosuke Niwa. * Source/WebCore/dom/Node.cpp: (WebCore::computeEditabilityFromComputedStyle): Remove a `display: none` check. This check is wrong for two reasons: 1) It only consults the style of the immediate element, not whether or not that element is in a `display: none` subtree. This regressed in r160966. This causes a confusing situation where `display: none` affects the editability of only the element it is directly applied to. 2) isContentEditable is not specified to be affected by `display: none`. * LayoutTests/editing/editability/isContentEditable-in-display-none-expected.txt: Added. * LayoutTests/editing/editability/isContentEditable-in-display-none.html: Added. Add a test that dumps the editability of a variety of different configurations of contenteditable elements and their children. Before this change, this test would have said that #nonVisible (the display: none contenteditable element) was read-only, but its child <p> was editable. Now we agree with Gecko and Blink who both say that both are editable. * LayoutTests/fast/events/event-input-contentEditable-expected.txt: * LayoutTests/fast/events/event-input-contentEditable.html: Adjust this test to expect an input event to be dispatched for programmatic editing in display: none elements. Also add a sub-test that checks the same, but in a child element. Before this change, we would not dispatch an input event to the display: none contenteditable itself, but *would* dispatch an input event for input into a child element. Now we agree with Gecko, who dispatch events in both cases. Canonical link: https://commits.webkit.org/250921@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,19 @@ | ||
BODY: Read-only | ||
#nonEditable: Read-only | ||
Directly inside a normal div. | ||
P: Read-only | ||
In a child of a normal div. | ||
#visible: Editable | ||
Directly inside a contenteditable. | ||
P: Editable | ||
In a child of a contenteditable. | ||
#nonVisible: Editable | ||
Directly inside a display:none contenteditable. | ||
P: Editable | ||
In a child of a display:none contenteditable. | ||
DIV: Read-only | ||
#nonVisibleParent: Editable | ||
Directly inside a contenteditable with a display:none parent. | ||
P: Editable | ||
In a child of a contenteditable with a display:none parent. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<style> | ||
body { white-space: pre-wrap; } | ||
</style> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
|
||
function visit(node, f, depth) { | ||
f(node, depth); | ||
for (let child of node.childNodes) | ||
visit(child, f, depth + 1); | ||
} | ||
|
||
window.onload = function () { | ||
let description = ""; | ||
visit(document.body, function (node, depth) { | ||
let indent = "\t".repeat(depth); | ||
|
||
if (node.nodeType == Node.TEXT_NODE) { | ||
let trimmedContent = node.textContent.trim(); | ||
if (trimmedContent) | ||
description += `${indent}${trimmedContent}\n`; | ||
return; | ||
} | ||
|
||
let identifier = node.id ? `#${node.id}` : node.nodeName; | ||
let editability = node.isContentEditable ? "Editable" : "Read-only"; | ||
description += `${indent}${identifier}: ${editability}\n`; | ||
}, 0); | ||
document.body.innerText = description; | ||
} | ||
</script> | ||
<body> | ||
<div id="nonEditable">Directly inside a normal div. | ||
<p>In a child of a normal div.</p> | ||
</div> | ||
<div id="visible" contenteditable>Directly inside a contenteditable. | ||
<p>In a child of a contenteditable.</p> | ||
</div> | ||
<div id="nonVisible" style="display: none" contenteditable>Directly inside a display:none contenteditable. | ||
<p>In a child of a display:none contenteditable.</p> | ||
</div> | ||
<div style="display: none"> | ||
<div id="nonVisibleParent" contenteditable>Directly inside a contenteditable with a display:none parent. | ||
<p>In a child of a contenteditable with a display:none parent.</p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters