Skip to content

Commit

Permalink
Bug 1873338 - Optimise out non-rendered content from SVG use element …
Browse files Browse the repository at this point in the history
…shadow trees r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D197850
  • Loading branch information
longsonr committed Feb 20, 2024
1 parent 3c4831f commit 13d0b4c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dom/svg/SVGUseElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "mozilla/dom/SVGGraphicsElement.h"
#include "mozilla/dom/SVGLengthBinding.h"
#include "mozilla/dom/SVGSVGElement.h"
#include "mozilla/dom/SVGSwitchElement.h"
#include "mozilla/dom/SVGSymbolElement.h"
#include "mozilla/dom/SVGUseElementBinding.h"
#include "nsGkAtoms.h"
Expand Down Expand Up @@ -251,7 +252,17 @@ static bool NodeCouldBeRendered(const nsINode& aNode) {
if (const auto* symbol = SVGSymbolElement::FromNode(aNode)) {
return symbol->CouldBeRendered();
}
// TODO: Do we have other cases we can optimize out easily?
if (const auto* svgGraphics = SVGGraphicsElement::FromNode(aNode)) {
if (!svgGraphics->PassesConditionalProcessingTests()) {
return false;
}
}
if (auto* svgSwitch =
SVGSwitchElement::FromNodeOrNull(aNode.GetParentNode())) {
if (&aNode != svgSwitch->GetActiveChild()) {
return false;
}
}
return true;
}

Expand Down

0 comments on commit 13d0b4c

Please sign in to comment.