mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 1373018 - Part 5: stylo: Move child/sibling pointers to GeckoStyleContext; r=bholley
MozReview-Commit-ID: Gay6RwpkNcu --HG-- extra : rebase_source : 57a7f22b3d830e2fdc47faa15ceafbe5020a5964
This commit is contained in:
parent
2991af8d79
commit
70773cfc42
@ -13,6 +13,7 @@
|
||||
#include <algorithm> // For std::max
|
||||
#include "gfxContext.h"
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/GeckoStyleContext.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/ViewportFrame.h"
|
||||
#include "mozilla/css/StyleRule.h" // For nsCSSSelector
|
||||
@ -23,6 +24,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsStyleChangeList.h"
|
||||
#include "nsRuleProcessorData.h"
|
||||
#include "nsStyleContextInlines.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
@ -3443,7 +3445,7 @@ ClearCachedInheritedStyleDataOnDescendants(
|
||||
for (size_t i = 0; i < aContextsToClear.Length(); i++) {
|
||||
auto& entry = aContextsToClear[i];
|
||||
if (!entry.mStyleContext->HasSingleReference()) {
|
||||
entry.mStyleContext->ClearCachedInheritedStyleDataOnDescendants(
|
||||
entry.mStyleContext->AsGecko()->ClearCachedInheritedStyleDataOnDescendants(
|
||||
entry.mStructs);
|
||||
}
|
||||
entry.mStyleContext = nullptr;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsStyleStruct.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsStyleContextInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -19,6 +20,8 @@ GeckoStyleContext::GeckoStyleContext(nsStyleContext* aParent,
|
||||
bool aSkipParentDisplayBasedStyleFixup)
|
||||
: nsStyleContext(aParent, OwningStyleContextSource(Move(aRuleNode)),
|
||||
aPseudoTag, aPseudoType)
|
||||
, mChild(nullptr)
|
||||
, mEmptyChild(nullptr)
|
||||
{
|
||||
mBits |= NS_STYLE_CONTEXT_IS_GECKO;
|
||||
|
||||
@ -36,6 +39,11 @@ GeckoStyleContext::GeckoStyleContext(nsStyleContext* aParent,
|
||||
}
|
||||
|
||||
mSource.AsGeckoRuleNode()->SetUsedDirectly(); // before ApplyStyleFixups()!
|
||||
// FinishConstruction() calls AddChild which needs these
|
||||
// to be initialized!
|
||||
mNextSibling = this;
|
||||
mPrevSibling = this;
|
||||
|
||||
FinishConstruction();
|
||||
ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);
|
||||
}
|
||||
@ -50,3 +58,181 @@ GeckoStyleContext::operator new(size_t sz, nsPresContext* aPresContext)
|
||||
return aPresContext->PresShell()->
|
||||
AllocateByObjectID(eArenaObjectID_GeckoStyleContext, sz);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GeckoStyleContext::AddChild(GeckoStyleContext* aChild)
|
||||
{
|
||||
NS_ASSERTION(aChild->mPrevSibling == aChild &&
|
||||
aChild->mNextSibling == aChild,
|
||||
"child already in a child list");
|
||||
|
||||
GeckoStyleContext **listPtr = aChild->mSource.MatchesNoRules() ? &mEmptyChild : &mChild;
|
||||
// Explicitly dereference listPtr so that compiler doesn't have to know that mNextSibling
|
||||
// etc. don't alias with what ever listPtr points at.
|
||||
GeckoStyleContext *list = *listPtr;
|
||||
|
||||
// Insert at the beginning of the list. See also FindChildWithRules.
|
||||
if (list) {
|
||||
// Link into existing elements, if there are any.
|
||||
aChild->mNextSibling = list;
|
||||
aChild->mPrevSibling = list->mPrevSibling;
|
||||
list->mPrevSibling->mNextSibling = aChild;
|
||||
list->mPrevSibling = aChild;
|
||||
}
|
||||
(*listPtr) = aChild;
|
||||
}
|
||||
|
||||
void
|
||||
GeckoStyleContext::RemoveChild(GeckoStyleContext* aChild)
|
||||
{
|
||||
NS_PRECONDITION(nullptr != aChild && this == aChild->mParent, "bad argument");
|
||||
|
||||
GeckoStyleContext **list = aChild->mSource.MatchesNoRules() ? &mEmptyChild : &mChild;
|
||||
|
||||
if (aChild->mPrevSibling != aChild) { // has siblings
|
||||
if ((*list) == aChild) {
|
||||
(*list) = (*list)->mNextSibling;
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION((*list) == aChild, "bad sibling pointers");
|
||||
(*list) = nullptr;
|
||||
}
|
||||
|
||||
aChild->mPrevSibling->mNextSibling = aChild->mNextSibling;
|
||||
aChild->mNextSibling->mPrevSibling = aChild->mPrevSibling;
|
||||
aChild->mNextSibling = aChild;
|
||||
aChild->mPrevSibling = aChild;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
GeckoStyleContext::ListDescendants(FILE* out, int32_t aIndent)
|
||||
{
|
||||
if (nullptr != mChild) {
|
||||
GeckoStyleContext* child = mChild;
|
||||
do {
|
||||
child->List(out, aIndent + 1, true);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (nullptr != mEmptyChild) {
|
||||
GeckoStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->List(out, aIndent + 1, true);
|
||||
child = child->mNextSibling;
|
||||
} while (mEmptyChild != child);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
GeckoStyleContext::ClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs)
|
||||
{
|
||||
if (mChild) {
|
||||
GeckoStyleContext* child = mChild;
|
||||
do {
|
||||
child->DoClearCachedInheritedStyleDataOnDescendants(aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (mEmptyChild) {
|
||||
GeckoStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->DoClearCachedInheritedStyleDataOnDescendants(aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (mEmptyChild != child);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GeckoStyleContext::DoClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs)
|
||||
{
|
||||
NS_ASSERTION(mFrameRefCnt == 0, "frame still referencing style context");
|
||||
for (nsStyleStructID i = nsStyleStructID_Inherited_Start;
|
||||
i < nsStyleStructID_Inherited_Start + nsStyleStructID_Inherited_Count;
|
||||
i = nsStyleStructID(i + 1)) {
|
||||
uint32_t bit = nsCachedStyleData::GetBitForSID(i);
|
||||
if (aStructs & bit) {
|
||||
if (!(mBits & bit) && mCachedInheritedData.mStyleStructs[i]) {
|
||||
aStructs &= ~bit;
|
||||
} else {
|
||||
mCachedInheritedData.mStyleStructs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mCachedResetData) {
|
||||
for (nsStyleStructID i = nsStyleStructID_Reset_Start;
|
||||
i < nsStyleStructID_Reset_Start + nsStyleStructID_Reset_Count;
|
||||
i = nsStyleStructID(i + 1)) {
|
||||
uint32_t bit = nsCachedStyleData::GetBitForSID(i);
|
||||
if (aStructs & bit) {
|
||||
if (!(mBits & bit) && mCachedResetData->mStyleStructs[i]) {
|
||||
aStructs &= ~bit;
|
||||
} else {
|
||||
mCachedResetData->mStyleStructs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aStructs == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClearCachedInheritedStyleDataOnDescendants(aStructs);
|
||||
}
|
||||
|
||||
|
||||
already_AddRefed<GeckoStyleContext>
|
||||
GeckoStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
NonOwningStyleContextSource aSource,
|
||||
NonOwningStyleContextSource aSourceIfVisited,
|
||||
bool aRelevantLinkVisited)
|
||||
{
|
||||
uint32_t threshold = 10; // The # of siblings we're willing to examine
|
||||
// before just giving this whole thing up.
|
||||
|
||||
RefPtr<GeckoStyleContext> result;
|
||||
GeckoStyleContext *list = aSource.MatchesNoRules() ? mEmptyChild : mChild;
|
||||
|
||||
if (list) {
|
||||
GeckoStyleContext *child = list;
|
||||
do {
|
||||
if (child->mSource.AsRaw() == aSource &&
|
||||
child->mPseudoTag == aPseudoTag &&
|
||||
!child->IsStyleIfVisited() &&
|
||||
child->RelevantLinkVisited() == aRelevantLinkVisited) {
|
||||
bool match = false;
|
||||
if (!aSourceIfVisited.IsNull()) {
|
||||
match = child->GetStyleIfVisited() &&
|
||||
child->GetStyleIfVisited()->AsGecko()->mSource.AsRaw() == aSourceIfVisited;
|
||||
} else {
|
||||
match = !child->GetStyleIfVisited();
|
||||
}
|
||||
if (match && !(child->mBits & NS_STYLE_INELIGIBLE_FOR_SHARING)) {
|
||||
result = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
child = child->mNextSibling;
|
||||
threshold--;
|
||||
if (threshold == 0)
|
||||
break;
|
||||
} while (child != list);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
if (result != list) {
|
||||
// Move result to the front of the list.
|
||||
RemoveChild(result);
|
||||
AddChild(result);
|
||||
}
|
||||
result->mBits |= NS_STYLE_IS_SHARED;
|
||||
}
|
||||
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,47 @@ public:
|
||||
nsPresContext* PresContext() const {
|
||||
return mSource.AsGeckoRuleNode()->PresContext();
|
||||
}
|
||||
|
||||
void AddChild(GeckoStyleContext* aChild);
|
||||
void RemoveChild(GeckoStyleContext* aChild);
|
||||
/**
|
||||
* On each descendant of this style context, clears out any cached inherited
|
||||
* structs indicated in aStructs.
|
||||
*/
|
||||
void ClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs);
|
||||
// Find, if it already exists *and is easily findable* (i.e., near the
|
||||
// start of the child list), a style context whose:
|
||||
// * GetPseudo() matches aPseudoTag
|
||||
// * mSource matches aSource
|
||||
// * !!GetStyleIfVisited() == !!aSourceIfVisited, and, if they're
|
||||
// non-null, GetStyleIfVisited()->mSource == aSourceIfVisited
|
||||
// * RelevantLinkVisited() == aRelevantLinkVisited
|
||||
already_AddRefed<GeckoStyleContext>
|
||||
FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
mozilla::NonOwningStyleContextSource aSource,
|
||||
mozilla::NonOwningStyleContextSource aSourceIfVisited,
|
||||
bool aRelevantLinkVisited);
|
||||
|
||||
#ifdef DEBUG
|
||||
void ListDescendants(FILE* out, int32_t aIndent);
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Helper for ClearCachedInheritedStyleDataOnDescendants.
|
||||
void DoClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs);
|
||||
|
||||
|
||||
public:
|
||||
// Children are kept in two circularly-linked lists. The list anchor
|
||||
// is not part of the list (null for empty), and we point to the first
|
||||
// child.
|
||||
// mEmptyChild for children whose rule node is the root rule node, and
|
||||
// mChild for other children. The order of children is not
|
||||
// meaningful.
|
||||
GeckoStyleContext* mChild;
|
||||
GeckoStyleContext* mEmptyChild;
|
||||
GeckoStyleContext* mPrevSibling;
|
||||
GeckoStyleContext* mNextSibling;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ EXPORTS += [
|
||||
'nsStyleAutoArray.h',
|
||||
'nsStyleConsts.h',
|
||||
'nsStyleContext.h',
|
||||
'nsStyleContextInlines.h',
|
||||
'nsStyleCoord.h',
|
||||
'nsStyleSet.h',
|
||||
'nsStyleStruct.h',
|
||||
|
@ -6,8 +6,6 @@
|
||||
/* the interface (to internal code) for retrieving computed style data */
|
||||
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsStyleContextInlines.h"
|
||||
|
||||
#include "CSSVariableImageTable.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
@ -37,6 +35,7 @@
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
#include "mozilla/GeckoStyleContext.h"
|
||||
#include "mozilla/ServoStyleContext.h"
|
||||
#include "nsStyleContextInlines.h"
|
||||
|
||||
#include "mozilla/ReflowInput.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
@ -87,8 +86,6 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
|
||||
nsIAtom* aPseudoTag,
|
||||
CSSPseudoElementType aPseudoType)
|
||||
: mParent(aParent)
|
||||
, mChild(nullptr)
|
||||
, mEmptyChild(nullptr)
|
||||
, mPseudoTag(aPseudoTag)
|
||||
, mSource(Move(aSource))
|
||||
, mCachedResetData(nullptr)
|
||||
@ -117,8 +114,6 @@ nsStyleContext::FinishConstruction()
|
||||
"Number of items in dependency table doesn't match IDs");
|
||||
#endif
|
||||
|
||||
mNextSibling = this;
|
||||
mPrevSibling = this;
|
||||
if (mParent) {
|
||||
mParent->AddChild(this);
|
||||
}
|
||||
@ -133,7 +128,10 @@ nsStyleContext::FinishConstruction()
|
||||
|
||||
nsStyleContext::~nsStyleContext()
|
||||
{
|
||||
NS_ASSERTION((nullptr == mChild) && (nullptr == mEmptyChild), "destructing context with children");
|
||||
if (const GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
NS_ASSERTION((nullptr == gecko->mChild) && (nullptr == gecko->mEmptyChild),
|
||||
"destructing context with children");
|
||||
}
|
||||
MOZ_ASSERT(!mSource.IsServoComputedValues() || !mCachedResetData);
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -255,66 +253,39 @@ nsStyleContext::AssertStructsNotUsedElsewhere(
|
||||
}
|
||||
}
|
||||
|
||||
if (mChild) {
|
||||
const nsStyleContext* child = mChild;
|
||||
do {
|
||||
child->AssertStructsNotUsedElsewhere(aDestroyingContext, aLevels - 1);
|
||||
child = child->mNextSibling;
|
||||
} while (child != mChild);
|
||||
}
|
||||
if (const GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
if (gecko->mChild) {
|
||||
const GeckoStyleContext* child = gecko->mChild;
|
||||
do {
|
||||
child->AssertStructsNotUsedElsewhere(aDestroyingContext, aLevels - 1);
|
||||
child = child->mNextSibling;
|
||||
} while (child != gecko->mChild);
|
||||
}
|
||||
|
||||
if (mEmptyChild) {
|
||||
const nsStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->AssertStructsNotUsedElsewhere(aDestroyingContext, aLevels - 1);
|
||||
child = child->mNextSibling;
|
||||
} while (child != mEmptyChild);
|
||||
if (gecko->mEmptyChild) {
|
||||
const GeckoStyleContext* child = gecko->mEmptyChild;
|
||||
do {
|
||||
child->AssertStructsNotUsedElsewhere(aDestroyingContext, aLevels - 1);
|
||||
child = child->mNextSibling;
|
||||
} while (child != gecko->mEmptyChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void nsStyleContext::AddChild(nsStyleContext* aChild)
|
||||
{
|
||||
NS_ASSERTION(aChild->mPrevSibling == aChild &&
|
||||
aChild->mNextSibling == aChild,
|
||||
"child already in a child list");
|
||||
|
||||
nsStyleContext **listPtr = aChild->mSource.MatchesNoRules() ? &mEmptyChild : &mChild;
|
||||
// Explicitly dereference listPtr so that compiler doesn't have to know that mNextSibling
|
||||
// etc. don't alias with what ever listPtr points at.
|
||||
nsStyleContext *list = *listPtr;
|
||||
|
||||
// Insert at the beginning of the list. See also FindChildWithRules.
|
||||
if (list) {
|
||||
// Link into existing elements, if there are any.
|
||||
aChild->mNextSibling = list;
|
||||
aChild->mPrevSibling = list->mPrevSibling;
|
||||
list->mPrevSibling->mNextSibling = aChild;
|
||||
list->mPrevSibling = aChild;
|
||||
if (GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
gecko->AddChild(aChild->AsGecko());
|
||||
}
|
||||
(*listPtr) = aChild;
|
||||
}
|
||||
|
||||
void nsStyleContext::RemoveChild(nsStyleContext* aChild)
|
||||
{
|
||||
NS_PRECONDITION(nullptr != aChild && this == aChild->mParent, "bad argument");
|
||||
|
||||
nsStyleContext **list = aChild->mSource.MatchesNoRules() ? &mEmptyChild : &mChild;
|
||||
|
||||
if (aChild->mPrevSibling != aChild) { // has siblings
|
||||
if ((*list) == aChild) {
|
||||
(*list) = (*list)->mNextSibling;
|
||||
}
|
||||
if (GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
gecko->RemoveChild(aChild->AsGecko());
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION((*list) == aChild, "bad sibling pointers");
|
||||
(*list) = nullptr;
|
||||
}
|
||||
|
||||
aChild->mPrevSibling->mNextSibling = aChild->mNextSibling;
|
||||
aChild->mNextSibling->mPrevSibling = aChild->mPrevSibling;
|
||||
aChild->mNextSibling = aChild;
|
||||
aChild->mPrevSibling = aChild;
|
||||
}
|
||||
|
||||
void
|
||||
@ -363,56 +334,6 @@ nsStyleContext::MoveTo(nsStyleContext* aNewParent)
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
NonOwningStyleContextSource aSource,
|
||||
NonOwningStyleContextSource aSourceIfVisited,
|
||||
bool aRelevantLinkVisited)
|
||||
{
|
||||
uint32_t threshold = 10; // The # of siblings we're willing to examine
|
||||
// before just giving this whole thing up.
|
||||
|
||||
RefPtr<nsStyleContext> result;
|
||||
nsStyleContext *list = aSource.MatchesNoRules() ? mEmptyChild : mChild;
|
||||
|
||||
if (list) {
|
||||
nsStyleContext *child = list;
|
||||
do {
|
||||
if (child->mSource.AsRaw() == aSource &&
|
||||
child->mPseudoTag == aPseudoTag &&
|
||||
!child->IsStyleIfVisited() &&
|
||||
child->RelevantLinkVisited() == aRelevantLinkVisited) {
|
||||
bool match = false;
|
||||
if (!aSourceIfVisited.IsNull()) {
|
||||
match = child->GetStyleIfVisited() &&
|
||||
child->GetStyleIfVisited()->mSource.AsRaw() == aSourceIfVisited;
|
||||
} else {
|
||||
match = !child->GetStyleIfVisited();
|
||||
}
|
||||
if (match && !(child->mBits & NS_STYLE_INELIGIBLE_FOR_SHARING)) {
|
||||
result = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
child = child->mNextSibling;
|
||||
threshold--;
|
||||
if (threshold == 0)
|
||||
break;
|
||||
} while (child != list);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
if (result != list) {
|
||||
// Move result to the front of the list.
|
||||
RemoveChild(result);
|
||||
AddChild(result);
|
||||
}
|
||||
result->mBits |= NS_STYLE_IS_SHARED;
|
||||
}
|
||||
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
const void* nsStyleContext::StyleData(nsStyleStructID aSID)
|
||||
{
|
||||
const void* cachedData = GetCachedStyleData(aSID);
|
||||
@ -476,7 +397,12 @@ nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID)
|
||||
// have kids depending on the data. ClearStyleData would be OK, but
|
||||
// this test for no mChild or mEmptyChild doesn't catch that case.)
|
||||
const void *current = StyleData(aSID);
|
||||
if (!mChild && !mEmptyChild &&
|
||||
GeckoStyleContext *child = nullptr, *emptyChild = nullptr;
|
||||
if (const GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
child = gecko->mChild;
|
||||
emptyChild = gecko->mEmptyChild;
|
||||
}
|
||||
if (!child && !emptyChild &&
|
||||
!(mBits & nsCachedStyleData::GetBitForSID(aSID)) &&
|
||||
GetCachedStyleData(aSID))
|
||||
return const_cast<void*>(current);
|
||||
@ -515,8 +441,10 @@ nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID)
|
||||
void*
|
||||
nsStyleContext::CreateEmptyStyleData(const nsStyleStructID& aSID)
|
||||
{
|
||||
MOZ_ASSERT(!mChild && !mEmptyChild &&
|
||||
!(mBits & nsCachedStyleData::GetBitForSID(aSID)) &&
|
||||
if (const GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
MOZ_ASSERT(!gecko->mChild && !gecko->mEmptyChild, "This style should not have been computed");
|
||||
}
|
||||
MOZ_ASSERT(!(mBits & nsCachedStyleData::GetBitForSID(aSID)) &&
|
||||
!GetCachedStyleData(aSID),
|
||||
"This style should not have been computed");
|
||||
|
||||
@ -1305,19 +1233,8 @@ void nsStyleContext::List(FILE* out, int32_t aIndent, bool aListDescendants)
|
||||
}
|
||||
|
||||
if (aListDescendants) {
|
||||
if (nullptr != mChild) {
|
||||
nsStyleContext* child = mChild;
|
||||
do {
|
||||
child->List(out, aIndent + 1, aListDescendants);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (nullptr != mEmptyChild) {
|
||||
nsStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->List(out, aIndent + 1, aListDescendants);
|
||||
child = child->mNextSibling;
|
||||
} while (mEmptyChild != child);
|
||||
if (GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
gecko->ListDescendants(out, aIndent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1535,64 +1452,6 @@ nsStyleContext::SwapStyleData(nsStyleContext* aNewContext, uint32_t aStructs)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContext::ClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs)
|
||||
{
|
||||
if (mChild) {
|
||||
nsStyleContext* child = mChild;
|
||||
do {
|
||||
child->DoClearCachedInheritedStyleDataOnDescendants(aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (mEmptyChild) {
|
||||
nsStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->DoClearCachedInheritedStyleDataOnDescendants(aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (mEmptyChild != child);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContext::DoClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs)
|
||||
{
|
||||
NS_ASSERTION(mFrameRefCnt == 0, "frame still referencing style context");
|
||||
for (nsStyleStructID i = nsStyleStructID_Inherited_Start;
|
||||
i < nsStyleStructID_Inherited_Start + nsStyleStructID_Inherited_Count;
|
||||
i = nsStyleStructID(i + 1)) {
|
||||
uint32_t bit = nsCachedStyleData::GetBitForSID(i);
|
||||
if (aStructs & bit) {
|
||||
if (!(mBits & bit) && mCachedInheritedData.mStyleStructs[i]) {
|
||||
aStructs &= ~bit;
|
||||
} else {
|
||||
mCachedInheritedData.mStyleStructs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mCachedResetData) {
|
||||
for (nsStyleStructID i = nsStyleStructID_Reset_Start;
|
||||
i < nsStyleStructID_Reset_Start + nsStyleStructID_Reset_Count;
|
||||
i = nsStyleStructID(i + 1)) {
|
||||
uint32_t bit = nsCachedStyleData::GetBitForSID(i);
|
||||
if (aStructs & bit) {
|
||||
if (!(mBits & bit) && mCachedResetData->mStyleStructs[i]) {
|
||||
aStructs &= ~bit;
|
||||
} else {
|
||||
mCachedResetData->mStyleStructs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aStructs == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClearCachedInheritedStyleDataOnDescendants(aStructs);
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContext::SetIneligibleForSharing()
|
||||
{
|
||||
@ -1600,19 +1459,21 @@ nsStyleContext::SetIneligibleForSharing()
|
||||
return;
|
||||
}
|
||||
mBits |= NS_STYLE_INELIGIBLE_FOR_SHARING;
|
||||
if (mChild) {
|
||||
nsStyleContext* child = mChild;
|
||||
do {
|
||||
child->SetIneligibleForSharing();
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (mEmptyChild) {
|
||||
nsStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->SetIneligibleForSharing();
|
||||
child = child->mNextSibling;
|
||||
} while (mEmptyChild != child);
|
||||
if (const GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
if (gecko->mChild) {
|
||||
GeckoStyleContext* child = gecko->mChild;
|
||||
do {
|
||||
child->SetIneligibleForSharing();
|
||||
child = child->mNextSibling;
|
||||
} while (gecko->mChild != child);
|
||||
}
|
||||
if (gecko->mEmptyChild) {
|
||||
GeckoStyleContext* child = gecko->mEmptyChild;
|
||||
do {
|
||||
child->SetIneligibleForSharing();
|
||||
child = child->mNextSibling;
|
||||
} while (gecko->mEmptyChild != child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1692,19 +1553,21 @@ nsStyleContext::LogStyleContextTree(bool aFirst, uint32_t aStructs)
|
||||
|
||||
LOG_RESTYLE_INDENT();
|
||||
|
||||
if (nullptr != mChild) {
|
||||
nsStyleContext* child = mChild;
|
||||
do {
|
||||
child->LogStyleContextTree(false, aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (mChild != child);
|
||||
}
|
||||
if (nullptr != mEmptyChild) {
|
||||
nsStyleContext* child = mEmptyChild;
|
||||
do {
|
||||
child->LogStyleContextTree(false, aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (mEmptyChild != child);
|
||||
if (const GeckoStyleContext* gecko = GetAsGecko()) {
|
||||
if (nullptr != gecko->mChild) {
|
||||
GeckoStyleContext* child = gecko->mChild;
|
||||
do {
|
||||
child->LogStyleContextTree(false, aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (gecko->mChild != child);
|
||||
}
|
||||
if (nullptr != gecko->mEmptyChild) {
|
||||
GeckoStyleContext* child = gecko->mEmptyChild;
|
||||
do {
|
||||
child->LogStyleContextTree(false, aStructs);
|
||||
child = child->mNextSibling;
|
||||
} while (gecko->mEmptyChild != child);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1724,3 +1587,4 @@ nsStyleContext::PresContext() const
|
||||
{
|
||||
MOZ_STYLO_FORWARD(PresContext, ())
|
||||
}
|
||||
|
||||
|
@ -154,19 +154,6 @@ public:
|
||||
bool IsPseudoElement() const { return mPseudoTag && !IsAnonBox(); }
|
||||
|
||||
|
||||
// Find, if it already exists *and is easily findable* (i.e., near the
|
||||
// start of the child list), a style context whose:
|
||||
// * GetPseudo() matches aPseudoTag
|
||||
// * mSource matches aSource
|
||||
// * !!GetStyleIfVisited() == !!aSourceIfVisited, and, if they're
|
||||
// non-null, GetStyleIfVisited()->mSource == aSourceIfVisited
|
||||
// * RelevantLinkVisited() == aRelevantLinkVisited
|
||||
already_AddRefed<nsStyleContext>
|
||||
FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
mozilla::NonOwningStyleContextSource aSource,
|
||||
mozilla::NonOwningStyleContextSource aSourceIfVisited,
|
||||
bool aRelevantLinkVisited);
|
||||
|
||||
// Does this style context or any of its ancestors have text
|
||||
// decoration lines?
|
||||
// Differs from nsStyleTextReset::HasTextDecorationLines, which tests
|
||||
@ -460,11 +447,6 @@ public:
|
||||
*/
|
||||
void SwapStyleData(nsStyleContext* aNewContext, uint32_t aStructs);
|
||||
|
||||
/**
|
||||
* On each descendant of this style context, clears out any cached inherited
|
||||
* structs indicated in aStructs.
|
||||
*/
|
||||
void ClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs);
|
||||
|
||||
/**
|
||||
* Sets the NS_STYLE_INELIGIBLE_FOR_SHARING bit on this style context
|
||||
@ -509,7 +491,7 @@ public:
|
||||
|
||||
mozilla::NonOwningStyleContextSource StyleSource() const { return mSource.AsRaw(); }
|
||||
|
||||
protected:
|
||||
public: // temporary
|
||||
// Private destructor, to discourage deletion outside of Release():
|
||||
~nsStyleContext();
|
||||
|
||||
@ -522,6 +504,7 @@ protected:
|
||||
// Helper post-contruct hook.
|
||||
void FinishConstruction();
|
||||
|
||||
// Only does stuff in Gecko mode
|
||||
void AddChild(nsStyleContext* aChild);
|
||||
void RemoveChild(nsStyleContext* aChild);
|
||||
|
||||
@ -681,9 +664,6 @@ protected:
|
||||
#undef STYLE_STRUCT_RESET
|
||||
#undef STYLE_STRUCT_INHERITED
|
||||
|
||||
// Helper for ClearCachedInheritedStyleDataOnDescendants.
|
||||
void DoClearCachedInheritedStyleDataOnDescendants(uint32_t aStructs);
|
||||
|
||||
#ifdef DEBUG
|
||||
void AssertStructsNotUsedElsewhere(nsStyleContext* aDestroyingContext,
|
||||
int32_t aLevels) const;
|
||||
@ -700,17 +680,6 @@ protected:
|
||||
|
||||
RefPtr<nsStyleContext> mParent;
|
||||
|
||||
// Children are kept in two circularly-linked lists. The list anchor
|
||||
// is not part of the list (null for empty), and we point to the first
|
||||
// child.
|
||||
// mEmptyChild for children whose rule node is the root rule node, and
|
||||
// mChild for other children. The order of children is not
|
||||
// meaningful.
|
||||
nsStyleContext* mChild;
|
||||
nsStyleContext* mEmptyChild;
|
||||
nsStyleContext* mPrevSibling;
|
||||
nsStyleContext* mNextSibling;
|
||||
|
||||
// Style to be used instead for the R, G, and B components of color,
|
||||
// background-color, and border-*-color if the nearest ancestor link
|
||||
// element is visited (see RelevantLinkVisited()).
|
||||
|
@ -11,8 +11,8 @@
|
||||
* in stylo mode.
|
||||
*/
|
||||
|
||||
#ifndef mozilla_nsStyleContextInlines_h
|
||||
#define mozilla_nsStyleContextInlines_h
|
||||
#ifndef nsStyleContextInlines_h
|
||||
#define nsStyleContextInlines_h
|
||||
|
||||
#include "nsStyleContext.h"
|
||||
#include "mozilla/ServoStyleContext.h"
|
||||
@ -23,4 +23,4 @@ using namespace mozilla;
|
||||
|
||||
MOZ_DEFINE_STYLO_METHODS(nsStyleContext, GeckoStyleContext, ServoStyleContext);
|
||||
|
||||
#endif // mozilla_nsStyleContextInlines_h
|
||||
#endif // nsStyleContextInlines_h
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "mozilla/RestyleManager.h"
|
||||
#include "mozilla/RestyleManagerInlines.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsStyleContextInlines.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -926,7 +927,7 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
|
||||
|
||||
RefPtr<nsStyleContext> result;
|
||||
if (aParentContext)
|
||||
result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode,
|
||||
result = aParentContext->AsGecko()->FindChildWithRules(aPseudoTag, aRuleNode,
|
||||
aVisitedRuleNode,
|
||||
relevantLinkVisited);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user