Bug 1381157 - Cache 'mContent->GetPrimaryFrame == this' with a flag on nsIFrame and replace these calls to GetPrimaryFrame. r=mats

MozReview-Commit-ID: 3VoxYlean52
This commit is contained in:
Neerja Pancholi 2017-09-17 17:21:32 +02:00
Родитель 56af2e7716
Коммит 62d822fcdd
4 изменённых файлов: 46 добавлений и 10 удалений

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

@ -911,12 +911,9 @@ public:
{
return (IsInUncomposedDoc() || IsInShadowTree()) ? mPrimaryFrame : nullptr;
}
void SetPrimaryFrame(nsIFrame* aFrame) {
MOZ_ASSERT(IsInUncomposedDoc() || IsInShadowTree(), "This will end badly!");
NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
mPrimaryFrame = aFrame;
}
// Defined in nsIContentInlines.h because it needs nsIFrame.
inline void SetPrimaryFrame(nsIFrame* aFrame);
nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
nsAString& aNamespaceURI) const;

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

@ -11,6 +11,7 @@
#include "nsIDocument.h"
#include "nsContentUtils.h"
#include "nsIAtom.h"
#include "nsIFrame.h"
#include "mozilla/dom/Element.h"
inline bool
@ -25,6 +26,22 @@ nsIContent::IsInChromeDocument() const
return nsContentUtils::IsChromeDoc(OwnerDoc());
}
inline void
nsIContent::SetPrimaryFrame(nsIFrame* aFrame)
{
MOZ_ASSERT(IsInUncomposedDoc() || IsInShadowTree(), "This will end badly!");
NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
if (aFrame) {
aFrame->SetIsPrimaryFrame(true);
} else if (nsIFrame* currentPrimaryFrame = GetPrimaryFrame()) {
currentPrimaryFrame->SetIsPrimaryFrame(false);
}
mPrimaryFrame = aFrame;
}
inline mozilla::dom::ShadowRoot* nsIContent::GetShadowRoot() const
{
if (!IsElement()) {

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

@ -740,6 +740,12 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
}
}
// XXXneerja All instances of 'mContent->GetPrimaryFrame() == this' have been
// replaced with IsPrimaryFrame() except for this one. The reason is that
// for native anonymous content our subclass Destroy method has already
// called UnbindFromTree so nsINode::mSubtreeRoot might be in use here and
// we don't want to call mContent->SetPrimaryFrame(nullptr) in that case.
// (bug 1400618 will fix that order)
bool isPrimaryFrame = (mContent && mContent->GetPrimaryFrame() == this);
if (isPrimaryFrame) {
// This needs to happen before we clear our Properties() table.
@ -1337,7 +1343,7 @@ nsIFrame::HasAnimationOfTransform(EffectSet* aEffectSet) const
return mContent &&
nsLayoutUtils::HasAnimationOfProperty(effects, eCSSProperty_transform) &&
IsFrameOfType(eSupportsCSSTransforms) &&
mContent->GetPrimaryFrame() == this;
IsPrimaryFrame();
}
bool
@ -1352,7 +1358,7 @@ nsIFrame::HasOpacityInternal(float aThreshold,
EffectSet* effects =
aEffectSet ? aEffectSet : EffectSet::GetEffectSet(this);
return (mContent && mContent->GetPrimaryFrame() == this &&
return (IsPrimaryFrame() &&
nsLayoutUtils::HasAnimationOfProperty(effects, eCSSProperty_opacity));
}
@ -9417,7 +9423,7 @@ nsFrame::DoGetParentStyleContext(nsIFrame** aProviderFrame) const
// Ensure that we don't return the display:contents style
// of the parent content for pseudos that have the same content
// as their primary frame (like -moz-list-bullets do):
mContent->GetPrimaryFrame() == this) ||
IsPrimaryFrame()) ||
/* if next is true then it's really a request for the table frame's
parent context, see nsTable[Outer]Frame::GetParentStyleContext. */
pseudo == nsCSSAnonBoxes::tableWrapper) {

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

@ -623,6 +623,7 @@ public:
, mParentIsWrapperAnonBox(false)
, mIsWrapperBoxNeedingRestyle(false)
, mReflowRequestedForCharDataChange(false)
, mIsPrimaryFrame(false)
{
mozilla::PodZero(&mOverflow);
}
@ -2012,6 +2013,13 @@ public:
return mState & aBits;
}
/**
* Return true if this frame is the primary frame for mContent.
*/
bool IsPrimaryFrame() const { return mIsPrimaryFrame; }
void SetIsPrimaryFrame(bool aIsPrimary) { mIsPrimaryFrame = aIsPrimary; }
/**
* This call is invoked on the primary frame for a character data content
* node, when it is changed in the content tree.
@ -4190,7 +4198,15 @@ protected:
*/
bool mReflowRequestedForCharDataChange : 1;
// There is a 10-bit gap left here.
private:
/**
* True if this is the primary frame for mContent.
*/
bool mIsPrimaryFrame : 1;
protected:
// There is a 9-bit gap left here.
// Helpers
/**