Bug 191874 - Mutation observers doesn't get notified of character data mutation made by the parser
Summary: Mutation observers doesn't get notified of character data mutation made by th...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-11-20 20:55 PST by Ryosuke Niwa
Modified: 2018-11-21 13:34 PST (History)
8 users (show)

See Also:


Attachments
Fixes the bug (4.63 KB, patch)
2018-11-20 20:57 PST, Ryosuke Niwa
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2018-11-20 20:55:13 PST
When MutationObserver is observing a text node e.g. via a subtree observation,
and the HTML parser appends more data to it, the observer never gets invoked
with mutation records of the character data mutation made by the parser.

<rdar://problem/42477645>
Comment 1 Ryosuke Niwa 2018-11-20 20:57:26 PST
Created attachment 355381 [details]
Fixes the bug
Comment 2 Antti Koivisto 2018-11-21 01:26:51 PST
Comment on attachment 355381 [details]
Fixes the bug

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

> Source/WebCore/dom/CharacterData.cpp:102
> +    String oldData;
> +    if (UNLIKELY(mutationRecipients))
> +        oldData = m_data;

Maybe just set oldData unconditionally? It is not clear that a branch is faster than minor ref churn.
Comment 3 Ryosuke Niwa 2018-11-21 13:24:17 PST
(In reply to Antti Koivisto from comment #2)
> Comment on attachment 355381 [details]
> Fixes the bug
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=355381&action=review
> 
> > Source/WebCore/dom/CharacterData.cpp:102
> > +    String oldData;
> > +    if (UNLIKELY(mutationRecipients))
> > +        oldData = m_data;
> 
> Maybe just set oldData unconditionally? It is not clear that a branch is
> faster than minor ref churn.

Okay. I guess we'd catch it on perf bots if it regressed perf.
Comment 4 Ryosuke Niwa 2018-11-21 13:33:51 PST
Committed r238429: <https://trac.webkit.org/changeset/238429>
Comment 5 Radar WebKit Bug Importer 2018-11-21 13:34:29 PST
<rdar://problem/46204294>