зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
6ec573da45
Коммит
8543cb7090
|
@ -980,39 +980,11 @@ InspectorUtils::GetUsedFontFaces(GlobalObject& aGlobalObject,
|
||||||
static EventStates
|
static EventStates
|
||||||
GetStatesForPseudoClass(const nsAString& aStatePseudo)
|
GetStatesForPseudoClass(const nsAString& aStatePseudo)
|
||||||
{
|
{
|
||||||
// An array of the states that are relevant for various pseudoclasses.
|
if (aStatePseudo.IsEmpty() || aStatePseudo[0] != u':') {
|
||||||
// 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) {
|
|
||||||
return EventStates();
|
return EventStates();
|
||||||
}
|
}
|
||||||
// Our array above is long enough that indexing into it with
|
NS_ConvertUTF16toUTF8 statePseudo(Substring(aStatePseudo, 1));
|
||||||
// NotPseudo is ok.
|
return EventStates(Servo_PseudoClass_GetStates(&statePseudo));
|
||||||
return sPseudoClassStates[static_cast<CSSPseudoClassTypeBase>(type)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
|
|
|
@ -820,6 +820,8 @@ SERVO_BINDING_FUNC(Servo_ParseFontShorthandForMatching, bool,
|
||||||
|
|
||||||
SERVO_BINDING_FUNC(Servo_Property_IsShorthand, bool,
|
SERVO_BINDING_FUNC(Servo_Property_IsShorthand, bool,
|
||||||
const nsACString* name, bool* found);
|
const nsACString* name, bool* found);
|
||||||
|
SERVO_BINDING_FUNC(Servo_PseudoClass_GetStates, uint64_t,
|
||||||
|
const nsACString* name)
|
||||||
|
|
||||||
// AddRef / Release functions
|
// AddRef / Release functions
|
||||||
#define SERVO_ARC_TYPE(name_, type_) \
|
#define SERVO_ARC_TYPE(name_, type_) \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче