Bug 1346256 Part 2: Define methods in ServoCSSRuleList to fill a hash of RawServoStyleRule to ServoStyleRule. r=heycam,xidorn

MozReview-Commit-ID: 4Swb9KwV0uO

--HG--
extra : rebase_source : 496b33bfdeaa4c4715796df6a8baa3fe1b4a9531
This commit is contained in:
Brad Werth 2017-04-07 08:07:37 -07:00
Родитель d4cc3a3790
Коммит ddb66e070e
2 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -202,6 +202,26 @@ ServoCSSRuleList::GetRuleType(uint32_t aIndex) const
return CastToPtr(rule)->Type();
}
void
ServoCSSRuleList::FillStyleRuleHashtable(StyleRuleHashtable& aTable)
{
for (uint32_t i = 0; i < mRules.Length(); i++) {
uint16_t type = GetRuleType(i);
if (type == nsIDOMCSSRule::STYLE_RULE) {
ServoStyleRule* castedRule = static_cast<ServoStyleRule*>(GetRule(i));
RawServoStyleRule* rawRule = castedRule->Raw();
aTable.Put(rawRule, castedRule);
} else if (type == nsIDOMCSSRule::MEDIA_RULE) {
ServoMediaRule* castedRule = static_cast<ServoMediaRule*>(GetRule(i));
// Call this method recursively on the ServoCSSRuleList in the rule.
ServoCSSRuleList* castedRuleList = static_cast<ServoCSSRuleList*>(
castedRule->CssRules());
castedRuleList->FillStyleRuleHashtable(aTable);
}
}
}
ServoCSSRuleList::~ServoCSSRuleList()
{
DropAllRules();

Просмотреть файл

@ -11,9 +11,11 @@
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/dom/CSSRuleList.h"
#include "nsDataHashtable.h"
namespace mozilla {
class ServoStyleRule;
class ServoStyleSheet;
namespace css {
class GroupRule;
@ -44,6 +46,10 @@ public:
uint16_t GetRuleType(uint32_t aIndex) const;
typedef nsDataHashtable<nsPtrHashKey<const RawServoStyleRule>,
ServoStyleRule*> StyleRuleHashtable;
void FillStyleRuleHashtable(StyleRuleHashtable& aTable);
private:
virtual ~ServoCSSRuleList();