Bug 1377158 - (Part 1) Set style backend to stylo when SVG is used as an image.
MozReview-Commit-ID: 9FnA8X84h87
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -13214,17 +13214,20 @@ nsIDocument::UpdateStyleBackendType()
MOZ_ASSERT(mStyleBackendType == StyleBackendType::None,
"no need to call UpdateStyleBackendType now");
// Assume Gecko by default.
mStyleBackendType = StyleBackendType::Gecko;
#ifdef MOZ_STYLO
if (nsLayoutUtils::StyloEnabled()) {
- if (!mDocumentContainer) {
+ if (IsBeingUsedAsImage()) {
+ // Enable stylo for SVG-as-image.
+ mStyleBackendType = StyleBackendType::Servo;
+ } else if (!mDocumentContainer) {
NS_WARNING("stylo: No docshell yet, assuming Gecko style system");
} else if ((IsHTMLOrXHTML() || IsSVGDocument()) &&
IsContentDocument()) {
// Disable stylo for about: pages other than about:blank, since
// they tend to use unsupported selectors like XUL tree pseudos.
bool isAbout = false;
mDocumentURI->SchemeIs("about", &isAbout);
if (!isAbout || NS_IsAboutBlank(mDocumentURI)) {