Bug 222406 - Render tree updates for Text node content mutations should happen during rendering update
Summary: Render tree updates for Text node content mutations should happen during rend...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: 224323
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-24 22:55 PST by Antti Koivisto
Modified: 2021-04-19 23:34 PDT (History)
12 users (show)

See Also:


Attachments
wip (4.50 KB, patch)
2021-02-24 22:56 PST, Antti Koivisto
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
patch (11.21 KB, patch)
2021-02-25 07:24 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (11.17 KB, patch)
2021-02-25 07:42 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (11.02 KB, patch)
2021-02-25 10:54 PST, Antti Koivisto
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
patch (9.47 KB, patch)
2021-02-26 03:15 PST, Antti Koivisto
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
patch (14.82 KB, patch)
2021-02-26 06:38 PST, Antti Koivisto
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
patch (14.84 KB, patch)
2021-02-26 07:37 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
alternative approach (3.63 KB, patch)
2021-02-26 08:00 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (14.84 KB, patch)
2021-02-26 08:06 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (16.89 KB, patch)
2021-02-26 09:46 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (16.92 KB, patch)
2021-02-26 09:49 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (16.36 KB, patch)
2021-02-26 11:21 PST, Antti Koivisto
simon.fraser: review+
Details | Formatted Diff | Diff
patch (16.86 KB, patch)
2021-02-26 23:45 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch for relanding (16.94 KB, patch)
2021-04-19 11:05 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2021-02-24 22:55:47 PST
Render tree should be mutated lazily as a part of rendering update like in all other cases.
Comment 1 Antti Koivisto 2021-02-24 22:56:44 PST
Created attachment 421504 [details]
wip
Comment 2 Antti Koivisto 2021-02-25 07:24:47 PST
Created attachment 421523 [details]
patch
Comment 3 Antti Koivisto 2021-02-25 07:42:08 PST
Created attachment 421525 [details]
patch
Comment 4 Antti Koivisto 2021-02-25 10:54:50 PST
Created attachment 421546 [details]
patch
Comment 5 Simon Fraser (smfr) 2021-02-25 13:15:20 PST
Comment on attachment 421546 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=421546&action=review

> Source/WebCore/ChangeLog:35
> +        This is because subsequent steps in multipart commands expect render tree to be up to date.

Shouldn't this be handled by the next step triggering a render tree update? It's going to be hard for author of new code to know if they have to call updateStyleIfNeeded() or not.

> Source/WebCore/ChangeLog:47
> +        Pending text update mat ref the node so this refcount assert is not correct.

mat ref?
Comment 6 Antti Koivisto 2021-02-25 13:38:55 PST
> Shouldn't this be handled by the next step triggering a render tree update?

In theory yes, but it is very difficult to discover all the paths that would need it as there is no guarantee test coverage is complete. In practice missing cases would be discover via regressions.

> It's going to be hard for author of new code to know if they have to call
> updateStyleIfNeeded() or not.

These just maintain the existing behaviour (sync render tree update on Text content mutations). 

Anyone working on this code needs to be careful about updates in any case, this patch in no way changes that.
Comment 7 Antti Koivisto 2021-02-25 13:39:43 PST
(In reply to Antti Koivisto from comment #6)
> These just maintain the existing behaviour (sync render tree update on Text
> content mutations). 

...in editing code specifically.
Comment 8 Antti Koivisto 2021-02-26 03:15:49 PST
Created attachment 421631 [details]
patch
Comment 9 Antti Koivisto 2021-02-26 06:38:45 PST
Created attachment 421636 [details]
patch
Comment 10 Antti Koivisto 2021-02-26 07:37:09 PST
Created attachment 421643 [details]
patch
Comment 11 Antti Koivisto 2021-02-26 08:00:47 PST Comment hidden (obsolete)
Comment 12 Antti Koivisto 2021-02-26 08:06:55 PST
Created attachment 421647 [details]
patch
Comment 13 Antti Koivisto 2021-02-26 09:46:00 PST
Created attachment 421664 [details]
patch
Comment 14 Antti Koivisto 2021-02-26 09:49:39 PST
Created attachment 421667 [details]
patch
Comment 15 Antti Koivisto 2021-02-26 11:21:58 PST
Created attachment 421679 [details]
patch
Comment 16 Simon Fraser (smfr) 2021-02-26 22:20:57 PST
Comment on attachment 421679 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=421679&action=review

> Source/WebCore/dom/CharacterData.cpp:105
> -    if (is<Text>(*this) && parentNode())
> +    if (is<Text>(*this))

This doesn't seem to be mentioned in the changelog.

> Source/WebCore/editing/CompositeEditCommand.cpp:1062
> +    if (!nodes.isEmpty())
> +        document().updateLayoutIgnorePendingStylesheets();

This is still pretty mysterious.
Comment 17 Antti Koivisto 2021-02-26 22:47:28 PST
> This doesn't seem to be mentioned in the changelog.

The check just moves to the function.
Comment 18 Antti Koivisto 2021-02-26 23:45:29 PST
Created attachment 421738 [details]
patch
Comment 19 EWS 2021-02-27 00:24:07 PST
Committed r273621: <https://commits.webkit.org/r273621>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 421738 [details].
Comment 20 Radar WebKit Bug Importer 2021-02-27 00:25:19 PST
<rdar://problem/74822830>
Comment 21 Darin Adler 2021-03-01 14:26:14 PST
Comment on attachment 421738 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=421738&action=review

> Source/WebCore/style/StyleUpdate.cpp:104
> +    auto result = m_texts.ensure(&text, [&] {
> +        return WTFMove(textUpdate);
> +    });

I think this is identical to:

    auto result = m_texts.add(&text, WTFMove(textUpdate));

Maybe because it looks like WTFMove causes a "move" that the ensure form seems safer, but pretty sure it’s no different.
Comment 22 Antti Koivisto 2021-03-02 07:33:03 PST
> Maybe because it looks like WTFMove causes a "move" that the ensure form
> seems safer, but pretty sure it’s no different.

Yeah, it just looked less dangerous. I think you are right that it is equivalent.
Comment 23 Antti Koivisto 2021-04-08 06:44:36 PDT
Reverted in r275657 due to PLT regression.
Comment 24 Antti Koivisto 2021-04-19 11:05:43 PDT
Created attachment 426446 [details]
patch for relanding
Comment 25 EWS 2021-04-19 23:33:58 PDT
Committed r276287 (236769@main): <https://commits.webkit.org/236769@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426446 [details].