Bug 1444193 - Load components.css into non-XUL document also when we load xul.css
Also limit the loading of xul.css/components.css to mobile video controls only.
MozReview-Commit-ID: KNRxhEhL2Aw
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -683,17 +683,16 @@ nsXULElement::UpdateEditableState(bool a
static inline bool XULElementsRulesInMinimalXULSheet(nsAtom* aTag)
{
return // scrollbar parts:
aTag == nsGkAtoms::scrollbar ||
aTag == nsGkAtoms::scrollbarbutton ||
aTag == nsGkAtoms::scrollcorner ||
aTag == nsGkAtoms::slider ||
aTag == nsGkAtoms::thumb ||
- aTag == nsGkAtoms::scale ||
// other
aTag == nsGkAtoms::datetimebox ||
aTag == nsGkAtoms::resizer ||
aTag == nsGkAtoms::label ||
aTag == nsGkAtoms::videocontrols;
}
#ifdef DEBUG
@@ -780,28 +779,33 @@ nsXULElement::BindToTree(nsIDocument* aD
// minimal set is not sufficient.
//
// We do this during binding, not element construction, because elements
// can be moved from the document that creates them to another document.
if (!XULElementsRulesInMinimalXULSheet(NodeInfo()->NameAtom())) {
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
doc->EnsureOnDemandBuiltInUASheet(cache->XULSheet());
+ doc->EnsureOnDemandBuiltInUASheet(cache->XULComponentsSheet());
// To keep memory usage down it is important that we try and avoid
- // pulling xul.css into non-XUL documents. That should be very rare, and
- // for HTML we currently should only pull it in if the document contains
- // an <audio> or <video> element. This assertion is here to make sure
- // that we don't fail to notice if a change to bindings causes us to
- // start pulling in xul.css much more frequently. If this assertion
- // fails then we need to figure out why, and how we can continue to avoid
- // pulling in xul.css.
- // Note that add-ons may introduce bindings that cause this assertion to
- // fire.
+ // pulling xul.css and componments.css into non-XUL documents.
+ // That should be very rare, and for HTML we currently should only pull it
+ // in if the document contains an <audio> or <video> control on mobile.
+ // We should not load xul.css on desktop because the control is implemented
+ // in HTML. This assertion is here to make sure that we don't fail to
+ // notice if a change to bindings causes us to start pulling in xul.css
+ // much more frequently. If this assertion fails then we need to figure
+ // out why, and how we can continue to avoid pulling in xul.css.
+#ifndef MOZ_WIDGET_ANDROID
+ NS_ERROR("Unexpected XUL element in non-XUL doc on desktop");
+#endif
+#ifdef MOZ_WIDGET_ANDROID
NS_ASSERTION(IsInVideoControls(this),
"Unexpected XUL element in non-XUL doc");
+#endif
}
}
if (doc && NeedTooltipSupport(*this)) {
AddTooltipSupport();
}
if (aDocument) {