[TreesInViz] Change T* Node() to const T& Node() in PropertyTree [chromium/src : main]

0 views
Skip to first unread message

Tzarial (Gerrit)

unread,
Apr 29, 2026, 6:04:01 PM (6 days ago) Apr 29
to Zhenyao Mo, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
Attention needed from Zhenyao Mo

Tzarial added 1 comment

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Tzarial . resolved

PTAL, thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Zhenyao Mo
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • 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: I19af920eafe6dd06c20ed70c78baa1db0effaab6
Gerrit-Change-Number: 7795685
Gerrit-PatchSet: 4
Gerrit-Owner: Tzarial <zo...@chromium.org>
Gerrit-Reviewer: Tzarial <zo...@chromium.org>
Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Ian Vollick <vol...@chromium.org>
Gerrit-CC: Kenneth Rohde Christiansen <kenneth.ch...@gmail.com>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Zhenyao Mo <z...@chromium.org>
Gerrit-Comment-Date: Wed, 29 Apr 2026 22:03:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Zhenyao Mo (Gerrit)

unread,
Apr 30, 2026, 12:18:38 PM (5 days ago) Apr 30
to Tzarial, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
Attention needed from Tzarial

Zhenyao Mo added 3 comments

Patchset-level comments
Zhenyao Mo . resolved

Thank you for working on this. It's a great effort to a more secure code base.

I haven't read through the entire CL, but I have some early questions on the design.

File cc/trees/property_tree.cc
Line 215, Patchset 4 (Latest): TransformNode* node = MutableNode(id);
Zhenyao Mo . unresolved

Same here, we expect the return to be non-null, so its a candidate to return reference.

Line 273, Patchset 4 (Latest): TransformNode* node = MutableNode(id);
Zhenyao Mo . unresolved

Quickly scanning through this file, I noticed, for example, here apparently we expect the node and parent_node to be non-null. So should we switch it also to reference rather than pointer? i.e., have a non-constant version of Node() and Parent() as well?

Open in Gerrit

Related details

Attention is currently required from:
  • Tzarial
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: I19af920eafe6dd06c20ed70c78baa1db0effaab6
    Gerrit-Change-Number: 7795685
    Gerrit-PatchSet: 4
    Gerrit-Owner: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Ian Vollick <vol...@chromium.org>
    Gerrit-CC: Kenneth Rohde Christiansen <kenneth.ch...@gmail.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Tzarial <zo...@chromium.org>
    Gerrit-Comment-Date: Thu, 30 Apr 2026 16:18:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tzarial (Gerrit)

    unread,
    Apr 30, 2026, 1:04:09 PM (5 days ago) Apr 30
    to Zhenyao Mo, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
    Attention needed from Zhenyao Mo

    Tzarial added 2 comments

    File cc/trees/property_tree.cc
    Line 215, Patchset 4 (Latest): TransformNode* node = MutableNode(id);
    Zhenyao Mo . unresolved

    Same here, we expect the return to be non-null, so its a candidate to return reference.

    Tzarial

    We didn't used to allow non-const references, but this seems to be recommended by https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs

    I will update the CL to return references.

    Line 273, Patchset 4 (Latest): TransformNode* node = MutableNode(id);
    Zhenyao Mo . unresolved

    Quickly scanning through this file, I noticed, for example, here apparently we expect the node and parent_node to be non-null. So should we switch it also to reference rather than pointer? i.e., have a non-constant version of Node() and Parent() as well?

    Tzarial

    Yes. That will be a follow up CL; this is large enough that I want to limit the scope as much as possible.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Zhenyao Mo
    Gerrit-Attention: Zhenyao Mo <z...@chromium.org>
    Gerrit-Comment-Date: Thu, 30 Apr 2026 17:03:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Zhenyao Mo <z...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tzarial (Gerrit)

    unread,
    May 4, 2026, 12:09:12 PM (yesterday) May 4
    to Zhenyao Mo, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
    Attention needed from Zhenyao Mo

    Tzarial added 2 comments

    Patchset-level comments
    File-level comment, Patchset 9 (Latest):
    Tzarial . resolved

    This CL should be ready for another review pass!

    File cc/trees/property_tree.cc
    Line 215, Patchset 4: TransformNode* node = MutableNode(id);
    Zhenyao Mo . resolved

    Same here, we expect the return to be non-null, so its a candidate to return reference.

    Tzarial

    We didn't used to allow non-const references, but this seems to be recommended by https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs

    I will update the CL to return references.

    Tzarial

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Zhenyao Mo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: I19af920eafe6dd06c20ed70c78baa1db0effaab6
    Gerrit-Change-Number: 7795685
    Gerrit-PatchSet: 9
    Gerrit-Owner: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Ian Vollick <vol...@chromium.org>
    Gerrit-CC: Kenneth Rohde Christiansen <kenneth.ch...@gmail.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Zhenyao Mo <z...@chromium.org>
    Gerrit-Comment-Date: Mon, 04 May 2026 16:09:00 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Zhenyao Mo <z...@chromium.org>
    Comment-In-Reply-To: Tzarial <zo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Zhenyao Mo (Gerrit)

    unread,
    May 4, 2026, 12:50:30 PM (yesterday) May 4
    to Tzarial, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
    Attention needed from Tzarial

    Zhenyao Mo added 3 comments

    Patchset-level comments
    Zhenyao Mo . resolved

    Again, I only looked at property_tree.h first and I have two questions.

    It's OK this is by design and you intend to clean it up in a followup.

    Let me know and I'll finish the review.

    Thanks for taking on such a large but super valuable refactoring!

    File cc/trees/property_tree.h
    Line 136, Patchset 9 (Latest): T* MutableFindNodeFromElementId(ElementId id) {
    Zhenyao Mo . unresolved

    Isn't this the same as T* FindNodeFromElementId() in #121?

    Line 116, Patchset 9 (Latest): T* MutableBack() { return size() ? &nodes_.back() : nullptr; }
    Zhenyao Mo . unresolved

    Isn't this the same as T* back() in #113?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Tzarial
    Gerrit-Attention: Tzarial <zo...@chromium.org>
    Gerrit-Comment-Date: Mon, 04 May 2026 16:50:11 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tzarial (Gerrit)

    unread,
    May 4, 2026, 1:53:42 PM (yesterday) May 4
    to Zhenyao Mo, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
    Attention needed from Zhenyao Mo

    Tzarial added 2 comments

    File cc/trees/property_tree.h
    Line 136, Patchset 9: T* MutableFindNodeFromElementId(ElementId id) {
    Zhenyao Mo . unresolved

    Isn't this the same as T* FindNodeFromElementId() in #121?

    Tzarial

    Yes. Eliminated the old one.

    Line 116, Patchset 9: T* MutableBack() { return size() ? &nodes_.back() : nullptr; }
    Zhenyao Mo . unresolved

    Isn't this the same as T* back() in #113?

    Tzarial

    Yes. Eliminated the old one.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Zhenyao Mo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: I19af920eafe6dd06c20ed70c78baa1db0effaab6
    Gerrit-Change-Number: 7795685
    Gerrit-PatchSet: 10
    Gerrit-Owner: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Ian Vollick <vol...@chromium.org>
    Gerrit-CC: Kenneth Rohde Christiansen <kenneth.ch...@gmail.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Zhenyao Mo <z...@chromium.org>
    Gerrit-Comment-Date: Mon, 04 May 2026 17:53:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Zhenyao Mo <z...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Zhenyao Mo (Gerrit)

    unread,
    1:05 PM (1 hour ago) 1:05 PM
    to Tzarial, Dirk Schulze, Kenneth Rohde Christiansen, Stephen Chenney, Menard, Alexis, Olga Gerchikov, Chromium LUCI CQ, Ian Vollick, android-bu...@system.gserviceaccount.com, blink-reviews-p...@chromium.org, fmalit...@chromium.org, kinuko...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org, drott+bl...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, fserb...@chromium.org, cc-...@chromium.org, jbauma...@chromium.org
    Attention needed from Tzarial

    Zhenyao Mo added 25 comments

    Patchset-level comments
    File-level comment, Patchset 11 (Latest):
    Zhenyao Mo . resolved

    Thank you for being patient.

    File cc/layers/render_surface_impl.cc
    Line 55, Patchset 11 (Latest): EffectNode& node = effect_tree.MutableNode(EffectTreeIndex());
    Zhenyao Mo . unresolved

    This can be Node instead

    File cc/trees/draw_property_utils.cc
    Line 218, Patchset 11 (Latest): DCHECK(filter_node);
    Zhenyao Mo . unresolved

    Here can be const EffectNode& and remove the DCHECK.

    Line 247, Patchset 11 (Latest): const ClipNode* clip_node = &clip_tree.Node(local_clip_id);
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 249, Patchset 11 (Latest): const EffectNode* target_node = &effect_tree.Node(target_id);
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 409, Patchset 11 (Latest): const TransformNode* node = &tree.Node(layer->transform_tree_index());
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 411, Patchset 11 (Latest): const TransformNode* parent = &tree.Node(node->parent_id);
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 589, Patchset 11 (Latest): const EffectNode* node = &tree.Node(render_surface->EffectTreeIndex());
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 604, Patchset 11 (Latest): const EffectNode* node = &tree.Node(layer->effect_tree_index());
    Zhenyao Mo . unresolved

    Can these two be reference instead?

    Line 696, Patchset 11 (Latest): const EffectNode* effect_node =
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 724, Patchset 11 (Latest): &property_trees->clip_tree().Node(layer->clip_tree_index());
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 729, Patchset 11 (Latest): const EffectNode* root_effect_node =
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 1062, Patchset 11 (Latest): const TransformNode* transform_node =
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 1064, Patchset 11 (Latest): const EffectNode* effect_node =
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 1085, Patchset 11 (Latest): &property_trees->transform_tree().Node(layer->transform_tree_index());
    Zhenyao Mo . unresolved

    Can this be reference instead?

    Line 1472, Patchset 11 (Latest): &property_trees->effect_tree().Node(render_surface->EffectTreeIndex());
    Zhenyao Mo . unresolved

    Can this be reference instead?

    File cc/trees/layer_tree_host.cc
    Line 1118, Patchset 11 (Latest): DCHECK_NE(layer->scroll_tree_index(), kInvalidPropertyNodeId);
    Zhenyao Mo . unresolved

    I think you can just do Node as you did in #1124. It's more than this DCHECK_NE

    File cc/trees/layer_tree_impl.cc
    Line 3003, Patchset 11 (Latest): node_id = node.parent_frame_id;
    Zhenyao Mo . resolved

    Both this loop and the above are much more secure!

    File cc/trees/property_tree.h
    Line 136, Patchset 9: T* MutableFindNodeFromElementId(ElementId id) {
    Zhenyao Mo . resolved

    Isn't this the same as T* FindNodeFromElementId() in #121?

    Tzarial

    Yes. Eliminated the old one.

    Zhenyao Mo

    Acknowledged

    Line 116, Patchset 9: T* MutableBack() { return size() ? &nodes_.back() : nullptr; }
    Zhenyao Mo . resolved

    Isn't this the same as T* back() in #113?

    Tzarial

    Yes. Eliminated the old one.

    Zhenyao Mo

    Acknowledged

    File cc/trees/property_tree.cc
    Line 273, Patchset 4: TransformNode* node = MutableNode(id);
    Zhenyao Mo . resolved

    Quickly scanning through this file, I noticed, for example, here apparently we expect the node and parent_node to be non-null. So should we switch it also to reference rather than pointer? i.e., have a non-constant version of Node() and Parent() as well?

    Tzarial

    Yes. That will be a follow up CL; this is large enough that I want to limit the scope as much as possible.

    Zhenyao Mo

    Acknowledged

    File third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc
    Line 1183, Patchset 11 (Latest): auto& cc_node = effect_tree.MutableNode(effect_id);
    Zhenyao Mo . unresolved

    This can be const and Node

    File third_party/blink/renderer/platform/graphics/compositing/property_tree_manager.cc
    Line 511, Patchset 11 (Latest): scroll_tree_.MutableFindNodeFromElementId(element_id)) {
    Zhenyao Mo . unresolved

    This can be const

    Line 532, Patchset 11 (Latest): transform_tree_.MutableFindNodeFromElementId(element_id);
    Zhenyao Mo . unresolved

    This can be const

    Line 600, Patchset 11 (Latest): DCHECK_NE(parent_id, cc::kInvalidPropertyNodeId);
    Zhenyao Mo . unresolved

    No need to DCHECK here because Node() below does the same CHECK

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Tzarial
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not 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: I19af920eafe6dd06c20ed70c78baa1db0effaab6
    Gerrit-Change-Number: 7795685
    Gerrit-PatchSet: 11
    Gerrit-Owner: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Tzarial <zo...@chromium.org>
    Gerrit-Reviewer: Zhenyao Mo <z...@chromium.org>
    Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
    Gerrit-CC: Ian Vollick <vol...@chromium.org>
    Gerrit-CC: Kenneth Rohde Christiansen <kenneth.ch...@gmail.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Tzarial <zo...@chromium.org>
    Gerrit-Comment-Date: Tue, 05 May 2026 17:05:03 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Zhenyao Mo <z...@chromium.org>
    Comment-In-Reply-To: Tzarial <zo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages