[webkit-changes] [WebKit/WebKit] 5824ba: Avoid allocating a new DocumentFragment when tryFa...
Chris Dumez
noreply at github.com
Thu Feb 16 22:19:55 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5824bab256ea74d26c8d4375ac7dbcabfc5c137d
https://github.com/WebKit/WebKit/commit/5824bab256ea74d26c8d4375ac7dbcabfc5c137d
Author: Chris Dumez <cdumez at apple.com>
Date: 2023-02-16 (Thu, 16 Feb 2023)
Changed paths:
M Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp
M Source/WebCore/html/parser/HTMLDocumentParserFastPath.h
Log Message:
-----------
Avoid allocating a new DocumentFragment when tryFastParsingHTMLFragment() fails
https://bugs.webkit.org/show_bug.cgi?id=252453
Reviewed by Ryosuke Niwa.
We have an optimization in place in createFragmentForMarkup() to keep reusing
the same DocumentFragment (Document::documentFragmentForInnerOuterHTML())
whenever the innerHTML setter is called. documentFragmentForInnerOuterHTML()
calls removeChildren() on the DocumentFragment in between calls for reuse.
We recently added a new fast HTML parsing path for innerHTML. However, when
fast parsing fails, it may leave the DocumentFragment with children due to
partial parsing. To address this, we were re-constructing the
DocumentFragment before calling the full HTML parser (slow path).
In this patch, we now call removeChildren() on the DocumentFragment if the
fast path fails, instead of re-allocating a new DocumentFragment. This is
consistent with what documentFragmentForInnerOuterHTML() is doing and
maintains our optimization which avoids re-allocating new DocumentFragments
for each innerHTML assignment.
* Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp:
(WebCore::tryFastParsingHTMLFragmentImpl):
(WebCore::tryFastParsingHTMLFragment):
* Source/WebCore/html/parser/HTMLDocumentParserFastPath.h:
Canonical link: https://commits.webkit.org/260424@main
More information about the webkit-changes
mailing list