2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
2001-05-31 22:19:43 +00:00
|
|
|
* David Hyatt <hyatt@netscape.com>
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-02-07 09:57:26 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIStyleRule.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
|
2000-03-31 07:08:36 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#include "nsIPresShell.h"
|
2000-12-15 06:09:50 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
|
|
|
#include "prenv.h"
|
2000-03-31 07:08:36 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
#include "nsRuleNode.h"
|
2002-08-24 14:41:28 +00:00
|
|
|
#include "nsUnitConversion.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2000-06-21 20:44:59 +00:00
|
|
|
#ifdef DEBUG
|
2001-05-31 22:19:43 +00:00
|
|
|
// #define NOISY_DEBUG
|
2001-05-03 13:20:48 +00:00
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
//----------------------------------------------------------------------
|
2001-05-03 13:20:48 +00:00
|
|
|
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext::nsStyleContext(nsStyleContext* aParent,
|
2001-12-02 00:44:45 +00:00
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsRuleNode* aRuleNode,
|
|
|
|
nsIPresContext* aPresContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
: mParent((nsStyleContext*)aParent),
|
|
|
|
mChild(nsnull),
|
|
|
|
mEmptyChild(nsnull),
|
|
|
|
mPseudoTag(aPseudoTag),
|
2001-12-02 00:44:45 +00:00
|
|
|
mRuleNode(aRuleNode),
|
2003-02-22 00:32:13 +00:00
|
|
|
mBits(0),
|
|
|
|
mRefCnt(0)
|
1999-09-03 23:34:20 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
mNextSibling = this;
|
|
|
|
mPrevSibling = this;
|
2001-12-02 00:44:45 +00:00
|
|
|
if (mParent) {
|
2003-02-22 00:32:13 +00:00
|
|
|
mParent->AddRef();
|
2001-05-31 22:19:43 +00:00
|
|
|
mParent->AppendChild(this);
|
1999-02-27 07:11:42 +00:00
|
|
|
}
|
2001-05-03 13:20:48 +00:00
|
|
|
|
2001-07-25 06:33:06 +00:00
|
|
|
ApplyStyleFixups(aPresContext);
|
2002-07-09 04:10:10 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(NS_STYLE_INHERIT_MASK &
|
|
|
|
(1 << PRInt32(nsStyleStructID_Length - 1)) != 0,
|
|
|
|
"NS_STYLE_INHERIT_MASK must be bigger, and other bits shifted");
|
2001-05-03 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleContext::~nsStyleContext()
|
2001-05-03 13:20:48 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
NS_ASSERTION((nsnull == mChild) && (nsnull == mEmptyChild), "destructing context with children");
|
2001-05-03 13:20:48 +00:00
|
|
|
|
2003-03-06 19:14:17 +00:00
|
|
|
nsIPresContext *presContext = mRuleNode->PresContext();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
presContext->GetShell(getter_AddRefs(shell));
|
|
|
|
nsCOMPtr<nsIStyleSet> set;
|
|
|
|
shell->GetStyleSet(getter_AddRefs(set));
|
|
|
|
set->NotifyStyleContextDestroyed(presContext, this);
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
if (mParent) {
|
|
|
|
mParent->RemoveChild(this);
|
2003-02-22 00:32:13 +00:00
|
|
|
mParent->Release();
|
1999-02-27 07:11:42 +00:00
|
|
|
}
|
2001-02-07 09:57:26 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// Free up our data structs.
|
|
|
|
if (mCachedStyleData.mResetData || mCachedStyleData.mInheritedData) {
|
|
|
|
mCachedStyleData.Destroy(mBits, presContext);
|
|
|
|
}
|
2001-02-07 09:57:26 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
void nsStyleContext::AppendChild(nsStyleContext* aChild)
|
2001-02-07 09:57:26 +00:00
|
|
|
{
|
2002-02-17 01:53:40 +00:00
|
|
|
if (aChild->mRuleNode->IsRoot()) {
|
|
|
|
// The child matched no rules.
|
|
|
|
if (!mEmptyChild) {
|
2001-05-31 22:19:43 +00:00
|
|
|
mEmptyChild = aChild;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aChild->mNextSibling = mEmptyChild;
|
|
|
|
aChild->mPrevSibling = mEmptyChild->mPrevSibling;
|
|
|
|
mEmptyChild->mPrevSibling->mNextSibling = aChild;
|
|
|
|
mEmptyChild->mPrevSibling = aChild;
|
|
|
|
}
|
2001-01-20 22:46:54 +00:00
|
|
|
}
|
2001-02-07 09:57:26 +00:00
|
|
|
else {
|
2002-02-17 01:53:40 +00:00
|
|
|
if (!mChild) {
|
2001-05-31 22:19:43 +00:00
|
|
|
mChild = aChild;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aChild->mNextSibling = mChild;
|
|
|
|
aChild->mPrevSibling = mChild->mPrevSibling;
|
|
|
|
mChild->mPrevSibling->mNextSibling = aChild;
|
|
|
|
mChild->mPrevSibling = aChild;
|
|
|
|
}
|
2001-02-07 09:57:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
void nsStyleContext::RemoveChild(nsStyleContext* aChild)
|
2001-02-07 09:57:26 +00:00
|
|
|
{
|
2002-02-17 01:53:40 +00:00
|
|
|
NS_PRECONDITION(nsnull != aChild && this == aChild->mParent, "bad argument");
|
2001-02-07 09:57:26 +00:00
|
|
|
|
2002-02-17 01:53:40 +00:00
|
|
|
if (aChild->mRuleNode->IsRoot()) { // is empty
|
2001-05-31 22:19:43 +00:00
|
|
|
if (aChild->mPrevSibling != aChild) { // has siblings
|
|
|
|
if (mEmptyChild == aChild) {
|
|
|
|
mEmptyChild = mEmptyChild->mNextSibling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(mEmptyChild == aChild, "bad sibling pointers");
|
|
|
|
mEmptyChild = nsnull;
|
2001-02-19 12:55:42 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
else { // isn't empty
|
|
|
|
if (aChild->mPrevSibling != aChild) { // has siblings
|
|
|
|
if (mChild == aChild) {
|
|
|
|
mChild = mChild->mNextSibling;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(mChild == aChild, "bad sibling pointers");
|
|
|
|
if (mChild == aChild) {
|
|
|
|
mChild = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aChild->mPrevSibling->mNextSibling = aChild->mNextSibling;
|
|
|
|
aChild->mNextSibling->mPrevSibling = aChild->mPrevSibling;
|
|
|
|
aChild->mNextSibling = aChild;
|
|
|
|
aChild->mPrevSibling = aChild;
|
1999-10-16 04:05:59 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
already_AddRefed<nsIAtom>
|
|
|
|
nsStyleContext::GetPseudoType() const
|
2000-06-22 05:38:26 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
nsIAtom* pseudoTag = mPseudoTag;
|
|
|
|
NS_IF_ADDREF(pseudoTag);
|
|
|
|
return pseudoTag;
|
2000-06-22 05:38:26 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
already_AddRefed<nsStyleContext>
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsRuleNode* aRuleNode)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
PRUint32 threshold = 10; // The # of siblings we're willing to examine
|
|
|
|
// before just giving this whole thing up.
|
2001-05-03 13:20:48 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aResult = nsnull;
|
2000-06-21 20:44:59 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
if ((nsnull != mChild) || (nsnull != mEmptyChild)) {
|
|
|
|
nsStyleContext* child;
|
2001-10-24 00:01:09 +00:00
|
|
|
if (aRuleNode->IsRoot()) {
|
2001-05-31 22:19:43 +00:00
|
|
|
if (nsnull != mEmptyChild) {
|
|
|
|
child = mEmptyChild;
|
|
|
|
do {
|
2002-03-31 16:59:00 +00:00
|
|
|
if (aPseudoTag == child->mPseudoTag) {
|
2001-05-31 22:19:43 +00:00
|
|
|
aResult = child;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
child = child->mNextSibling;
|
|
|
|
threshold--;
|
|
|
|
if (threshold == 0)
|
|
|
|
break;
|
|
|
|
} while (child != mEmptyChild);
|
|
|
|
}
|
1999-09-29 03:30:47 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
else if (nsnull != mChild) {
|
|
|
|
child = mChild;
|
|
|
|
|
1999-09-29 03:30:47 +00:00
|
|
|
do {
|
2002-03-31 16:59:00 +00:00
|
|
|
if (child->mRuleNode == aRuleNode && child->mPseudoTag == aPseudoTag) {
|
2001-05-31 22:19:43 +00:00
|
|
|
aResult = child;
|
|
|
|
break;
|
|
|
|
}
|
1999-09-29 03:30:47 +00:00
|
|
|
child = child->mNextSibling;
|
2001-05-31 22:19:43 +00:00
|
|
|
threshold--;
|
|
|
|
if (threshold == 0)
|
|
|
|
break;
|
|
|
|
} while (child != mChild);
|
1999-09-29 03:30:47 +00:00
|
|
|
}
|
1998-10-27 03:03:02 +00:00
|
|
|
}
|
2003-02-22 00:32:13 +00:00
|
|
|
|
|
|
|
if (aResult)
|
|
|
|
aResult->AddRef();
|
|
|
|
|
|
|
|
return aResult;
|
1998-06-05 06:01:55 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
PRBool nsStyleContext::Equals(const nsStyleContext* aOther) const
|
1998-06-05 06:01:55 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
const nsStyleContext* other = (nsStyleContext*)aOther;
|
|
|
|
|
|
|
|
if (other != this) {
|
|
|
|
if (mParent != other->mParent) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
else if (mBits != other->mBits) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
else if (mPseudoTag != other->mPseudoTag) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
else if (mRuleNode != other->mRuleNode) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
1998-06-05 06:01:55 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
return result;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
//=========================================================================================================
|
|
|
|
|
|
|
|
const nsStyleStruct* nsStyleContext::GetStyleData(nsStyleStructID aSID)
|
1998-04-21 00:02:44 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
const nsStyleStruct* cachedData = mCachedStyleData.GetStyleData(aSID);
|
|
|
|
if (cachedData)
|
|
|
|
return cachedData; // We have computed data stored on this node in the context tree.
|
2001-11-14 08:19:13 +00:00
|
|
|
return mRuleNode->GetStyleData(aSID, this, PR_TRUE); // Our rule node will take care of it for us.
|
|
|
|
}
|
|
|
|
|
2001-11-14 08:29:11 +00:00
|
|
|
inline const nsStyleStruct* nsStyleContext::PeekStyleData(nsStyleStructID aSID)
|
2001-11-14 08:19:13 +00:00
|
|
|
{
|
|
|
|
const nsStyleStruct* cachedData = mCachedStyleData.GetStyleData(aSID);
|
|
|
|
if (cachedData)
|
|
|
|
return cachedData; // We have computed data stored on this node in the context tree.
|
|
|
|
return mRuleNode->GetStyleData(aSID, this, PR_FALSE); // Our rule node will take care of it for us.
|
1999-02-27 07:11:42 +00:00
|
|
|
}
|
1998-12-07 18:51:26 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleContext::GetBorderPaddingFor(nsStyleBorderPadding& aBorderPadding)
|
1999-02-27 07:11:42 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
nsMargin border, padding;
|
2003-05-15 03:42:21 +00:00
|
|
|
if (GetStyleBorder()->GetBorder(border)) {
|
|
|
|
if (GetStylePadding()->GetPadding(padding)) {
|
2001-12-02 00:44:45 +00:00
|
|
|
border += padding;
|
|
|
|
aBorderPadding.SetBorderPadding(border);
|
|
|
|
}
|
2000-06-21 20:44:59 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// This is an evil evil function, since it forces you to alloc your own separate copy of
|
|
|
|
// style data! Do not use this function unless you absolutely have to! You should avoid
|
|
|
|
// this at all costs! -dwh
|
|
|
|
nsStyleStruct*
|
|
|
|
nsStyleContext::GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID)
|
2000-06-21 20:44:59 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleStruct* result = nsnull;
|
|
|
|
switch (aSID) {
|
|
|
|
case eStyleStruct_Display: {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* dis = GetStyleDisplay();
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleDisplay* newDis = new (aPresContext) nsStyleDisplay(*dis);
|
2002-07-09 04:10:10 +00:00
|
|
|
SetStyle(aSID, newDis);
|
2001-05-31 22:19:43 +00:00
|
|
|
result = newDis;
|
2002-07-09 04:10:10 +00:00
|
|
|
mBits &= ~NS_STYLE_INHERIT_BIT(Display);
|
2001-05-31 22:19:43 +00:00
|
|
|
break;
|
2000-06-21 20:44:59 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
case eStyleStruct_Background: {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBackground* bg = GetStyleBackground();
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleBackground* newBG = new (aPresContext) nsStyleBackground(*bg);
|
2002-07-09 04:10:10 +00:00
|
|
|
SetStyle(aSID, newBG);
|
2001-05-31 22:19:43 +00:00
|
|
|
result = newBG;
|
2002-07-09 04:10:10 +00:00
|
|
|
mBits &= ~NS_STYLE_INHERIT_BIT(Background);
|
2001-05-31 22:19:43 +00:00
|
|
|
break;
|
2000-06-21 20:44:59 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
case eStyleStruct_Text: {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleText* text = GetStyleText();
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleText* newText = new (aPresContext) nsStyleText(*text);
|
2002-07-09 04:10:10 +00:00
|
|
|
SetStyle(aSID, newText);
|
2001-05-31 22:19:43 +00:00
|
|
|
result = newText;
|
2002-07-09 04:10:10 +00:00
|
|
|
mBits &= ~NS_STYLE_INHERIT_BIT(Text);
|
2001-05-31 22:19:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-14 03:47:02 +00:00
|
|
|
case eStyleStruct_TextReset: {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTextReset* reset = GetStyleTextReset();
|
2001-12-14 03:47:02 +00:00
|
|
|
nsStyleTextReset* newReset = new (aPresContext) nsStyleTextReset(*reset);
|
2002-07-09 04:10:10 +00:00
|
|
|
SetStyle(aSID, newReset);
|
2001-12-14 03:47:02 +00:00
|
|
|
result = newReset;
|
2002-07-09 04:10:10 +00:00
|
|
|
mBits &= ~NS_STYLE_INHERIT_BIT(TextReset);
|
2001-12-14 03:47:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
default:
|
|
|
|
NS_ERROR("Struct type not supported. Please find another way to do this if you can!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2000-06-21 20:44:59 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2002-07-09 04:10:10 +00:00
|
|
|
nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct)
|
2000-12-15 06:09:50 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
// This method should only be called from nsRuleNode! It is not a public
|
|
|
|
// method!
|
|
|
|
|
2002-07-09 04:10:10 +00:00
|
|
|
NS_ASSERTION(aSID >= 0 && aSID < nsStyleStructID_Length, "out of bounds");
|
|
|
|
|
|
|
|
// NOTE: nsCachedStyleData::GetStyleData works roughly the same way.
|
2002-08-06 13:46:35 +00:00
|
|
|
// See the comments there (in nsRuleNode.h) for more details about
|
|
|
|
// what this is doing and why.
|
|
|
|
|
2002-07-09 04:10:10 +00:00
|
|
|
const nsCachedStyleData::StyleStructInfo& info =
|
|
|
|
nsCachedStyleData::gInfo[aSID];
|
|
|
|
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, &mCachedStyleData) +
|
|
|
|
info.mCachedStyleDataOffset;
|
|
|
|
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
|
|
|
|
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
|
|
|
if (!resetOrInherit) {
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
mRuleNode->GetPresContext(getter_AddRefs(presContext));
|
|
|
|
if (mCachedStyleData.IsReset(aSID)) {
|
2001-12-02 00:44:45 +00:00
|
|
|
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
|
2002-07-09 04:10:10 +00:00
|
|
|
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
|
|
|
|
} else {
|
|
|
|
mCachedStyleData.mInheritedData =
|
|
|
|
new (presContext.get()) nsInheritedStyleData;
|
|
|
|
resetOrInherit =
|
|
|
|
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
|
2001-12-02 00:44:45 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2002-07-09 04:10:10 +00:00
|
|
|
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
|
|
|
|
*NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot) = aStruct;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2001-07-25 06:33:06 +00:00
|
|
|
void
|
|
|
|
nsStyleContext::ApplyStyleFixups(nsIPresContext* aPresContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2001-07-25 06:33:06 +00:00
|
|
|
// See if we have any text decorations.
|
|
|
|
// First see if our parent has text decorations. If our parent does, then we inherit the bit.
|
|
|
|
if (mParent && mParent->HasTextDecorations())
|
|
|
|
mBits |= NS_STYLE_HAS_TEXT_DECORATIONS;
|
|
|
|
else {
|
|
|
|
// We might have defined a decoration.
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTextReset* text = GetStyleTextReset();
|
2001-07-25 06:33:06 +00:00
|
|
|
if (text->mTextDecoration != NS_STYLE_TEXT_DECORATION_NONE &&
|
|
|
|
text->mTextDecoration != NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL)
|
|
|
|
mBits |= NS_STYLE_HAS_TEXT_DECORATIONS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Correct tables.
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
2001-07-25 06:33:06 +00:00
|
|
|
if (disp->mDisplay == NS_STYLE_DISPLAY_TABLE) {
|
|
|
|
// -moz-center and -moz-right are used for HTML's alignment
|
|
|
|
// This is covering the <div align="right"><table>...</table></div> case.
|
|
|
|
// In this case, we don't want to inherit the text alignment into the table.
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleText* text = GetStyleText();
|
2001-07-25 06:33:06 +00:00
|
|
|
|
|
|
|
if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER ||
|
|
|
|
text->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)
|
|
|
|
{
|
|
|
|
nsStyleText* uniqueText = (nsStyleText*)GetUniqueStyleData(aPresContext, eStyleStruct_Text);
|
|
|
|
uniqueText->mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-18 22:48:35 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2003-06-18 01:59:57 +00:00
|
|
|
nsStyleContext::ClearStyleData(nsIPresContext* aPresContext)
|
2001-07-25 06:33:06 +00:00
|
|
|
{
|
2003-06-18 01:59:57 +00:00
|
|
|
// First we need to clear out all of our style data.
|
|
|
|
if (mCachedStyleData.mResetData || mCachedStyleData.mInheritedData)
|
|
|
|
mCachedStyleData.Destroy(mBits, aPresContext);
|
2001-07-18 22:48:35 +00:00
|
|
|
|
2003-06-18 01:59:57 +00:00
|
|
|
mBits = 0; // Clear all bits.
|
2001-07-18 22:48:35 +00:00
|
|
|
|
2001-07-25 06:33:06 +00:00
|
|
|
ApplyStyleFixups(aPresContext);
|
2001-07-18 22:48:35 +00:00
|
|
|
|
|
|
|
if (mChild) {
|
|
|
|
nsStyleContext* child = mChild;
|
|
|
|
do {
|
2003-06-18 01:59:57 +00:00
|
|
|
child->ClearStyleData(aPresContext);
|
2001-07-18 22:48:35 +00:00
|
|
|
child = child->mNextSibling;
|
|
|
|
} while (mChild != child);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mEmptyChild) {
|
|
|
|
nsStyleContext* child = mEmptyChild;
|
|
|
|
do {
|
2003-06-18 01:59:57 +00:00
|
|
|
child->ClearStyleData(aPresContext);
|
2001-07-18 22:48:35 +00:00
|
|
|
child = child->mNextSibling;
|
|
|
|
} while (mEmptyChild != child);
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2000-12-15 06:09:50 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsChangeHint
|
|
|
|
nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
nsChangeHint hint = NS_STYLE_HINT_NONE;
|
2003-03-16 00:20:21 +00:00
|
|
|
NS_ENSURE_TRUE(aOther, hint);
|
|
|
|
// We must always ensure that we populate the structs on the new style
|
|
|
|
// context that are filled in on the old context, so that if we get
|
|
|
|
// two style changes in succession, the second of which causes a real
|
|
|
|
// style change, the PeekStyleData doesn't fail.
|
|
|
|
|
|
|
|
// If our rule nodes are the same, then we are looking at the same
|
|
|
|
// style data. We know this because CalcStyleDifference is always
|
|
|
|
// called on two style contexts that point to the same element, so we
|
|
|
|
// know that our position in the style context tree is the same and
|
|
|
|
// our position in the rule node tree is also the same.
|
|
|
|
PRBool compare = mRuleNode != aOther->mRuleNode;
|
|
|
|
|
|
|
|
nsChangeHint maxHint = NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
|
2003-03-16 04:51:56 +00:00
|
|
|
#define DO_STRUCT_DIFFERENCE(struct_) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
const nsStyle##struct_* this##struct_ = \
|
|
|
|
NS_STATIC_CAST(const nsStyle##struct_*, \
|
|
|
|
PeekStyleData(NS_GET_STYLESTRUCTID(nsStyle##struct_))); \
|
|
|
|
if (this##struct_) { \
|
|
|
|
const nsStyle##struct_* other##struct_ = \
|
|
|
|
NS_STATIC_CAST(const nsStyle##struct_*, \
|
|
|
|
aOther->GetStyleData(NS_GET_STYLESTRUCTID(nsStyle##struct_))); \
|
|
|
|
if (compare && \
|
|
|
|
!NS_IsHintSubset(maxHint, hint) && \
|
|
|
|
this##struct_ != other##struct_) { \
|
|
|
|
NS_UpdateHint(hint, this##struct_->CalcDifference(*other##struct_)); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
2003-03-16 00:20:21 +00:00
|
|
|
// We begin by examining those style structs that are capable of
|
|
|
|
// causing the maximal difference, a FRAMECHANGE.
|
|
|
|
// FRAMECHANGE Structs: Display, XUL, Content, UserInterface,
|
|
|
|
// Visibility, Quotes
|
2003-03-16 04:51:56 +00:00
|
|
|
DO_STRUCT_DIFFERENCE(Display);
|
|
|
|
DO_STRUCT_DIFFERENCE(XUL);
|
|
|
|
DO_STRUCT_DIFFERENCE(Content);
|
|
|
|
DO_STRUCT_DIFFERENCE(UserInterface);
|
|
|
|
DO_STRUCT_DIFFERENCE(Visibility);
|
2001-12-12 07:59:31 +00:00
|
|
|
#ifdef MOZ_SVG
|
2003-03-16 04:51:56 +00:00
|
|
|
DO_STRUCT_DIFFERENCE(SVG);
|
2001-12-12 07:59:31 +00:00
|
|
|
#endif
|
2003-03-16 00:20:21 +00:00
|
|
|
// If the quotes implementation is ever going to change we might not need
|
|
|
|
// a framechange here and a reflow should be sufficient. See bug 35768.
|
2003-03-16 04:51:56 +00:00
|
|
|
DO_STRUCT_DIFFERENCE(Quotes);
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2003-03-16 00:20:21 +00:00
|
|
|
// At this point, we know that the worst kind of damage we could do is
|
|
|
|
// a reflow.
|
|
|
|
maxHint = NS_STYLE_HINT_REFLOW;
|
|
|
|
|
|
|
|
// The following structs cause (as their maximal difference) a reflow
|
|
|
|
// to occur. REFLOW Structs: Font, Margin, Padding, Border, List,
|
|
|
|
// Position, Text, TextReset, Table, TableBorder
|
2003-03-16 04:51:56 +00:00
|
|
|
DO_STRUCT_DIFFERENCE(Font);
|
|
|
|
DO_STRUCT_DIFFERENCE(Margin);
|
|
|
|
DO_STRUCT_DIFFERENCE(Padding);
|
|
|
|
DO_STRUCT_DIFFERENCE(Border);
|
|
|
|
DO_STRUCT_DIFFERENCE(List);
|
|
|
|
DO_STRUCT_DIFFERENCE(Position);
|
|
|
|
DO_STRUCT_DIFFERENCE(Text);
|
|
|
|
DO_STRUCT_DIFFERENCE(TextReset);
|
|
|
|
DO_STRUCT_DIFFERENCE(Table);
|
|
|
|
DO_STRUCT_DIFFERENCE(TableBorder);
|
2003-03-16 00:20:21 +00:00
|
|
|
|
|
|
|
// At this point, we know that the worst kind of damage we could do is
|
|
|
|
// a re-render (i.e., a VISUAL change).
|
|
|
|
maxHint = NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
// The following structs cause (as their maximal difference) a
|
|
|
|
// re-render to occur. VISUAL Structs: Color, Background, Outline,
|
|
|
|
// UIReset
|
2003-03-16 04:51:56 +00:00
|
|
|
DO_STRUCT_DIFFERENCE(Color);
|
|
|
|
DO_STRUCT_DIFFERENCE(Background);
|
|
|
|
DO_STRUCT_DIFFERENCE(Outline);
|
|
|
|
DO_STRUCT_DIFFERENCE(UIReset);
|
|
|
|
|
|
|
|
#undef DO_STRUCT_DIFFERENCE
|
2000-06-21 20:44:59 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
return hint;
|
2000-06-21 20:44:59 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:14:17 +00:00
|
|
|
void
|
|
|
|
nsStyleContext::Mark()
|
|
|
|
{
|
|
|
|
// Mark our rule node.
|
|
|
|
mRuleNode->Mark();
|
|
|
|
|
|
|
|
// Mark our children (i.e., tell them to mark their rule nodes, etc.).
|
|
|
|
if (mChild) {
|
|
|
|
nsStyleContext* child = mChild;
|
|
|
|
do {
|
|
|
|
child->Mark();
|
|
|
|
child = child->mNextSibling;
|
|
|
|
} while (mChild != child);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mEmptyChild) {
|
|
|
|
nsStyleContext* child = mEmptyChild;
|
|
|
|
do {
|
|
|
|
child->Mark();
|
|
|
|
child = child->mNextSibling;
|
|
|
|
} while (mEmptyChild != child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-16 05:31:36 +00:00
|
|
|
#ifdef DEBUG
|
2001-05-31 22:19:43 +00:00
|
|
|
void nsStyleContext::List(FILE* out, PRInt32 aIndent)
|
1998-05-18 21:04:26 +00:00
|
|
|
{
|
|
|
|
// Indent
|
1999-07-05 18:43:38 +00:00
|
|
|
PRInt32 ix;
|
|
|
|
for (ix = aIndent; --ix >= 0; ) fputs(" ", out);
|
2002-09-30 14:18:27 +00:00
|
|
|
fprintf(out, "%p(%d) parent=%p ",
|
2003-02-22 00:32:13 +00:00
|
|
|
(void*)this, mRefCnt, (void *)mParent);
|
2001-12-02 00:44:45 +00:00
|
|
|
if (mPseudoTag) {
|
1998-11-03 20:18:40 +00:00
|
|
|
nsAutoString buffer;
|
|
|
|
mPseudoTag->ToString(buffer);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out);
|
1998-11-03 20:18:40 +00:00
|
|
|
fputs(" ", out);
|
|
|
|
}
|
2001-10-17 00:25:26 +00:00
|
|
|
|
2001-10-24 00:01:09 +00:00
|
|
|
if (mRuleNode) {
|
2001-10-17 00:25:26 +00:00
|
|
|
fputs("{\n", out);
|
2001-10-24 00:01:09 +00:00
|
|
|
nsRuleNode* ruleNode = mRuleNode;
|
2001-10-17 00:25:26 +00:00
|
|
|
while (ruleNode) {
|
|
|
|
nsCOMPtr<nsIStyleRule> styleRule;
|
|
|
|
ruleNode->GetRule(getter_AddRefs(styleRule));
|
|
|
|
if (styleRule) {
|
|
|
|
styleRule->List(out, aIndent + 1);
|
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
ruleNode = ruleNode->GetParent();
|
2001-10-17 00:25:26 +00:00
|
|
|
}
|
|
|
|
for (ix = aIndent; --ix >= 0; ) fputs(" ", out);
|
|
|
|
fputs("}\n", out);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("{}\n", out);
|
|
|
|
}
|
|
|
|
|
1998-06-26 05:49:01 +00:00
|
|
|
if (nsnull != mChild) {
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleContext* child = mChild;
|
1998-06-26 05:49:01 +00:00
|
|
|
do {
|
|
|
|
child->List(out, aIndent + 1);
|
1998-07-17 05:43:31 +00:00
|
|
|
child = child->mNextSibling;
|
1998-06-26 05:49:01 +00:00
|
|
|
} while (mChild != child);
|
|
|
|
}
|
1998-10-08 01:27:38 +00:00
|
|
|
if (nsnull != mEmptyChild) {
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleContext* child = mEmptyChild;
|
1998-11-03 20:18:40 +00:00
|
|
|
do {
|
|
|
|
child->List(out, aIndent + 1);
|
|
|
|
child = child->mNextSibling;
|
|
|
|
} while (mEmptyChild != child);
|
1998-10-08 01:27:38 +00:00
|
|
|
}
|
1998-05-18 21:04:26 +00:00
|
|
|
}
|
|
|
|
|
2000-12-07 15:31:40 +00:00
|
|
|
static void IndentBy(FILE* out, PRInt32 aIndent) {
|
|
|
|
while (--aIndent >= 0) fputs(" ", out);
|
|
|
|
}
|
|
|
|
// virtual
|
2001-05-31 22:19:43 +00:00
|
|
|
void nsStyleContext::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
|
2000-12-07 15:31:40 +00:00
|
|
|
{
|
|
|
|
nsAutoString str;
|
|
|
|
|
|
|
|
// FONT
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleFont* font = GetStyleFont();
|
2001-09-27 18:33:58 +00:00
|
|
|
fprintf(out, "<font %s %d %d %d />\n",
|
2001-05-31 22:19:43 +00:00
|
|
|
NS_ConvertUCS2toUTF8(font->mFont.name).get(),
|
2001-09-27 18:33:58 +00:00
|
|
|
font->mFont.size,
|
|
|
|
font->mSize,
|
2001-05-31 22:19:43 +00:00
|
|
|
font->mFlags);
|
2000-12-07 15:31:40 +00:00
|
|
|
|
|
|
|
// COLOR
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleColor* color = GetStyleColor();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<color data=\"%ld\"/>\n",
|
|
|
|
(long)color->mColor);
|
2000-12-07 15:31:40 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// BACKGROUND
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBackground* bg = GetStyleBackground();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<background data=\"%d %d %d %ld %ld %ld %s\"/>\n",
|
|
|
|
(int)bg->mBackgroundAttachment,
|
|
|
|
(int)bg->mBackgroundFlags,
|
|
|
|
(int)bg->mBackgroundRepeat,
|
|
|
|
(long)bg->mBackgroundColor,
|
2003-01-19 02:36:04 +00:00
|
|
|
(long)bg->mBackgroundXPosition.mCoord, // potentially lossy on some platforms
|
|
|
|
(long)bg->mBackgroundYPosition.mCoord, // potentially lossy on some platforms
|
2001-05-31 22:19:43 +00:00
|
|
|
NS_ConvertUCS2toUTF8(bg->mBackgroundImage).get());
|
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
// SPACING (ie. margin, padding, border, outline)
|
2000-12-07 15:31:40 +00:00
|
|
|
IndentBy(out,aIndent);
|
|
|
|
fprintf(out, "<spacing data=\"");
|
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleMargin* margin = GetStyleMargin();
|
2001-05-31 22:19:43 +00:00
|
|
|
margin->mMargin.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePadding* padding = GetStylePadding();
|
2001-05-31 22:19:43 +00:00
|
|
|
padding->mPadding.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBorder* border = GetStyleBorder();
|
2001-05-31 22:19:43 +00:00
|
|
|
border->mBorder.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
border->mBorderRadius.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleOutline* outline = GetStyleOutline();
|
2001-05-31 22:19:43 +00:00
|
|
|
outline->mOutlineRadius.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
outline->mOutlineWidth.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "%d", (int)border->mFloatEdge);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
|
|
|
// LIST
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleList* list = GetStyleList();
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "<list data=\"%d %d %s\" />\n",
|
2001-05-31 22:19:43 +00:00
|
|
|
(int)list->mListStyleType,
|
|
|
|
(int)list->mListStyleType,
|
|
|
|
NS_ConvertUCS2toUTF8(list->mListStyleImage).get());
|
2000-12-07 15:31:40 +00:00
|
|
|
|
|
|
|
// POSITION
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* pos = GetStylePosition();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<position data=\"");
|
|
|
|
pos->mOffset.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
pos->mWidth.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
pos->mMinWidth.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
pos->mMaxWidth.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
pos->mHeight.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
pos->mMinHeight.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
pos->mMaxHeight.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "%d ", (int)pos->mBoxSizing);
|
|
|
|
pos->mZIndex.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
|
|
|
// TEXT
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleText* text = GetStyleText();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<text data=\"%d %d %d ",
|
|
|
|
(int)text->mTextAlign,
|
|
|
|
(int)text->mTextTransform,
|
|
|
|
(int)text->mWhiteSpace);
|
|
|
|
text->mLetterSpacing.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
text->mLineHeight.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
text->mTextIndent.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
text->mWordSpacing.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// TEXT RESET
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTextReset* textReset = GetStyleTextReset();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<textreset data=\"%d ",
|
|
|
|
(int)textReset->mTextDecoration);
|
|
|
|
textReset->mVerticalAlign.ToString(str);
|
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
2000-12-07 15:31:40 +00:00
|
|
|
// DISPLAY
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<display data=\"%d %d %d %d %d %d %d %d %ld %ld %ld %ld %s\" />\n",
|
|
|
|
(int)disp->mPosition,
|
|
|
|
(int)disp->mDisplay,
|
|
|
|
(int)disp->mFloats,
|
|
|
|
(int)disp->mBreakType,
|
|
|
|
(int)disp->mBreakBefore,
|
|
|
|
(int)disp->mBreakAfter,
|
|
|
|
(int)disp->mOverflow,
|
|
|
|
(int)disp->mClipFlags,
|
|
|
|
(long)disp->mClip.x,
|
|
|
|
(long)disp->mClip.y,
|
|
|
|
(long)disp->mClip.width,
|
|
|
|
(long)disp->mClip.height,
|
|
|
|
NS_ConvertUCS2toUTF8(disp->mBinding).get()
|
2000-12-07 15:31:40 +00:00
|
|
|
);
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// VISIBILITY
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<visibility data=\"%d %d %f\" />\n",
|
|
|
|
(int)vis->mDirection,
|
|
|
|
(int)vis->mVisible,
|
|
|
|
(float)vis->mOpacity
|
|
|
|
);
|
|
|
|
|
2000-12-07 15:31:40 +00:00
|
|
|
// TABLE
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTable* table = GetStyleTable();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<table data=\"%d %d %d ",
|
|
|
|
(int)table->mLayoutStrategy,
|
|
|
|
(int)table->mFrame,
|
|
|
|
(int)table->mRules);
|
|
|
|
fprintf(out, "%ld %ld ",
|
|
|
|
(long)table->mCols,
|
|
|
|
(long)table->mSpan);
|
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
|
|
|
// TABLEBORDER
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTableBorder* tableBorder = GetStyleTableBorder();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<tableborder data=\"%d ",
|
|
|
|
(int)tableBorder->mBorderCollapse);
|
|
|
|
tableBorder->mBorderSpacingX.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
tableBorder->mBorderSpacingY.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "%d %d ",
|
|
|
|
(int)tableBorder->mCaptionSide,
|
|
|
|
(int)tableBorder->mEmptyCells);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
|
|
|
// CONTENT
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleContent* content = GetStyleContent();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<content data=\"%ld %ld %ld ",
|
|
|
|
(long)content->ContentCount(),
|
|
|
|
(long)content->CounterIncrementCount(),
|
|
|
|
(long)content->CounterResetCount());
|
|
|
|
// XXX: iterate over the content and counters...
|
|
|
|
content->mMarkerOffset.ToString(str);
|
2000-12-07 15:31:40 +00:00
|
|
|
fprintf(out, "%s ", NS_ConvertUCS2toUTF8(str).get());
|
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// QUOTES
|
2000-12-07 15:31:40 +00:00
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleQuotes* quotes = GetStyleQuotes();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<quotes data=\"%ld ",
|
|
|
|
(long)quotes->QuotesCount());
|
|
|
|
// XXX: iterate over the quotes...
|
|
|
|
fprintf(out, "\" />\n");
|
2000-12-07 15:31:40 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// UI
|
2000-12-07 15:31:40 +00:00
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleUserInterface* ui = GetStyleUserInterface();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<ui data=\"%d %d %d %d %s\" />\n",
|
|
|
|
(int)ui->mUserInput,
|
|
|
|
(int)ui->mUserModify,
|
|
|
|
(int)ui->mUserFocus,
|
|
|
|
(int)ui->mCursor,
|
|
|
|
NS_ConvertUCS2toUTF8(ui->mCursorImage).get());
|
|
|
|
|
|
|
|
// UIReset
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleUIReset* uiReset = GetStyleUIReset();
|
2001-05-31 22:19:43 +00:00
|
|
|
fprintf(out, "<uireset data=\"%d %d %d\" />\n",
|
|
|
|
(int)uiReset->mUserSelect,
|
|
|
|
(int)uiReset->mKeyEquivalent,
|
|
|
|
(int)uiReset->mResizer);
|
2001-05-03 13:20:48 +00:00
|
|
|
|
|
|
|
// XUL
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleXUL* xul = GetStyleXUL();
|
2001-09-25 23:35:36 +00:00
|
|
|
fprintf(out, "<xul data=\"%d %d %d %d %d %d",
|
2001-08-02 00:09:27 +00:00
|
|
|
(int)xul->mBoxAlign,
|
|
|
|
(int)xul->mBoxDirection,
|
|
|
|
(int)xul->mBoxFlex,
|
|
|
|
(int)xul->mBoxOrient,
|
2001-09-25 22:17:00 +00:00
|
|
|
(int)xul->mBoxPack,
|
|
|
|
(int)xul->mBoxOrdinal);
|
2002-02-14 14:54:06 +00:00
|
|
|
fprintf(out, "\" />\n");
|
2001-12-12 07:59:31 +00:00
|
|
|
|
|
|
|
// SVG
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
IndentBy(out,aIndent);
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleSVG* svg = GetStyleSVG();
|
2001-12-12 07:59:31 +00:00
|
|
|
fprintf(out, "<svg data=\"%d %f %f %d %f",
|
|
|
|
(int)svg->mStroke.mType,
|
|
|
|
svg->mStrokeWidth,
|
|
|
|
svg->mStrokeOpacity,
|
|
|
|
(int)svg->mFill.mType,
|
|
|
|
svg->mFillOpacity);
|
2001-05-03 13:20:48 +00:00
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
#endif
|
|
|
|
//#insert new style structs here#
|
2000-12-07 15:31:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
|
|
|
// (which comes from the presShell) to perform the allocation.
|
|
|
|
void*
|
2002-07-02 20:25:30 +00:00
|
|
|
nsStyleContext::operator new(size_t sz, nsIPresContext* aPresContext) CPP_THROW_NEW
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
// Check the recycle list first.
|
|
|
|
void* result = nsnull;
|
|
|
|
aPresContext->AllocateFromShell(sz, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Overridden to prevent the global delete from being called, since the memory
|
|
|
|
// came out of an nsIArena instead of the global delete operator's heap.
|
|
|
|
void
|
|
|
|
nsStyleContext::Destroy()
|
|
|
|
{
|
|
|
|
// Get the pres context from our rule node.
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
mRuleNode->GetPresContext(getter_AddRefs(presContext));
|
|
|
|
|
|
|
|
// Call our destructor.
|
|
|
|
this->~nsStyleContext();
|
|
|
|
|
|
|
|
// Don't let the memory be freed, since it will be recycled
|
|
|
|
// instead. Don't call the global operator delete.
|
|
|
|
presContext->FreeToShell(sizeof(nsStyleContext), this);
|
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
NS_NewStyleContext(nsStyleContext* aParentContext,
|
1998-11-03 20:18:40 +00:00
|
|
|
nsIAtom* aPseudoTag,
|
2001-10-24 00:01:09 +00:00
|
|
|
nsRuleNode* aRuleNode,
|
1998-05-26 23:14:09 +00:00
|
|
|
nsIPresContext* aPresContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleContext* context = new (aPresContext) nsStyleContext(aParentContext, aPseudoTag,
|
2001-10-24 00:01:09 +00:00
|
|
|
aRuleNode, aPresContext);
|
2003-02-22 00:32:13 +00:00
|
|
|
if (context)
|
|
|
|
context->AddRef();
|
|
|
|
return context;
|
2000-06-21 20:44:59 +00:00
|
|
|
}
|
|
|
|
|