зеркало из https://github.com/mozilla/gecko-dev.git
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 : 771ac051648526b2cef59acc8f700548762b73b6
This commit is contained in:
Родитель
50b320d9d3
Коммит
7c2789c8d2
|
@ -204,6 +204,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();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче