Bug 804975 - Part 2: Add a RuleNodeCacheConditions class and use it instead of a boolean canStoreInRuleTree during style computation. r=dbaron

This commit is contained in:
Cameron McCormack 2015-06-23 11:48:18 +10:00
parent eb16a87eb1
commit 46ef4eb2da
14 changed files with 766 additions and 581 deletions

View File

@ -70,6 +70,7 @@
#include "nsCaret.h"
#include "nsISelection.h"
#include "nsDOMTokenList.h"
#include "mozilla/RuleNodeCacheConditions.h"
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
// GetTickCount().
@ -129,7 +130,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
NS_ASSERTION(currElem.GetUnit() == eCSSUnit_Function,
"Stream should consist solely of functions!");
nsCSSValue::Array* array = currElem.GetArrayValue();
bool canStoreInRuleTree = true;
RuleNodeCacheConditions conditions;
switch (nsStyleTransformMatrix::TransformFunctionOf(array)) {
case eCSSKeyword_rotatex:
{
@ -201,7 +202,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
case eCSSKeyword_translatex:
{
double x = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(1), aContext, aPresContext, canStoreInRuleTree,
array->Item(1), aContext, aPresContext, conditions,
&aRefBox, &TransformReferenceBox::Width);
aFunctions.AppendElement(Translation(x, 0, 0));
break;
@ -209,7 +210,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
case eCSSKeyword_translatey:
{
double y = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(1), aContext, aPresContext, canStoreInRuleTree,
array->Item(1), aContext, aPresContext, conditions,
&aRefBox, &TransformReferenceBox::Height);
aFunctions.AppendElement(Translation(0, y, 0));
break;
@ -217,7 +218,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
case eCSSKeyword_translatez:
{
double z = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(1), aContext, aPresContext, canStoreInRuleTree,
array->Item(1), aContext, aPresContext, conditions,
nullptr);
aFunctions.AppendElement(Translation(0, 0, z));
break;
@ -225,13 +226,13 @@ static void AddTransformFunctions(nsCSSValueList* aList,
case eCSSKeyword_translate:
{
double x = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(1), aContext, aPresContext, canStoreInRuleTree,
array->Item(1), aContext, aPresContext, conditions,
&aRefBox, &TransformReferenceBox::Width);
// translate(x) is shorthand for translate(x, 0)
double y = 0;
if (array->Count() == 3) {
y = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(2), aContext, aPresContext, canStoreInRuleTree,
array->Item(2), aContext, aPresContext, conditions,
&aRefBox, &TransformReferenceBox::Height);
}
aFunctions.AppendElement(Translation(x, y, 0));
@ -240,13 +241,13 @@ static void AddTransformFunctions(nsCSSValueList* aList,
case eCSSKeyword_translate3d:
{
double x = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(1), aContext, aPresContext, canStoreInRuleTree,
array->Item(1), aContext, aPresContext, conditions,
&aRefBox, &TransformReferenceBox::Width);
double y = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(2), aContext, aPresContext, canStoreInRuleTree,
array->Item(2), aContext, aPresContext, conditions,
&aRefBox, &TransformReferenceBox::Height);
double z = nsStyleTransformMatrix::ProcessTranslatePart(
array->Item(3), aContext, aPresContext, canStoreInRuleTree,
array->Item(3), aContext, aPresContext, conditions,
nullptr);
aFunctions.AppendElement(Translation(x, y, z));
@ -325,7 +326,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
nsStyleTransformMatrix::ProcessInterpolateMatrix(matrix, array,
aContext,
aPresContext,
canStoreInRuleTree,
conditions,
aRefBox);
aFunctions.AppendElement(TransformMatrix(gfx::ToMatrix4x4(matrix)));
break;
@ -4909,7 +4910,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
}
/* Get the matrix, then change its basis to factor in the origin. */
bool dummy;
RuleNodeCacheConditions dummy;
gfx3DMatrix result;
// Call IsSVGTransformed() regardless of the value of
// disp->mSpecifiedTransform, since we still need any transformFromSVGParent.

View File

@ -99,6 +99,7 @@
#include "mozilla/Telemetry.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/RuleNodeCacheConditions.h"
#ifdef MOZ_XUL
#include "nsXULPopupManager.h"
@ -464,7 +465,7 @@ GetScaleForValue(const StyleAnimationValue& aValue, nsIFrame* aFrame)
return gfxSize();
}
bool dontCare;
RuleNodeCacheConditions dontCare;
TransformReferenceBox refBox(aFrame);
gfx3DMatrix transform = nsStyleTransformMatrix::ReadTransforms(
list->mHead,

View File

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=78: */
/* 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/. */
/*
* an object that stores the result of determining whether a style struct that
* was computed can be cached in the rule tree, and if so, what the cache
* key is
*/
#include "RuleNodeCacheConditions.h"
#include "nsStyleContext.h"
#include "WritingModes.h"
using namespace mozilla;
bool
RuleNodeCacheConditions::Matches(nsStyleContext* aStyleContext) const
{
MOZ_ASSERT(Cacheable());
if ((mBits & eHaveFontSize) &&
mFontSize != aStyleContext->StyleFont()->mFont.size) {
return false;
}
if ((mBits & eHaveWritingMode) &&
(GetWritingMode() != WritingMode(aStyleContext).GetBits())) {
return false;
}
return true;
}
#ifdef DEBUG
void
RuleNodeCacheConditions::List() const
{
printf("{ ");
bool first = true;
if (mBits & eHaveFontSize) {
printf("FontSize(%d)", mFontSize);
first = false;
}
if (mBits & eHaveWritingMode) {
if (!first) {
printf(", ");
}
printf("WritingMode(0x%x)", GetWritingMode());
}
printf(" }");
}
#endif

View File

@ -0,0 +1,120 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
/*
* an object that stores the result of determining whether a style struct that
* was computed can be cached in the rule tree, and if so, what the conditions
* it relies on are
*/
#ifndef RuleNodeCacheConditions_h_
#define RuleNodeCacheConditions_h_
#include "mozilla/Attributes.h"
#include "nsCoord.h"
#include "nsTArray.h"
class nsStyleContext;
namespace mozilla {
class RuleNodeCacheConditions
{
public:
RuleNodeCacheConditions()
: mFontSize(0), mBits(0) {}
RuleNodeCacheConditions(const RuleNodeCacheConditions& aOther)
: mFontSize(aOther.mFontSize), mBits(aOther.mBits) {}
RuleNodeCacheConditions& operator=(const RuleNodeCacheConditions& aOther)
{
mFontSize = aOther.mFontSize;
mBits = aOther.mBits;
return *this;
}
bool operator==(const RuleNodeCacheConditions& aOther) const
{
return mFontSize == aOther.mFontSize &&
mBits == aOther.mBits;
}
bool operator!=(const RuleNodeCacheConditions& aOther) const
{
return !(*this == aOther);
}
bool Matches(nsStyleContext* aStyleContext) const;
void SetFontSizeDependency(nscoord aCoord)
{
MOZ_ASSERT(!(mBits & eHaveFontSize) || mFontSize == aCoord);
mFontSize = aCoord;
mBits |= eHaveFontSize;
}
void SetWritingModeDependency(uint8_t aWritingMode)
{
MOZ_ASSERT(!(mBits & eHaveWritingMode) || GetWritingMode() == aWritingMode);
mBits |= (static_cast<uint64_t>(aWritingMode) << eWritingModeShift) |
eHaveWritingMode;
}
void SetUncacheable()
{
mBits |= eUncacheable;
}
bool Cacheable() const
{
return !(mBits & eUncacheable);
}
bool CacheableWithDependencies() const
{
return !(mBits & eUncacheable) &&
(mBits & eHaveBitsMask) != 0;
}
bool CacheableWithoutDependencies() const
{
// We're not uncacheable and we have don't have a font-size or
// writing mode value.
return (mBits & eHaveBitsMask) == 0;
}
#ifdef DEBUG
void List() const;
#endif
private:
enum {
eUncacheable = 0x0001,
eHaveFontSize = 0x0002,
eHaveWritingMode = 0x0004,
eHaveBitsMask = 0x00ff,
eWritingModeMask = 0xff00,
eWritingModeShift = 8,
};
uint8_t GetWritingMode() const
{
return static_cast<uint8_t>(
(mBits & eWritingModeMask) >> eWritingModeShift);
}
// The font size from which em units are derived.
nscoord mFontSize;
// Values in mBits:
// bit 0: are we set to "uncacheable"?
// bit 1: do we have a font size value?
// bit 2: do we have a writing mode value?
// bits 2-7: unused
// bits 8-15: writing mode (uint8_t)
// bits 16-31: unused
uint32_t mBits;
};
} // namespace mozilla
#endif // !defined(RuleNodeCacheConditions_h_)

View File

@ -7,7 +7,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/RuleNodeCacheConditions.h"
#include "mozilla/StyleAnimationValue.h"
#include "nsStyleTransformMatrix.h"
#include "nsCOMArray.h"
@ -2868,11 +2868,11 @@ SubstitutePixelValues(nsStyleContext* aStyleContext,
const nsCSSValue& aInput, nsCSSValue& aOutput)
{
if (aInput.IsCalcUnit()) {
bool canStoreInRuleTree = true;
RuleNodeCacheConditions conditions;
nsRuleNode::ComputedCalc c =
nsRuleNode::SpecifiedCalcToComputedCalc(aInput, aStyleContext,
aStyleContext->PresContext(),
canStoreInRuleTree);
conditions);
nsStyleCoord::CalcValue c2;
c2.mLength = c.mLength;
c2.mPercent = c.mPercent;
@ -2889,10 +2889,10 @@ SubstitutePixelValues(nsStyleContext* aStyleContext,
aOutput.SetArrayValue(outputArray, aInput.GetUnit());
} else if (aInput.IsLengthUnit() &&
aInput.GetUnit() != eCSSUnit_Pixel) {
bool canStoreInRuleTree = true;
RuleNodeCacheConditions conditions;
nscoord len = nsRuleNode::CalcLength(aInput, aStyleContext,
aStyleContext->PresContext(),
canStoreInRuleTree);
conditions);
aOutput.SetFloatValue(nsPresContext::AppUnitsToFloatCSSPixels(len),
eCSSUnit_Pixel);
} else {

View File

@ -85,6 +85,7 @@ EXPORTS.mozilla += [
'CSSVariableResolver.h',
'CSSVariableValues.h',
'IncrementalClearCOMRuleArray.h',
'RuleNodeCacheConditions.h',
'StyleAnimationValue.h',
]
@ -163,6 +164,7 @@ UNIFIED_SOURCES += [
'nsStyleTransformMatrix.cpp',
'nsStyleUtil.cpp',
'nsTransitionManager.cpp',
'RuleNodeCacheConditions.cpp',
'StyleAnimationValue.cpp',
'StyleRule.cpp',
'SVGAttrAnimationRuleProcessor.cpp',

View File

@ -254,7 +254,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
aRuleData->mCanStoreInRuleTree = false;
aRuleData->mConditions.SetUncacheable();
}
nsCSSValue* target = aRuleData->ValueFor(iProp);
if (target->GetUnit() == eCSSUnit_Null) {
@ -693,7 +693,7 @@ nsCSSExpandedDataBlock::MapRuleInfoInto(nsCSSProperty aPropID,
nsCSSProperty physicalProp = aPropID;
if (nsCSSProps::PropHasFlags(aPropID, CSS_PROPERTY_LOGICAL)) {
EnsurePhysicalProperty(physicalProp, aRuleData);
aRuleData->mCanStoreInRuleTree = false;
aRuleData->mConditions.SetUncacheable();
}
nsCSSValue* dest = aRuleData->ValueFor(physicalProp);

View File

@ -1265,7 +1265,7 @@ nsComputedDOMStyle::DoGetTransform()
nsStyleTransformMatrix::TransformReferenceBox refBox(mInnerFrame,
nsSize(0, 0));
bool dummy;
RuleNodeCacheConditions dummy;
gfx3DMatrix matrix =
nsStyleTransformMatrix::ReadTransforms(display->mSpecifiedTransform->mHead,
mStyleContextHolder,

View File

@ -28,7 +28,6 @@ nsRuleData::GetPoisonOffset()
nsRuleData::nsRuleData(uint32_t aSIDs, nsCSSValue* aValueStorage,
nsPresContext* aContext, nsStyleContext* aStyleContext)
: mSIDs(aSIDs),
mCanStoreInRuleTree(true),
mPresContext(aContext),
mStyleContext(aStyleContext),
mValueStorage(aValueStorage)

View File

@ -12,6 +12,7 @@
#define nsRuleData_h_
#include "mozilla/CSSVariableDeclarations.h"
#include "mozilla/RuleNodeCacheConditions.h"
#include "nsCSSProps.h"
#include "nsCSSValue.h"
#include "nsStyleStructFwd.h"
@ -25,7 +26,7 @@ typedef void (*nsPostResolveFunc)(void* aStyleStruct, nsRuleData* aData);
struct nsRuleData
{
const uint32_t mSIDs;
bool mCanStoreInRuleTree;
mozilla::RuleNodeCacheConditions mConditions;
bool mIsImportantRule;
uint16_t mLevel; // an nsStyleSet::sheetType
nsPresContext* const mPresContext;

File diff suppressed because it is too large Load Diff

View File

@ -12,18 +12,19 @@
#define nsRuleNode_h___
#include "mozilla/RangedArray.h"
#include "mozilla/RuleNodeCacheConditions.h"
#include "nsPresContext.h"
#include "nsStyleStruct.h"
class nsStyleContext;
struct nsRuleData;
class nsIStyleRule;
struct nsCSSValueList;
class nsCSSPropertySet;
class nsCSSValue;
class nsIStyleRule;
class nsStyleContext;
class nsStyleCoord;
struct nsCSSRect;
struct nsCSSValueList;
struct nsCSSValuePairList;
struct nsRuleData;
struct nsInheritedStyleData
{
@ -435,119 +436,119 @@ protected:
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeVisibilityData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeFontData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeColorData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeBackgroundData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeMarginData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeBorderData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputePaddingData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeOutlineData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeListData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputePositionData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTableData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTableBorderData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeContentData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeQuotesData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTextData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeTextResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeUserInterfaceData(void* aStartStruct,
@ -555,49 +556,49 @@ protected:
nsStyleContext* aContext,
nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeUIResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeXULData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeColumnData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeSVGData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeSVGResetData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
const void*
ComputeVariablesData(void* aStartStruct,
const nsRuleData* aRuleData,
nsStyleContext* aContext, nsRuleNode* aHighestNode,
RuleDetail aRuleDetail,
const bool aCanStoreInRuleTree);
const mozilla::RuleNodeCacheConditions aConditions);
// helpers for |ComputeFontData| that need access to |mNoneBits|:
static void SetFontSize(nsPresContext* aPresContext,
@ -610,7 +611,7 @@ protected:
nscoord aScriptLevelAdjustedParentSize,
bool aUsedStartStruct,
bool aAtRoot,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
static void SetFont(nsPresContext* aPresContext,
nsStyleContext* aContext,
@ -619,7 +620,7 @@ protected:
const nsStyleFont* aParentFont,
nsStyleFont* aFont,
bool aStartStruct,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
static void SetGenericFont(nsPresContext* aPresContext,
nsStyleContext* aContext,
@ -633,17 +634,17 @@ protected:
GetShadowData(const nsCSSValueList* aList,
nsStyleContext* aContext,
bool aIsBoxShadow,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
bool SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
void SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath,
const nsCSSValue* aValue,
nsStyleContext* aStyleContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
private:
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
@ -764,7 +765,7 @@ public:
static nscoord CalcLength(const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
struct ComputedCalc {
nscoord mLength;
@ -777,7 +778,7 @@ public:
SpecifiedCalcToComputedCalc(const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree);
mozilla::RuleNodeCacheConditions& aConditions);
// Compute the value of an nsStyleCoord that IsCalcUnit().
// (Values that don't require aPercentageBasis should be handled

View File

@ -148,7 +148,7 @@ float
ProcessTranslatePart(const nsCSSValue& aValue,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox* aRefBox,
TransformReferenceBox::DimensionGetter aDimensionGetter)
{
@ -172,12 +172,12 @@ ProcessTranslatePart(const nsCSSValue& aValue,
} else if (aValue.IsCalcUnit()) {
nsRuleNode::ComputedCalc result =
nsRuleNode::SpecifiedCalcToComputedCalc(aValue, aContext, aPresContext,
aCanStoreInRuleTree);
aConditions);
percent = result.mPercent;
offset = result.mLength;
} else {
offset = nsRuleNode::CalcLength(aValue, aContext, aPresContext,
aCanStoreInRuleTree);
aConditions);
}
float translation = NSAppUnitsToFloatPixels(offset,
@ -204,7 +204,7 @@ ProcessMatrix(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 7, "Invalid array!");
@ -223,10 +223,10 @@ ProcessMatrix(gfx3DMatrix& aMatrix,
* and their percent parts stored in aX[0] and aY[1].
*/
result._31 = ProcessTranslatePart(aData->Item(5),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Width);
result._32 = ProcessTranslatePart(aData->Item(6),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Height);
aMatrix.PreMultiply(result);
@ -237,7 +237,7 @@ ProcessMatrix3D(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 17, "Invalid array!");
@ -259,13 +259,13 @@ ProcessMatrix3D(gfx3DMatrix& aMatrix,
temp._44 = aData->Item(16).GetFloatValue();
temp._41 = ProcessTranslatePart(aData->Item(13),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Width);
temp._42 = ProcessTranslatePart(aData->Item(14),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Height);
temp._43 = ProcessTranslatePart(aData->Item(15),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
nullptr);
aMatrix.PreMultiply(temp);
@ -277,7 +277,7 @@ ProcessInterpolateMatrix(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
@ -286,13 +286,13 @@ ProcessInterpolateMatrix(gfx3DMatrix& aMatrix,
if (aData->Item(1).GetUnit() == eCSSUnit_List) {
matrix1 = nsStyleTransformMatrix::ReadTransforms(aData->Item(1).GetListValue(),
aContext, aPresContext,
aCanStoreInRuleTree,
aConditions,
aRefBox, nsPresContext::AppUnitsPerCSSPixel());
}
if (aData->Item(2).GetUnit() == eCSSUnit_List) {
matrix2 = ReadTransforms(aData->Item(2).GetListValue(),
aContext, aPresContext,
aCanStoreInRuleTree,
aConditions,
aRefBox, nsPresContext::AppUnitsPerCSSPixel());
}
double progress = aData->Item(3).GetPercentValue();
@ -308,7 +308,7 @@ ProcessTranslateX(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
@ -316,7 +316,7 @@ ProcessTranslateX(gfx3DMatrix& aMatrix,
Point3D temp;
temp.x = ProcessTranslatePart(aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Width);
aMatrix.Translate(temp);
}
@ -327,7 +327,7 @@ ProcessTranslateY(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
@ -335,7 +335,7 @@ ProcessTranslateY(gfx3DMatrix& aMatrix,
Point3D temp;
temp.y = ProcessTranslatePart(aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Height);
aMatrix.Translate(temp);
}
@ -345,14 +345,14 @@ ProcessTranslateZ(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree)
RuleNodeCacheConditions& aConditions)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
Point3D temp;
temp.z = ProcessTranslatePart(aData->Item(1), aContext,
aPresContext, aCanStoreInRuleTree,
aPresContext, aConditions,
nullptr);
aMatrix.Translate(temp);
}
@ -363,7 +363,7 @@ ProcessTranslate(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Invalid array!");
@ -371,13 +371,13 @@ ProcessTranslate(gfx3DMatrix& aMatrix,
Point3D temp;
temp.x = ProcessTranslatePart(aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Width);
/* If we read in a Y component, set it appropriately */
if (aData->Count() == 3) {
temp.y = ProcessTranslatePart(aData->Item(2),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Height);
}
aMatrix.Translate(temp);
@ -388,7 +388,7 @@ ProcessTranslate3D(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
@ -396,15 +396,15 @@ ProcessTranslate3D(gfx3DMatrix& aMatrix,
Point3D temp;
temp.x = ProcessTranslatePart(aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Width);
temp.y = ProcessTranslatePart(aData->Item(2),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
&aRefBox, &TransformReferenceBox::Height);
temp.z = ProcessTranslatePart(aData->Item(3),
aContext, aPresContext, aCanStoreInRuleTree,
aContext, aPresContext, aConditions,
nullptr);
aMatrix.Translate(temp);
@ -592,12 +592,12 @@ ProcessPerspective(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext *aContext,
nsPresContext *aPresContext,
bool &aCanStoreInRuleTree)
RuleNodeCacheConditions& aConditions)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
float depth = ProcessTranslatePart(aData->Item(1), aContext,
aPresContext, aCanStoreInRuleTree,
aPresContext, aConditions,
nullptr);
aMatrix.Perspective(depth);
}
@ -612,7 +612,7 @@ MatrixForTransformFunction(gfx3DMatrix& aMatrix,
const nsCSSValue::Array * aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox)
{
NS_PRECONDITION(aData, "Why did you want to get data from a null array?");
@ -625,23 +625,23 @@ MatrixForTransformFunction(gfx3DMatrix& aMatrix,
switch (TransformFunctionOf(aData)) {
case eCSSKeyword_translatex:
ProcessTranslateX(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_translatey:
ProcessTranslateY(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_translatez:
ProcessTranslateZ(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree);
aConditions);
break;
case eCSSKeyword_translate:
ProcessTranslate(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_translate3d:
ProcessTranslate3D(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_scalex:
ProcessScaleX(aMatrix, aData);
@ -682,19 +682,19 @@ MatrixForTransformFunction(gfx3DMatrix& aMatrix,
break;
case eCSSKeyword_matrix:
ProcessMatrix(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_matrix3d:
ProcessMatrix3D(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_interpolatematrix:
ProcessInterpolateMatrix(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree, aRefBox);
aConditions, aRefBox);
break;
case eCSSKeyword_perspective:
ProcessPerspective(aMatrix, aData, aContext, aPresContext,
aCanStoreInRuleTree);
aConditions);
break;
default:
NS_NOTREACHED("Unknown transform function!");
@ -716,7 +716,7 @@ gfx3DMatrix
ReadTransforms(const nsCSSValueList* aList,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool &aCanStoreInRuleTree,
RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aRefBox,
float aAppUnitsPerMatrixUnit)
{
@ -736,7 +736,7 @@ ReadTransforms(const nsCSSValueList* aList,
/* Read in a single transform matrix. */
MatrixForTransformFunction(result, currElem.GetArrayValue(), aContext,
aPresContext, aCanStoreInRuleTree, aRefBox);
aPresContext, aConditions, aRefBox);
}
float scale = float(nsPresContext::AppUnitsPerCSSPixel()) / aAppUnitsPerMatrixUnit;

View File

@ -17,6 +17,9 @@ class nsIFrame;
class nsStyleContext;
class nsPresContext;
struct nsRect;
namespace mozilla {
class RuleNodeCacheConditions;
}
/**
* A helper to generate gfxMatrixes from css transform functions.
@ -128,7 +131,7 @@ namespace nsStyleTransformMatrix {
float ProcessTranslatePart(const nsCSSValue& aValue,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
mozilla::RuleNodeCacheConditions& aConditions,
TransformReferenceBox* aRefBox,
TransformReferenceBox::DimensionGetter aDimensionGetter = nullptr);
@ -137,7 +140,7 @@ namespace nsStyleTransformMatrix {
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
mozilla::RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aBounds);
/**
@ -147,8 +150,8 @@ namespace nsStyleTransformMatrix {
* @param aData The nsCSSValueList containing the transform functions
* @param aContext The style context, used for unit conversion.
* @param aPresContext The presentation context, used for unit conversion.
* @param aCanStoreInRuleTree Set to false if the result cannot be cached
* in the rule tree, otherwise untouched.
* @param aConditions Set to uncachable (by calling SetUncacheable()) if the
* result cannot be cached in the rule tree, otherwise untouched.
* @param aBounds The frame's bounding rectangle.
* @param aAppUnitsPerMatrixUnit The number of app units per device pixel.
*
@ -159,7 +162,7 @@ namespace nsStyleTransformMatrix {
gfx3DMatrix ReadTransforms(const nsCSSValueList* aList,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool &aCanStoreInRuleTree,
mozilla::RuleNodeCacheConditions& aConditions,
TransformReferenceBox& aBounds,
float aAppUnitsPerMatrixUnit);