Remove additional elements from the active formatting elements list [chromium/src : main]

0 views
Skip to first unread message

Mason Freed (Gerrit)

unread,
Feb 24, 2026, 11:20:26 AM (11 days ago) Feb 24
to Javier Fernandez, Michał Bentkowski, Daniel Vogelheim, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Daniel Vogelheim, Javier Fernandez and Michał Bentkowski

Mason Freed added 5 comments

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Mason Freed . unresolved

I think it's a good idea to conform to the spec here, so thanks for putting this patch together. Two things:

  • Since it's a behavior change, it should definitely be gated behind a runtime enabled feature flag (default "stable" is ok). Just in case.
  • I'd like a security person to take a look too, since changes in this area can expose MXSS or sanitizer holes. I added a few folks.
File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
Line 1737, Patchset 10 (Latest): // 4.14.4
Mason Freed . unresolved

Likely 4.13.4?

Line 1741, Patchset 10 (Latest): bookmark =
tree_.ActiveFormattingElements()->BookmarkFor(formatting_element);
Mason Freed . unresolved

Why is this `bookmark` reassignment line here? I think it's likely a bug.

File third_party/blink/renderer/core/html/parser/html_tree_builder_adoption_agency_test.cc
Line 90, Patchset 10 (Latest): // <aside> should contain a new <b> element, because <sdide> is not a
Mason Freed . unresolved

nit: `aside`

File third_party/blink/web_tests/fast/dom/HTMLStyleElement/parser-reparent.html
File-level comment, Patchset 10 (Latest):
Mason Freed . unresolved

How come this one is being deleted?

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Vogelheim
  • Javier Fernandez
  • Michał Bentkowski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
Gerrit-Change-Number: 7535115
Gerrit-PatchSet: 10
Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
Gerrit-Attention: Daniel Vogelheim <voge...@chromium.org>
Gerrit-Attention: Michał Bentkowski <secur...@google.com>
Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 16:20:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Javier Fernandez (Gerrit)

unread,
Feb 24, 2026, 12:07:28 PM (10 days ago) Feb 24
to Mason Freed, Michał Bentkowski, Daniel Vogelheim, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Daniel Vogelheim, Mason Freed and Michał Bentkowski

Javier Fernandez added 6 comments

Patchset-level comments
File-level comment, Patchset 10:
Mason Freed . resolved

I think it's a good idea to conform to the spec here, so thanks for putting this patch together. Two things:

  • Since it's a behavior change, it should definitely be gated behind a runtime enabled feature flag (default "stable" is ok). Just in case.
  • I'd like a security person to take a look too, since changes in this area can expose MXSS or sanitizer holes. I added a few folks.
Javier Fernandez

Acknowledged

File-level comment, Patchset 11 (Latest):
Javier Fernandez . resolved

Thanks for the review.
I addressed some of the suggested changes and replied inline to the questions.

File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
Line 1737, Patchset 10: // 4.14.4
Mason Freed . resolved

Likely 4.13.4?

Javier Fernandez

Yeah, indeed.

Line 1741, Patchset 10: bookmark =
tree_.ActiveFormattingElements()->BookmarkFor(formatting_element);
Mason Freed . unresolved

Why is this `bookmark` reassignment line here? I think it's likely a bug.

Javier Fernandez

Given that we have removed an element from the ActiveFormattingElements list, the bookmark contains an index that is no longer valid.

File third_party/blink/renderer/core/html/parser/html_tree_builder_adoption_agency_test.cc
Line 90, Patchset 10: // <aside> should contain a new <b> element, because <sdide> is not a
Mason Freed . resolved

nit: `aside`

Javier Fernandez

Done

File third_party/blink/web_tests/fast/dom/HTMLStyleElement/parser-reparent.html
Mason Freed . unresolved

How come this one is being deleted?

Javier Fernandez

This test has been added in the CL 1389333005 [1] as a regression tests for the crbug.com/40356377. The bug was about a change in how the styles are being added to the DOM elements. However, there was a case where the some elements in the HTML tree where re-parented, precisely as part of the Agency Adoption algorithm.

After this change, the test case defined in the test doesn't trigger such re-parenting process. I tried to find another case which produced similar behavior, but I couldn't find it.

I don't think that test cover an actual use case, but some unexpected behavior due to the Agency Algorithm's behavior implemented back then. However, I admit my thesis isn't solid enough; the fact that I couldn't find a case where a similar reparenting happens doesn't mean it doesn't exists. Hence, I appreciate any feedback on this issue.

[1] https://codereview.chromium.org/1389333005

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Vogelheim
  • Mason Freed
  • Michał Bentkowski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
Gerrit-Change-Number: 7535115
Gerrit-PatchSet: 11
Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Daniel Vogelheim <voge...@chromium.org>
Gerrit-Attention: Michał Bentkowski <secur...@google.com>
Gerrit-Comment-Date: Tue, 24 Feb 2026 17:07:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Feb 25, 2026, 12:26:00 PM (9 days ago) Feb 25
to Javier Fernandez, Michał Bentkowski, Daniel Vogelheim, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Daniel Vogelheim, Javier Fernandez and Michał Bentkowski

Mason Freed added 2 comments

File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
Line 1741, Patchset 10: bookmark =
tree_.ActiveFormattingElements()->BookmarkFor(formatting_element);
Mason Freed . unresolved

Why is this `bookmark` reassignment line here? I think it's likely a bug.

Javier Fernandez

Given that we have removed an element from the ActiveFormattingElements list, the bookmark contains an index that is no longer valid.

Mason Freed

During the first iteration of the inner loop, if `last_node == furthest_block`, the algorithm correctly moves the bookmark (Step 4.13.7: `bookmark.MoveToAfter(node_entry);`). If a subsequent iteration triggers the `inner_loop_counter > 3` condition, resetting the bookmark to `BookmarkFor(formatting_element)` overwrites the MoveToAfter adjustment made in the earlier iteration. This will cause the adopted elements to be inserted in the wrong position in the formatting elements list.

Since `Remove()` invalidates the existing bookmark index, we might need to handle that invalidation gracefully somehow, rather than resetting the bookmark to the original formatting_element.

Test case:
`<b><i><s><u><em><div></b><p>X</p>`

File third_party/blink/web_tests/fast/dom/HTMLStyleElement/parser-reparent.html
File-level comment, Patchset 10:
Mason Freed . resolved

How come this one is being deleted?

Javier Fernandez

This test has been added in the CL 1389333005 [1] as a regression tests for the crbug.com/40356377. The bug was about a change in how the styles are being added to the DOM elements. However, there was a case where the some elements in the HTML tree where re-parented, precisely as part of the Agency Adoption algorithm.

After this change, the test case defined in the test doesn't trigger such re-parenting process. I tried to find another case which produced similar behavior, but I couldn't find it.

I don't think that test cover an actual use case, but some unexpected behavior due to the Agency Algorithm's behavior implemented back then. However, I admit my thesis isn't solid enough; the fact that I couldn't find a case where a similar reparenting happens doesn't mean it doesn't exists. Hence, I appreciate any feedback on this issue.

[1] https://codereview.chromium.org/1389333005

Mason Freed

Thanks for the archeology. I'm ok deleting it, given what you found.

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Vogelheim
  • Javier Fernandez
  • Michał Bentkowski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
Gerrit-Change-Number: 7535115
Gerrit-PatchSet: 11
Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
Gerrit-Attention: Daniel Vogelheim <voge...@chromium.org>
Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
Gerrit-Attention: Michał Bentkowski <secur...@google.com>
Gerrit-Comment-Date: Wed, 25 Feb 2026 17:25:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
Comment-In-Reply-To: Javier Fernandez <jfern...@igalia.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Daniel Vogelheim (Gerrit)

unread,
Feb 25, 2026, 12:58:18 PM (9 days ago) Feb 25
to Javier Fernandez, Daniel Vogelheim, Mason Freed, Michał Bentkowski, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Javier Fernandez and Michał Bentkowski

Daniel Vogelheim voted and added 2 comments

Votes added by Daniel Vogelheim

Code-Review+1

2 comments

Patchset-level comments
File-level comment, Patchset 10:
Mason Freed . unresolved

I think it's a good idea to conform to the spec here, so thanks for putting this patch together. Two things:

  • Since it's a behavior change, it should definitely be gated behind a runtime enabled feature flag (default "stable" is ok). Just in case.
  • I'd like a security person to take a look too, since changes in this area can expose MXSS or sanitizer holes. I added a few folks.
Javier Fernandez

Acknowledged

Daniel Vogelheim

I'd like a security person to take a look too, since changes in this area can expose MXSS or sanitizer holes. I added a few folks.

Thanks. I don't see an additional risk here.

Sanitizer: Sanitizer deliberately runs _after_ the full parser - and thus after any re-parenting - and thus shouldn't be affected. So I don't think Sanitizer would be affected. (The only Sanitizer construct of relevance here is replace-with-children, which would see whatever final tree the HTML parser produces.)

mXSS: I think the whole re-parenting is indeed mXSS-sensitive, but I don't think this opens any opportunities that weren't there before. At the worst, people might have to adopt their POCs a little... :-D

----

If we want to be fancy, we could include an additional test in third_party/blink/web_tests/external/wpt/sanitizer-api/sethtml-tree-construction.sub.dat that ensures Sanitizer only looks at it after the full parse.

E.g. something like this, adopted from run-adoption01-data.

  • If Sanitizer runs before adoption agency, then result should be <div><b> only.
  • In the current state (before this patch), then result should have an empty <aside>

```
#data
<div><b><em><foo><foob><fooc><aside></b></em></div>
#config
{ "removeElements": ["em"] }
#document
| <div>
| <b>
| <aside>
| <b>
```

Daniel Vogelheim . resolved

lgtm (from Sanitizer perspective; please still wait for other reviewers)

Open in Gerrit

Related details

Attention is currently required from:
  • Javier Fernandez
  • Michał Bentkowski
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
    Gerrit-Change-Number: 7535115
    Gerrit-PatchSet: 11
    Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
    Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
    Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Attention: Michał Bentkowski <secur...@google.com>
    Gerrit-Comment-Date: Wed, 25 Feb 2026 17:57:55 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Javier Fernandez (Gerrit)

    unread,
    Mar 3, 2026, 6:58:26 AM (4 days ago) Mar 3
    to Daniel Vogelheim, Mason Freed, Michał Bentkowski, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
    Attention needed from Mason Freed and Michał Bentkowski

    Javier Fernandez added 2 comments

    Patchset-level comments
    File-level comment, Patchset 13 (Latest):
    Javier Fernandez . resolved

    Hi @masonf
    The last submitted patch should have fixed the issue you mentioned in the last review. Could you please take a look ?
    Thanks.

    File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
    Line 1741, Patchset 10: bookmark =
    tree_.ActiveFormattingElements()->BookmarkFor(formatting_element);
    Mason Freed . unresolved

    Why is this `bookmark` reassignment line here? I think it's likely a bug.

    Javier Fernandez

    Given that we have removed an element from the ActiveFormattingElements list, the bookmark contains an index that is no longer valid.

    Mason Freed

    During the first iteration of the inner loop, if `last_node == furthest_block`, the algorithm correctly moves the bookmark (Step 4.13.7: `bookmark.MoveToAfter(node_entry);`). If a subsequent iteration triggers the `inner_loop_counter > 3` condition, resetting the bookmark to `BookmarkFor(formatting_element)` overwrites the MoveToAfter adjustment made in the earlier iteration. This will cause the adopted elements to be inserted in the wrong position in the formatting elements list.

    Since `Remove()` invalidates the existing bookmark index, we might need to handle that invalidation gracefully somehow, rather than resetting the bookmark to the original formatting_element.

    Test case:
    `<b><i><s><u><em><div></b><p>X</p>`

    Javier Fernandez

    Yeah, the way I overrode the bookmark was indeed buggy. I defined a new unit test with that case.

    The last patch fixed the bug and I think it regenerates the bookmark correctly after removing the element form the formatting list.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mason Freed
    • Michał Bentkowski
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
    Gerrit-Change-Number: 7535115
    Gerrit-PatchSet: 13
    Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
    Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: Michał Bentkowski <secur...@google.com>
    Gerrit-Comment-Date: Tue, 03 Mar 2026 11:58:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Michał Bentkowski (Gerrit)

    unread,
    Mar 3, 2026, 7:03:32 AM (4 days ago) Mar 3
    to Javier Fernandez, Daniel Vogelheim, Mason Freed, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
    Attention needed from Javier Fernandez and Mason Freed

    Michał Bentkowski added 1 comment

    Patchset-level comments
    Michał Bentkowski . resolved

    LGTM, while I agree this code is in a potentially hot mXSS area, I don't think it gives any new capabilities that weren't there before.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Javier Fernandez
    • Mason Freed
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
    Gerrit-Change-Number: 7535115
    Gerrit-PatchSet: 13
    Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
    Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Comment-Date: Tue, 03 Mar 2026 12:03:13 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Michał Bentkowski (Gerrit)

    unread,
    Mar 3, 2026, 7:04:04 AM (4 days ago) Mar 3
    to Javier Fernandez, Daniel Vogelheim, Mason Freed, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
    Attention needed from Javier Fernandez and Mason Freed

    Michał Bentkowski added 1 comment

    Patchset-level comments
    Michał Bentkowski . resolved

    LGTM, while I agree this code is in a potentially hot mXSS area, I don't think it gives any new capabilities that weren't there before.

    Michał Bentkowski

    Also I moved myself to CC, since I'm not actually permitted to vote.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Javier Fernandez
    • Mason Freed
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
    Gerrit-Change-Number: 7535115
    Gerrit-PatchSet: 13
    Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
    Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Michał Bentkowski <secur...@google.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Comment-Date: Tue, 03 Mar 2026 12:03:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Michał Bentkowski <secur...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Mar 4, 2026, 6:14:50 PM (2 days ago) Mar 4
    to Javier Fernandez, Michał Bentkowski, Daniel Vogelheim, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
    Attention needed from Javier Fernandez

    Mason Freed added 3 comments

    Patchset-level comments
    Mason Freed . unresolved

    Thanks! I think that looks like the right logic.

    Given the potential for bugs in this area of the code, can you please add a feature flag that guards the new behavior? So that if there are issues, we can roll it back easily? Be sure to add a comment about what the flag does, and a note that it will land in M147 and can be removed in M149.

    File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
    Line 1741, Patchset 13 (Latest): Element* bookmark_element = bookmark.Mark()->GetElement();
    Mason Freed . unresolved

    Can you add this, just above this line?

    ```
    DCHECK(bookmark.Mark());
    ```

    Line 1751, Patchset 13 (Latest): node_in_active_formatting_elements = false;
    Mason Freed . unresolved

    Can you add a comment above this line:

    ```
    // Set to false so the subsequent step (4.13.5) removes the node from
    // the stack of open elements and continues the inner loop.
    ```

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Javier Fernandez
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
    Gerrit-Change-Number: 7535115
    Gerrit-PatchSet: 13
    Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
    Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Michał Bentkowski <secur...@google.com>
    Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
    Gerrit-Comment-Date: Wed, 04 Mar 2026 23:14:39 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Javier Fernandez (Gerrit)

    unread,
    Mar 5, 2026, 6:55:04 PM (yesterday) Mar 5
    to Michał Bentkowski, Daniel Vogelheim, Mason Freed, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, jmedle...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
    Attention needed from Daniel Vogelheim and Mason Freed

    Javier Fernandez added 4 comments

    Patchset-level comments
    File-level comment, Patchset 13:
    Mason Freed . resolved

    Thanks! I think that looks like the right logic.

    Given the potential for bugs in this area of the code, can you please add a feature flag that guards the new behavior? So that if there are issues, we can roll it back easily? Be sure to add a comment about what the flag does, and a note that it will land in M147 and can be removed in M149.

    Javier Fernandez

    Done

    File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
    Line 1741, Patchset 13: Element* bookmark_element = bookmark.Mark()->GetElement();
    Mason Freed . resolved

    Can you add this, just above this line?

    ```
    DCHECK(bookmark.Mark());
    ```

    Javier Fernandez

    Done

    Line 1741, Patchset 10: bookmark =
    tree_.ActiveFormattingElements()->BookmarkFor(formatting_element);
    Mason Freed . resolved

    Why is this `bookmark` reassignment line here? I think it's likely a bug.

    Javier Fernandez

    Given that we have removed an element from the ActiveFormattingElements list, the bookmark contains an index that is no longer valid.

    Mason Freed

    During the first iteration of the inner loop, if `last_node == furthest_block`, the algorithm correctly moves the bookmark (Step 4.13.7: `bookmark.MoveToAfter(node_entry);`). If a subsequent iteration triggers the `inner_loop_counter > 3` condition, resetting the bookmark to `BookmarkFor(formatting_element)` overwrites the MoveToAfter adjustment made in the earlier iteration. This will cause the adopted elements to be inserted in the wrong position in the formatting elements list.

    Since `Remove()` invalidates the existing bookmark index, we might need to handle that invalidation gracefully somehow, rather than resetting the bookmark to the original formatting_element.

    Test case:
    `<b><i><s><u><em><div></b><p>X</p>`

    Javier Fernandez

    Yeah, the way I overrode the bookmark was indeed buggy. I defined a new unit test with that case.

    The last patch fixed the bug and I think it regenerates the bookmark correctly after removing the element form the formatting list.

    Javier Fernandez

    Done

    Line 1751, Patchset 13: node_in_active_formatting_elements = false;
    Mason Freed . resolved

    Can you add a comment above this line:

    ```
    // Set to false so the subsequent step (4.13.5) removes the node from
    // the stack of open elements and continues the inner loop.
    ```

    Javier Fernandez

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Vogelheim
    • Mason Freed
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
      Gerrit-Change-Number: 7535115
      Gerrit-PatchSet: 15
      Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
      Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
      Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-CC: Michał Bentkowski <secur...@google.com>
      Gerrit-Attention: Mason Freed <mas...@chromium.org>
      Gerrit-Attention: Daniel Vogelheim <voge...@chromium.org>
      Gerrit-Comment-Date: Thu, 05 Mar 2026 23:54:50 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mason Freed (Gerrit)

      unread,
      3:22 PM (8 hours ago) 3:22 PM
      to Javier Fernandez, Michał Bentkowski, Daniel Vogelheim, chrom...@appspot.gserviceaccount.com, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, jmedle...@chromium.org, blink-rev...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
      Attention needed from Daniel Vogelheim and Javier Fernandez

      Mason Freed added 2 comments

      File third_party/blink/renderer/core/html/parser/html_tree_builder.cc
      Line 1721, Patchset 16 (Latest): if (node == formatting_element_item) {
      break;
      }
      Mason Freed . unresolved

      Thanks for adding the flag, but this branch still changes position relative to the old code.

      Also, and more critically, I think the new logic (with the flag disabled) just doesn't check `inner_loop_counter` vs. `kInnerIterationLimit` at all. I think that's a potential infinite loop.

      It might be a good idea to just add a big if/else block for the runtime feature, with exactly the old code in the `else` block. That way it's easy to see from inspection that the flag-disabled behavior is exactly the same.

      File third_party/blink/renderer/platform/runtime_enabled_features.json5
      Line 3065, Patchset 16 (Latest): // formatting list when the internal loop reached the maximum number of iterations.
      Mason Freed . unresolved

      nit: line wrap this please.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Daniel Vogelheim
      • Javier Fernandez
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I92a79e68c21f85a52822a57deccbb48ae21afc52
      Gerrit-Change-Number: 7535115
      Gerrit-PatchSet: 16
      Gerrit-Owner: Javier Fernandez <jfern...@igalia.com>
      Gerrit-Reviewer: Daniel Vogelheim <voge...@chromium.org>
      Gerrit-Reviewer: Javier Fernandez <jfern...@igalia.com>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-CC: Michał Bentkowski <secur...@google.com>
      Gerrit-Attention: Daniel Vogelheim <voge...@chromium.org>
      Gerrit-Attention: Javier Fernandez <jfern...@igalia.com>
      Gerrit-Comment-Date: Fri, 06 Mar 2026 20:22:07 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages