[webkit-changes] [WebKit/WebKit] bb36b7: Serialization algorithms should not be changed in ...

Chris Dumez noreply at github.com
Fri Jun 16 09:50:25 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bb36b71707e3e11d6ced5ce2438d9aa69d53ccfb
      https://github.com/WebKit/WebKit/commit/bb36b71707e3e11d6ced5ce2438d9aa69d53ccfb
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-06-16 (Fri, 16 Jun 2023)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/html/syntax/serializing-html-fragments/template-expected.txt
    M Source/WebCore/editing/MarkupAccumulator.cpp
    M Source/WebCore/editing/MarkupAccumulator.h
    M Source/WebCore/editing/markup.cpp
    M Source/WebCore/editing/markup.h
    M Source/WebCore/page/PageSerializer.cpp

  Log Message:
  -----------
  Serialization algorithms should not be changed in the middle of a serialization
https://bugs.webkit.org/show_bug.cgi?id=258154

Reviewed by Darin Adler.

Some of the code in MarkupAccumulator would rely on the node's document to
determine whether or not to use the XML or HTML serialization algorithm instead
of using the serialization algorithm passed to the MarkupAccumulator
constructor. This is often fine but leads to behavior changes when the node is
a <template> since they have their own template document.

This meant that we may start serialization as HTML and then switch to XML for
serialization a particular template node.

To address the issue, we now make sure to pass the correct serialization
algorithm to the MarkupAccumulator and use this value consistently during
serialization, without checking the document of the node currently being
serialized.

This aligns our behavior with Chrome and Firefox, which were already passing
the corresponding WPT test.

Corresponding Blink change:
- https://chromium-review.googlesource.com/c/chromium/src/+/1640584

* LayoutTests/imported/w3c/web-platform-tests/html/syntax/serializing-html-fragments/template-expected.txt:
* Source/WebCore/editing/MarkupAccumulator.cpp:
(WebCore::shouldSelfClose):
(WebCore::MarkupAccumulator::appendOpenTag):
(WebCore::MarkupAccumulator::appendAttribute):
* Source/WebCore/editing/MarkupAccumulator.h:
* Source/WebCore/editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
(WebCore::serializePreservingVisualAppearanceInternal):
* Source/WebCore/page/PageSerializer.cpp:
(WebCore::PageSerializer::SerializerMarkupAccumulator::SerializerMarkupAccumulator):

Canonical link: https://commits.webkit.org/265248@main




More information about the webkit-changes mailing list