Bug 1352968 part 7 - Make RuleHasPendingChildSheet a static method of StyleSheet. r=heycam
MozReview-Commit-ID: HPJgsFftT6f
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -657,27 +657,16 @@ CSSRuleList*
CSSStyleSheet::GetCssRulesInternal(ErrorResult& aRv)
{
if (!mRuleCollection) {
mRuleCollection = new CSSRuleListImpl(this);
}
return mRuleCollection;
}
-static bool
-RuleHasPendingChildSheet(css::Rule *cssRule)
-{
- nsCOMPtr<nsIDOMCSSImportRule> importRule(do_QueryInterface(cssRule));
- NS_ASSERTION(importRule, "Rule which has type IMPORT_RULE and does not implement nsIDOMCSSImportRule!");
- nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
- importRule->GetStyleSheet(getter_AddRefs(childSheet));
- RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(childSheet);
- return cssSheet != nullptr && !cssSheet->IsComplete();
-}
-
uint32_t
CSSStyleSheet::InsertRuleInternal(const nsAString& aRule,
uint32_t aIndex,
ErrorResult& aRv)
{
MOZ_ASSERT(mInner->mComplete);
WillDirty();
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -796,9 +796,20 @@ StyleSheet::Media()
// nsWrapperCache
JSObject*
StyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return dom::CSSStyleSheetBinding::Wrap(aCx, this, aGivenProto);
}
+/* static */ bool
+StyleSheet::RuleHasPendingChildSheet(css::Rule* aRule)
+{
+ MOZ_ASSERT(aRule->GetType() == css::Rule::IMPORT_RULE);
+ auto rule = static_cast<dom::CSSImportRule*>(aRule);
+ if (StyleSheet* childSheet = rule->GetStyleSheet()) {
+ return !childSheet->IsComplete();
+ }
+ return false;
+}
+
} // namespace mozilla
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -295,16 +295,19 @@ protected:
// Unlink our inner, if needed, for cycle collection
virtual void UnlinkInner();
// Traverse our inner, if needed, for cycle collection
virtual void TraverseInner(nsCycleCollectionTraversalCallback &);
void ClearRuleCascades();
virtual void ClearRuleCascadesInternal() {}
+ // Return whether the given @import rule has pending child sheet.
+ static bool RuleHasPendingChildSheet(css::Rule* aRule);
+
StyleSheet* mParent; // weak ref
nsString mTitle;
nsIDocument* mDocument; // weak ref; parents maintain this for their children
nsINode* mOwningNode; // weak ref
dom::CSSImportRule* mOwnerRule; // weak ref
RefPtr<dom::MediaList> mMedia;