From 4e903ddf5ce47b491e1a6872fe0d51eb6a17c3ec Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 8 Mar 2017 18:27:53 +1100 Subject: [PATCH] Bug 1315601 part 14 - Add InsertRuleIntoGroup support to ServoStyleSheet. r=heycam MozReview-Commit-ID: GUHtvjQXECW --HG-- extra : rebase_source : dadf70886038ae4d1d62945ee4f4fbc4a3e756aa --- layout/style/ServoCSSRuleList.h | 1 + layout/style/ServoStyleSheet.cpp | 11 +++++++++++ layout/style/ServoStyleSheet.h | 3 +++ layout/style/StyleSheet.cpp | 3 +-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/layout/style/ServoCSSRuleList.h b/layout/style/ServoCSSRuleList.h index 8477ae7c5a57..626c50b53498 100644 --- a/layout/style/ServoCSSRuleList.h +++ b/layout/style/ServoCSSRuleList.h @@ -24,6 +24,7 @@ class ServoCSSRuleList final : public dom::CSSRuleList { public: explicit ServoCSSRuleList(already_AddRefed aRawRules); + css::GroupRule* GetParentRule() const { return mParentRule; } void SetParentRule(css::GroupRule* aParentRule); void SetStyleSheet(StyleSheet* aSheet); diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index 2204adbd0392..a5af3b461b15 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -10,6 +10,7 @@ #include "mozilla/StyleBackendType.h" #include "mozilla/ServoBindings.h" #include "mozilla/ServoCSSRuleList.h" +#include "mozilla/css/GroupRule.h" #include "mozilla/dom/CSSRuleList.h" #include "mozAutoDocUpdate.h" @@ -202,4 +203,14 @@ ServoStyleSheet::DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv) } } +nsresult +ServoStyleSheet::InsertRuleIntoGroupInternal(const nsAString& aRule, + css::GroupRule* aGroup, + uint32_t aIndex) +{ + auto rules = static_cast(aGroup->CssRules()); + MOZ_ASSERT(rules->GetParentRule() == aGroup); + return rules->InsertRule(aRule, aIndex); +} + } // namespace mozilla diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h index 97d49f2a0a3d..8555f7adf59c 100644 --- a/layout/style/ServoStyleSheet.h +++ b/layout/style/ServoStyleSheet.h @@ -103,6 +103,9 @@ protected: uint32_t InsertRuleInternal(const nsAString& aRule, uint32_t aIndex, ErrorResult& aRv); void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv); + nsresult InsertRuleIntoGroupInternal(const nsAString& aRule, + css::GroupRule* aGroup, + uint32_t aIndex); void EnabledStateChangedInternal() {} diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 90e361a24838..fdb901eb2e80 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -473,8 +473,7 @@ StyleSheet::InsertRuleIntoGroup(const nsAString& aRule, if (IsGecko()) { result = AsGecko()->InsertRuleIntoGroupInternal(aRule, aGroup, aIndex); } else { - // TODO - result = NS_ERROR_NOT_IMPLEMENTED; + result = AsServo()->InsertRuleIntoGroupInternal(aRule, aGroup, aIndex); } NS_ENSURE_SUCCESS(result, result);