Adds ability to restore previous state in manual slot assignment when encountered exception.
Previous to this CL, during manual slot assignment, if an exception is thrown, the state of the HTMLSlotElement is indeterminate. HTMLSlotElement should be restored to the previous state where previous assigned nodes are preserved. This CL implements this behavior by doing the exception check of assigned nodes before the actual assignment. Thus, if an exception is encountered, the assign() function could just return, preserving the previous state. However, this way of doing slot assignment adds an extra loop for assigned nodes. I had tried to do it in one loop. But that required saving the previous state of the Slot and restoring it if exception is detected. I think the added complexity isn't worth it for the little performance benefit. In addition, I made sure that the state of the candidate_assigned_slot_map_ is accurate after each slot assignment recalc. The previous implementation could leave removed nodes still in the map. Because in SlotAssignment:RecalcAssignment(), the children traversal, NodeTraversal::ChildrenOf(owner_->host(), wouldn't encounter removed nodes. Bug: 869308 Change-Id: I3c8938f1c4360d664497b6d16a7753c545729e6f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124293 Commit-Queue: Yu Han <yuzhehan@chromium.org> Reviewed-by:Mason Freed <masonfreed@chromium.org> Cr-Commit-Position: refs/heads/master@{#757723}
Showing
Please register or sign in to comment