From 8ede3509cab60f7d8989c49e6c2848c0e7aab499 Mon Sep 17 00:00:00 2001 From: stevennovaryo Date: Fri, 30 May 2025 01:21:16 +0800 Subject: [PATCH] Style nit Signed-off-by: stevennovaryo --- components/layout/stylesheets/details.css | 4 +-- components/script/dom/htmldetailselement.rs | 12 ++++---- tests/wpt/meta/MANIFEST.json | 30 +++++++++++++++++++ .../details-content-security-policy.html | 14 +++++++++ .../details-multiple-summaries-ref.html | 19 ++++++++++++ .../details-multiple-summaries.html | 15 ++++++++++ 6 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 tests/wpt/tests/html/rendering/the-details-element/details-content-security-policy.html create mode 100644 tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries-ref.html create mode 100644 tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries.html diff --git a/components/layout/stylesheets/details.css b/components/layout/stylesheets/details.css index d7ff253f501..5dc63815391 100644 --- a/components/layout/stylesheets/details.css +++ b/components/layout/stylesheets/details.css @@ -1,10 +1,10 @@ /* We should use `content-visibility` but it is yet to be implemented. * These rule would not comply with ::details-content and should be removed * with it's implementation */ -slot[id="internal-contents-slot"] { +slot#internal-contents-slot { display: none; } -:host([open]) slot[id="internal-contents-slot"] { +:host([open]) slot#internal-contents-slot { display: block; } diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index c57fec5ed6e..423bfe45d97 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -104,7 +104,7 @@ impl HTMLDetailsElement { .expect("UA shadow tree was not created") } - /// + /// fn create_shadow_tree(&self, can_gc: CanGc) { let document = self.owner_document(); let root = self @@ -163,7 +163,8 @@ impl HTMLDetailsElement { .AppendChild(descendants_slot.upcast::(), can_gc) .unwrap(); - // > 3. The third child element is either a link or style element with the following styles for the default summary: + // > 3. The third child element is either a link or style element with the following + // > styles for the default summary: let link_element = HTMLLinkElement::new( local_name!("link"), None, @@ -191,7 +192,6 @@ impl HTMLDetailsElement { ); link_element.set_stylesheet(details_stylesheet.unwrap()); - let _ = self.shadow_tree.borrow_mut().insert(ShadowTree { summary_slot: summary_slot.as_traced(), descendants_slot: descendants_slot.as_traced(), @@ -220,7 +220,9 @@ impl HTMLDetailsElement { for child in self.upcast::().children() { if let Some(element) = child.downcast::() { // Assign the first summary element to the summary slot. - if element.local_name() == &local_name!("summary") && !discovered_first_summary_element { + if element.local_name() == &local_name!("summary") && + !discovered_first_summary_element + { shadow_tree .summary_slot .Assign(vec![ElementOrText::Element(DomRoot::from_ref(element))]); @@ -242,7 +244,7 @@ impl HTMLDetailsElement { shadow_tree .summary_slot .Assign(vec![ElementOrText::Element(DomRoot::upcast( - shadow_tree.fallback_summary.as_rooted() + shadow_tree.fallback_summary.as_rooted(), ))]); } } diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 0e367d5653e..b44f105f9ef 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -352512,6 +352512,19 @@ {} ] ], + "details-content-security-policy.html": [ + "2e98d81e31420d43dcdff110dd3703c5a2e9ddb4", + [ + "html/rendering/the-details-element/details-content-security-policy.html", + [ + [ + "/html/rendering/the-details-element/single-summary.html", + "==" + ] + ], + {} + ] + ], "details-display-type-001-ref.html": [ "925ee19f775fd07ac6e679598329d05f609e5335", [ @@ -352551,6 +352564,19 @@ {} ] ], + "details-multiple-summaries.html": [ + "55829ce57bc1cf12109ac2d553fa93a86b4422b4", + [ + "html/rendering/the-details-element/details-multiple-summaries.html", + [ + [ + "/html/rendering/the-details-element/details-multiple-summaries-ref.html", + "==" + ] + ], + {} + ] + ], "details-pseudo-elements-001.html": [ "f9d48101fb65edfc868a67a5722cdbfc0e8f7f1b", [ @@ -480162,6 +480188,10 @@ "297634b521fab5e61d0bbac9edb4480b5de7366d", [] ], + "details-multiple-summaries-ref.html": [ + "a23296880c15e3578f1428f0ca51073fc49df6c2", + [] + ], "details-pseudo-elements-001-ref.html": [ "0c77c0e14fc3e0f3707e6dee32aea5a9738b6fb1", [] diff --git a/tests/wpt/tests/html/rendering/the-details-element/details-content-security-policy.html b/tests/wpt/tests/html/rendering/the-details-element/details-content-security-policy.html new file mode 100644 index 00000000000..2e98d81e314 --- /dev/null +++ b/tests/wpt/tests/html/rendering/the-details-element/details-content-security-policy.html @@ -0,0 +1,14 @@ + + + + + + + Details Element Appearance Should not be Affected By Content Security Policy + + + +
+ This is the main summary + This is the content +
diff --git a/tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries-ref.html b/tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries-ref.html new file mode 100644 index 00000000000..a23296880c1 --- /dev/null +++ b/tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries-ref.html @@ -0,0 +1,19 @@ + + + + + Details Element Should not Discard the Additional Summary Element + + + + +
+ This is the main summary + This is the additional summary + This is the content +
diff --git a/tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries.html b/tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries.html new file mode 100644 index 00000000000..55829ce57bc --- /dev/null +++ b/tests/wpt/tests/html/rendering/the-details-element/details-multiple-summaries.html @@ -0,0 +1,15 @@ + + + + + Details Element Should not Discard the Additional Summary Element + + + + + +
+ This is the main summary + This is the additional summary + This is the content +