Bug 1373018 - Part 8: stylo: Move nsStyleContext::SetStyle to GeckoStyleContext; r=bholley

MozReview-Commit-ID: ycXu95whnG

--HG--
extra : rebase_source : 852051aa074cc8ed8f11f0d68c26fe4f0a6962b6
This commit is contained in:
Manish Goregaokar 2017-06-10 22:27:45 -07:00
Родитель 828745da04
Коммит 02ab46c24d
16 изменённых файлов: 244 добавлений и 254 удалений

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

@ -6,7 +6,7 @@
#include "AnimValuesStyleRule.h"
#include "nsRuleData.h"
#include "nsStyleContext.h"
#include "mozilla/GeckoStyleContext.h"
namespace mozilla {
@ -15,7 +15,7 @@ NS_IMPL_ISUPPORTS(AnimValuesStyleRule, nsIStyleRule)
void
AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
nsStyleContext *contextParent = aRuleData->mStyleContext->GetParent();
GeckoStyleContext *contextParent = aRuleData->mStyleContext->GetParent();
if (contextParent && contextParent->HasPseudoElementData()) {
// Don't apply transitions or animations to things inside of
// pseudo-elements.

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

@ -15,6 +15,7 @@
#include "mozilla/AnimationUtils.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/EffectSet.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/LayerAnimationInfo.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/RestyleManagerInlines.h"
@ -33,6 +34,7 @@
#include "nsLayoutUtils.h"
#include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
#include "nsRuleProcessorData.h" // For ElementRuleProcessorData etc.
#include "nsStyleContextInlines.h"
#include "nsTArray.h"
#include <bitset>
#include <initializer_list>
@ -801,7 +803,7 @@ EffectCompositor::GetOverriddenProperties(StyleBackendType aBackendType,
break;
case StyleBackendType::Gecko:
nsRuleNode::ComputePropertiesOverridingAnimation(propertiesToTrack,
aStyleContext,
aStyleContext->AsGecko(),
result);
break;

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

@ -15,6 +15,7 @@
#include "mozilla/AnimationUtils.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/EffectSet.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/FloatingPoint.h" // For IsFinite
#include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
#include "mozilla/KeyframeUtils.h"
@ -28,6 +29,7 @@
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
#include "nsIPresShell.h"
#include "nsIScriptError.h"
#include "nsStyleContextInlines.h"
namespace mozilla {
@ -1643,7 +1645,7 @@ CreateStyleContextForAnimationValue(nsCSSPropertyID aProperty,
// We need to call StyleData to generate cached data for the style context.
// Otherwise CalcStyleDifference returns no meaningful result.
styleContext->StyleData(nsCSSProps::kSIDTable[aProperty]);
styleContext->AsGecko()->StyleData(nsCSSProps::kSIDTable[aProperty]);
return styleContext.forget();
}

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

@ -86,6 +86,7 @@
#include "nsAutoLayoutPhase.h"
#include "nsStyleStructInlines.h"
#include "nsPageContentFrame.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/RestyleManagerInlines.h"
#include "StickyScrollContainer.h"

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

@ -42,6 +42,7 @@
#include "nsFrameManager.h"
#include "nsLayoutUtils.h"
#include "LayoutLogging.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/GeckoRestyleManager.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/RestyleManagerInlines.h"

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

@ -769,3 +769,48 @@ GeckoStyleContext::HasNoChildren() const
{
return (nullptr == mChild) && (nullptr == mEmptyChild);
}
void
GeckoStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
{
// This method should only be called from nsRuleNode! It is not a public
// method!
NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
// NOTE: nsCachedStyleData::GetStyleData works roughly the same way.
// See the comments there (in nsRuleNode.h) for more details about
// what this is doing and why.
void** dataSlot;
if (nsCachedStyleData::IsReset(aSID)) {
if (!mCachedResetData) {
mCachedResetData = new (PresContext()) nsResetStyleData;
}
dataSlot = &mCachedResetData->mStyleStructs[aSID];
} else {
dataSlot = &mCachedInheritedData.mStyleStructs[aSID];
}
NS_ASSERTION(!*dataSlot || (mBits & nsCachedStyleData::GetBitForSID(aSID)),
"Going to leak style data");
*dataSlot = aStruct;
}
const void*
GeckoStyleContext::StyleData(nsStyleStructID aSID)
{
const void* cachedData = GetCachedStyleData(aSID);
if (cachedData)
return cachedData; // We have computed data stored on this node in the context tree.
// Our style source will take care of it for us.
const void* newData = AsGecko()->RuleNode()->GetStyleData(aSID, this->AsGecko(), true);
if (!nsCachedStyleData::IsReset(aSID)) {
// always cache inherited data on the style context; the rule
// node set the bit in mBits for us if needed.
mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
}
return newData;
}

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

@ -56,6 +56,28 @@ public:
nsRuleNode* aSourceIfVisited,
bool aRelevantLinkVisited);
// Tell this style context to cache aStruct as the struct for aSID
void SetStyle(nsStyleStructID aSID, void* aStruct);
/*
* Get the style data for a style struct. This is the most important
* member function of nsStyleContext. It fills in a const pointer
* to a style data struct that is appropriate for the style context's
* frame. This struct may be shared with other contexts (either in
* the rule tree or the style context tree), so it should not be
* modified.
*
* This function will NOT return null (even when out of memory) when
* given a valid style struct ID, so the result does not need to be
* null-checked.
*
* The typesafe functions below are preferred to the use of this
* function, both because they're easier to read and because they're
* faster.
*/
const void* NS_FASTCALL StyleData(nsStyleStructID aSID) MOZ_NONNULL_RETURN;
#ifdef DEBUG
void AssertChildStructsNotUsedElsewhere(nsStyleContext* aDestroyingContext,
int32_t aLevels) const;

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

@ -50,6 +50,7 @@
#include "mozilla/EffectCompositor.h"
#include "mozilla/EffectSet.h"
#include "mozilla/EventStates.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/Keyframe.h"
#include "mozilla/Mutex.h"
#include "mozilla/ServoElementSnapshot.h"

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

@ -3520,7 +3520,7 @@ ComputeValuesFromStyleRule(nsCSSPropertyID aProperty,
// Force walk of rule tree
nsStyleStructID sid = nsCSSProps::kSIDTable[aProperty];
tmpStyleContext->StyleData(sid);
tmpStyleContext->AsGecko()->StyleData(sid);
// The rule node will have unconditional cached style data if the value is
// not context-sensitive. So if there's nothing cached, it's not context
@ -3971,7 +3971,7 @@ SubstitutePixelValues(nsStyleContext* aStyleContext,
if (aInput.IsCalcUnit()) {
RuleNodeCacheConditions conditions;
nsRuleNode::ComputedCalc c =
nsRuleNode::SpecifiedCalcToComputedCalc(aInput, aStyleContext,
nsRuleNode::SpecifiedCalcToComputedCalc(aInput, aStyleContext->AsGecko(),
aStyleContext->PresContext(),
conditions);
nsStyleCoord::CalcValue c2;
@ -3991,7 +3991,7 @@ SubstitutePixelValues(nsStyleContext* aStyleContext,
} else if (aInput.IsLengthUnit() &&
aInput.GetUnit() != eCSSUnit_Pixel) {
RuleNodeCacheConditions conditions;
nscoord len = nsRuleNode::CalcLength(aInput, aStyleContext,
nscoord len = nsRuleNode::CalcLength(aInput, aStyleContext->AsGecko(),
aStyleContext->PresContext(),
conditions);
aOutput.SetFloatValue(nsPresContext::AppUnitsToFloatCSSPixels(len),
@ -4221,7 +4221,7 @@ StyleAnimationValue::ExtractComputedValue(nsCSSPropertyID aProperty,
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
"bad property");
const void* styleStruct =
aStyleContext->StyleData(nsCSSProps::kSIDTable[aProperty]);
aStyleContext->AsGecko()->StyleData(nsCSSProps::kSIDTable[aProperty]);
ptrdiff_t ssOffset = nsCSSProps::kStyleStructOffsetTable[aProperty];
nsStyleAnimType animType = nsCSSProps::kAnimTypeTable[aProperty];
MOZ_ASSERT(0 <= ssOffset ||

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

@ -39,7 +39,7 @@
#include "nsCSSPseudoElements.h"
#include "nsThemeConstants.h"
#include "PLDHashTable.h"
#include "nsStyleContext.h"
#include "GeckoStyleContext.h"
#include "nsStyleSet.h"
#include "nsStyleStruct.h"
#include "nsSize.h"
@ -91,7 +91,7 @@ enum UnsetAction
void*
nsConditionalResetStyleData::GetConditionalStyleData(nsStyleStructID aSID,
nsStyleContext* aStyleContext) const
GeckoStyleContext* aStyleContext) const
{
Entry* e = static_cast<Entry*>(mEntries[aSID]);
MOZ_ASSERT(e, "if mConditionalBits bit is set, we must have at least one "
@ -145,14 +145,14 @@ CreateStyleImageRequest(nsPresContext* aPresContext, const nsCSSValue& aValue,
static void
SetStyleShapeSourceToCSSValue(StyleShapeSource* aShapeSource,
const nsCSSValue* aValue,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions);
/* Helper function to convert a CSS <position> specified value into its
* computed-style form. */
static void
ComputePositionValue(nsStyleContext* aStyleContext,
ComputePositionValue(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
Position& aComputedValue,
RuleNodeCacheConditions& aConditions);
@ -925,7 +925,7 @@ GetFloatFromBoxPosition(int32_t aEnumValue)
// changes aCoord iff it returns true
static bool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord,
const nsStyleCoord& aParentCoord,
int32_t aMask, nsStyleContext* aStyleContext,
int32_t aMask, GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -1054,7 +1054,7 @@ static inline bool SetAbsCoord(const nsCSSValue& aValue,
// The values of the following variables will never be used; so it does not
// matter what to set.
const nsStyleCoord dummyParentCoord;
nsStyleContext* dummyStyleContext = nullptr;
GeckoStyleContext* dummyStyleContext = nullptr;
nsPresContext* dummyPresContext = nullptr;
RuleNodeCacheConditions dummyCacheKey;
@ -1074,7 +1074,7 @@ static bool
SetPairCoords(const nsCSSValue& aValue,
nsStyleCoord& aCoordX, nsStyleCoord& aCoordY,
const nsStyleCoord& aParentX, const nsStyleCoord& aParentY,
int32_t aMask, nsStyleContext* aStyleContext,
int32_t aMask, GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext, RuleNodeCacheConditions& aConditions)
{
const nsCSSValue& valX =
@ -1233,7 +1233,7 @@ static Maybe<nscoord>
ComputeLineWidthValue(const nsCSSValue& aValue,
const nscoord aParentCoord,
const nscoord aInitialCoord,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -1269,7 +1269,7 @@ ComputeLineWidthValue(const nsCSSValue& aValue,
}
static void SetGradientCoord(const nsCSSValue& aValue, nsPresContext* aPresContext,
nsStyleContext* aContext, nsStyleCoord& aResult,
GeckoStyleContext* aContext, nsStyleCoord& aResult,
RuleNodeCacheConditions& aConditions)
{
// OK to pass bad aParentCoord since we're not passing SETCOORD_INHERIT
@ -1282,7 +1282,7 @@ static void SetGradientCoord(const nsCSSValue& aValue, nsPresContext* aPresConte
}
static void SetGradient(const nsCSSValue& aValue, nsPresContext* aPresContext,
nsStyleContext* aContext, nsStyleGradient& aResult,
GeckoStyleContext* aContext, nsStyleGradient& aResult,
RuleNodeCacheConditions& aConditions)
{
MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Gradient,
@ -1380,7 +1380,7 @@ static void SetGradient(const nsCSSValue& aValue, nsPresContext* aPresContext,
}
// -moz-image-rect(<uri>, <top>, <right>, <bottom>, <left>)
static void SetStyleImageToImageRect(nsStyleContext* aStyleContext,
static void SetStyleImageToImageRect(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
nsStyleImage& aResult)
{
@ -1415,7 +1415,7 @@ static void SetStyleImageToImageRect(nsStyleContext* aStyleContext,
aResult.SetCropRect(MakeUnique<nsStyleSides>(cropRect));
}
static void SetStyleImage(nsStyleContext* aStyleContext,
static void SetStyleImage(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
nsStyleImage& aResult,
RuleNodeCacheConditions& aConditions)
@ -1986,15 +1986,15 @@ nsRuleNode::PropagateDependentBit(nsStyleStructID aSID, nsRuleNode* aHighestNode
}
/* static */ void
nsRuleNode::PropagateGrandancestorBit(nsStyleContext* aContext,
nsStyleContext* aContextInheritedFrom)
nsRuleNode::PropagateGrandancestorBit(GeckoStyleContext* aContext,
GeckoStyleContext* aContextInheritedFrom)
{
MOZ_ASSERT(aContext);
MOZ_ASSERT(aContextInheritedFrom &&
aContextInheritedFrom != aContext,
"aContextInheritedFrom must be an ancestor of aContext");
for (nsStyleContext* context = aContext->GetParent();
for (GeckoStyleContext* context = aContext->GetParent();
context != aContextInheritedFrom;
context = context->GetParent()) {
if (!context) {
@ -2396,7 +2396,7 @@ nsRuleNode::CheckSpecifiedProperties(const nsStyleStructID aSID,
// return the bit to check in nsCSSProp's flags table. Otherwise,
// return 0.
inline uint32_t
GetPseudoRestriction(nsStyleContext *aContext)
GetPseudoRestriction(GeckoStyleContext *aContext)
{
// This needs to match nsStyleSet::WalkRestrictionRule.
uint32_t pseudoRestriction = 0;
@ -2457,7 +2457,7 @@ AutoCSSValueArray::~AutoCSSValueArray()
/* static */ bool
nsRuleNode::ResolveVariableReferences(const nsStyleStructID aSID,
nsRuleData* aRuleData,
nsStyleContext* aContext)
GeckoStyleContext* aContext)
{
MOZ_ASSERT(aSID != eStyleStruct_Variables);
MOZ_ASSERT(aRuleData->mSIDs & nsCachedStyleData::GetBitForSID(aSID));
@ -2509,7 +2509,7 @@ nsRuleNode::ResolveVariableReferences(const nsStyleStructID aSID,
const void*
nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
nsStyleContext* aContext)
GeckoStyleContext* aContext)
{
// use placement new[] on the result of alloca() to allocate a
// variable-sized stack array, including execution of constructors,
@ -2689,7 +2689,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
// All information must necessarily be inherited from our parent style context.
// In the absence of any computed data in the rule tree and with
// no rules specified that didn't have values of 'inherit', we should check our parent.
nsStyleContext* parentContext = aContext->GetParent();
GeckoStyleContext* parentContext = aContext->GetParent();
if (isReset) {
/* Reset structs don't inherit from first-line. */
/* See similar code in COMPUTE_START_RESET */
@ -2721,7 +2721,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
}
typedef const void* (nsRuleNode::*ComputeFunc)(void*, const nsRuleData*,
nsStyleContext*, nsRuleNode*,
GeckoStyleContext*, nsRuleNode*,
RuleDetail,
const RuleNodeCacheConditions);
static const ComputeFunc sComputeFuncs[] = {
@ -2737,7 +2737,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
}
const void*
nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext)
nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, GeckoStyleContext* aContext)
{
switch (aSID) {
case eStyleStruct_Font:
@ -2916,7 +2916,7 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex
NS_ASSERTION(aRuleDetail != eRuleFullInherited, \
"should not have bothered calling Compute*Data"); \
\
nsStyleContext* parentContext = aContext->GetParent(); \
GeckoStyleContext* parentContext = aContext->GetParent(); \
\
nsStyle##type_* data_ = nullptr; \
mozilla::Maybe<nsStyle##type_> maybeFakeParentData; \
@ -2976,7 +2976,7 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex
NS_ASSERTION(aRuleDetail != eRuleFullInherited, \
"should not have bothered calling Compute*Data"); \
\
nsStyleContext* parentContext = aContext->GetParent(); \
GeckoStyleContext* parentContext = aContext->GetParent(); \
/* Reset structs don't inherit from first-line */ \
/* See similar code in WalkRuleTree */ \
while (parentContext && \
@ -3304,13 +3304,13 @@ struct SetFontSizeCalcOps : public css::BasicCoordCalcOps,
const nscoord mParentSize;
const nsStyleFont* const mParentFont;
nsPresContext* const mPresContext;
nsStyleContext* const mStyleContext;
GeckoStyleContext* const mStyleContext;
const bool mAtRoot;
RuleNodeCacheConditions& mConditions;
SetFontSizeCalcOps(nscoord aParentSize, const nsStyleFont* aParentFont,
nsPresContext* aPresContext,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
bool aAtRoot,
RuleNodeCacheConditions& aConditions)
: mParentSize(aParentSize),
@ -3355,7 +3355,7 @@ struct SetFontSizeCalcOps : public css::BasicCoordCalcOps,
/* static */ void
nsRuleNode::SetFontSize(nsPresContext* aPresContext,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
const nsRuleData* aRuleData,
const nsStyleFont* aFont,
const nsStyleFont* aParentFont,
@ -3534,7 +3534,7 @@ nsRuleNode::ComputeSystemFont(nsFont* aSystemFont, LookAndFeel::FontID aFontID,
}
/* static */ void
nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
nsRuleNode::SetFont(nsPresContext* aPresContext, GeckoStyleContext* aContext,
uint8_t aGenericFontID, const nsRuleData* aRuleData,
const nsStyleFont* aParentFont,
nsStyleFont* aFont, bool aUsedStartStruct,
@ -4161,14 +4161,14 @@ nsRuleNode::ComputeFontVariations(const nsCSSValuePairList* aVariationsList,
// - re-apply cascading rules from there without caching intermediate values
/* static */ void
nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
uint8_t aGenericFontID,
nsStyleFont* aFont)
{
// walk up the contexts until a context with the desired generic font
AutoTArray<nsStyleContext*, 8> contextPath;
AutoTArray<GeckoStyleContext*, 8> contextPath;
contextPath.AppendElement(aContext);
nsStyleContext* higherContext = aContext->GetParent();
GeckoStyleContext* higherContext = aContext->GetParent();
while (higherContext) {
if (higherContext->StyleFont()->mGenericID == aGenericFontID) {
// done walking up the higher contexts
@ -4201,7 +4201,7 @@ nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
void* dataStorage = alloca(nprops * sizeof(nsCSSValue));
for (int32_t i = contextPath.Length() - 1; i >= 0; --i) {
nsStyleContext* context = contextPath[i];
GeckoStyleContext* context = contextPath[i];
AutoCSSValueArray dataArray(dataStorage, nprops);
nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Font), dataArray.get(),
@ -4254,7 +4254,7 @@ nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
const void*
nsRuleNode::ComputeFontData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -4362,7 +4362,7 @@ inline uint32_t ListLength(const T* aList)
static already_AddRefed<nsCSSShadowArray>
GetShadowData(const nsCSSValueList* aList,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
bool aIsBoxShadow,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
@ -4503,11 +4503,11 @@ struct LengthNumberCalcObj
struct LengthNumberCalcOps : public css::FloatCoeffsAlreadyNormalizedOps
{
typedef LengthNumberCalcObj result_type;
nsStyleContext* const mStyleContext;
GeckoStyleContext* const mStyleContext;
nsPresContext* const mPresContext;
RuleNodeCacheConditions& mConditions;
LengthNumberCalcOps(nsStyleContext* aStyleContext,
LengthNumberCalcOps(GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
: mStyleContext(aStyleContext),
@ -4585,7 +4585,7 @@ struct LengthNumberCalcOps : public css::FloatCoeffsAlreadyNormalizedOps
struct SetLineHeightCalcOps : public LengthNumberCalcOps
{
SetLineHeightCalcOps(nsStyleContext* aStyleContext,
SetLineHeightCalcOps(GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
: LengthNumberCalcOps(aStyleContext, aPresContext, aConditions)
@ -4622,7 +4622,7 @@ struct SetLineHeightCalcOps : public LengthNumberCalcOps
const void*
nsRuleNode::ComputeTextData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -4748,7 +4748,7 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
NS_STYLE_TEXT_ALIGN_MATCH_PARENT ==
textAlignValue->GetIntValue()) {
conditions.SetUncacheable();
nsStyleContext* parent = aContext->GetParent();
GeckoStyleContext* parent = aContext->GetParent();
if (parent) {
uint8_t parentAlign = parentText->mTextAlign;
uint8_t parentDirection = parent->StyleVisibility()->mDirection;
@ -5004,7 +5004,7 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
const void*
nsRuleNode::ComputeTextResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -5143,7 +5143,7 @@ nsRuleNode::ComputeTextResetData(void* aStartStruct,
const void*
nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -5233,7 +5233,7 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
const void*
nsRuleNode::ComputeUIResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -5487,7 +5487,7 @@ GetWillChangeBitFieldFromPropFlags(const nsCSSPropertyID& aProp)
const void*
nsRuleNode::ComputeDisplayData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -6584,7 +6584,7 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
const void*
nsRuleNode::ComputeVisibilityData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -6682,7 +6682,7 @@ nsRuleNode::ComputeVisibilityData(void* aStartStruct,
const void*
nsRuleNode::ComputeColorData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -6718,7 +6718,7 @@ struct BackgroundItemComputer {
template <>
struct BackgroundItemComputer<nsCSSValueList, uint8_t>
{
static void ComputeValue(nsStyleContext* aStyleContext,
static void ComputeValue(GeckoStyleContext* aStyleContext,
const nsCSSValueList* aSpecifiedValue,
uint8_t& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -6731,7 +6731,7 @@ struct BackgroundItemComputer<nsCSSValueList, uint8_t>
template <>
struct BackgroundItemComputer<nsCSSValuePairList, nsStyleImageLayers::Repeat>
{
static void ComputeValue(nsStyleContext* aStyleContext,
static void ComputeValue(GeckoStyleContext* aStyleContext,
const nsCSSValuePairList* aSpecifiedValue,
nsStyleImageLayers::Repeat& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -6792,7 +6792,7 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleImageLayers::Repeat>
template <>
struct BackgroundItemComputer<nsCSSValueList, nsStyleImage>
{
static void ComputeValue(nsStyleContext* aStyleContext,
static void ComputeValue(GeckoStyleContext* aStyleContext,
const nsCSSValueList* aSpecifiedValue,
nsStyleImage& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -6807,7 +6807,7 @@ struct BackgroundItemComputer<nsCSSValueList, T>
{
typedef typename EnableIf<IsEnum<T>::value, T>::Type ComputedType;
static void ComputeValue(nsStyleContext* aStyleContext,
static void ComputeValue(GeckoStyleContext* aStyleContext,
const nsCSSValueList* aSpecifiedValue,
ComputedType& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -6822,7 +6822,7 @@ struct BackgroundItemComputer<nsCSSValueList, T>
* which represent an edge and an offset from that edge.
*/
static void
ComputePositionCoord(nsStyleContext* aStyleContext,
ComputePositionCoord(GeckoStyleContext* aStyleContext,
const nsCSSValue& aEdge,
const nsCSSValue& aOffset,
Position::Coord* aResult,
@ -6873,7 +6873,7 @@ ComputePositionCoord(nsStyleContext* aStyleContext,
/* Helper function to convert a CSS <position> specified value into its
* computed-style form. */
static void
ComputePositionValue(nsStyleContext* aStyleContext,
ComputePositionValue(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
Position& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -6910,7 +6910,7 @@ ComputePositionValue(nsStyleContext* aStyleContext,
/* Helper function to convert the -x or -y part of a CSS <position> specified
* value into its computed-style form. */
static void
ComputePositionCoordValue(nsStyleContext* aStyleContext,
ComputePositionCoordValue(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
Position::Coord& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -6953,7 +6953,7 @@ static const BackgroundSizeAxis gBGSizeAxes[] = {
template <>
struct BackgroundItemComputer<nsCSSValuePairList, nsStyleImageLayers::Size>
{
static void ComputeValue(nsStyleContext* aStyleContext,
static void ComputeValue(GeckoStyleContext* aStyleContext,
const nsCSSValuePairList* aSpecifiedValue,
nsStyleImageLayers::Size& aComputedValue,
RuleNodeCacheConditions& aConditions)
@ -7036,7 +7036,7 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleImageLayers::Size>
template <class ComputedValueItem>
static void
SetImageLayerList(nsStyleContext* aStyleContext,
SetImageLayerList(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
@ -7105,7 +7105,7 @@ SetImageLayerList(nsStyleContext* aStyleContext,
// SetImageLayerList generic enough to handle both cases.
static void
SetImageLayerPositionCoordList(
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
@ -7171,7 +7171,7 @@ SetImageLayerPositionCoordList(
template <class ComputedValueItem>
static void
SetImageLayerPairList(nsStyleContext* aStyleContext,
SetImageLayerPairList(GeckoStyleContext* aStyleContext,
const nsCSSValue& aValue,
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
const nsStyleAutoArray<nsStyleImageLayers::Layer>& aParentLayers,
@ -7319,7 +7319,7 @@ nsRuleNode::FillAllBackgroundLists(nsStyleImageLayers& aImage,
const void*
nsRuleNode::ComputeBackgroundData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -7440,7 +7440,7 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
const void*
nsRuleNode::ComputeMarginData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -7545,7 +7545,7 @@ SetBorderImageSlice(const nsCSSValue& aValue,
const void*
nsRuleNode::ComputeBorderData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -7804,7 +7804,7 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
const void*
nsRuleNode::ComputePaddingData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -7832,7 +7832,7 @@ nsRuleNode::ComputePaddingData(void* aStartStruct,
const void*
nsRuleNode::ComputeOutlineData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -7916,7 +7916,7 @@ nsRuleNode::ComputeOutlineData(void* aStartStruct,
const void*
nsRuleNode::ComputeListData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -8107,7 +8107,7 @@ nsRuleNode::ComputeListData(void* aStartStruct,
static void
SetGridTrackBreadth(const nsCSSValue& aValue,
nsStyleCoord& aResult,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -8135,7 +8135,7 @@ static void
SetGridTrackSize(const nsCSSValue& aValue,
nsStyleCoord& aResultMin,
nsStyleCoord& aResultMax,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -8171,7 +8171,7 @@ SetGridAutoColumnsRows(const nsCSSValue& aValue,
nsStyleCoord& aResultMax,
const nsStyleCoord& aParentValueMin,
const nsStyleCoord& aParentValueMax,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
@ -8221,7 +8221,7 @@ static void
SetGridTrackList(const nsCSSValue& aValue,
nsStyleGridTemplate& aResult,
const nsStyleGridTemplate& aParentValue,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
@ -8413,7 +8413,7 @@ SetGridLine(const nsCSSValue& aValue,
const void*
nsRuleNode::ComputePositionData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -8756,7 +8756,7 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
const void*
nsRuleNode::ComputeTableData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -8782,7 +8782,7 @@ nsRuleNode::ComputeTableData(void* aStartStruct,
const void*
nsRuleNode::ComputeTableBorderData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -8839,7 +8839,7 @@ nsRuleNode::ComputeTableBorderData(void* aStartStruct,
const void*
nsRuleNode::ComputeContentData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -9062,7 +9062,7 @@ nsRuleNode::ComputeContentData(void* aStartStruct,
const void*
nsRuleNode::ComputeXULData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -9121,7 +9121,7 @@ nsRuleNode::ComputeXULData(void* aStartStruct,
const void*
nsRuleNode::ComputeColumnData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -9217,7 +9217,7 @@ nsRuleNode::ComputeColumnData(void* aStartStruct,
static void
SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint,
nsPresContext* aPresContext, nsStyleContext *aContext,
nsPresContext* aPresContext, GeckoStyleContext *aContext,
nsStyleSVGPaint& aResult, nsStyleSVGPaintType aInitialPaintType,
RuleNodeCacheConditions& aConditions)
{
@ -9376,7 +9376,7 @@ nsRuleNode::FillAllMaskLists(nsStyleImageLayers& aMask,
const void*
nsRuleNode::ComputeSVGData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -9682,7 +9682,7 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
static already_AddRefed<StyleBasicShape>
GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -9835,7 +9835,7 @@ static void
SetStyleShapeSourceToCSSValue(
StyleShapeSource* aShapeSource,
const nsCSSValue* aValue,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -9873,7 +9873,7 @@ SetStyleShapeSourceToCSSValue(
static bool
SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsPresContext* aPresContext,
RuleNodeCacheConditions& aConditions)
{
@ -9931,7 +9931,7 @@ SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
const void*
nsRuleNode::ComputeSVGResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -10156,7 +10156,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
const void*
nsRuleNode::ComputeVariablesData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -10178,7 +10178,7 @@ nsRuleNode::ComputeVariablesData(void* aStartStruct,
const void*
nsRuleNode::ComputeEffectsData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail aRuleDetail,
const RuleNodeCacheConditions aConditions)
@ -10338,7 +10338,7 @@ nsRuleNode::ComputeEffectsData(void* aStartStruct,
const void*
nsRuleNode::GetStyleData(nsStyleStructID aSID,
nsStyleContext* aContext,
GeckoStyleContext* aContext,
bool aComputeData)
{
NS_ASSERTION(IsUsedDirectly(),
@ -10407,6 +10407,8 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
}
#endif
RefPtr<GeckoStyleContext> styleContext = aStyleContext->AsGecko();
uint32_t inheritBits = 0;
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BACKGROUND)
inheritBits |= NS_STYLE_INHERIT_BIT(Background);
@ -10452,9 +10454,9 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
void* dataStorage = alloca(nprops * sizeof(nsCSSValue));
AutoCSSValueArray dataArray(dataStorage, nprops);
/* We're relying on the use of |aStyleContext| not mutating it! */
/* We're relying on the use of |styleContext| not mutating it! */
nsRuleData ruleData(inheritBits, dataArray.get(),
aStyleContext->PresContext(), aStyleContext);
styleContext->PresContext(), styleContext);
if (ruleTypeMask & NS_AUTHOR_SPECIFIED_BACKGROUND) {
ruleData.mValueOffsets[eStyleStruct_Background] = backgroundOffset;
@ -10552,7 +10554,7 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
}
}
nsStyleContext* styleContext = aStyleContext;
GeckoStyleContext* styleContextRef = styleContext;
// We need to be careful not to count styles covered up by user-important or
// UA-important declarations. But we do want to catch explicit inherit
@ -10563,7 +10565,7 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
bool haveExplicitUAInherit;
do {
haveExplicitUAInherit = false;
for (nsRuleNode* ruleNode = styleContext->RuleNode(); ruleNode;
for (nsRuleNode* ruleNode = styleContextRef->RuleNode(); ruleNode;
ruleNode = ruleNode->GetParent()) {
nsIStyleRule *rule = ruleNode->GetRule();
if (rule) {
@ -10630,7 +10632,7 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
for (uint32_t i = 0; i < nValues; ++i)
if (values[i]->GetUnit() == eCSSUnit_DummyInherit)
values[i]->Reset();
styleContext = styleContext->GetParent();
styleContextRef = styleContextRef->GetParent();
}
} while (haveExplicitUAInherit && styleContext);
@ -10640,7 +10642,7 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
/* static */ void
nsRuleNode::ComputePropertiesOverridingAnimation(
const nsTArray<nsCSSPropertyID>& aProperties,
nsStyleContext* aStyleContext,
GeckoStyleContext* aStyleContext,
nsCSSPropertyIDSet& aPropertiesOverridden)
{
/*
@ -10740,14 +10742,14 @@ nsRuleNode::ComputeColor(const nsCSSValue& aValue, nsPresContext* aPresContext,
}
/* static */ bool
nsRuleNode::ParentHasPseudoElementData(nsStyleContext* aContext)
nsRuleNode::ParentHasPseudoElementData(GeckoStyleContext* aContext)
{
nsStyleContext* parent = aContext->GetParent();
GeckoStyleContext* parent = aContext->GetParent();
return parent && parent->HasPseudoElementData();
}
/* static */ void
nsRuleNode::StoreStyleOnContext(nsStyleContext* aContext,
nsRuleNode::StoreStyleOnContext(GeckoStyleContext* aContext,
nsStyleStructID aSID,
void* aStruct)
{
@ -10757,7 +10759,7 @@ nsRuleNode::StoreStyleOnContext(nsStyleContext* aContext,
#ifdef DEBUG
bool
nsRuleNode::ContextHasCachedData(nsStyleContext* aContext,
nsRuleNode::ContextHasCachedData(GeckoStyleContext* aContext,
nsStyleStructID aSID)
{
return !!aContext->GetCachedStyleData(aSID);

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

@ -25,13 +25,16 @@ class nsCSSPropertyIDSet;
class nsCSSValue;
class nsFontMetrics;
class nsIStyleRule;
class nsStyleContext;
class nsStyleCoord;
struct nsCSSRect;
struct nsCSSValueList;
struct nsCSSValuePairList;
struct nsRuleData;
namespace mozilla {
class GeckoStyleContext;
}
struct nsInheritedStyleData
{
mozilla::RangedArray<void*,
@ -163,7 +166,7 @@ struct nsConditionalResetStyleData
}
void* GetStyleData(nsStyleStructID aSID,
nsStyleContext* aStyleContext,
mozilla::GeckoStyleContext* aStyleContext,
bool aCanComputeData) const {
if (!(mConditionalBits & GetBitForSID(aSID))) {
return mEntries[aSID];
@ -183,7 +186,7 @@ struct nsConditionalResetStyleData
private:
// non-inline helper for GetStyleData
void* GetConditionalStyleData(nsStyleStructID aSID,
nsStyleContext* aStyleContext) const;
mozilla::GeckoStyleContext* aStyleContext) const;
public:
void SetStyleData(nsStyleStructID aSID, void* aStyleStruct) {
@ -284,7 +287,7 @@ struct nsCachedStyleData
}
void* NS_FASTCALL GetStyleData(const nsStyleStructID aSID,
nsStyleContext* aStyleContext,
mozilla::GeckoStyleContext* aStyleContext,
bool aCanComputeData) {
if (IsReset(aSID)) {
if (mResetData) {
@ -320,7 +323,7 @@ struct nsCachedStyleData
mInheritedData->mStyleStructs[eStyleStruct_##name_]) : nullptr; \
}
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
nsStyle##name_ * NS_FASTCALL GetStyle##name_ (nsStyleContext* aContext, \
nsStyle##name_ * NS_FASTCALL GetStyle##name_ (mozilla::GeckoStyleContext* aContext, \
bool aCanComputeData) { \
return mResetData ? static_cast<nsStyle##name_*>( \
mResetData->GetStyleData(eStyleStruct_##name_, aContext, \
@ -355,9 +358,9 @@ struct nsCachedStyleData
* destroyed when their reference-count drops to zero, but are instead
* destroyed during a GC sweep.
*
* An nsStyleContext, which represents the computed style data for an
* An mozilla::GeckoStyleContext, which represents the computed style data for an
* element, points to an nsRuleNode. The path from the root of the rule
* tree to the nsStyleContext's mRuleNode gives the list of the rules
* tree to the mozilla::GeckoStyleContext's mRuleNode gives the list of the rules
* matched, from least important in the cascading order to most
* important in the cascading order.
*
@ -374,14 +377,14 @@ struct nsCachedStyleData
* 1. [mainly reset structs] When a style data struct will contain the
* same computed value for any elements that match the same set of
* rules (common for reset structs), it can be stored on the
* nsRuleNode instead of on the nsStyleContext.
* nsRuleNode instead of on the mozilla::GeckoStyleContext.
* 2. [only? reset structs] When (1) occurs, and an nsRuleNode doesn't
* have any rules that change the values in the struct, the
* nsRuleNode can share that struct with its parent nsRuleNode.
* 3. [mainly inherited structs] When an element doesn't match any
* rules that change the value of a property (or, in the edge case,
* when all the values specified are 'inherit'), the nsStyleContext
* can use the same nsStyle* struct as its parent nsStyleContext.
* when all the values specified are 'inherit'), the mozilla::GeckoStyleContext
* can use the same nsStyle* struct as its parent mozilla::GeckoStyleContext.
*
* Since the data represented by an nsIStyleRule are immutable, the data
* represented by an nsRuleNode are also immutable.
@ -565,11 +568,11 @@ protected:
void PropagateDependentBit(nsStyleStructID aSID, nsRuleNode* aHighestNode,
void* aStruct);
void PropagateNoneBit(uint32_t aBit, nsRuleNode* aHighestNode);
static void PropagateGrandancestorBit(nsStyleContext* aContext,
nsStyleContext* aContextInheritedFrom);
static void PropagateGrandancestorBit(mozilla::GeckoStyleContext* aContext,
mozilla::GeckoStyleContext* aContextInheritedFrom);
const void* SetDefaultOnRoot(const nsStyleStructID aSID,
nsStyleContext* aContext);
mozilla::GeckoStyleContext* aContext);
/**
* Resolves any property values in aRuleData for a given style struct that
@ -581,127 +584,127 @@ protected:
*/
static bool ResolveVariableReferences(const nsStyleStructID aSID,
nsRuleData* aRuleData,
nsStyleContext* aContext);
mozilla::GeckoStyleContext* aContext);
const void*
WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext);
WalkRuleTree(const nsStyleStructID aSID, mozilla::GeckoStyleContext* aContext);
const void*
ComputeDisplayData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeVisibilityData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeFontData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeColorData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeBackgroundData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeMarginData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeBorderData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputePaddingData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeOutlineData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeListData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputePositionData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTableData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTableBorderData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeContentData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTextData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTextResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeUserInterfaceData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext,
mozilla::GeckoStyleContext* aContext,
nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
@ -709,55 +712,55 @@ protected:
const void*
ComputeUIResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeXULData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeColumnData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeSVGData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeSVGResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeVariablesData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeEffectsData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
mozilla::GeckoStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const mozilla::RuleNodeCacheConditions aConditions);
// helpers for |ComputeFontData| that need access to |mNoneBits|:
static void SetFontSize(nsPresContext* aPresContext,
nsStyleContext* aContext,
mozilla::GeckoStyleContext* aContext,
const nsRuleData* aRuleData,
const nsStyleFont* aFont,
const nsStyleFont* aParentFont,
@ -770,7 +773,7 @@ protected:
mozilla::RuleNodeCacheConditions& aConditions);
static void SetFont(nsPresContext* aPresContext,
nsStyleContext* aContext,
mozilla::GeckoStyleContext* aContext,
uint8_t aGenericFontID,
const nsRuleData* aRuleData,
const nsStyleFont* aParentFont,
@ -779,7 +782,7 @@ protected:
mozilla::RuleNodeCacheConditions& aConditions);
static void SetGenericFont(nsPresContext* aPresContext,
nsStyleContext* aContext,
mozilla::GeckoStyleContext* aContext,
uint8_t aGenericFontID,
nsStyleFont* aFont);
@ -890,7 +893,7 @@ public:
nsPresContext* PresContext() const { return mPresContext; }
const void* GetStyleData(nsStyleStructID aSID,
nsStyleContext* aContext,
mozilla::GeckoStyleContext* aContext,
bool aComputeData);
void GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
@ -901,7 +904,7 @@ public:
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \
template<bool aComputeData> \
const nsStyle##name_* \
GetStyle##name_(nsStyleContext* aContext, uint64_t& aContextStyleBits) \
GetStyle##name_(mozilla::GeckoStyleContext* aContext, uint64_t& aContextStyleBits) \
{ \
NS_ASSERTION(IsUsedDirectly(), \
"if we ever call this on rule nodes that aren't used " \
@ -940,7 +943,7 @@ public:
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
template<bool aComputeData> \
const nsStyle##name_* \
GetStyle##name_(nsStyleContext* aContext) \
GetStyle##name_(mozilla::GeckoStyleContext* aContext) \
{ \
NS_ASSERTION(IsUsedDirectly(), \
"if we ever call this on rule nodes that aren't used " \
@ -996,7 +999,7 @@ public:
static void
ComputePropertiesOverridingAnimation(
const nsTArray<nsCSSPropertyID>& aProperties,
nsStyleContext* aStyleContext,
mozilla::GeckoStyleContext* aStyleContext,
nsCSSPropertyIDSet& aPropertiesOverridden);
// Expose this so media queries can use it
@ -1091,7 +1094,7 @@ public:
nsStyleContext* aStyleContext,
nscolor& aResult);
static bool ParentHasPseudoElementData(nsStyleContext* aContext);
static bool ParentHasPseudoElementData(mozilla::GeckoStyleContext* aContext);
static void ComputeTimingFunction(const nsCSSValue& aValue,
nsTimingFunction& aResult);
@ -1113,12 +1116,12 @@ private:
#ifdef DEBUG
// non-inline helper function to allow assertions without incomplete
// type errors
bool ContextHasCachedData(nsStyleContext* aContext, nsStyleStructID aSID);
bool ContextHasCachedData(mozilla::GeckoStyleContext* aContext, nsStyleStructID aSID);
#endif
// Store style struct on the style context and tell the style context
// that it doesn't own the data
static void StoreStyleOnContext(nsStyleContext* aContext,
static void StoreStyleOnContext(mozilla::GeckoStyleContext* aContext,
nsStyleStructID aSID,
void* aStruct);
};

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

@ -318,82 +318,6 @@ nsStyleContext::MoveTo(nsStyleContext* aNewParent)
}
}
const void* nsStyleContext::StyleData(nsStyleStructID aSID)
{
const void* cachedData = GetCachedStyleData(aSID);
if (cachedData)
return cachedData; // We have computed data stored on this node in the context tree.
// Our style source will take care of it for us.
const void* newData;
if (IsGecko()) {
newData = AsGecko()->RuleNode()->GetStyleData(aSID, this, true);
if (!nsCachedStyleData::IsReset(aSID)) {
// always cache inherited data on the style context; the rule
// node set the bit in mBits for us if needed.
mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
}
} else {
newData = StyleStructFromServoComputedValues(aSID);
// perform any remaining main thread work on the struct
switch (aSID) {
#define STYLE_STRUCT(name_, checkdata_cb_) \
case eStyleStruct_##name_: { \
auto data = static_cast<const nsStyle##name_*>(newData); \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext()); \
break; \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
default:
MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value");
break;
}
// The Servo-backed StyleContextSource owns the struct.
AddStyleBit(nsCachedStyleData::GetBitForSID(aSID));
// XXXbholley: Unconditionally caching reset structs here defeats the memory
// optimization where we lazily allocate mCachedResetData, so that we can avoid
// performing an FFI call each time we want to get the style structs. We should
// measure the tradeoffs at some point. If the FFI overhead is low and the memory
// win significant, we should consider _always_ grabbing the struct over FFI, and
// potentially giving mCachedInheritedData the same treatment.
//
// Note that there is a similar comment in the struct getters in nsStyleContext.h.
SetStyle(aSID, const_cast<void*>(newData));
}
return newData;
}
void
nsStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
{
MOZ_ASSERT(!IsServo(),
"Servo shouldn't cache style structs in the style context!");
// This method should only be called from nsRuleNode! It is not a public
// method!
NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
// NOTE: nsCachedStyleData::GetStyleData works roughly the same way.
// See the comments there (in nsRuleNode.h) for more details about
// what this is doing and why.
void** dataSlot;
if (nsCachedStyleData::IsReset(aSID)) {
if (!mCachedResetData) {
mCachedResetData = new (PresContext()) nsResetStyleData;
}
dataSlot = &mCachedResetData->mStyleStructs[aSID];
} else {
dataSlot = &mCachedInheritedData.mStyleStructs[aSID];
}
NS_ASSERTION(!*dataSlot || (mBits & nsCachedStyleData::GetBitForSID(aSID)),
"Going to leak style data");
*dataSlot = aStruct;
}
template<class StyleContextLike>
nsChangeHint
nsStyleContext::CalcStyleDifferenceInternal(StyleContextLike* aNewContext,
@ -1098,3 +1022,14 @@ nsStyleContext::PresContext() const
MOZ_STYLO_FORWARD(PresContext, ())
}
GeckoStyleContext*
nsStyleContext::GetParent() const
{
MOZ_ASSERT(IsGecko(),
"This should be used only in Gecko-backed style system!");
if (mParent) {
return mParent->AsGecko();
} else {
return nullptr;
}
}

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

@ -130,11 +130,7 @@ public:
nsPresContext* PresContext() const;
nsStyleContext* GetParent() const {
MOZ_ASSERT(IsGecko(),
"This should be used only in Gecko-backed style system!");
return mParent;
}
mozilla::GeckoStyleContext* GetParent() const;
nsStyleContext* GetParentAllowServo() const {
return mParent;
@ -266,9 +262,6 @@ public:
bool IsShared() const
{ return !!(mBits & NS_STYLE_IS_SHARED); }
// Tell this style context to cache aStruct as the struct for aSID
void SetStyle(nsStyleStructID aSID, void* aStruct);
/**
* Returns whether this style context has cached style data for a
* given style struct and it does NOT own that struct. This can
@ -283,24 +276,6 @@ public:
void AddStyleBit(const uint64_t& aBit) { mBits |= aBit; }
/*
* Get the style data for a style struct. This is the most important
* member function of nsStyleContext. It fills in a const pointer
* to a style data struct that is appropriate for the style context's
* frame. This struct may be shared with other contexts (either in
* the rule tree or the style context tree), so it should not be
* modified.
*
* This function will NOT return null (even when out of memory) when
* given a valid style struct ID, so the result does not need to be
* null-checked.
*
* The typesafe functions below are preferred to the use of this
* function, both because they're easier to read and because they're
* faster.
*/
const void* NS_FASTCALL StyleData(nsStyleStructID aSID) MOZ_NONNULL_RETURN;
/**
* Define typesafe getter functions for each style struct by
* preprocessing the list of style structs. These functions are the
@ -554,7 +529,7 @@ protected:
AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_); \
const nsStyle##name_ * newData = \
StyleSource().AsGeckoRuleNode()-> \
GetStyle##name_<aComputeData>(this, mBits); \
GetStyle##name_<aComputeData>(this->AsGecko(), mBits); \
/* always cache inherited data on the style context; the rule */\
/* node set the bit in mBits for us if needed. */ \
mCachedInheritedData.mStyleStructs[eStyleStruct_##name_] = \
@ -621,7 +596,7 @@ protected:
/* Have the rulenode deal */ \
AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_); \
return StyleSource().AsGeckoRuleNode()-> \
GetStyle##name_<aComputeData>(this); \
GetStyle##name_<aComputeData>(this->AsGecko()); \
} \
const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_));\
if (!aComputeData && needToCompute) { \

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

@ -30,5 +30,4 @@ nsStyleContext::RuleNode()
return AsGecko()->RuleNode();
}
#endif // nsStyleContextInlines_h

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

@ -13,6 +13,7 @@
#include "nsCOMPtr.h"
#include "nsCSSRendering.h"
#include "nsIPresShell.h"
#include "mozilla/GeckoStyleContext.h"
using namespace mozilla;
@ -298,7 +299,7 @@ nsTableColGroupFrame::RemoveFrame(ChildListID aListID,
nsStyleContext* psc = colFrame->GetParentStyleContext(&providerFrame);
if (psc->StyleSource().IsGeckoRuleNodeOrNull()) {
// This check code is useful only in Gecko-backed style system.
if (colFrame->StyleContext()->GetParent() == psc) {
if (static_cast<nsStyleContext*>(colFrame->StyleContext()->GetParent()) == psc) {
NS_ASSERTION(col->StyleContext() == colFrame->StyleContext() &&
col->GetContent() == colFrame->GetContent(),
"How did that happen??");

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

@ -29,6 +29,7 @@
#include "nsIServiceManager.h"
#include "nsContainerFrame.h"
#include "nsContentCID.h"
#include "mozilla/GeckoStyleContext.h"
#include "mozilla/StyleSetHandle.h"
#include "mozilla/StyleSetHandleInlines.h"
#include "nsLayoutUtils.h"
@ -284,7 +285,7 @@ nsSplitterFrame::Init(nsIContent* aContent,
nsGkAtoms::orient)) {
aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
NS_LITERAL_STRING("vertical"), false);
nsStyleContext* parentStyleContext = StyleContext()->GetParent();
GeckoStyleContext* parentStyleContext = StyleContext()->GetParent();
RefPtr<nsStyleContext> newContext = PresContext()->StyleSet()->
ResolveStyleFor(aContent->AsElement(), parentStyleContext,
LazyComputeBehavior::Allow);