Bug 1282485 - Plugin fallback rule - don't use fallback when the descendant has an embed element draft
authorFelipe Gomes <felipc@gmail.com>
Tue, 08 Nov 2016 17:35:42 -0200
changeset 435456 9c21f2a0761d92e99b38f742e390be5ab7a16777
parent 435452 dff29cfe89c8b32340ccd0b5a55f38f2a3b04c8c
child 435457 2c64af68b3b7195df3e9f3872a505dba1bab23fd
push id35054
push userfelipc@gmail.com
push dateTue, 08 Nov 2016 19:36:12 +0000
bugs1282485
milestone52.0a1
Bug 1282485 - Plugin fallback rule - don't use fallback when the descendant has an embed element MozReview-Commit-ID: 4bSVVgFbKMX
dom/base/nsObjectLoadingContent.cpp
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -3592,18 +3592,31 @@ nsObjectLoadingContent::HasGoodFallback(
 
   nsTArray<nsCString> rulesList;
   nsCString prefString;
   if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackRules, &prefString))) {
       ParseString(prefString, ',', rulesList);
   }
 
   for (uint32_t i = 0; i < rulesList.Length(); ++i) {
-    // Add more rules here
-
+    // RULE "embed":
+    // Don't use fallback content if the object contains an <embed> inside its
+    // fallback content.
+    if (rulesList[i].EqualsLiteral("embed")) {
+      nsTArray<nsINodeList*> childNodes;
+      for (nsIContent* child = thisContent->GetFirstChild();
+           child;
+           child = child->GetNextNode(thisContent)) {
+        if (child->IsHTMLElement(nsGkAtoms::embed)) {
+          return false;
+        }
+      }
+    }
+
+    // RULE "true":
     // By having a rule that returns true, we can put it at the end of the rules list
     // to change the default-to-false behavior to be default-to-true.
     if (rulesList[i].EqualsLiteral("true")) {
       return true;
     }
   }
 
   return false;