mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 569719 part 4: Move nsCSSExpandedDataBlock::RuleDataPropertyAt into struct nsRuleData. r=dbaron
This commit is contained in:
parent
85cd8e693c
commit
aebfe9eed8
@ -136,6 +136,7 @@ CPPSRCS = \
|
||||
nsLayoutStylesheetCache.cpp \
|
||||
nsMediaFeatures.cpp \
|
||||
nsROCSSPrimitiveValue.cpp \
|
||||
nsRuleData.cpp \
|
||||
nsRuleNode.cpp \
|
||||
nsStyleAnimation.cpp \
|
||||
nsStyleContext.cpp \
|
||||
|
@ -238,8 +238,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
||||
"out of range");
|
||||
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
|
||||
aRuleData->mSIDs) {
|
||||
void *prop =
|
||||
nsCSSExpandedDataBlock::RuleDataPropertyAt(aRuleData, iProp);
|
||||
void *prop = aRuleData->StorageFor(iProp);
|
||||
switch (nsCSSProps::kTypeTable[iProp]) {
|
||||
case eCSSType_Value: {
|
||||
nsCSSValue* target = static_cast<nsCSSValue*>(prop);
|
||||
@ -581,21 +580,13 @@ nsCSSExpandedDataBlock::~nsCSSExpandedDataBlock()
|
||||
AssertInitialState();
|
||||
}
|
||||
|
||||
const nsCSSExpandedDataBlock::PropertyOffsetInfo
|
||||
nsCSSExpandedDataBlock::kOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
|
||||
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \
|
||||
member_, type_, kwtable_) \
|
||||
{ offsetof(nsCSSExpandedDataBlock, m##datastruct_.member_), \
|
||||
size_t(-1), \
|
||||
size_t(-1) },
|
||||
const size_t
|
||||
nsCSSExpandedDataBlock::kOffsetTable[] = {
|
||||
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
||||
{ offsetof(nsCSSExpandedDataBlock, m##datastruct_.member_), \
|
||||
offsetof(nsRuleData, m##datastruct_##Data), \
|
||||
offsetof(nsRuleData##datastruct_, member_) },
|
||||
offsetof(nsCSSExpandedDataBlock, m##datastruct_.member_),
|
||||
#include "nsCSSPropList.h"
|
||||
#undef CSS_PROP
|
||||
#undef CSS_PROP_BACKENDONLY
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -278,15 +278,9 @@ private:
|
||||
void DoAssertInitialState();
|
||||
#endif
|
||||
|
||||
struct PropertyOffsetInfo {
|
||||
// XXX These could probably be pointer-to-member, if the casting can
|
||||
// be done correctly.
|
||||
size_t block_offset; // offset of value in nsCSSExpandedDataBlock
|
||||
size_t ruledata_struct_offset; // offset of nsRuleData* in nsRuleData
|
||||
size_t ruledata_member_offset; // offset of value in nsRuleData*
|
||||
};
|
||||
|
||||
static const PropertyOffsetInfo kOffsetTable[];
|
||||
// XXX These could probably be pointer-to-member, if the casting can
|
||||
// be done correctly.
|
||||
static const size_t kOffsetTable[];
|
||||
|
||||
/*
|
||||
* mPropertiesSet stores a bit for every property that is present,
|
||||
@ -307,28 +301,8 @@ public:
|
||||
* |nsCSSValueList**| (etc.).
|
||||
*/
|
||||
void* PropertyAt(nsCSSProperty aProperty) {
|
||||
const PropertyOffsetInfo& offsets =
|
||||
nsCSSExpandedDataBlock::kOffsetTable[aProperty];
|
||||
return reinterpret_cast<void*>(reinterpret_cast<char*>(this) +
|
||||
offsets.block_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the storage location within |aRuleData| of the value of
|
||||
* the property (i.e., either an |nsCSSValue*|, |nsCSSRect*|, or
|
||||
* |nsCSSValueList**| (etc.).
|
||||
*/
|
||||
static void* RuleDataPropertyAt(nsRuleData *aRuleData,
|
||||
nsCSSProperty aProperty) {
|
||||
const PropertyOffsetInfo& offsets =
|
||||
nsCSSExpandedDataBlock::kOffsetTable[aProperty];
|
||||
NS_ASSERTION(offsets.ruledata_struct_offset != size_t(-1),
|
||||
"property should not use CSS_PROP_BACKENDONLY");
|
||||
char* cssstruct = *reinterpret_cast<char**>
|
||||
(reinterpret_cast<char*>(aRuleData) +
|
||||
offsets.ruledata_struct_offset);
|
||||
return reinterpret_cast<void*>
|
||||
(cssstruct + offsets.ruledata_member_offset);
|
||||
size_t offset = nsCSSExpandedDataBlock::kOffsetTable[aProperty];
|
||||
return reinterpret_cast<void*>(reinterpret_cast<char*>(this) + offset);
|
||||
}
|
||||
|
||||
void SetPropertyBit(nsCSSProperty aProperty) {
|
||||
|
81
layout/style/nsRuleData.cpp
Normal file
81
layout/style/nsRuleData.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsRuleData.h"
|
||||
#include "nsCSSProps.h"
|
||||
|
||||
namespace {
|
||||
|
||||
struct PropertyOffsetInfo {
|
||||
// XXX These could probably be pointer-to-member, if the casting can
|
||||
// be done correctly.
|
||||
size_t struct_offset; // offset of nsRuleDataThing* in nsRuleData
|
||||
size_t member_offset; // offset of value in nsRuleDataThing
|
||||
};
|
||||
|
||||
const PropertyOffsetInfo kOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
|
||||
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \
|
||||
member_, type_, kwtable_) \
|
||||
{ size_t(-1), size_t(-1) },
|
||||
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
|
||||
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
||||
{ offsetof(nsRuleData, m##datastruct_##Data), \
|
||||
offsetof(nsRuleData##datastruct_, member_) },
|
||||
#include "nsCSSPropList.h"
|
||||
#undef CSS_PROP
|
||||
#undef CSS_PROP_BACKENDONLY
|
||||
};
|
||||
|
||||
} // anon namespace
|
||||
|
||||
void*
|
||||
nsRuleData::StorageFor(nsCSSProperty aProperty)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aProperty < eCSSProperty_COUNT_no_shorthands,
|
||||
"invalid or shorthand property");
|
||||
|
||||
const PropertyOffsetInfo& offsets = kOffsetTable[aProperty];
|
||||
NS_ABORT_IF_FALSE(offsets.struct_offset != size_t(-1),
|
||||
"backend-only property");
|
||||
|
||||
char* cssstruct = *reinterpret_cast<char**>
|
||||
(reinterpret_cast<char*>(this) + offsets.struct_offset);
|
||||
NS_ABORT_IF_FALSE(cssstruct, "substructure pointer should never be null");
|
||||
|
||||
return reinterpret_cast<void*>(cssstruct + offsets.member_offset);
|
||||
}
|
@ -38,18 +38,20 @@
|
||||
|
||||
/*
|
||||
* temporary (expanded) representation of property-value pairs used to
|
||||
* hold data from matched rules during style data computation
|
||||
* hold data from matched rules during style data computation.
|
||||
*/
|
||||
|
||||
#ifndef nsRuleData_h_
|
||||
#define nsRuleData_h_
|
||||
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsCSSStruct.h"
|
||||
#include "nsStyleStructFwd.h"
|
||||
|
||||
class nsPresContext;
|
||||
class nsStyleContext;
|
||||
|
||||
struct nsRuleData;
|
||||
|
||||
typedef void (*nsPostResolveFunc)(void* aStyleStruct, nsRuleData* aData);
|
||||
|
||||
struct nsRuleData
|
||||
@ -61,7 +63,9 @@ struct nsRuleData
|
||||
nsPresContext* mPresContext;
|
||||
nsStyleContext* mStyleContext;
|
||||
nsPostResolveFunc mPostResolveCallback;
|
||||
nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures!
|
||||
|
||||
// Should always be stack-allocated! We don't own these structures!
|
||||
nsRuleDataFont* mFontData;
|
||||
nsRuleDataDisplay* mDisplayData;
|
||||
nsRuleDataMargin* mMarginData;
|
||||
nsRuleDataList* mListData;
|
||||
@ -73,18 +77,37 @@ struct nsRuleData
|
||||
nsRuleDataUserInterface* mUserInterfaceData;
|
||||
nsRuleDataXUL* mXULData;
|
||||
nsRuleDataSVG* mSVGData;
|
||||
|
||||
nsRuleDataColumn* mColumnData;
|
||||
|
||||
nsRuleData(PRUint32 aSIDs, nsPresContext* aContext, nsStyleContext* aStyleContext)
|
||||
:mSIDs(aSIDs), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
|
||||
mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
||||
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
|
||||
mUserInterfaceData(nsnull), mXULData(nsnull), mSVGData(nsnull), mColumnData(nsnull)
|
||||
{
|
||||
mCanStoreInRuleTree = PR_TRUE;
|
||||
}
|
||||
nsRuleData(PRUint32 aSIDs,
|
||||
nsPresContext* aContext,
|
||||
nsStyleContext* aStyleContext)
|
||||
: mSIDs(aSIDs),
|
||||
mCanStoreInRuleTree(PR_TRUE),
|
||||
mPresContext(aContext),
|
||||
mStyleContext(aStyleContext),
|
||||
mPostResolveCallback(nsnull),
|
||||
mFontData(nsnull),
|
||||
mDisplayData(nsnull),
|
||||
mMarginData(nsnull),
|
||||
mListData(nsnull),
|
||||
mPositionData(nsnull),
|
||||
mTableData(nsnull),
|
||||
mColorData(nsnull),
|
||||
mContentData(nsnull),
|
||||
mTextData(nsnull),
|
||||
mUserInterfaceData(nsnull),
|
||||
mXULData(nsnull),
|
||||
mSVGData(nsnull),
|
||||
mColumnData(nsnull)
|
||||
{}
|
||||
~nsRuleData() {}
|
||||
|
||||
/**
|
||||
* Non-typesafe worker routine for the above five value retrieval
|
||||
* functions. Avoid using.
|
||||
*/
|
||||
void* StorageFor(nsCSSProperty aProperty);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "gfxColor.h"
|
||||
#include "nsCSSPropertySet.h"
|
||||
#include "nsStyleAnimation.h"
|
||||
#include "nsCSSDataBlock.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
@ -242,8 +241,7 @@ AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
||||
if (aRuleData->mSIDs & nsCachedStyleData::GetBitForSID(
|
||||
nsCSSProps::kSIDTable[cv.mProperty]))
|
||||
{
|
||||
void *prop =
|
||||
nsCSSExpandedDataBlock::RuleDataPropertyAt(aRuleData, cv.mProperty);
|
||||
void *prop = aRuleData->StorageFor(cv.mProperty);
|
||||
#ifdef DEBUG
|
||||
PRBool ok =
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user