• Yu Han's avatar
    Adds ability for slot to preserve order of its manually assigned nodes. · e627e1f4
    Yu Han authored
    Prior to this CL, the ordering of the manually assigned nodes is not
    preserved. Nodes were assigned in tree-order. In addition, assignment
    is not absolute. A slotable node can be assign to multiple slots, and
    where it appears is when the assigned slot first appear in a tree-order
    traversal, not the last slot the node is assigned to.
    
    This CL does two things. One, the order of manually assigned node is
    preserved. Two, assignment is absolute. The implementation uses a
    HeapHashMap, candidate_assigned_slot_map_, to keep track of
    assignment node -> slot. It uses this map during node assignment to
    find if another assigned slot exists. When found, the node is
    removed from the previously assigned slot.
    
    Preserving the ordering of manually assigned nodes is done in
    HTMLSlotElement::UpdateManuallyAssignedNodesOrdering(). This is called
    at the end of SlotAssignment::RecalcAssignment(). RecalcAssignment()
    walks the ShadowHost's children in tree-order, so the assigned node
    could be out of order from how these nodes were assigned.  I thought
    about making a separate function for manually assigned nodes, looping
    though assigned nodes instead. But I decided against it at this point
    due to the complexity of the recalc function.
    
    For Reference: point 1 in this comment is addressed by this CL.
    https://github.com/whatwg/html/issues/3534#issuecomment-537802687
    
    
    Bug: 869308
    Change-Id: Idc45cb593313b00f13cd5f29df8972bfe246ecce
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2103403Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
    Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
    Commit-Queue: Yu Han <yuzhehan@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#757574}
    e627e1f4
imperative-api.html 1.75 KB