From 57f68063f26a1015f6acc649e14135e75eca55a2 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 9 Oct 2020 19:21:18 +0000 Subject: [PATCH] Remove anonymous box from details/summary shadow dom Previously, there was an anonymous
in the shadow dom for the element, which caused display:contents to not behave in an interoperable way. See [1] for a spec PR that clarifies the spec, and this CL matches the new clarification. The new WPT added here passes already on Gecko and WebKit. [1] https://github.com/whatwg/html/pull/4746 Fixed: 973074 Change-Id: Iba54616c4e54e357dd71b7de30de18bde8ff3983 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462217 Commit-Queue: Mason Freed Reviewed-by: Oriol Brufau Auto-Submit: Mason Freed Cr-Commit-Position: refs/heads/master@{#815731} --- .../core/html/html_details_element.cc | 12 +++---- .../details-blockification.html | 35 +++++++++++++++++++ ...t-dispatching-details-summary-expected.txt | 3 +- 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 third_party/blink/web_tests/external/wpt/html/rendering/the-details-element/details-blockification.html diff --git a/third_party/blink/renderer/core/html/html_details_element.cc b/third_party/blink/renderer/core/html/html_details_element.cc index 13ab1f9781dec5..42c8395ef86c14 100644 --- a/third_party/blink/renderer/core/html/html_details_element.cc +++ b/third_party/blink/renderer/core/html/html_details_element.cc @@ -89,12 +89,12 @@ void HTMLDetailsElement::DidAddUserAgentShadowRoot(ShadowRoot& root) { summary_slot->AppendChild(default_summary); root.AppendChild(summary_slot); - auto* content = MakeGarbageCollected(GetDocument()); - content->SetIdAttribute(shadow_element_names::kIdDetailsContent); - content->AppendChild( - HTMLSlotElement::CreateUserAgentDefaultSlot(GetDocument())); - content->SetInlineStyleProperty(CSSPropertyID::kDisplay, CSSValueID::kNone); - root.AppendChild(content); + HTMLSlotElement* content_slot = + HTMLSlotElement::CreateUserAgentDefaultSlot(GetDocument()); + content_slot->SetIdAttribute(shadow_element_names::kIdDetailsContent); + content_slot->SetInlineStyleProperty(CSSPropertyID::kDisplay, + CSSValueID::kNone); + root.AppendChild(content_slot); } Element* HTMLDetailsElement::FindMainSummary() const { diff --git a/third_party/blink/web_tests/external/wpt/html/rendering/the-details-element/details-blockification.html b/third_party/blink/web_tests/external/wpt/html/rendering/the-details-element/details-blockification.html new file mode 100644 index 00000000000000..cc94e92fe0cdfb --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/rendering/the-details-element/details-blockification.html @@ -0,0 +1,35 @@ + + +CSS Test: details children blockification + + + + + + +
+
+ foo +
bar +
+
+ +
+
+ foo +
bar +
+
+ + diff --git a/third_party/blink/web_tests/fast/dom/shadow/shadow-dom-event-dispatching-details-summary-expected.txt b/third_party/blink/web_tests/fast/dom/shadow/shadow-dom-event-dispatching-details-summary-expected.txt index f78414ece3703d..611b1031ea16fb 100644 --- a/third_party/blink/web_tests/fast/dom/shadow/shadow-dom-event-dispatching-details-summary-expected.txt +++ b/third_party/blink/web_tests/fast/dom/shadow/shadow-dom-event-dispatching-details-summary-expected.txt @@ -8,8 +8,7 @@ DIV id=sandbox SUMMARY id=summary DIV id=details-marker SLOT - DIV id=details-content - SLOT + SLOT id=details-content Moving mouse from details to summary