Bug 1943542 - Remove contenteditable / EditorOverride sheet. r=masayuki

Move the relevant bits to html.css or other UA sheets, and use faster
things than attribute selectors (read: classes) for resizers and such
things.

The hidden class can just be a hidden attribute since we don't otherwise
style these.

The cursor can just be set at the resizer / grabber creation time.

One known behavior change other than this is not styling using the
_moz_abspos attribute. The reasoning for this is that these are content
nodes, and in general having these kinds of rules for content nodes
isn't great. E.g. these two pages behave differently:

 * data:text/html,<div _moz_abspos=black>boo</div>
 * data:text/html,<div _moz_abspos=black>boo</div><div contenteditable></div>

We could use the style attribute for this, I suppose, just like we set
the position or what not, but then we need to save / restore as needed
or something. I'd rather not change the stacking order or backgrounds or
what not, too.

If you feel very strongly about that piece of functionality of the
abspos editor I could try to restore it somehow. But I honestly rather
not.

The rest of the stuff should just work.

Differential Revision: https://phabricator.services.mozilla.com/D235319
This commit is contained in:
Emilio Cobos Álvarez
2025-01-26 12:31:18 +00:00
parent 5fcc6c93b8
commit d5d33843fb
18 changed files with 240 additions and 708 deletions

View File

@@ -402,16 +402,6 @@ nsresult HTMLEditor::Init(Document& aDocument,
// init the type-in state
mPendingStylesToApplyToNewContent = new PendingStyles();
if (!IsInteractionAllowed()) {
nsCOMPtr<nsIURI> uaURI;
rv = NS_NewURI(getter_AddRefs(uaURI),
"resource://gre/res/EditorOverride.css");
NS_ENSURE_SUCCESS(rv, rv);
rv = document->LoadAdditionalStyleSheet(Document::eAgentSheet, uaURI);
NS_ENSURE_SUCCESS(rv, rv);
}
AutoEditActionDataSetter editActionData(*this, EditAction::eInitializing);
if (NS_WARN_IF(!editActionData.CanHandle())) {
return NS_ERROR_FAILURE;
@@ -464,15 +454,6 @@ void HTMLEditor::PreDestroy() {
RefPtr<Document> document = GetDocument();
if (document) {
document->RemoveMutationObserver(this);
if (!IsInteractionAllowed()) {
nsCOMPtr<nsIURI> uaURI;
nsresult rv = NS_NewURI(getter_AddRefs(uaURI),
"resource://gre/res/EditorOverride.css");
if (NS_SUCCEEDED(rv)) {
document->RemoveAdditionalStyleSheet(Document::eAgentSheet, uaURI);
}
}
}
// Clean up after our anonymous content -- we don't want these nodes to