diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index e5ea23ef89225..48fdfd9510825 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -110,6 +110,7 @@ static const char *kPrefJavaMIME = "plugin.java.mime"; static const char *kPrefYoutubeRewrite = "plugins.rewrite_youtube_embeds"; static const char *kPrefBlockURIs = "browser.safebrowsing.blockedURIs.enabled"; static const char *kPrefFavorFallbackMode = "plugins.favorfallback.mode"; +static const char *kPrefFavorFallbackRules = "plugins.favorfallback.rules"; using namespace mozilla; using namespace mozilla::dom; @@ -3452,7 +3453,89 @@ nsObjectLoadingContent::HasGoodFallback() { return false; } - // xxx to be filled + nsTArray rulesList; + nsCString prefString; + if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackRules, &prefString))) { + ParseString(prefString, ',', rulesList); + } + + for (uint32_t i = 0; i < rulesList.Length(); ++i) { + // RULE "embed": + // Don't use fallback content if the object contains an inside its + // fallback content. + if (rulesList[i].EqualsLiteral("embed")) { + nsTArray childNodes; + for (nsIContent* child = thisContent->GetFirstChild(); + child; + child = child->GetNextNode(thisContent)) { + if (child->IsHTMLElement(nsGkAtoms::embed)) { + return false; + } + } + } + + // RULE "video": + // Use fallback content if the object contains a