Bug 1373018 - Part 3: stylo: Move mPresContext to ServoStyleContext; r=bholley

MozReview-Commit-ID: 2BmRpIjxEO8

--HG--
extra : rebase_source : 51b9d1cd0963d0d243a6e575eff3a7407ee27485
This commit is contained in:
Manish Goregaokar 2017-06-10 22:27:45 -07:00
parent 7fceedfbae
commit 719eec238a
7 changed files with 44 additions and 21 deletions

View File

@ -21,9 +21,6 @@ GeckoStyleContext::GeckoStyleContext(nsStyleContext* aParent,
aPseudoTag, aPseudoType)
{
mBits |= NS_STYLE_CONTEXT_IS_GECKO;
#ifdef MOZ_STYLO
mPresContext = mSource.AsGeckoRuleNode()->PresContext();
#endif
if (aParent) {
#ifdef DEBUG

View File

@ -20,6 +20,10 @@ public:
bool aSkipParentDisplayBasedStyleFixup);
void* operator new(size_t sz, nsPresContext* aPresContext);
nsPresContext* PresContext() const {
return mSource.AsGeckoRuleNode()->PresContext();
}
};
}

View File

@ -21,9 +21,7 @@ ServoStyleContext::ServoStyleContext(nsStyleContext* aParent,
: nsStyleContext(aParent, OwningStyleContextSource(Move(aComputedValues)),
aPseudoTag, aPseudoType)
{
#ifdef MOZ_STYLO
mPresContext = aPresContext;
#endif
FinishConstruction();

View File

@ -18,6 +18,13 @@ public:
nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType,
already_AddRefed<ServoComputedValues> aComputedValues);
nsPresContext* PresContext() const {
return mPresContext;
}
private:
nsPresContext* mPresContext;
};
}

View File

@ -91,9 +91,6 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
, mEmptyChild(nullptr)
, mPseudoTag(aPseudoTag)
, mSource(Move(aSource))
#ifdef MOZ_STYLO
, mPresContext(nullptr)
#endif
, mCachedResetData(nullptr)
, mBits(((uint64_t)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT)
, mRefCnt(0)
@ -1721,3 +1718,9 @@ nsStyleContext::Initialize()
"layout.css.expensive-style-struct-assertions.enabled");
}
#endif
nsPresContext*
nsStyleContext::PresContext() const
{
MOZ_STYLO_FORWARD(PresContext, ())
}

View File

@ -128,13 +128,7 @@ public:
return mRefCnt == 1;
}
nsPresContext* PresContext() const {
#ifdef MOZ_STYLO
return mPresContext;
#else
return mSource.AsGeckoRuleNode()->PresContext();
#endif
}
nsPresContext* PresContext() const;
nsStyleContext* GetParent() const {
MOZ_ASSERT(mSource.IsGeckoRuleNode(),
@ -731,12 +725,6 @@ protected:
// when it's released and nulled out during teardown.
const mozilla::OwningStyleContextSource mSource;
#ifdef MOZ_STYLO
// In Gecko, we can get this off the rule node. We make this conditional
// on stylo builds to avoid the memory bloat on release.
nsPresContext* mPresContext;
#endif
// mCachedInheritedData and mCachedResetData point to both structs that
// are owned by this style context and structs that are owned by one of
// this style context's ancestors (which are indirectly owned since this

View File

@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Inlined methods for nsStyleContext. Will just redirect to
* GeckoStyleContext methods when compiled without stylo, but will do
* virtual dispatch (by checking which kind of container it is)
* in stylo mode.
*/
#ifndef mozilla_nsStyleContextInlines_h
#define mozilla_nsStyleContextInlines_h
#include "nsStyleContext.h"
#include "mozilla/ServoStyleContext.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/ServoUtils.h"
using namespace mozilla;
MOZ_DEFINE_STYLO_METHODS(nsStyleContext, GeckoStyleContext, ServoStyleContext);
#endif // mozilla_nsStyleContextInlines_h