diff options
author | Linus Groh <mail@linusgroh.de> | 2022-04-20 19:48:48 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-04-20 19:49:01 +0200 |
commit | 95541d706497479c58bbb07d3ced965c354ba579 (patch) | |
tree | a8b2204e90c86b5e8344c201db1aa51f3ffebcec /Userland/Libraries/LibWeb/DOM | |
parent | bf16061142456473de66f1c3c85345ca8dd04377 (diff) | |
download | serenity-95541d706497479c58bbb07d3ced965c354ba579.zip |
LibWeb: Fix various spec comment inconsistencies
- Don't add multiple numbers to nested steps, just the innermost one
(as rendered in the HTML document)
- "Otherwise" comments go before the else, not after it
- "FIXME:" goes before step number, not between it and the comment text
- Always add a period between number and comment text
The majority of these were introduced in #13756, but some unrelated ones
have been updated as well.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp | 121 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Node.cpp | 103 |
3 files changed, 118 insertions, 116 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index f84792455a..409ccd43de 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1354,11 +1354,11 @@ void Document::evaluate_media_queries_and_report_changes() // 1. For each MediaQueryList object target that has doc as its document, // in the order they were created, oldest first, run these substeps: for (auto& media_query_list_ptr : m_media_query_lists) { - // 1.1. If target’s matches state has changed since the last time these steps - // were run, fire an event at target using the MediaQueryListEvent constructor, - // with its type attribute initialized to change, its isTrusted attribute - // initialized to true, its media attribute initialized to target’s media, - // and its matches attribute initialized to target’s matches state. + // 1. If target’s matches state has changed since the last time these steps + // were run, fire an event at target using the MediaQueryListEvent constructor, + // with its type attribute initialized to change, its isTrusted attribute + // initialized to true, its media attribute initialized to target’s media, + // and its matches attribute initialized to target’s matches state. if (media_query_list_ptr.is_null()) continue; auto media_query_list = media_query_list_ptr.strong_ref(); diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index 8f2a552855..52bd6a3913 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -36,17 +36,17 @@ static EventTarget* retarget(EventTarget* left, EventTarget* right) // To retarget an object A against an object B, repeat these steps until they return an object: for (;;) { // 1. If one of the following is true then return A. - // 1.1 A is not a node + // - A is not a node if (!is<Node>(left)) return left; - // 1.2 A’s root is not a shadow root + // - A’s root is not a shadow root auto* left_node = verify_cast<Node>(left); auto& left_root = left_node->root(); if (!is<ShadowRoot>(left_root)) return left; - // B is a node and A’s root is a shadow-including inclusive ancestor of B + // - B is a node and A’s root is a shadow-including inclusive ancestor of B if (is<Node>(right) && left_root.is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*right))) return left; @@ -181,11 +181,11 @@ void EventDispatcher::invoke(Event::PathEntry& struct_, Event& event, Event::Pha // 9. If found is false and event’s isTrusted attribute is true, then: if (!found && event.is_trusted()) { - // 9.1 Let originalEventType be event’s type attribute value. + // 1. Let originalEventType be event’s type attribute value. auto original_event_type = event.type(); - // 9.2 If event’s type attribute value is a match for any of the strings in the first column in the following table, - // set event’s type attribute value to the string in the second column on the same row as the matching string, and return otherwise. + // 2. If event’s type attribute value is a match for any of the strings in the first column in the following table, + // set event’s type attribute value to the string in the second column on the same row as the matching string, and return otherwise. if (event.type() == "animationend") event.set_type("webkitAnimationEnd"); else if (event.type() == "animationiteration") @@ -197,10 +197,10 @@ void EventDispatcher::invoke(Event::PathEntry& struct_, Event& event, Event::Pha else return; - // 9.3 Inner invoke with event, listeners, phase, invocationTargetInShadowTree, and legacyOutputDidListenersThrowFlag if given. + // 3. Inner invoke with event, listeners, phase, invocationTargetInShadowTree, and legacyOutputDidListenersThrowFlag if given. inner_invoke(event, listeners, phase, invocation_target_in_shadow_tree); - // 9.4 Set event’s type attribute value to originalEventType. + // 4. Set event’s type attribute value to originalEventType. event.set_type(original_event_type); } } @@ -229,95 +229,96 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr< bool clear_targets = false; // 5. If target is not relatedTarget or target is event’s relatedTarget, then: if (related_target != target || event->related_target() == target) { - // 5.1 Let touchTargets be a new list. + // 1. Let touchTargets be a new list. Event::TouchTargetList touch_targets; - // 5.2 For each touchTarget of event’s touch target list, append the result of retargeting touchTarget against target to touchTargets. + // 2. For each touchTarget of event’s touch target list, append the result of retargeting touchTarget against target to touchTargets. for (auto& touch_target : event->touch_target_list()) { touch_targets.append(retarget(touch_target, target)); } - // 5.3 Append to an event path with event, target, targetOverride, relatedTarget, touchTargets, and false. + // 3. Append to an event path with event, target, targetOverride, relatedTarget, touchTargets, and false. event->append_to_path(*target, target_override, related_target, touch_targets, false); - // 5.4 Let isActivationEvent be true, if event is a MouseEvent object and event’s type attribute is "click"; otherwise false. + // 4. Let isActivationEvent be true, if event is a MouseEvent object and event’s type attribute is "click"; otherwise false. bool is_activation_event = is<UIEvents::MouseEvent>(*event) && event->type() == HTML::EventNames::click; - // 5.5 If isActivationEvent is true and target has activation behavior, then set activationTarget to target. + // 5. If isActivationEvent is true and target has activation behavior, then set activationTarget to target. if (is_activation_event && target->activation_behavior) activation_target = target; - // 5.6 FIXME: Let slottable be target, if target is a slottable and is assigned, and null otherwise. + // FIXME: 6. Let slottable be target, if target is a slottable and is assigned, and null otherwise. - // 5.7 Let slot-in-closed-tree be false + // 7. Let slot-in-closed-tree be false bool slot_in_closed_tree = false; - // 5.8 Let parent be the result of invoking target’s get the parent with event. + // 8. Let parent be the result of invoking target’s get the parent with event. auto* parent = target->get_parent(event); - // 5.9 While parent is non-null: + // 9. While parent is non-null: while (parent) { - // FIXME: - // 5.9.1 If slottable is non-null: - // 5.9.1.1 Assert: parent is a slot. - // 5.9.1.2 Set slottable to null. - // 5.9.1.3 If parent’s root is a shadow root whose mode is "closed", then set slot-in-closed-tree to true. - // 5.9.2 If parent is a slottable and is assigned, then set slottable to parent. - - // 5.9.3 Let relatedTarget be the result of retargeting event’s relatedTarget against parent. + // FIXME: 1. If slottable is non-null: + // 1. Assert: parent is a slot. + // 2. Set slottable to null. + // 3. If parent’s root is a shadow root whose mode is "closed", then set slot-in-closed-tree to true. + // FIXME: 2. If parent is a slottable and is assigned, then set slottable to parent. + + // 3. Let relatedTarget be the result of retargeting event’s relatedTarget against parent. related_target = retarget(event->related_target(), parent); - // 5.9.4 Let touchTargets be a new list. + // 4. Let touchTargets be a new list. touch_targets.clear(); - // 5.9.5 For each touchTarget of event’s touch target list, append the result of retargeting touchTarget against parent to touchTargets. + // 5. For each touchTarget of event’s touch target list, append the result of retargeting touchTarget against parent to touchTargets. for (auto& touch_target : event->touch_target_list()) { touch_targets.append(retarget(touch_target, parent)); } - // 5.9.6 If parent is a Window object, or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then: + // 6. If parent is a Window object, or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then: if (is<HTML::Window>(parent) || (is<Node>(parent) && verify_cast<Node>(*target).root().is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*parent)))) { - // 5.9.6.1 If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent. + // 1. If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent. if (is_activation_event && event->bubbles() && !activation_target && parent->activation_behavior) activation_target = parent; - // 5.9.6.2 Append to an event path with event, parent, null, relatedTarget, touchTargets, and slot-in-closed-tree. + // 2. Append to an event path with event, parent, null, relatedTarget, touchTargets, and slot-in-closed-tree. event->append_to_path(*parent, nullptr, related_target, touch_targets, slot_in_closed_tree); - } else if (related_target == parent) { - // 5.9.7 Otherwise, if parent is relatedTarget, then set parent to null. + } + // 7. Otherwise, if parent is relatedTarget, then set parent to null. + else if (related_target == parent) { parent = nullptr; - } else { - // 5.9.8 Otherwise, set target to parent and then: + } + // 8. Otherwise, set target to parent and then: + else { target = *parent; - // 5.9.8.1 If isActivationEvent is true, activationTarget is null, and target has activation behavior, then set activationTarget to target. + // 1. If isActivationEvent is true, activationTarget is null, and target has activation behavior, then set activationTarget to target. if (is_activation_event && !activation_target && target->activation_behavior) activation_target = target; - // 5.9.8.2 Append to an event path with event, parent, target, relatedTarget, touchTargets, and slot-in-closed-tree. + // 2. Append to an event path with event, parent, target, relatedTarget, touchTargets, and slot-in-closed-tree. event->append_to_path(*parent, target, related_target, touch_targets, slot_in_closed_tree); } - // 5.9.9 If parent is non-null, then set parent to the result of invoking parent’s get the parent with event. + // 9. If parent is non-null, then set parent to the result of invoking parent’s get the parent with event. if (parent) { parent = parent->get_parent(event); } - // 5.9.10 Set slot-in-closed-tree to false. + // 10. Set slot-in-closed-tree to false. slot_in_closed_tree = false; } - // 5.10 Let clearTargetsStruct be the last struct in event’s path whose shadow-adjusted target is non-null. + // 10. Let clearTargetsStruct be the last struct in event’s path whose shadow-adjusted target is non-null. auto clear_targets_struct = event->path().last_matching([](auto& entry) { return !entry.shadow_adjusted_target.is_null(); }); VERIFY(clear_targets_struct.has_value()); - // 5.11 Let clearTargets be true if clearTargetsStruct’s shadow-adjusted target, clearTargetsStruct’s relatedTarget, - // or an EventTarget object in clearTargetsStruct’s touch target list is a node and its root is a shadow root; otherwise false. + // 11. Let clearTargets be true if clearTargetsStruct’s shadow-adjusted target, clearTargetsStruct’s relatedTarget, + // or an EventTarget object in clearTargetsStruct’s touch target list is a node and its root is a shadow root; otherwise false. if (is<Node>(clear_targets_struct.value().shadow_adjusted_target.ptr())) { auto& shadow_adjusted_target_node = verify_cast<Node>(*clear_targets_struct.value().shadow_adjusted_target); if (is<ShadowRoot>(shadow_adjusted_target_node.root())) @@ -342,39 +343,40 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr< } } - // 5.12 If activationTarget is non-null and activationTarget has legacy-pre-activation behavior, then run activationTarget’s legacy-pre-activation behavior. + // 12. If activationTarget is non-null and activationTarget has legacy-pre-activation behavior, then run activationTarget’s legacy-pre-activation behavior. if (activation_target) activation_target->legacy_pre_activation_behavior(); - // 5.13 For each struct in event’s path, in reverse order: + // 13. For each struct in event’s path, in reverse order: for (auto& entry : event->path().in_reverse()) { - // 5.13.1 If struct’s shadow-adjusted target is non-null, then set event’s eventPhase attribute to AT_TARGET. + // 1. If struct’s shadow-adjusted target is non-null, then set event’s eventPhase attribute to AT_TARGET. if (entry.shadow_adjusted_target) event->set_phase(Event::Phase::AtTarget); + // 2. Otherwise, set event’s eventPhase attribute to CAPTURING_PHASE. else - // 5.13.2 Otherwise, set event’s eventPhase attribute to CAPTURING_PHASE. event->set_phase(Event::Phase::CapturingPhase); - // 5.13.3 Invoke with struct, event, "capturing", and legacyOutputDidListenersThrowFlag if given. + // 3. Invoke with struct, event, "capturing", and legacyOutputDidListenersThrowFlag if given. invoke(entry, event, Event::Phase::CapturingPhase); } - // 5.14 For each struct in event’s path: + // 14. For each struct in event’s path: for (auto& entry : event->path()) { - // 5.14.1 If struct’s shadow-adjusted target is non-null, then set event’s eventPhase attribute to AT_TARGET. + // 1. If struct’s shadow-adjusted target is non-null, then set event’s eventPhase attribute to AT_TARGET. if (entry.shadow_adjusted_target) { event->set_phase(Event::Phase::AtTarget); - } else { - // 5.14.2 Otherwise: - // 5.14.2.1 If event’s bubbles attribute is false, then continue. + } + // 2. Otherwise: + else { + // 1. If event’s bubbles attribute is false, then continue. if (!event->bubbles()) continue; - // 5.14.2.2 Set event’s eventPhase attribute to BUBBLING_PHASE. + // 2. Set event’s eventPhase attribute to BUBBLING_PHASE. event->set_phase(Event::Phase::BubblingPhase); } - // 5.14.3 Invoke with struct, event, "bubbling", and legacyOutputDidListenersThrowFlag if given. + // 3. Invoke with struct, event, "bubbling", and legacyOutputDidListenersThrowFlag if given. invoke(entry, event, Event::Phase::BubblingPhase); } } @@ -395,24 +397,25 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr< // 10. If clearTargets, then: if (clear_targets) { - // 10.1 Set event’s target to null. + // 1. Set event’s target to null. event->set_target(nullptr); - // 10.2 Set event’s relatedTarget to null. + // 2. Set event’s relatedTarget to null. event->set_related_target(nullptr); - // 10.3 Set event’s touch target list to the empty list. + // 3. Set event’s touch target list to the empty list. event->clear_touch_target_list(); } // 11. If activationTarget is non-null, then: if (activation_target) { - // 11.1 If event’s canceled flag is unset, then run activationTarget’s activation behavior with event. + // 1. If event’s canceled flag is unset, then run activationTarget’s activation behavior with event. if (!event->cancelled()) { activation_target->activation_behavior(event); activation_target->legacy_cancelled_activation_behavior_was_not_called(); - } else { - // 11.2 Otherwise, if activationTarget has legacy-canceled-activation behavior, then run activationTarget’s legacy-canceled-activation behavior. + } + // 2. Otherwise, if activationTarget has legacy-canceled-activation behavior, then run activationTarget’s legacy-canceled-activation behavior. + else { activation_target->legacy_cancelled_activation_behavior(); } } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 0b8e6031bc..84e82a1e56 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -358,59 +358,58 @@ void Node::insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool supp // 4. If node is a DocumentFragment node, then: if (is<DocumentFragment>(*node)) { - // 4.1 Remove its children with the suppress observers flag set. + // 1. Remove its children with the suppress observers flag set. node->remove_all_children(true); - // 4.2 FIXME: Queue a tree mutation record for node with « », nodes, null, and null. + // FIXME: 2. Queue a tree mutation record for node with « », nodes, null, and null. // NOTE: This step intentionally does not pay attention to the suppress observers flag. } // 5. If child is non-null, then: if (child) { - // 5.1 For each live range whose start node is parent and start offset is greater than child’s index, increase its start offset by count. + // 1. For each live range whose start node is parent and start offset is greater than child’s index, increase its start offset by count. for (auto& range : Range::live_ranges()) { if (range->start_container() == this && range->start_offset() > child->index()) range->set_start(*range->start_container(), range->start_offset() + count); } - // 5.2 For each live range whose end node is parent and end offset is greater than child’s index, increase its end offset by count. + // 2. For each live range whose end node is parent and end offset is greater than child’s index, increase its end offset by count. for (auto& range : Range::live_ranges()) { if (range->end_container() == this && range->end_offset() > child->index()) range->set_end(*range->end_container(), range->end_offset() + count); } } - // 6. FIXME: Let previousSibling be child’s previous sibling or parent’s last child if child is null. (Currently unused so not included) + // FIXME: 6. Let previousSibling be child’s previous sibling or parent’s last child if child is null. (Currently unused so not included) // 7. For each node in nodes, in tree order: // FIXME: In tree order for (auto& node_to_insert : nodes) { - // 7.1 Adopt node into parent’s node document. + // 1. Adopt node into parent’s node document. document().adopt_node(node_to_insert); - // 7.2 If child is null, then append node to parent’s children. + // 2. If child is null, then append node to parent’s children. if (!child) TreeNode<Node>::append_child(node_to_insert); + // 3. Otherwise, insert node into parent’s children before child’s index. else - // 7.3 Otherwise, insert node into parent’s children before child’s index. TreeNode<Node>::insert_before(node_to_insert, child); - // FIXME: 7.4 If parent is a shadow host and node is a slottable, then assign a slot for node. - // FIXME: 7.5 If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal a slot change for parent. - // FIXME: 7.6 Run assign slottables for a tree with node’s root. + // FIXME: 4. If parent is a shadow host and node is a slottable, then assign a slot for node. + // FIXME: 5. If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal a slot change for parent. + // FIXME: 6. Run assign slottables for a tree with node’s root. // FIXME: This should be shadow-including. - // 7.7 For each shadow-including inclusive descendant inclusiveDescendant of node, in shadow-including tree order: + // 7. For each shadow-including inclusive descendant inclusiveDescendant of node, in shadow-including tree order: node_to_insert.for_each_in_inclusive_subtree([&](Node& inclusive_descendant) { - // 7.7.1 Run the insertion steps with inclusiveDescendant. + // 1. Run the insertion steps with inclusiveDescendant. inclusive_descendant.inserted(); - // 7.7.2 If inclusiveDescendant is connected, then: + // 2. If inclusiveDescendant is connected, then: if (inclusive_descendant.is_connected()) { - // 7.7.2.1 FIXME: If inclusiveDescendant is custom, then enqueue a custom element callback reaction with inclusiveDescendant, - // callback name "connectedCallback", and an empty argument list. + // FIXME: 1. If inclusiveDescendant is custom, then enqueue a custom element callback reaction with inclusiveDescendant, callback name "connectedCallback", and an empty argument list. - // 7.7.2.2 FIXME: Otherwise, try to upgrade inclusiveDescendant. + // FIXME: 2. Otherwise, try to upgrade inclusiveDescendant. // NOTE: If this successfully upgrades inclusiveDescendant, its connectedCallback will be enqueued automatically during the upgrade an element algorithm. } @@ -518,42 +517,42 @@ void Node::remove(bool suppress_observers) node_iterator.run_pre_removing_steps(*this); }); - // 9. FIXME: Let oldPreviousSibling be node’s previous sibling. (Currently unused so not included) - // 10. FIXME: Let oldNextSibling be node’s next sibling. (Currently unused so not included) + // FIXME: 9. Let oldPreviousSibling be node’s previous sibling. (Currently unused so not included) + // FIXME: 10. Let oldNextSibling be node’s next sibling. (Currently unused so not included) // 11. Remove node from its parent’s children. parent->TreeNode::remove_child(*this); - // 12. FIXME: If node is assigned, then run assign slottables for node’s assigned slot. + // FIXME: 12. If node is assigned, then run assign slottables for node’s assigned slot. - // 13. FIXME: If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal a slot change for parent. + // FIXME: 13. If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal a slot change for parent. - // 14. FIXME: If node has an inclusive descendant that is a slot, then: - // 14.1 Run assign slottables for a tree with parent’s root. - // 14.2 Run assign slottables for a tree with node. + // FIXME: 14. If node has an inclusive descendant that is a slot, then: + // 1. Run assign slottables for a tree with parent’s root. + // 2. Run assign slottables for a tree with node. // 15. Run the removing steps with node and parent. removed_from(parent); - // 16. FIXME: Let isParentConnected be parent’s connected. (Currently unused so not included) + // FIXME: 16. Let isParentConnected be parent’s connected. (Currently unused so not included) - // 17. FIXME: If node is custom and isParentConnected is true, then enqueue a custom element callback reaction with node, + // FIXME: 17. If node is custom and isParentConnected is true, then enqueue a custom element callback reaction with node, // callback name "disconnectedCallback", and an empty argument list. // NOTE: It is intentional for now that custom elements do not get parent passed. This might change in the future if there is a need. // FIXME: This should be shadow-including. // 18. For each shadow-including descendant descendant of node, in shadow-including tree order, then: for_each_in_subtree([&](Node& descendant) { - // 18.1 Run the removing steps with descendant + // 1. Run the removing steps with descendant descendant.removed_from(nullptr); - // 18.2 FIXME: If descendant is custom and isParentConnected is true, then enqueue a custom element callback reaction with descendant, + // FIXME: 2. If descendant is custom and isParentConnected is true, then enqueue a custom element callback reaction with descendant, // callback name "disconnectedCallback", and an empty argument list. return IterationDecision::Continue; }); - // 19. FIXME: For each inclusive ancestor inclusiveAncestor of parent, and then for each registered of inclusiveAncestor’s registered observer list, + // FIXME: 19. For each inclusive ancestor inclusiveAncestor of parent, and then for each registered of inclusiveAncestor’s registered observer list, // if registered’s options["subtree"] is true, then append a new transient registered observer // whose observer is registered’s observer, options is registered’s options, and source is registered to node’s registered observer list. @@ -624,24 +623,24 @@ ExceptionOr<NonnullRefPtr<Node>> Node::replace_child(NonnullRefPtr<Node> node, N if (reference_child == node) reference_child = node->next_sibling(); - // 9. FIXME: Let previousSibling be child’s previous sibling. (Currently unused so not included) - // 10. FIXME: Let removedNodes be the empty set. (Currently unused so not included) + // FIXME: 9. Let previousSibling be child’s previous sibling. (Currently unused so not included) + // FIXME: 10. Let removedNodes be the empty set. (Currently unused so not included) // 11. If child’s parent is non-null, then: // NOTE: The above can only be false if child is node. if (child->parent()) { - // 11.1 FIXME: Set removedNodes to « child ». + // FIXME: 1. Set removedNodes to « child ». - // 11.2 Remove child with the suppress observers flag set. + // 2. Remove child with the suppress observers flag set. child->remove(true); } - // 12. FIXME: Let nodes be node’s children if node is a DocumentFragment node; otherwise « node ». (Currently unused so not included) + // FIXME: 12. Let nodes be node’s children if node is a DocumentFragment node; otherwise « node ». (Currently unused so not included) // 13. Insert node into parent before referenceChild with the suppress observers flag set. insert_before(node, reference_child, true); - // 14. FIXME: Queue a tree mutation record for parent with nodes, removedNodes, previousSibling, and referenceChild. + // FIXME: 14. Queue a tree mutation record for parent with nodes, removedNodes, previousSibling, and referenceChild. // 15. Return child. return child; @@ -657,14 +656,14 @@ NonnullRefPtr<Node> Node::clone_node(Document* document, bool clone_children) // 2. If node is an element, then: if (is<Element>(this)) { - // 2.1 Let copy be the result of creating an element, given document, node’s local name, node’s namespace, node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset. + // 1. Let copy be the result of creating an element, given document, node’s local name, node’s namespace, node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset. auto& element = *verify_cast<Element>(this); auto element_copy = DOM::create_element(*document, element.local_name(), element.namespace_() /* FIXME: node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset */); - // 2.2 For each attribute in node’s attribute list: + // 2. For each attribute in node’s attribute list: element.for_each_attribute([&](auto& name, auto& value) { - // 2.2.1 Let copyAttribute be a clone of attribute. - // 2.2.2 Append copyAttribute to copy. + // 1. Let copyAttribute be a clone of attribute. + // 2. Append copyAttribute to copy. element_copy->set_attribute(name, value); }); copy = move(element_copy); @@ -886,15 +885,15 @@ u16 Node::compare_document_position(RefPtr<Node> other) // 5. If node2 is an attribute, then: if (is<Attribute>(node2)) { - // 5.1 Set attr2 to node2 and node2 to attr2’s element. + // 1. Set attr2 to node2 and node2 to attr2’s element. attr2 = verify_cast<Attribute>(node2); node2 = const_cast<Element*>(attr2->owner_element()); - // 5.2 If attr1 and node1 are non-null, and node2 is node1, then: + // 2. If attr1 and node1 are non-null, and node2 is node1, then: if (attr1 && node1 && node2 == node1) { - // 5.2.1 FIXME: For each attr in node2’s attribute list: - // 5.2.1.1 FIXME: If attr equals attr1, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_PRECEDING. - // 5.2.1.2 FIXME: If attr equals attr2, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_FOLLOWING. + // FIXME: 1. For each attr in node2’s attribute list: + // 1. If attr equals attr1, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_PRECEDING. + // 2. If attr equals attr2, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_FOLLOWING. } } @@ -1085,10 +1084,10 @@ bool Node::is_shadow_including_inclusive_ancestor_of(Node const& other) const // https://dom.spec.whatwg.org/#concept-node-replace-all void Node::replace_all(RefPtr<Node> node) { - // 1. FIXME: Let removedNodes be parent’s children. (Current unused so not included) - // 2. FIXME: Let addedNodes be the empty set. (Currently unused so not included) - // 3. FIXME: If node is a DocumentFragment node, then set addedNodes to node’s children. - // 4. FIXME: Otherwise, if node is non-null, set addedNodes to « node ». + // FIXME: 1. Let removedNodes be parent’s children. (Current unused so not included) + // FIXME: 2. Let addedNodes be the empty set. (Currently unused so not included) + // FIXME: 3. If node is a DocumentFragment node, then set addedNodes to node’s children. + // FIXME: 4. Otherwise, if node is non-null, set addedNodes to « node ». // 5. Remove all parent’s children, in tree order, with the suppress observers flag set. remove_all_children(true); @@ -1097,7 +1096,7 @@ void Node::replace_all(RefPtr<Node> node) if (node) insert_before(*node, nullptr, true); - // 7. FIXME: If either addedNodes or removedNodes is not empty, then queue a tree mutation record for parent with addedNodes, removedNodes, null, and null. + // FIXME: 7. If either addedNodes or removedNodes is not empty, then queue a tree mutation record for parent with addedNodes, removedNodes, null, and null. } // https://dom.spec.whatwg.org/#string-replace-all @@ -1117,13 +1116,13 @@ void Node::string_replace_all(String const& string) // https://w3c.github.io/DOM-Parsing/#dfn-fragment-serializing-algorithm String Node::serialize_fragment(/* FIXME: Requires well-formed flag */) const { - // 1. FIXME: Let context document be the value of node's node document. + // FIXME: 1. Let context document be the value of node's node document. - // 2. FIXME: If context document is an HTML document, return an HTML serialization of node. + // FIXME: 2. If context document is an HTML document, return an HTML serialization of node. // (We currently always do this) return HTML::HTMLParser::serialize_html_fragment(*this); - // 3. FIXME: Otherwise, context document is an XML document; return an XML serialization of node passing the flag require well-formed. + // FIXME: 3. Otherwise, context document is an XML document; return an XML serialization of node passing the flag require well-formed. } // https://dom.spec.whatwg.org/#dom-node-issamenode |