Bug 1422528: Inline and make stylo take the rare path for GetClasses directly. r=bz

Servo already checks MayHaveClass. This should improve Gecko performance, too.

MozReview-Commit-ID: KpVOVsKh6pe

--HG--
extra : rebase_source : b0384546b1430915a18536b6ee8b29a936599873
This commit is contained in:
Emilio Cobos Álvarez 2017-12-02 21:45:33 +01:00
Родитель d65dfc2d3d
Коммит 3125691c3f
4 изменённых файлов: 26 добавлений и 16 удалений

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

@ -205,18 +205,10 @@ nsIContent::DoGetID() const
}
const nsAttrValue*
Element::DoGetClasses() const
Element::GetSVGAnimatedClass() const
{
MOZ_ASSERT(MayHaveClass(), "Unexpected call");
if (IsSVGElement()) {
const nsAttrValue* animClass =
static_cast<const nsSVGElement*>(this)->GetAnimatedClassName();
if (animClass) {
return animClass;
}
}
return GetParsedAttr(nsGkAtoms::_class);
MOZ_ASSERT(MayHaveClass() && IsSVGElement(), "Unexpected call");
return static_cast<const nsSVGElement*>(this)->GetAnimatedClassName();
}
NS_IMETHODIMP

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

@ -900,6 +900,25 @@ public:
return nullptr;
}
/**
* Hook for implementing GetClasses. This should only be called if the
* ElementMayHaveClass flag is set.
*
* Public only because Servo needs to call it too, and it ensures the
* precondition before calling this.
*/
const nsAttrValue* DoGetClasses() const
{
MOZ_ASSERT(MayHaveClass(), "Unexpected call");
if (IsSVGElement()) {
if (const nsAttrValue* value = GetSVGAnimatedClass()) {
return value;
}
}
return GetParsedAttr(nsGkAtoms::_class);
}
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override
{
@ -1900,10 +1919,9 @@ protected:
private:
/**
* Hook for implementing GetClasses. This is guaranteed to only be
* called if the NODE_MAY_HAVE_CLASS flag is set.
* Slow path for DoGetClasses, this should only be called for SVG elements.
*/
const nsAttrValue* DoGetClasses() const;
const nsAttrValue* GetSVGAnimatedClass() const;
/**
* Get this element's client area rect in app units.

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

@ -1059,7 +1059,7 @@ template <typename Implementor>
static uint32_t
ClassOrClassList(Implementor* aElement, nsAtom** aClass, nsAtom*** aClassList)
{
const nsAttrValue* attr = aElement->GetClasses();
const nsAttrValue* attr = aElement->DoGetClasses();
if (!attr) {
return 0;
}

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

@ -151,7 +151,7 @@ public:
return nullptr;
}
const nsAttrValue* GetClasses() const
const nsAttrValue* DoGetClasses() const
{
MOZ_ASSERT(HasAttrs());
return &mClass;