Title: [273938] trunk/Source/WebCore
Revision
273938
Author
commit-qu...@webkit.org
Date
2021-03-04 17:50:52 -0800 (Thu, 04 Mar 2021)

Log Message

Deploy Ref<T> in SVGUseElement.cpp
https://bugs.webkit.org/show_bug.cgi?id=222637

Patch by Julian Gonzalez <julian_a_gonza...@apple.com> on 2021-03-04
Reviewed by Ryosuke Niwa.

Remove usage of raw pointers in a few functions here
that showed issues in 222397.

Thanks to Darin Adler for the initial version of this patch
and Ryosuke Niwa for refinements.

* svg/SVGUseElement.cpp:
(WebCore::disassociateAndRemoveClones):
(WebCore::removeDisallowedElementsFromSubtree):
(WebCore::removeSymbolElementsFromSubtree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273937 => 273938)


--- trunk/Source/WebCore/ChangeLog	2021-03-05 01:45:24 UTC (rev 273937)
+++ trunk/Source/WebCore/ChangeLog	2021-03-05 01:50:52 UTC (rev 273938)
@@ -1,3 +1,21 @@
+2021-03-04  Julian Gonzalez  <julian_a_gonza...@apple.com>
+
+        Deploy Ref<T> in SVGUseElement.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=222637
+
+        Reviewed by Ryosuke Niwa.
+
+        Remove usage of raw pointers in a few functions here
+        that showed issues in 222397.
+
+        Thanks to Darin Adler for the initial version of this patch
+        and Ryosuke Niwa for refinements.
+
+        * svg/SVGUseElement.cpp:
+        (WebCore::disassociateAndRemoveClones):
+        (WebCore::removeDisallowedElementsFromSubtree):
+        (WebCore::removeSymbolElementsFromSubtree):
+
 2021-03-04  Ryosuke Niwa  <rn...@webkit.org>
 
         "precustomized" state of custom elements can become HTMLUnknownElement

Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (273937 => 273938)


--- trunk/Source/WebCore/svg/SVGUseElement.cpp	2021-03-05 01:45:24 UTC (rev 273937)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp	2021-03-05 01:50:52 UTC (rev 273938)
@@ -309,14 +309,14 @@
     return targetClone->renderer();
 }
 
-static inline void disassociateAndRemoveClones(const Vector<Element*>& clones)
+static inline void disassociateAndRemoveClones(const Vector<Ref<Element>>& clones)
 {
     for (auto& clone : clones) {
-        for (auto& descendant : descendantsOfType<SVGElement>(*clone))
+        for (auto& descendant : descendantsOfType<SVGElement>(clone.get()))
             descendant.setCorrespondingElement(nullptr);
         if (is<SVGElement>(clone))
-            downcast<SVGElement>(*clone).setCorrespondingElement(nullptr);
-        clone->parentNode()->removeChild(*clone);
+            downcast<SVGElement>(clone.get()).setCorrespondingElement(nullptr);
+        clone->remove();
     }
 }
 
@@ -330,10 +330,10 @@
     // Assert that it's not in a document to make sure callers are still using it this way.
     ASSERT(!subtree.isConnected());
 
-    Vector<Element*> disallowedElements;
+    Vector<Ref<Element>> disallowedElements;
     for (auto it = descendantsOfType<Element>(subtree).begin(); it; ) {
         if (isDisallowedElement(*it)) {
-            disallowedElements.append(&*it);
+            disallowedElements.append(*it);
             it.traverseNextSkippingChildren();
             continue;
         }
@@ -349,10 +349,10 @@
     // don't need to be cloned to get correct rendering. 2) expandSymbolElementsInShadowTree will turn them
     // into <svg> elements, which is correct for symbol elements directly referenced by use elements,
     // but incorrect for ones that just happen to be in a subtree.
-    Vector<Element*> symbolElements;
+    Vector<Ref<Element>> symbolElements;
     for (auto it = descendantsOfType<Element>(subtree).begin(); it; ) {
         if (is<SVGSymbolElement>(*it)) {
-            symbolElements.append(&*it);
+            symbolElements.append(*it);
             it.traverseNextSkippingChildren();
             continue;
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to