Backed out changeset cfc393773f0d (bug 1404897)

This commit is contained in:
Sebastian Hengst 2017-10-04 12:55:11 +02:00
Родитель 4c9e5899c5
Коммит d90f0a5f6d
4 изменённых файлов: 17 добавлений и 111 удалений

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

@ -3496,21 +3496,13 @@ Element::Closest(const nsAString& aSelector, ErrorResult& aResult)
bool
Element::Matches(const nsAString& aSelector, ErrorResult& aError)
{
return WithSelectorList<bool>(
aSelector,
aError,
[&](const RawServoSelectorList* aList) {
if (!aList) {
return false;
}
return Servo_SelectorList_Matches(this, aList);
},
[&](nsCSSSelectorList* aList) {
if (!aList) {
nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aError);
if (!selectorList) {
// Either we failed (and aError already has the exception), or this
// is a pseudo-element-only selector that matches nothing.
return false;
}
TreeMatchContext matchingContext(false,
nsRuleWalker::eRelevantLinkUnvisited,
OwnerDoc(),
@ -3518,9 +3510,7 @@ Element::Matches(const nsAString& aSelector, ErrorResult& aError)
matchingContext.SetHasSpecifiedScope();
matchingContext.AddScopeElement(this);
return nsCSSRuleProcessor::SelectorListMatches(this, matchingContext,
aList);
}
);
selectorList);
}
static const nsAttrValue::EnumTable kCORSAttributeTable[] = {

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

@ -2676,47 +2676,6 @@ nsINode::Length() const
}
}
const RawServoSelectorList*
nsINode::ParseServoSelectorList(
const nsAString& aSelectorString,
ErrorResult& aRv)
{
nsIDocument* doc = OwnerDoc();
MOZ_ASSERT(doc->IsStyledByServo());
nsIDocument::SelectorCache& cache = doc->GetSelectorCache();
nsIDocument::SelectorCache::SelectorList* list =
cache.GetList(aSelectorString);
if (list) {
if (!*list) {
// Invalid selector.
aRv.ThrowDOMException(NS_ERROR_DOM_SYNTAX_ERR,
NS_LITERAL_CSTRING("'") + NS_ConvertUTF16toUTF8(aSelectorString) +
NS_LITERAL_CSTRING("' is not a valid selector")
);
}
// FIXME(emilio): Make this private and use `WithSelectorList` everywhere,
// then assert.
if (list->IsServo()) {
return list->AsServo();
}
}
NS_ConvertUTF16toUTF8 selectorString(aSelectorString);
auto* selectorList = Servo_SelectorList_Parse(&selectorString);
if (!selectorList) {
aRv.ThrowDOMException(NS_ERROR_DOM_SYNTAX_ERR,
NS_LITERAL_CSTRING("'") + selectorString +
NS_LITERAL_CSTRING("' is not a valid selector")
);
}
cache.CacheList(aSelectorString, UniquePtr<RawServoSelectorList>(selectorList));
return selectorList;
}
nsCSSSelectorList*
nsINode::ParseSelectorList(const nsAString& aSelectorString,
ErrorResult& aRv)
@ -2733,13 +2692,9 @@ nsINode::ParseSelectorList(const nsAString& aSelectorString,
NS_LITERAL_CSTRING("' is not a valid selector")
);
}
// FIXME(emilio): Make this private and use `WithSelectorList` everywhere,
// then assert.
if (list->IsGecko()) {
MOZ_ASSERT(list->IsGecko(), "We haven't done anything with Servo yet");
return list->AsGecko();
}
}
nsCSSParser parser(doc->CSSLoader());

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

@ -55,7 +55,6 @@ class nsNodeSupportsWeakRefTearoff;
class nsNodeWeakReference;
class nsDOMMutationObserver;
class nsRange;
struct RawServoSelectorList;
namespace mozilla {
class EventListenerManager;
@ -2067,46 +2066,10 @@ protected:
* contained pseudo-element selectors.
*
* A failing aRv means the string was not a valid selector.
*
* Note that the selector list returned here is owned by the owner doc's
* selector cache.
*/
nsCSSSelectorList* ParseSelectorList(const nsAString& aSelectorString,
mozilla::ErrorResult& aRv);
/**
* Parse the given selector string into a servo SelectorList.
*
* Never returns null if aRv is not failing.
*
* Note that the selector list returned here is owned by the owner doc's
* selector cache.
*/
const RawServoSelectorList* ParseServoSelectorList(
const nsAString& aSelectorString,
mozilla::ErrorResult& aRv);
/**
* Parse the given selector string into a SelectorList.
*
* A null return value with a non-failing aRv means the string only
* contained pseudo-element selectors.
*
* A failing aRv means the string was not a valid selector.
*/
template<typename Ret, typename ServoFunctor, typename GeckoFunctor>
Ret WithSelectorList(
const nsAString& aSelectorString,
mozilla::ErrorResult& aRv,
const ServoFunctor& aServoFunctor,
const GeckoFunctor& aGeckoFunctor)
{
if (IsStyledByServo()) {
return aServoFunctor(ParseServoSelectorList(aSelectorString, aRv));
}
return aGeckoFunctor(ParseSelectorList(aSelectorString, aRv));
}
public:
/* Event stuff that documents and elements share. This needs to be
NS_IMETHOD because some subclasses implement DOM methods with

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

@ -132,8 +132,6 @@ SERVO_BINDING_FUNC(Servo_StyleSet_ResolveForDeclarations,
SERVO_BINDING_FUNC(Servo_SelectorList_Parse,
RawServoSelectorList*,
const nsACString* selector_list)
SERVO_BINDING_FUNC(Servo_SelectorList_Matches, bool,
RawGeckoElementBorrowed, RawServoSelectorListBorrowed)
SERVO_BINDING_FUNC(Servo_StyleSet_AddSizeOfExcludingThis, void,
mozilla::MallocSizeOf malloc_size_of,
mozilla::MallocSizeOf malloc_enclosing_size_of,