Title: [212095] branches/safari-603-branch

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (212094 => 212095)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-10 08:16:19 UTC (rev 212094)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-10 08:16:24 UTC (rev 212095)
@@ -1,5 +1,25 @@
 2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r212028. rdar://problem/30234133
+
+    2017-02-09  Ryosuke Niwa  <rn...@webkit.org>
+
+            Crash in render tree after dynamically mutating the slot value
+            https://bugs.webkit.org/show_bug.cgi?id=167502
+
+            Reviewed by Antti Koivisto.
+
+            Added regression tests for the crash, and one for assigning non-empty slot value to a child
+            of a summary element. The slot attribute should always be ignored since the fact summary
+            element has its own shadow tree is an implementation detail that should never be exposed.
+
+            * fast/html/details-summary-slot-expected.html: Added.
+            * fast/html/details-summary-slot.html: Added.
+            * fast/shadow-dom/shadow-slot-attribute-change-crash-expected.txt: Added.
+            * fast/shadow-dom/shadow-slot-attribute-change-crash.html: Added.
+
+2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r212027. rdar://problem/30145076
 
     2017-02-09  Antti Koivisto  <an...@apple.com>

Added: branches/safari-603-branch/LayoutTests/fast/html/details-summary-slot-expected.html (0 => 212095)


--- branches/safari-603-branch/LayoutTests/fast/html/details-summary-slot-expected.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/html/details-summary-slot-expected.html	2017-02-10 08:16:24 UTC (rev 212095)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests sets slot on a child of summary element inside a details element. It should have no effect.</p>
+<details><summary><div>PASS</div></summary></details>
+</body>
+</html>

Added: branches/safari-603-branch/LayoutTests/fast/html/details-summary-slot.html (0 => 212095)


--- branches/safari-603-branch/LayoutTests/fast/html/details-summary-slot.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/html/details-summary-slot.html	2017-02-10 08:16:24 UTC (rev 212095)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests sets slot on a child of summary element inside a details element. It should have no effect.</p>
+<details><summary><div>PASS</div></summary></details>
+<script>
+document.querySelector('div').slot = 'foo';
+</script>
+</body>
+</html>

Added: branches/safari-603-branch/LayoutTests/fast/shadow-dom/shadow-slot-attribute-change-crash-expected.txt (0 => 212095)


--- branches/safari-603-branch/LayoutTests/fast/shadow-dom/shadow-slot-attribute-change-crash-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/shadow-dom/shadow-slot-attribute-change-crash-expected.txt	2017-02-10 08:16:24 UTC (rev 212095)
@@ -0,0 +1,3 @@
+This tests dynamically mutating the slot value. WebKit should not crash.
+
+PASS - WebKit did not crash

Added: branches/safari-603-branch/LayoutTests/fast/shadow-dom/shadow-slot-attribute-change-crash.html (0 => 212095)


--- branches/safari-603-branch/LayoutTests/fast/shadow-dom/shadow-slot-attribute-change-crash.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/shadow-dom/shadow-slot-attribute-change-crash.html	2017-02-10 08:16:24 UTC (rev 212095)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests dynamically mutating the slot value. WebKit should not crash.</p>
+<outer-host style="display: block; -webkit-column-count: 2;"><inner-host style="display: block;"><div id="mutateThis">?<section style="column-span: all;"></section></div></inner-host></outer-host>
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+let outerHost = document.querySelector('outer-host');
+outerHost.attachShadow({mode: 'closed'}).innerHTML = '<slot></slot>';
+
+let innerHost = document.querySelector('inner-host').attachShadow({mode: 'closed'});
+innerHost.innerHTML = '<slot></slot>';
+
+outerHost.getBoundingClientRect();
+mutateThis.slot = "f";
+outerHost.getBoundingClientRect();
+mutateThis.innerText = "";
+
+document.write('PASS - WebKit did not crash');
+
+</script>
+</body>
+</html>

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (212094 => 212095)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-10 08:16:19 UTC (rev 212094)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-10 08:16:24 UTC (rev 212095)
@@ -1,5 +1,29 @@
 2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r212028. rdar://problem/30234133
+
+    2017-02-09  Ryosuke Niwa  <rn...@webkit.org>
+
+            Crash in render tree after dynamically mutating the slot value
+            https://bugs.webkit.org/show_bug.cgi?id=167502
+
+            Reviewed by Antti Koivisto.
+
+            The crash was caused by attributeChanged not destructing the render tree after an assigned element had been
+            removed from its slot. Since the style resolver can no longer find this element in the flat tree, we need to
+            delete its render object as if the element had been removed from the DOM tree.
+
+            Tests: fast/html/details-summary-slot.html
+                   fast/shadow-dom/shadow-slot-attribute-change-crash.html
+
+            * dom/Element.cpp:
+            (WebCore::Element::attributeChanged):
+            * html/HTMLSummaryElement.cpp:
+            (WebCore::SummarySlotElement): Added. Always use the default slot regardless of the slot attribute's value.
+            (WebCore::HTMLSummaryElement::create): Use SummarySlotElement
+
+2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r212027. rdar://problem/30145076
 
     2017-02-09  Antti Koivisto  <an...@apple.com>

Modified: branches/safari-603-branch/Source/WebCore/dom/Element.cpp (212094 => 212095)


--- branches/safari-603-branch/Source/WebCore/dom/Element.cpp	2017-02-10 08:16:19 UTC (rev 212094)
+++ branches/safari-603-branch/Source/WebCore/dom/Element.cpp	2017-02-10 08:16:24 UTC (rev 212095)
@@ -1326,7 +1326,7 @@
         else if (name == HTMLNames::slotAttr) {
             if (auto* parent = parentElement()) {
                 if (auto* shadowRoot = parent->shadowRoot())
-                    shadowRoot->hostChildElementDidChangeSlotAttribute(oldValue, newValue);
+                    shadowRoot->hostChildElementDidChangeSlotAttribute(*this, oldValue, newValue);
             }
         }
     }

Modified: branches/safari-603-branch/Source/WebCore/dom/ShadowRoot.h (212094 => 212095)


--- branches/safari-603-branch/Source/WebCore/dom/ShadowRoot.h	2017-02-10 08:16:19 UTC (rev 212094)
+++ branches/safari-603-branch/Source/WebCore/dom/ShadowRoot.h	2017-02-10 08:16:24 UTC (rev 212095)
@@ -77,7 +77,7 @@
     void didRemoveAllChildrenOfShadowHost();
     void didChangeDefaultSlot();
     void hostChildElementDidChange(const Element&);
-    void hostChildElementDidChangeSlotAttribute(const AtomicString& oldValue, const AtomicString& newValue);
+    void hostChildElementDidChangeSlotAttribute(Element&, const AtomicString& oldValue, const AtomicString& newValue);
 
     const Vector<Node*>* assignedNodesForSlot(const HTMLSlotElement&);
 

Modified: branches/safari-603-branch/Source/WebCore/dom/SlotAssignment.h (212094 => 212095)


--- branches/safari-603-branch/Source/WebCore/dom/SlotAssignment.h	2017-02-10 08:16:19 UTC (rev 212094)
+++ branches/safari-603-branch/Source/WebCore/dom/SlotAssignment.h	2017-02-10 08:16:24 UTC (rev 212095)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "RenderTreeUpdater.h"
 #include "ShadowRoot.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
@@ -113,12 +114,13 @@
         m_slotAssignment->hostChildElementDidChange(childElement, *this);
 }
 
-inline void ShadowRoot::hostChildElementDidChangeSlotAttribute(const AtomicString& oldValue, const AtomicString& newValue)
+inline void ShadowRoot::hostChildElementDidChangeSlotAttribute(Element& element, const AtomicString& oldValue, const AtomicString& newValue)
 {
-    if (m_slotAssignment) {
-        m_slotAssignment->didChangeSlot(oldValue, *this);
-        m_slotAssignment->didChangeSlot(newValue, *this);
-    }
+    if (!m_slotAssignment)
+        return;
+    m_slotAssignment->didChangeSlot(oldValue, *this);
+    m_slotAssignment->didChangeSlot(newValue, *this);
+    RenderTreeUpdater::tearDownRenderers(element);
 }
 
 } // namespace WebCore

Modified: branches/safari-603-branch/Source/WebCore/html/HTMLSummaryElement.cpp (212094 => 212095)


--- branches/safari-603-branch/Source/WebCore/html/HTMLSummaryElement.cpp	2017-02-10 08:16:19 UTC (rev 212094)
+++ branches/safari-603-branch/Source/WebCore/html/HTMLSummaryElement.cpp	2017-02-10 08:16:24 UTC (rev 212095)
@@ -32,15 +32,26 @@
 #include "PlatformMouseEvent.h"
 #include "RenderBlockFlow.h"
 #include "ShadowRoot.h"
+#include "SlotAssignment.h"
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
+class SummarySlotElement final : public SlotAssignment {
+private:
+    void hostChildElementDidChange(const Element&, ShadowRoot& shadowRoot) override
+    {
+        didChangeSlot(SlotAssignment::defaultSlotName(), shadowRoot);
+    }
+
+    const AtomicString& slotNameForHostChild(const Node&) const override { return SlotAssignment::defaultSlotName(); }
+};
+
 Ref<HTMLSummaryElement> HTMLSummaryElement::create(const QualifiedName& tagName, Document& document)
 {
     Ref<HTMLSummaryElement> summary = adoptRef(*new HTMLSummaryElement(tagName, document));
-    summary->addShadowRoot(ShadowRoot::create(document, ShadowRootMode::UserAgent));
+    summary->addShadowRoot(ShadowRoot::create(document, std::make_unique<SummarySlotElement>()));
     return summary;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to