Bug 1449097 - Use Servo to implement GetStatesForPseudoClass function in InspectorUtils. r=emilio

MozReview-Commit-ID: 2tL5otfqCiw

--HG--
extra : rebase_source : fe9ddd2a840efb33f5c0d7f53c7c755a0929a8f9
This commit is contained in:
Xidorn Quan 2018-03-28 09:41:04 +11:00
Родитель 6ec573da45
Коммит 8543cb7090
2 изменённых файлов: 5 добавлений и 31 удалений

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

@ -980,39 +980,11 @@ InspectorUtils::GetUsedFontFaces(GlobalObject& aGlobalObject,
static EventStates
GetStatesForPseudoClass(const nsAString& aStatePseudo)
{
// An array of the states that are relevant for various pseudoclasses.
// XXXbz this duplicates code in nsCSSRuleProcessor
static const EventStates sPseudoClassStates[] = {
#define CSS_PSEUDO_CLASS(_name, _value, _flags, _pref) \
EventStates(),
#define CSS_STATE_PSEUDO_CLASS(_name, _value, _flags, _pref, _states) \
_states,
#include "nsCSSPseudoClassList.h"
#undef CSS_STATE_PSEUDO_CLASS
#undef CSS_PSEUDO_CLASS
// Add more entries for our fake values to make sure we can't
// index out of bounds into this array no matter what.
EventStates(),
EventStates()
};
static_assert(MOZ_ARRAY_LENGTH(sPseudoClassStates) ==
static_cast<size_t>(CSSPseudoClassType::MAX),
"Length of PseudoClassStates array is incorrect");
RefPtr<nsAtom> atom = NS_Atomize(aStatePseudo);
CSSPseudoClassType type = nsCSSPseudoClasses::
GetPseudoType(atom, CSSEnabledState::eIgnoreEnabledState);
// Ignore :any-link so we don't give the element simultaneous
// visited and unvisited style state
if (type == CSSPseudoClassType::anyLink ||
type == CSSPseudoClassType::mozAnyLink) {
if (aStatePseudo.IsEmpty() || aStatePseudo[0] != u':') {
return EventStates();
}
// Our array above is long enough that indexing into it with
// NotPseudo is ok.
return sPseudoClassStates[static_cast<CSSPseudoClassTypeBase>(type)];
NS_ConvertUTF16toUTF8 statePseudo(Substring(aStatePseudo, 1));
return EventStates(Servo_PseudoClass_GetStates(&statePseudo));
}
/* static */ void

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

@ -820,6 +820,8 @@ SERVO_BINDING_FUNC(Servo_ParseFontShorthandForMatching, bool,
SERVO_BINDING_FUNC(Servo_Property_IsShorthand, bool,
const nsACString* name, bool* found);
SERVO_BINDING_FUNC(Servo_PseudoClass_GetStates, uint64_t,
const nsACString* name)
// AddRef / Release functions
#define SERVO_ARC_TYPE(name_, type_) \