added some experimental CSS3 properties

fixed style context impact reporting
This commit is contained in:
peterl%netscape.com 1999-07-24 18:59:43 +00:00
Родитель 8a7e45d78b
Коммит 195fa109e9
7 изменённых файлов: 387 добавлений и 426 удалений

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

@ -489,6 +489,8 @@ void StyleSpacingImpl::ResetFrom(const nsStyleSpacing* aParent, nsIPresContext*
mOutlineWidth = medium;
mOutlineStyle = NS_STYLE_BORDER_STYLE_NONE;
mOutlineColor = NS_RGB(0, 0, 0);
mFloatEdge = NS_STYLE_FLOAT_EDGE_CONTENT;
mHasCachedMargin = PR_FALSE;
mHasCachedPadding = PR_FALSE;
@ -649,13 +651,15 @@ PRInt32 StyleSpacingImpl::CalcDifference(const StyleSpacingImpl& aOther) const
{
if ((mMargin == aOther.mMargin) &&
(mPadding == aOther.mPadding) &&
(mBorder == aOther.mBorder)) {
(mBorder == aOther.mBorder) &&
(mFloatEdge == aOther.mFloatEdge)) {
PRInt32 ix;
for (ix = 0; ix < 4; ix++) {
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) ||
(mBorderColor[ix] != aOther.mBorderColor[ix])) {
if ((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix])) {
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) &&
((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix]))) {
return NS_STYLE_HINT_REFLOW; // border on or off
}
return NS_STYLE_HINT_VISUAL;
@ -746,6 +750,7 @@ void StylePositionImpl::ResetFrom(const nsStylePosition* aParent, nsIPresContext
mHeight.SetAutoValue();
mMinHeight.SetCoordValue(0);
mMaxHeight.Reset();
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
mZIndex.SetAutoValue();
}
@ -759,6 +764,7 @@ PRInt32 StylePositionImpl::CalcDifference(const StylePositionImpl& aOther) const
(mHeight == aOther.mHeight) &&
(mMinHeight == aOther.mMinHeight) &&
(mMaxHeight == aOther.mMaxHeight) &&
(mBoxSizing == aOther.mBoxSizing) &&
(mZIndex == aOther.mZIndex)) {
return NS_STYLE_HINT_NONE;
}
@ -875,6 +881,11 @@ PRInt32 StyleDisplayImpl::CalcDifference(const StyleDisplayImpl& aOther) const
(mClip == aOther.mClip)) {
return NS_STYLE_HINT_NONE;
}
if ((mVisible != aOther.mVisible) &&
((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible))) {
return NS_STYLE_HINT_REFLOW;
}
return NS_STYLE_HINT_VISUAL;
}
return NS_STYLE_HINT_REFLOW;
@ -1214,6 +1225,67 @@ StyleContentImpl::CalcDifference(const StyleContentImpl& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
//-----------------------
// nsStyleUserInterface
//
nsStyleUserInterface::nsStyleUserInterface(void) { }
struct StyleUserInterfaceImpl: public nsStyleUserInterface {
StyleUserInterfaceImpl(void) { }
void ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext);
PRInt32 CalcDifference(const StyleUserInterfaceImpl& aOther) const;
private: // These are not allowed
StyleUserInterfaceImpl(const StyleUserInterfaceImpl& aOther);
StyleUserInterfaceImpl& operator=(const StyleUserInterfaceImpl& aOther);
};
void StyleUserInterfaceImpl::ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext)
{
if (aParent) {
mUserInput = aParent->mUserInput;
mModifyContent = aParent->mModifyContent;
mAutoSelect = aParent->mAutoSelect;
mAutoTab = aParent->mAutoTab;
}
else {
mUserInput = NS_STYLE_USER_INPUT_AUTO;
mModifyContent = NS_STYLE_MODIFY_CONTENT_READ_ONLY;
mAutoSelect = NS_STYLE_AUTO_SELECT_NONE;
mAutoTab = NS_STYLE_AUTO_TAB_AUTO;
}
mSelectionStyle = NS_STYLE_SELECTION_STYLE_ANY;
mKeyEquivalent = PRUnichar(0); // XXX what type should this be?
mResizer = NS_STYLE_RESIZER_AUTO;
}
PRInt32 StyleUserInterfaceImpl::CalcDifference(const StyleUserInterfaceImpl& aOther) const
{
if ((mUserInput == aOther.mUserInput) &&
(mResizer == aOther.mResizer)) {
if ((mModifyContent == aOther.mModifyContent) &&
(mSelectionStyle == aOther.mSelectionStyle)) {
if ((mAutoSelect == aOther.mAutoSelect) &&
(mKeyEquivalent == aOther.mKeyEquivalent) &&
(mAutoTab == aOther.mAutoTab) &&
(mResizer == aOther.mResizer)) {
return NS_STYLE_HINT_NONE;
}
return NS_STYLE_HINT_CONTENT;
}
return NS_STYLE_HINT_VISUAL;
}
if ((mUserInput != aOther.mUserInput) &&
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
return NS_STYLE_HINT_FRAMECHANGE;
}
return NS_STYLE_HINT_VISUAL;
}
//----------------------------------------------------------------------
class StyleContextImpl : public nsIStyleContext {
@ -1266,15 +1338,16 @@ protected:
PRInt32 mDataCode;
// the style data...
StyleFontImpl mFont;
StyleColorImpl mColor;
StyleSpacingImpl mSpacing;
StyleListImpl mList;
StylePositionImpl mPosition;
StyleTextImpl mText;
StyleDisplayImpl mDisplay;
StyleTableImpl* mTable;
StyleContentImpl* mContent;
StyleFontImpl mFont;
StyleColorImpl mColor;
StyleSpacingImpl mSpacing;
StyleListImpl mList;
StylePositionImpl mPosition;
StyleTextImpl mText;
StyleDisplayImpl mDisplay;
StyleTableImpl mTable;
StyleContentImpl mContent;
StyleUserInterfaceImpl mUserInterface;
#ifdef DEBUG_REFS
PRInt32 mInstance;
@ -1311,8 +1384,9 @@ StyleContextImpl::StyleContextImpl(nsIStyleContext* aParent,
mPosition(),
mText(),
mDisplay(),
mTable(nsnull),
mContent(nsnull)
mTable(),
mContent(),
mUserInterface()
{
NS_INIT_REFCNT();
NS_IF_ADDREF(mPseudoTag);
@ -1351,16 +1425,6 @@ StyleContextImpl::~StyleContextImpl()
NS_IF_RELEASE(mRules);
if (mTable) {
delete mTable;
mTable = nsnull;
}
if (mContent) {
delete mContent;
mContent = nsnull;
}
#ifdef DEBUG_REFS
fprintf(stdout, "%d of %d - StyleContext\n", mInstance, gInstanceCount);
--gInstanceCount;
@ -1639,43 +1703,14 @@ const nsStyleStruct* StyleContextImpl::GetStyleData(nsStyleStructID aSID)
case eStyleStruct_Display:
result = &mDisplay;
break;
case eStyleStruct_Table: // this one gets created lazily
if (nsnull == mTable) {
mTable = new StyleTableImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mTable) {
break;
}
parent = parent->mParent;
}
if (parent) {
mTable->ResetFrom(parent->mTable, nsnull);
}
else {
mTable->ResetFrom(nsnull, nsnull);
}
}
result = mTable;
case eStyleStruct_Table:
result = &mTable;
break;
case eStyleStruct_Content: // lazy creation
if (nsnull == mContent) {
mContent = new StyleContentImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has content data so we can inherit from it
if (parent->mContent) {
break;
}
parent = parent->mParent;
}
if (parent) {
mContent->ResetFrom(parent->mContent, nsnull);
}
else {
mContent->ResetFrom(nsnull, nsnull);
}
}
result = mContent;
case eStyleStruct_Content:
result = &mContent;
break;
case eStyleStruct_UserInterface:
result = &mUserInterface;
break;
default:
NS_ERROR("Invalid style struct id");
@ -1710,43 +1745,14 @@ nsStyleStruct* StyleContextImpl::GetMutableStyleData(nsStyleStructID aSID)
case eStyleStruct_Display:
result = &mDisplay;
break;
case eStyleStruct_Table: // this one gets created lazily
if (nsnull == mTable) {
mTable = new StyleTableImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mTable) {
break;
}
parent = parent->mParent;
}
if (parent) {
mTable->ResetFrom(parent->mTable, nsnull);
}
else {
mTable->ResetFrom(nsnull, nsnull);
}
}
result = mTable;
case eStyleStruct_Table:
result = &mTable;
break;
case eStyleStruct_Content: // this one gets created lazily
if (nsnull == mContent) {
mContent = new StyleContentImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mContent) {
break;
}
parent = parent->mParent;
}
if (parent) {
mContent->ResetFrom(parent->mContent, nsnull);
}
else {
mContent->ResetFrom(nsnull, nsnull);
}
}
result = mContent;
case eStyleStruct_Content:
result = &mContent;
break;
case eStyleStruct_UserInterface:
result = &mUserInterface;
break;
default:
NS_ERROR("Invalid style struct id");
@ -1795,18 +1801,24 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
mColor.ResetFrom(&(mParent->mColor), aPresContext);
mSpacing.ResetFrom(&(mParent->mSpacing), aPresContext);
mList.ResetFrom(&(mParent->mList), aPresContext);
mText.ResetFrom(&(mParent->mText), aPresContext);
mPosition.ResetFrom(&(mParent->mPosition), aPresContext);
mText.ResetFrom(&(mParent->mText), aPresContext);
mDisplay.ResetFrom(&(mParent->mDisplay), aPresContext);
mTable.ResetFrom(&(mParent->mTable), aPresContext);
mContent.ResetFrom(&(mParent->mContent), aPresContext);
mUserInterface.ResetFrom(&(mParent->mUserInterface), aPresContext);
}
else {
mFont.ResetFrom(nsnull, aPresContext);
mColor.ResetFrom(nsnull, aPresContext);
mSpacing.ResetFrom(nsnull, aPresContext);
mList.ResetFrom(nsnull, aPresContext);
mText.ResetFrom(nsnull, aPresContext);
mPosition.ResetFrom(nsnull, aPresContext);
mText.ResetFrom(nsnull, aPresContext);
mDisplay.ResetFrom(nsnull, aPresContext);
mTable.ResetFrom(nsnull, aPresContext);
mContent.ResetFrom(nsnull, aPresContext);
mUserInterface.ResetFrom(nsnull, aPresContext);
}
PRUint32 cnt = 0;
@ -1851,6 +1863,9 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
mText.ResetFrom(nsnull, aPresContext);
mPosition.ResetFrom(nsnull, aPresContext);
mDisplay.ResetFrom(nsnull, aPresContext);
mTable.ResetFrom(nsnull, aPresContext);
mContent.ResetFrom(nsnull, aPresContext);
mUserInterface.ResetFrom(nsnull, aPresContext);
mDisplay.mVisible = visible;
mDisplay.mDirection = direction;
@ -1951,53 +1966,19 @@ StyleContextImpl::CalcStyleDifference(nsIStyleContext* aOther, PRInt32& aHint) c
}
}
if (aHint < NS_STYLE_HINT_MAX) {
if (mTable) {
if (other->mTable) {
hint = mTable->CalcDifference(*(other->mTable));
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
else {
if (other->mTable) {
hint = NS_STYLE_HINT_REFLOW;
}
else {
hint = NS_STYLE_HINT_NONE;
}
}
hint = mTable.CalcDifference(other->mTable);
if (aHint < hint) {
aHint = hint;
}
}
if (aHint < NS_STYLE_HINT_MAX) {
if (mContent) {
if (other->mContent) {
hint = mContent->CalcDifference(*(other->mContent));
}
else {
if (mContent->ContentCount()) {
hint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
}
else {
if (other->mContent) {
if (other->mContent->ContentCount()) {
hint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
else {
hint = NS_STYLE_HINT_NONE;
}
hint = mContent.CalcDifference(other->mContent);
if (aHint < hint) {
aHint = hint;
}
}
if (aHint < NS_STYLE_HINT_MAX) {
hint = mUserInterface.CalcDifference(other->mUserInterface);
if (aHint < hint) {
aHint = hint;
}

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

@ -264,6 +264,7 @@
#define NS_STYLE_DISPLAY_TABLE_ROW 15
#define NS_STYLE_DISPLAY_TABLE_CELL 16
#define NS_STYLE_DISPLAY_TABLE_CAPTION 17
#define NS_STYLE_DISPLAY_MENU 18
// See nsStyleDisplay
#define NS_STYLE_FLOAT_NONE 0

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

@ -81,6 +81,8 @@ struct nsStyleSpacing: public nsStyleStruct {
nsStyleCoord mOutlineWidth; // [reset] length, enum (see nsStyleConsts.h)
PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h
PRBool GetMargin(nsMargin& aMargin) const;
PRBool GetPadding(nsMargin& aPadding) const;
PRBool GetBorder(nsMargin& aBorder) const;
@ -145,6 +147,7 @@ struct nsStylePosition : public nsStyleStruct {
nsStyleCoord mHeight; // [reset] coord, percent, auto, inherit
nsStyleCoord mMinHeight; // [reset] coord, percent, inherit
nsStyleCoord mMaxHeight; // [reset] coord, percent, null, inherit
PRUint8 mBoxSizing; // [reset] see nsStyleConsts.h
nsStyleCoord mZIndex; // [reset]
@ -280,6 +283,18 @@ protected:
nsString* mQuotes;
};
struct nsStyleUserInterface: public nsStyleStruct {
PRUint8 mUserInput; // [inherited]
PRUint8 mModifyContent; // [inherited]
PRUint8 mSelectionStyle; // [reset]
PRUint8 mAutoSelect; // [inherited]
PRUnichar mKeyEquivalent; // [reset] XXX what type should this be?
PRUint8 mAutoTab; // [inherited]
PRUint8 mResizer; // [reset]
protected:
nsStyleUserInterface(void);
};
#define BORDER_PRECEDENT_EQUAL 0
#define BORDER_PRECEDENT_LOWER 1
#define BORDER_PRECEDENT_HIGHER 2

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

@ -264,6 +264,7 @@
#define NS_STYLE_DISPLAY_TABLE_ROW 15
#define NS_STYLE_DISPLAY_TABLE_CELL 16
#define NS_STYLE_DISPLAY_TABLE_CAPTION 17
#define NS_STYLE_DISPLAY_MENU 18
// See nsStyleDisplay
#define NS_STYLE_FLOAT_NONE 0

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

@ -19,15 +19,16 @@
#define nsStyleStruct_h___
enum nsStyleStructID {
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
eStyleStruct_Spacing = 3,
eStyleStruct_List = 4,
eStyleStruct_Position = 5,
eStyleStruct_Text = 6,
eStyleStruct_Display = 7,
eStyleStruct_Table = 8,
eStyleStruct_Content = 9
eStyleStruct_Font = 1,
eStyleStruct_Color = 2,
eStyleStruct_Spacing = 3,
eStyleStruct_List = 4,
eStyleStruct_Position = 5,
eStyleStruct_Text = 6,
eStyleStruct_Display = 7,
eStyleStruct_Table = 8,
eStyleStruct_Content = 9,
eStyleStruct_UserInterface = 10
};

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

@ -489,6 +489,8 @@ void StyleSpacingImpl::ResetFrom(const nsStyleSpacing* aParent, nsIPresContext*
mOutlineWidth = medium;
mOutlineStyle = NS_STYLE_BORDER_STYLE_NONE;
mOutlineColor = NS_RGB(0, 0, 0);
mFloatEdge = NS_STYLE_FLOAT_EDGE_CONTENT;
mHasCachedMargin = PR_FALSE;
mHasCachedPadding = PR_FALSE;
@ -649,13 +651,15 @@ PRInt32 StyleSpacingImpl::CalcDifference(const StyleSpacingImpl& aOther) const
{
if ((mMargin == aOther.mMargin) &&
(mPadding == aOther.mPadding) &&
(mBorder == aOther.mBorder)) {
(mBorder == aOther.mBorder) &&
(mFloatEdge == aOther.mFloatEdge)) {
PRInt32 ix;
for (ix = 0; ix < 4; ix++) {
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) ||
(mBorderColor[ix] != aOther.mBorderColor[ix])) {
if ((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix])) {
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) &&
((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix]))) {
return NS_STYLE_HINT_REFLOW; // border on or off
}
return NS_STYLE_HINT_VISUAL;
@ -746,6 +750,7 @@ void StylePositionImpl::ResetFrom(const nsStylePosition* aParent, nsIPresContext
mHeight.SetAutoValue();
mMinHeight.SetCoordValue(0);
mMaxHeight.Reset();
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
mZIndex.SetAutoValue();
}
@ -759,6 +764,7 @@ PRInt32 StylePositionImpl::CalcDifference(const StylePositionImpl& aOther) const
(mHeight == aOther.mHeight) &&
(mMinHeight == aOther.mMinHeight) &&
(mMaxHeight == aOther.mMaxHeight) &&
(mBoxSizing == aOther.mBoxSizing) &&
(mZIndex == aOther.mZIndex)) {
return NS_STYLE_HINT_NONE;
}
@ -875,6 +881,11 @@ PRInt32 StyleDisplayImpl::CalcDifference(const StyleDisplayImpl& aOther) const
(mClip == aOther.mClip)) {
return NS_STYLE_HINT_NONE;
}
if ((mVisible != aOther.mVisible) &&
((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible))) {
return NS_STYLE_HINT_REFLOW;
}
return NS_STYLE_HINT_VISUAL;
}
return NS_STYLE_HINT_REFLOW;
@ -1214,6 +1225,67 @@ StyleContentImpl::CalcDifference(const StyleContentImpl& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
//-----------------------
// nsStyleUserInterface
//
nsStyleUserInterface::nsStyleUserInterface(void) { }
struct StyleUserInterfaceImpl: public nsStyleUserInterface {
StyleUserInterfaceImpl(void) { }
void ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext);
PRInt32 CalcDifference(const StyleUserInterfaceImpl& aOther) const;
private: // These are not allowed
StyleUserInterfaceImpl(const StyleUserInterfaceImpl& aOther);
StyleUserInterfaceImpl& operator=(const StyleUserInterfaceImpl& aOther);
};
void StyleUserInterfaceImpl::ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext)
{
if (aParent) {
mUserInput = aParent->mUserInput;
mModifyContent = aParent->mModifyContent;
mAutoSelect = aParent->mAutoSelect;
mAutoTab = aParent->mAutoTab;
}
else {
mUserInput = NS_STYLE_USER_INPUT_AUTO;
mModifyContent = NS_STYLE_MODIFY_CONTENT_READ_ONLY;
mAutoSelect = NS_STYLE_AUTO_SELECT_NONE;
mAutoTab = NS_STYLE_AUTO_TAB_AUTO;
}
mSelectionStyle = NS_STYLE_SELECTION_STYLE_ANY;
mKeyEquivalent = PRUnichar(0); // XXX what type should this be?
mResizer = NS_STYLE_RESIZER_AUTO;
}
PRInt32 StyleUserInterfaceImpl::CalcDifference(const StyleUserInterfaceImpl& aOther) const
{
if ((mUserInput == aOther.mUserInput) &&
(mResizer == aOther.mResizer)) {
if ((mModifyContent == aOther.mModifyContent) &&
(mSelectionStyle == aOther.mSelectionStyle)) {
if ((mAutoSelect == aOther.mAutoSelect) &&
(mKeyEquivalent == aOther.mKeyEquivalent) &&
(mAutoTab == aOther.mAutoTab) &&
(mResizer == aOther.mResizer)) {
return NS_STYLE_HINT_NONE;
}
return NS_STYLE_HINT_CONTENT;
}
return NS_STYLE_HINT_VISUAL;
}
if ((mUserInput != aOther.mUserInput) &&
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
return NS_STYLE_HINT_FRAMECHANGE;
}
return NS_STYLE_HINT_VISUAL;
}
//----------------------------------------------------------------------
class StyleContextImpl : public nsIStyleContext {
@ -1266,15 +1338,16 @@ protected:
PRInt32 mDataCode;
// the style data...
StyleFontImpl mFont;
StyleColorImpl mColor;
StyleSpacingImpl mSpacing;
StyleListImpl mList;
StylePositionImpl mPosition;
StyleTextImpl mText;
StyleDisplayImpl mDisplay;
StyleTableImpl* mTable;
StyleContentImpl* mContent;
StyleFontImpl mFont;
StyleColorImpl mColor;
StyleSpacingImpl mSpacing;
StyleListImpl mList;
StylePositionImpl mPosition;
StyleTextImpl mText;
StyleDisplayImpl mDisplay;
StyleTableImpl mTable;
StyleContentImpl mContent;
StyleUserInterfaceImpl mUserInterface;
#ifdef DEBUG_REFS
PRInt32 mInstance;
@ -1311,8 +1384,9 @@ StyleContextImpl::StyleContextImpl(nsIStyleContext* aParent,
mPosition(),
mText(),
mDisplay(),
mTable(nsnull),
mContent(nsnull)
mTable(),
mContent(),
mUserInterface()
{
NS_INIT_REFCNT();
NS_IF_ADDREF(mPseudoTag);
@ -1351,16 +1425,6 @@ StyleContextImpl::~StyleContextImpl()
NS_IF_RELEASE(mRules);
if (mTable) {
delete mTable;
mTable = nsnull;
}
if (mContent) {
delete mContent;
mContent = nsnull;
}
#ifdef DEBUG_REFS
fprintf(stdout, "%d of %d - StyleContext\n", mInstance, gInstanceCount);
--gInstanceCount;
@ -1639,43 +1703,14 @@ const nsStyleStruct* StyleContextImpl::GetStyleData(nsStyleStructID aSID)
case eStyleStruct_Display:
result = &mDisplay;
break;
case eStyleStruct_Table: // this one gets created lazily
if (nsnull == mTable) {
mTable = new StyleTableImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mTable) {
break;
}
parent = parent->mParent;
}
if (parent) {
mTable->ResetFrom(parent->mTable, nsnull);
}
else {
mTable->ResetFrom(nsnull, nsnull);
}
}
result = mTable;
case eStyleStruct_Table:
result = &mTable;
break;
case eStyleStruct_Content: // lazy creation
if (nsnull == mContent) {
mContent = new StyleContentImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has content data so we can inherit from it
if (parent->mContent) {
break;
}
parent = parent->mParent;
}
if (parent) {
mContent->ResetFrom(parent->mContent, nsnull);
}
else {
mContent->ResetFrom(nsnull, nsnull);
}
}
result = mContent;
case eStyleStruct_Content:
result = &mContent;
break;
case eStyleStruct_UserInterface:
result = &mUserInterface;
break;
default:
NS_ERROR("Invalid style struct id");
@ -1710,43 +1745,14 @@ nsStyleStruct* StyleContextImpl::GetMutableStyleData(nsStyleStructID aSID)
case eStyleStruct_Display:
result = &mDisplay;
break;
case eStyleStruct_Table: // this one gets created lazily
if (nsnull == mTable) {
mTable = new StyleTableImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mTable) {
break;
}
parent = parent->mParent;
}
if (parent) {
mTable->ResetFrom(parent->mTable, nsnull);
}
else {
mTable->ResetFrom(nsnull, nsnull);
}
}
result = mTable;
case eStyleStruct_Table:
result = &mTable;
break;
case eStyleStruct_Content: // this one gets created lazily
if (nsnull == mContent) {
mContent = new StyleContentImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mContent) {
break;
}
parent = parent->mParent;
}
if (parent) {
mContent->ResetFrom(parent->mContent, nsnull);
}
else {
mContent->ResetFrom(nsnull, nsnull);
}
}
result = mContent;
case eStyleStruct_Content:
result = &mContent;
break;
case eStyleStruct_UserInterface:
result = &mUserInterface;
break;
default:
NS_ERROR("Invalid style struct id");
@ -1795,18 +1801,24 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
mColor.ResetFrom(&(mParent->mColor), aPresContext);
mSpacing.ResetFrom(&(mParent->mSpacing), aPresContext);
mList.ResetFrom(&(mParent->mList), aPresContext);
mText.ResetFrom(&(mParent->mText), aPresContext);
mPosition.ResetFrom(&(mParent->mPosition), aPresContext);
mText.ResetFrom(&(mParent->mText), aPresContext);
mDisplay.ResetFrom(&(mParent->mDisplay), aPresContext);
mTable.ResetFrom(&(mParent->mTable), aPresContext);
mContent.ResetFrom(&(mParent->mContent), aPresContext);
mUserInterface.ResetFrom(&(mParent->mUserInterface), aPresContext);
}
else {
mFont.ResetFrom(nsnull, aPresContext);
mColor.ResetFrom(nsnull, aPresContext);
mSpacing.ResetFrom(nsnull, aPresContext);
mList.ResetFrom(nsnull, aPresContext);
mText.ResetFrom(nsnull, aPresContext);
mPosition.ResetFrom(nsnull, aPresContext);
mText.ResetFrom(nsnull, aPresContext);
mDisplay.ResetFrom(nsnull, aPresContext);
mTable.ResetFrom(nsnull, aPresContext);
mContent.ResetFrom(nsnull, aPresContext);
mUserInterface.ResetFrom(nsnull, aPresContext);
}
PRUint32 cnt = 0;
@ -1851,6 +1863,9 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
mText.ResetFrom(nsnull, aPresContext);
mPosition.ResetFrom(nsnull, aPresContext);
mDisplay.ResetFrom(nsnull, aPresContext);
mTable.ResetFrom(nsnull, aPresContext);
mContent.ResetFrom(nsnull, aPresContext);
mUserInterface.ResetFrom(nsnull, aPresContext);
mDisplay.mVisible = visible;
mDisplay.mDirection = direction;
@ -1951,53 +1966,19 @@ StyleContextImpl::CalcStyleDifference(nsIStyleContext* aOther, PRInt32& aHint) c
}
}
if (aHint < NS_STYLE_HINT_MAX) {
if (mTable) {
if (other->mTable) {
hint = mTable->CalcDifference(*(other->mTable));
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
else {
if (other->mTable) {
hint = NS_STYLE_HINT_REFLOW;
}
else {
hint = NS_STYLE_HINT_NONE;
}
}
hint = mTable.CalcDifference(other->mTable);
if (aHint < hint) {
aHint = hint;
}
}
if (aHint < NS_STYLE_HINT_MAX) {
if (mContent) {
if (other->mContent) {
hint = mContent->CalcDifference(*(other->mContent));
}
else {
if (mContent->ContentCount()) {
hint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
}
else {
if (other->mContent) {
if (other->mContent->ContentCount()) {
hint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
else {
hint = NS_STYLE_HINT_NONE;
}
hint = mContent.CalcDifference(other->mContent);
if (aHint < hint) {
aHint = hint;
}
}
if (aHint < NS_STYLE_HINT_MAX) {
hint = mUserInterface.CalcDifference(other->mUserInterface);
if (aHint < hint) {
aHint = hint;
}

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

@ -489,6 +489,8 @@ void StyleSpacingImpl::ResetFrom(const nsStyleSpacing* aParent, nsIPresContext*
mOutlineWidth = medium;
mOutlineStyle = NS_STYLE_BORDER_STYLE_NONE;
mOutlineColor = NS_RGB(0, 0, 0);
mFloatEdge = NS_STYLE_FLOAT_EDGE_CONTENT;
mHasCachedMargin = PR_FALSE;
mHasCachedPadding = PR_FALSE;
@ -649,13 +651,15 @@ PRInt32 StyleSpacingImpl::CalcDifference(const StyleSpacingImpl& aOther) const
{
if ((mMargin == aOther.mMargin) &&
(mPadding == aOther.mPadding) &&
(mBorder == aOther.mBorder)) {
(mBorder == aOther.mBorder) &&
(mFloatEdge == aOther.mFloatEdge)) {
PRInt32 ix;
for (ix = 0; ix < 4; ix++) {
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) ||
(mBorderColor[ix] != aOther.mBorderColor[ix])) {
if ((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix])) {
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) &&
((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix]))) {
return NS_STYLE_HINT_REFLOW; // border on or off
}
return NS_STYLE_HINT_VISUAL;
@ -746,6 +750,7 @@ void StylePositionImpl::ResetFrom(const nsStylePosition* aParent, nsIPresContext
mHeight.SetAutoValue();
mMinHeight.SetCoordValue(0);
mMaxHeight.Reset();
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
mZIndex.SetAutoValue();
}
@ -759,6 +764,7 @@ PRInt32 StylePositionImpl::CalcDifference(const StylePositionImpl& aOther) const
(mHeight == aOther.mHeight) &&
(mMinHeight == aOther.mMinHeight) &&
(mMaxHeight == aOther.mMaxHeight) &&
(mBoxSizing == aOther.mBoxSizing) &&
(mZIndex == aOther.mZIndex)) {
return NS_STYLE_HINT_NONE;
}
@ -875,6 +881,11 @@ PRInt32 StyleDisplayImpl::CalcDifference(const StyleDisplayImpl& aOther) const
(mClip == aOther.mClip)) {
return NS_STYLE_HINT_NONE;
}
if ((mVisible != aOther.mVisible) &&
((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible))) {
return NS_STYLE_HINT_REFLOW;
}
return NS_STYLE_HINT_VISUAL;
}
return NS_STYLE_HINT_REFLOW;
@ -1214,6 +1225,67 @@ StyleContentImpl::CalcDifference(const StyleContentImpl& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
//-----------------------
// nsStyleUserInterface
//
nsStyleUserInterface::nsStyleUserInterface(void) { }
struct StyleUserInterfaceImpl: public nsStyleUserInterface {
StyleUserInterfaceImpl(void) { }
void ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext);
PRInt32 CalcDifference(const StyleUserInterfaceImpl& aOther) const;
private: // These are not allowed
StyleUserInterfaceImpl(const StyleUserInterfaceImpl& aOther);
StyleUserInterfaceImpl& operator=(const StyleUserInterfaceImpl& aOther);
};
void StyleUserInterfaceImpl::ResetFrom(const nsStyleUserInterface* aParent, nsIPresContext* aPresContext)
{
if (aParent) {
mUserInput = aParent->mUserInput;
mModifyContent = aParent->mModifyContent;
mAutoSelect = aParent->mAutoSelect;
mAutoTab = aParent->mAutoTab;
}
else {
mUserInput = NS_STYLE_USER_INPUT_AUTO;
mModifyContent = NS_STYLE_MODIFY_CONTENT_READ_ONLY;
mAutoSelect = NS_STYLE_AUTO_SELECT_NONE;
mAutoTab = NS_STYLE_AUTO_TAB_AUTO;
}
mSelectionStyle = NS_STYLE_SELECTION_STYLE_ANY;
mKeyEquivalent = PRUnichar(0); // XXX what type should this be?
mResizer = NS_STYLE_RESIZER_AUTO;
}
PRInt32 StyleUserInterfaceImpl::CalcDifference(const StyleUserInterfaceImpl& aOther) const
{
if ((mUserInput == aOther.mUserInput) &&
(mResizer == aOther.mResizer)) {
if ((mModifyContent == aOther.mModifyContent) &&
(mSelectionStyle == aOther.mSelectionStyle)) {
if ((mAutoSelect == aOther.mAutoSelect) &&
(mKeyEquivalent == aOther.mKeyEquivalent) &&
(mAutoTab == aOther.mAutoTab) &&
(mResizer == aOther.mResizer)) {
return NS_STYLE_HINT_NONE;
}
return NS_STYLE_HINT_CONTENT;
}
return NS_STYLE_HINT_VISUAL;
}
if ((mUserInput != aOther.mUserInput) &&
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
return NS_STYLE_HINT_FRAMECHANGE;
}
return NS_STYLE_HINT_VISUAL;
}
//----------------------------------------------------------------------
class StyleContextImpl : public nsIStyleContext {
@ -1266,15 +1338,16 @@ protected:
PRInt32 mDataCode;
// the style data...
StyleFontImpl mFont;
StyleColorImpl mColor;
StyleSpacingImpl mSpacing;
StyleListImpl mList;
StylePositionImpl mPosition;
StyleTextImpl mText;
StyleDisplayImpl mDisplay;
StyleTableImpl* mTable;
StyleContentImpl* mContent;
StyleFontImpl mFont;
StyleColorImpl mColor;
StyleSpacingImpl mSpacing;
StyleListImpl mList;
StylePositionImpl mPosition;
StyleTextImpl mText;
StyleDisplayImpl mDisplay;
StyleTableImpl mTable;
StyleContentImpl mContent;
StyleUserInterfaceImpl mUserInterface;
#ifdef DEBUG_REFS
PRInt32 mInstance;
@ -1311,8 +1384,9 @@ StyleContextImpl::StyleContextImpl(nsIStyleContext* aParent,
mPosition(),
mText(),
mDisplay(),
mTable(nsnull),
mContent(nsnull)
mTable(),
mContent(),
mUserInterface()
{
NS_INIT_REFCNT();
NS_IF_ADDREF(mPseudoTag);
@ -1351,16 +1425,6 @@ StyleContextImpl::~StyleContextImpl()
NS_IF_RELEASE(mRules);
if (mTable) {
delete mTable;
mTable = nsnull;
}
if (mContent) {
delete mContent;
mContent = nsnull;
}
#ifdef DEBUG_REFS
fprintf(stdout, "%d of %d - StyleContext\n", mInstance, gInstanceCount);
--gInstanceCount;
@ -1639,43 +1703,14 @@ const nsStyleStruct* StyleContextImpl::GetStyleData(nsStyleStructID aSID)
case eStyleStruct_Display:
result = &mDisplay;
break;
case eStyleStruct_Table: // this one gets created lazily
if (nsnull == mTable) {
mTable = new StyleTableImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mTable) {
break;
}
parent = parent->mParent;
}
if (parent) {
mTable->ResetFrom(parent->mTable, nsnull);
}
else {
mTable->ResetFrom(nsnull, nsnull);
}
}
result = mTable;
case eStyleStruct_Table:
result = &mTable;
break;
case eStyleStruct_Content: // lazy creation
if (nsnull == mContent) {
mContent = new StyleContentImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has content data so we can inherit from it
if (parent->mContent) {
break;
}
parent = parent->mParent;
}
if (parent) {
mContent->ResetFrom(parent->mContent, nsnull);
}
else {
mContent->ResetFrom(nsnull, nsnull);
}
}
result = mContent;
case eStyleStruct_Content:
result = &mContent;
break;
case eStyleStruct_UserInterface:
result = &mUserInterface;
break;
default:
NS_ERROR("Invalid style struct id");
@ -1710,43 +1745,14 @@ nsStyleStruct* StyleContextImpl::GetMutableStyleData(nsStyleStructID aSID)
case eStyleStruct_Display:
result = &mDisplay;
break;
case eStyleStruct_Table: // this one gets created lazily
if (nsnull == mTable) {
mTable = new StyleTableImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mTable) {
break;
}
parent = parent->mParent;
}
if (parent) {
mTable->ResetFrom(parent->mTable, nsnull);
}
else {
mTable->ResetFrom(nsnull, nsnull);
}
}
result = mTable;
case eStyleStruct_Table:
result = &mTable;
break;
case eStyleStruct_Content: // this one gets created lazily
if (nsnull == mContent) {
mContent = new StyleContentImpl();
StyleContextImpl* parent = mParent;
while (parent) { // find first parent that has table data so we can inherit from it
if (parent->mContent) {
break;
}
parent = parent->mParent;
}
if (parent) {
mContent->ResetFrom(parent->mContent, nsnull);
}
else {
mContent->ResetFrom(nsnull, nsnull);
}
}
result = mContent;
case eStyleStruct_Content:
result = &mContent;
break;
case eStyleStruct_UserInterface:
result = &mUserInterface;
break;
default:
NS_ERROR("Invalid style struct id");
@ -1795,18 +1801,24 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
mColor.ResetFrom(&(mParent->mColor), aPresContext);
mSpacing.ResetFrom(&(mParent->mSpacing), aPresContext);
mList.ResetFrom(&(mParent->mList), aPresContext);
mText.ResetFrom(&(mParent->mText), aPresContext);
mPosition.ResetFrom(&(mParent->mPosition), aPresContext);
mText.ResetFrom(&(mParent->mText), aPresContext);
mDisplay.ResetFrom(&(mParent->mDisplay), aPresContext);
mTable.ResetFrom(&(mParent->mTable), aPresContext);
mContent.ResetFrom(&(mParent->mContent), aPresContext);
mUserInterface.ResetFrom(&(mParent->mUserInterface), aPresContext);
}
else {
mFont.ResetFrom(nsnull, aPresContext);
mColor.ResetFrom(nsnull, aPresContext);
mSpacing.ResetFrom(nsnull, aPresContext);
mList.ResetFrom(nsnull, aPresContext);
mText.ResetFrom(nsnull, aPresContext);
mPosition.ResetFrom(nsnull, aPresContext);
mText.ResetFrom(nsnull, aPresContext);
mDisplay.ResetFrom(nsnull, aPresContext);
mTable.ResetFrom(nsnull, aPresContext);
mContent.ResetFrom(nsnull, aPresContext);
mUserInterface.ResetFrom(nsnull, aPresContext);
}
PRUint32 cnt = 0;
@ -1851,6 +1863,9 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
mText.ResetFrom(nsnull, aPresContext);
mPosition.ResetFrom(nsnull, aPresContext);
mDisplay.ResetFrom(nsnull, aPresContext);
mTable.ResetFrom(nsnull, aPresContext);
mContent.ResetFrom(nsnull, aPresContext);
mUserInterface.ResetFrom(nsnull, aPresContext);
mDisplay.mVisible = visible;
mDisplay.mDirection = direction;
@ -1951,53 +1966,19 @@ StyleContextImpl::CalcStyleDifference(nsIStyleContext* aOther, PRInt32& aHint) c
}
}
if (aHint < NS_STYLE_HINT_MAX) {
if (mTable) {
if (other->mTable) {
hint = mTable->CalcDifference(*(other->mTable));
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
else {
if (other->mTable) {
hint = NS_STYLE_HINT_REFLOW;
}
else {
hint = NS_STYLE_HINT_NONE;
}
}
hint = mTable.CalcDifference(other->mTable);
if (aHint < hint) {
aHint = hint;
}
}
if (aHint < NS_STYLE_HINT_MAX) {
if (mContent) {
if (other->mContent) {
hint = mContent->CalcDifference(*(other->mContent));
}
else {
if (mContent->ContentCount()) {
hint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
}
else {
if (other->mContent) {
if (other->mContent->ContentCount()) {
hint = NS_STYLE_HINT_FRAMECHANGE;
}
else {
hint = NS_STYLE_HINT_REFLOW;
}
}
else {
hint = NS_STYLE_HINT_NONE;
}
hint = mContent.CalcDifference(other->mContent);
if (aHint < hint) {
aHint = hint;
}
}
if (aHint < NS_STYLE_HINT_MAX) {
hint = mUserInterface.CalcDifference(other->mUserInterface);
if (aHint < hint) {
aHint = hint;
}