Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Cyclic elements, NamedNodeMap #50

Merged
merged 23 commits into from May 28, 2021
Merged

Conversation

philip-peterson
Copy link
Collaborator

@philip-peterson philip-peterson commented May 21, 2021

Introduces a layer to elements to store common functionality like NamedNodeMap. In this we store a reference back up to the Node which owns the Element (Elements are always inside of Nodes because of our composition system which replaces the C++ inheritance model). Note that in order to do this we needed a new ConcreteNode constructor which can handle the cyclic nature. Fortunately, with the builders, this isn't so much an issue.

Also fleshes out NamedNodeMap to lay foundations for support for attributes.

@philip-peterson philip-peterson changed the title ElementCommon and rename the old ElementStore to ElementKind Cyclic elements, NamedNodeMap May 22, 2021
@philip-peterson
Copy link
Collaborator Author

Alright, I think it's settled down now, should be ready for review.

.common
.ptr_eq(&Arc::downgrade(&button.common)));

match &button.common.node_graph.node.contents {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just asserts that the weak pointers do in fact point back up to the correct structures and not to some second cloned version of the underlying data.

HtmlBodyStore,
))),
);
let button = ElementNodeArc::new_cyclic(sbox.clone(), |node_weak| {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to update these instantiations because of the cyclic nature of the ElementStore now.

node_store: ElementKind,

/// Reference back up to the DOM node
pub(crate) node: AnyNodeWeak,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the cause for all the complexity. We will need to be able to have references to the node for things like Attr.ownerElement (which is not only readable by the user but also used when updating the NamedNodeMap).

impl AttributeStore {
pub(crate) fn new(name: String) -> AttributeStore {
AttributeStore {
name,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to lower-case this

@philip-peterson
Copy link
Collaborator Author

Going to merge this since it's been open for a week.

@philip-peterson philip-peterson merged commit ffcc31b into master May 28, 2021
@philip-peterson philip-peterson deleted the peterson/element-pointers branch May 28, 2021 03:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant