Bug 1450705: Don't go through the binding manager to see if our parent is an SVG element. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 02 Apr 2018 17:53:36 +0200
changeset 776036 085f26c85295cfee8874e34be3ac413c3f2eb44b
parent 776021 72032264b2d2dfbde9a4649201f447a5f98224cb
push id104797
push userbmo:emilio@crisal.io
push dateMon, 02 Apr 2018 16:04:17 +0000
reviewersbz
bugs1450705
milestone61.0a1
Bug 1450705: Don't go through the binding manager to see if our parent is an SVG element. r?bz We don't extend svg elements, except in a lone test, that isn't really impacted by this. I agree this should look at the frame btw, though that looks a bit out of scope for this bug. MozReview-Commit-ID: MbvIE5TszB
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5286,31 +5286,28 @@ nsCSSFrameConstructor::FindSVGData(Eleme
 
   static const FrameConstructionData sSuppressData = SUPPRESS_FCDATA();
   static const FrameConstructionData sContainerData =
     SIMPLE_SVG_FCDATA(NS_NewSVGContainerFrame);
 
   bool parentIsSVG = aIsWithinSVGText;
   nsIContent* parentContent =
     aParentFrame ? aParentFrame->GetContent() : nullptr;
-  // XXXbz should this really be based on the XBL-resolved tag of the parent
-  // frame's content?  Should it not be based on the type of the parent frame
-  // (e.g. whether it's an SVG frame)?
+
+  // XXXbz should this really be based on the tag of the parent frame's content?
+  // Should it not be based on the type of the parent frame (e.g. whether it's
+  // an SVG frame)?
   if (parentContent) {
-    int32_t parentNSID;
-    nsAtom* parentTag =
-      parentContent->OwnerDoc()->BindingManager()->
-        ResolveTag(parentContent, &parentNSID);
-
     // It's not clear whether the SVG spec intends to allow any SVG
     // content within svg:foreignObject at all (SVG 1.1, section
     // 23.2), but if it does, it better be svg:svg.  So given that
     // we're allowing it, treat it as a non-SVG parent.
-    parentIsSVG = parentNSID == kNameSpaceID_SVG &&
-                  parentTag != nsGkAtoms::foreignObject;
+    parentIsSVG =
+      parentContent->IsSVGElement() &&
+      parentContent->NodeInfo()->NameAtom() != nsGkAtoms::foreignObject;
   }
 
   if ((aTag != nsGkAtoms::svg && !parentIsSVG) ||
       (aTag == nsGkAtoms::desc || aTag == nsGkAtoms::title ||
        aTag == nsGkAtoms::metadata)) {
     // Sections 5.1 and G.4 of SVG 1.1 say that SVG elements other than
     // svg:svg not contained within svg:svg are incorrect, although they
     // don't seem to specify error handling.  Ignore them, since many of