2017-06-19 08:45:43 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_ServoStyleRuleMap_h
|
|
|
|
#define mozilla_ServoStyleRuleMap_h
|
|
|
|
|
2018-06-04 16:35:50 +03:00
|
|
|
#include "mozilla/dom/CSSStyleRule.h"
|
2018-04-30 20:23:14 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2017-06-19 08:45:43 +03:00
|
|
|
|
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
|
|
|
|
struct RawServoStyleRule;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
class ServoCSSRuleList;
|
|
|
|
class ServoStyleSet;
|
|
|
|
namespace css {
|
|
|
|
class Rule;
|
|
|
|
} // namespace css
|
2018-02-25 20:01:42 +03:00
|
|
|
namespace dom {
|
|
|
|
class ShadowRoot;
|
|
|
|
}
|
2017-11-28 03:50:45 +03:00
|
|
|
class ServoStyleRuleMap {
|
2017-06-19 08:45:43 +03:00
|
|
|
public:
|
2018-02-12 15:57:26 +03:00
|
|
|
ServoStyleRuleMap() = default;
|
2017-06-19 08:45:43 +03:00
|
|
|
|
2018-02-12 15:57:26 +03:00
|
|
|
void EnsureTable(ServoStyleSet&);
|
2018-02-25 20:01:42 +03:00
|
|
|
void EnsureTable(dom::ShadowRoot&);
|
|
|
|
|
2018-06-04 16:35:50 +03:00
|
|
|
dom::CSSStyleRule* Lookup(const RawServoStyleRule* aRawRule) const {
|
2017-06-19 08:45:43 +03:00
|
|
|
return mTable.Get(aRawRule);
|
|
|
|
}
|
|
|
|
|
2018-04-30 20:23:14 +03:00
|
|
|
void SheetAdded(StyleSheet&);
|
|
|
|
void SheetRemoved(StyleSheet&);
|
2017-06-19 08:45:43 +03:00
|
|
|
|
2018-04-30 20:23:14 +03:00
|
|
|
void RuleAdded(StyleSheet& aStyleSheet, css::Rule&);
|
|
|
|
void RuleRemoved(StyleSheet& aStyleSheet, css::Rule&);
|
2017-06-19 08:45:43 +03:00
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
2018-02-12 15:57:26 +03:00
|
|
|
~ServoStyleRuleMap() = default;
|
2017-06-19 08:45:43 +03:00
|
|
|
|
2017-11-28 03:50:45 +03:00
|
|
|
private:
|
2017-06-19 08:45:43 +03:00
|
|
|
// Since we would never have a document which contains no style rule,
|
|
|
|
// we use IsEmpty as an indication whether we need to walk through
|
|
|
|
// all stylesheets to fill the table.
|
|
|
|
bool IsEmpty() const { return mTable.Count() == 0; }
|
|
|
|
|
2018-04-30 20:23:14 +03:00
|
|
|
void FillTableFromRule(css::Rule&);
|
|
|
|
void FillTableFromRuleList(ServoCSSRuleList&);
|
|
|
|
void FillTableFromStyleSheet(StyleSheet&);
|
2017-06-19 08:45:43 +03:00
|
|
|
|
|
|
|
typedef nsDataHashtable<nsPtrHashKey<const RawServoStyleRule>,
|
2018-06-04 16:35:50 +03:00
|
|
|
WeakPtr<dom::CSSStyleRule>>
|
|
|
|
Hashtable;
|
2017-06-19 08:45:43 +03:00
|
|
|
Hashtable mTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ServoStyleRuleMap_h
|