2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* 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/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04: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-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-08-02 18:34:55 +04:00
|
|
|
* Contributor(s):
|
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
2004-01-08 01:30:53 +03:00
|
|
|
* Brian Ryner <bryner@brianryner.com>
|
2008-07-26 20:14:48 +04:00
|
|
|
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* 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"),
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the container for the style sheets that apply to a presentation, and
|
|
|
|
* the internal API that the style system exposes for creating (and
|
|
|
|
* potentially re-creating) style contexts
|
|
|
|
*/
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsStyleSet.h"
|
|
|
|
#include "nsNetUtil.h"
|
2010-05-12 00:41:47 +04:00
|
|
|
#include "nsCSSStyleSheet.h"
|
1999-01-23 10:01:57 +03:00
|
|
|
#include "nsIDocument.h"
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsRuleWalker.h"
|
|
|
|
#include "nsStyleContext.h"
|
2011-03-11 05:48:57 +03:00
|
|
|
#include "mozilla/css/StyleRule.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2003-02-23 20:28:25 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2004-07-28 11:08:41 +04:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIFrame.h"
|
2007-10-12 22:37:51 +04:00
|
|
|
#include "nsContentUtils.h"
|
2011-08-23 03:34:12 +04:00
|
|
|
#include "nsRuleData.h"
|
2009-08-01 19:53:40 +04:00
|
|
|
#include "nsRuleProcessorData.h"
|
2009-10-08 07:22:42 +04:00
|
|
|
#include "nsTransitionManager.h"
|
2011-04-12 10:18:44 +04:00
|
|
|
#include "nsAnimationManager.h"
|
2011-04-21 21:35:52 +04:00
|
|
|
#include "nsEventStates.h"
|
2010-05-05 22:18:05 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2010-04-30 17:12:06 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2010-04-30 17:12:06 +04:00
|
|
|
using namespace mozilla::dom;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2008-12-12 21:59:03 +03:00
|
|
|
NS_IMPL_ISUPPORTS1(nsEmptyStyleRule, nsIStyleRule)
|
|
|
|
|
2010-05-20 06:28:00 +04:00
|
|
|
/* virtual */ void
|
2008-12-12 21:59:03 +03:00
|
|
|
nsEmptyStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2010-05-20 06:28:00 +04:00
|
|
|
/* virtual */ void
|
2008-12-12 21:59:03 +03:00
|
|
|
nsEmptyStyleRule::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-08-23 03:34:12 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsInitialStyleRule, nsIStyleRule)
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsInitialStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
// Iterate over the property groups
|
|
|
|
for (nsStyleStructID sid = nsStyleStructID(0);
|
|
|
|
sid < nsStyleStructID_Length; sid = nsStyleStructID(sid + 1)) {
|
|
|
|
if (aRuleData->mSIDs & (1 << sid)) {
|
|
|
|
// Iterate over nsCSSValues within the property group
|
|
|
|
nsCSSValue * const value_start =
|
|
|
|
aRuleData->mValueStorage + aRuleData->mValueOffsets[sid];
|
|
|
|
for (nsCSSValue *value = value_start,
|
|
|
|
*value_end = value + nsCSSProps::PropertyCountInStruct(sid);
|
|
|
|
value != value_end; ++value) {
|
|
|
|
// If MathML is disabled take care not to set MathML properties (or we
|
|
|
|
// will trigger assertions in nsRuleNode)
|
|
|
|
if (sid == eStyleStruct_Font &&
|
|
|
|
!aRuleData->mPresContext->Document()->GetMathMLEnabled()) {
|
|
|
|
size_t index = value - value_start;
|
|
|
|
if (index == nsCSSProps::PropertyIndexInStruct(
|
|
|
|
eCSSProperty_script_level) ||
|
|
|
|
index == nsCSSProps::PropertyIndexInStruct(
|
|
|
|
eCSSProperty_script_size_multiplier) ||
|
|
|
|
index == nsCSSProps::PropertyIndexInStruct(
|
|
|
|
eCSSProperty_script_min_size)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value->GetUnit() == eCSSUnit_Null) {
|
|
|
|
value->SetInitialValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* virtual */ void
|
|
|
|
nsInitialStyleRule::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-26 02:22:38 +03:00
|
|
|
static const nsStyleSet::sheetType gCSSSheetTypes[] = {
|
|
|
|
nsStyleSet::eAgentSheet,
|
|
|
|
nsStyleSet::eUserSheet,
|
|
|
|
nsStyleSet::eDocSheet,
|
|
|
|
nsStyleSet::eOverrideSheet
|
|
|
|
};
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleSet::nsStyleSet()
|
|
|
|
: mRuleTree(nsnull),
|
2004-01-08 22:23:12 +03:00
|
|
|
mBatching(0),
|
2011-10-17 18:59:28 +04:00
|
|
|
mInShutdown(false),
|
|
|
|
mAuthorStyleDisabled(false),
|
|
|
|
mInReconstruct(false),
|
2012-04-17 23:22:49 +04:00
|
|
|
mDirty(0),
|
|
|
|
mUnusedRuleNodeCount(0)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-01 22:24:38 +04:00
|
|
|
size_t
|
2011-12-09 09:01:52 +04:00
|
|
|
nsStyleSet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
2011-08-01 22:24:38 +04:00
|
|
|
{
|
2012-01-25 12:52:51 +04:00
|
|
|
size_t n = aMallocSizeOf(this);
|
2011-08-01 22:25:20 +04:00
|
|
|
|
|
|
|
for (int i = 0; i < eSheetTypeCount; i++) {
|
|
|
|
if (mRuleProcessors[i]) {
|
2011-12-09 09:01:52 +04:00
|
|
|
n += mRuleProcessors[i]->SizeOfIncludingThis(aMallocSizeOf);
|
2011-08-01 22:25:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
2011-08-01 22:24:38 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleSet::Init(nsPresContext *aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2008-12-12 21:59:03 +03:00
|
|
|
mFirstLineRule = new nsEmptyStyleRule;
|
|
|
|
mFirstLetterRule = new nsEmptyStyleRule;
|
|
|
|
if (!mFirstLineRule || !mFirstLetterRule) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2004-01-08 22:23:12 +03:00
|
|
|
if (!BuildDefaultStyleData(aPresContext)) {
|
|
|
|
mDefaultStyleData.Destroy(0, aPresContext);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mRuleTree = nsRuleNode::CreateRootNode(aPresContext);
|
|
|
|
if (!mRuleTree) {
|
|
|
|
mDefaultStyleData.Destroy(0, aPresContext);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-10-08 07:09:31 +04:00
|
|
|
}
|
|
|
|
|
2011-04-12 10:18:44 +04:00
|
|
|
GatherRuleProcessors(eAnimationSheet);
|
2009-10-08 07:22:42 +04:00
|
|
|
GatherRuleProcessors(eTransitionSheet);
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
return NS_OK;
|
2000-08-12 10:28:02 +04:00
|
|
|
}
|
|
|
|
|
2007-07-25 21:14:13 +04:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::BeginReconstruct()
|
|
|
|
{
|
2009-01-30 07:39:23 +03:00
|
|
|
NS_ASSERTION(!mInReconstruct, "Unmatched begin/end?");
|
2007-07-25 21:14:13 +04:00
|
|
|
NS_ASSERTION(mRuleTree, "Reconstructing before first construction?");
|
|
|
|
|
|
|
|
// Create a new rule tree root
|
|
|
|
nsRuleNode* newTree =
|
|
|
|
nsRuleNode::CreateRootNode(mRuleTree->GetPresContext());
|
|
|
|
if (!newTree)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
// Save the old rule tree so we can destroy it later
|
2009-01-30 07:39:23 +03:00
|
|
|
if (!mOldRuleTrees.AppendElement(mRuleTree)) {
|
|
|
|
newTree->Destroy();
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2007-07-25 21:14:13 +04:00
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
// We need to keep mRoots so that the rule tree GC will only free the
|
|
|
|
// rule trees that really aren't referenced anymore (which should be
|
|
|
|
// all of them, if there are no bugs in reresolution code).
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mInReconstruct = true;
|
2007-07-25 21:14:13 +04:00
|
|
|
mRuleTree = newTree;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSet::EndReconstruct()
|
|
|
|
{
|
2009-01-30 07:39:23 +03:00
|
|
|
NS_ASSERTION(mInReconstruct, "Unmatched begin/end?");
|
2011-10-17 18:59:28 +04:00
|
|
|
mInReconstruct = false;
|
2009-01-17 00:32:09 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
for (PRInt32 i = mRoots.Length() - 1; i >= 0; --i) {
|
|
|
|
nsRuleNode *n = mRoots[i]->GetRuleNode();
|
|
|
|
while (n->GetParent()) {
|
|
|
|
n = n->GetParent();
|
|
|
|
}
|
|
|
|
// Since nsStyleContext's mParent and mRuleNode are immutable, and
|
|
|
|
// style contexts own their parents, and nsStyleContext asserts in
|
|
|
|
// its constructor that the style context and its parent are in the
|
|
|
|
// same rule tree, we don't need to check any of the children of
|
|
|
|
// mRoots; we only need to check the rule nodes of mRoots
|
|
|
|
// themselves.
|
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
NS_ASSERTION(n == mRuleTree, "style context has old rule node");
|
2009-01-17 00:32:09 +03:00
|
|
|
}
|
|
|
|
#endif
|
2009-01-30 07:39:23 +03:00
|
|
|
// This *should* destroy the only element of mOldRuleTrees, but in
|
|
|
|
// case of some bugs (which would trigger the above assertions), it
|
|
|
|
// won't.
|
|
|
|
GCRuleTrees();
|
2007-07-25 21:14:13 +04:00
|
|
|
}
|
|
|
|
|
2008-11-03 05:29:51 +03:00
|
|
|
void
|
|
|
|
nsStyleSet::SetQuirkStyleSheet(nsIStyleSheet* aQuirkStyleSheet)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aQuirkStyleSheet, "Must have quirk sheet if this is called");
|
|
|
|
NS_ASSERTION(!mQuirkStyleSheet, "Multiple calls to SetQuirkStyleSheet?");
|
|
|
|
NS_ASSERTION(mSheets[eAgentSheet].IndexOf(aQuirkStyleSheet) != -1,
|
|
|
|
"Quirk style sheet not one of our agent sheets?");
|
|
|
|
mQuirkStyleSheet = aQuirkStyleSheet;
|
|
|
|
}
|
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
nsresult
|
2004-07-28 11:08:41 +04:00
|
|
|
nsStyleSet::GatherRuleProcessors(sheetType aType)
|
1999-10-08 07:09:31 +04:00
|
|
|
{
|
2004-07-28 11:08:41 +04:00
|
|
|
mRuleProcessors[aType] = nsnull;
|
2004-08-05 15:38:42 +04:00
|
|
|
if (mAuthorStyleDisabled && (aType == eDocSheet ||
|
2011-01-15 05:14:41 +03:00
|
|
|
aType == ePresHintSheet ||
|
2004-08-05 15:38:42 +04:00
|
|
|
aType == eStyleAttrSheet)) {
|
|
|
|
//don't regather if this level is disabled
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-04-12 10:18:44 +04:00
|
|
|
if (aType == eAnimationSheet) {
|
|
|
|
// We have no sheet for the animations level; just a rule
|
|
|
|
// processor. (XXX: We should probably do this for the other
|
|
|
|
// non-CSS levels too!)
|
|
|
|
mRuleProcessors[aType] = PresContext()->AnimationManager();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-10-08 07:22:42 +04:00
|
|
|
if (aType == eTransitionSheet) {
|
|
|
|
// We have no sheet for the transitions level; just a rule
|
|
|
|
// processor. (XXX: We should probably do this for the other
|
|
|
|
// non-CSS levels too!)
|
|
|
|
mRuleProcessors[aType] = PresContext()->TransitionManager();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-01-08 01:30:53 +03:00
|
|
|
if (mSheets[aType].Count()) {
|
2004-07-28 11:08:41 +04:00
|
|
|
switch (aType) {
|
|
|
|
case eAgentSheet:
|
|
|
|
case eUserSheet:
|
|
|
|
case eDocSheet:
|
|
|
|
case eOverrideSheet: {
|
|
|
|
// levels containing CSS stylesheets
|
|
|
|
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
2010-05-12 00:41:47 +04:00
|
|
|
nsTArray<nsRefPtr<nsCSSStyleSheet> > cssSheets(sheets.Count());
|
2004-07-28 11:08:41 +04:00
|
|
|
for (PRInt32 i = 0, i_end = sheets.Count(); i < i_end; ++i) {
|
2010-05-12 00:41:47 +04:00
|
|
|
nsRefPtr<nsCSSStyleSheet> cssSheet = do_QueryObject(sheets[i]);
|
2004-07-28 11:08:41 +04:00
|
|
|
NS_ASSERTION(cssSheet, "not a CSS sheet");
|
2010-05-12 00:41:47 +04:00
|
|
|
cssSheets.AppendElement(cssSheet);
|
2004-07-28 11:08:41 +04:00
|
|
|
}
|
2008-11-27 06:50:16 +03:00
|
|
|
mRuleProcessors[aType] = new nsCSSRuleProcessor(cssSheets,
|
|
|
|
PRUint8(aType));
|
2004-07-28 11:08:41 +04:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// levels containing non-CSS stylesheets
|
|
|
|
NS_ASSERTION(mSheets[aType].Count() == 1, "only one sheet per level");
|
|
|
|
mRuleProcessors[aType] = do_QueryInterface(mSheets[aType][0]);
|
|
|
|
break;
|
|
|
|
}
|
1999-10-08 07:09:31 +04:00
|
|
|
}
|
2000-08-12 10:28:02 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-10-08 07:09:31 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-01-08 01:30:53 +03:00
|
|
|
NS_PRECONDITION(aSheet, "null arg");
|
2010-05-14 23:05:14 +04:00
|
|
|
NS_ASSERTION(aSheet->IsApplicable(),
|
2010-05-13 00:18:47 +04:00
|
|
|
"Inapplicable sheet being placed in style set");
|
2004-01-08 01:30:53 +03:00
|
|
|
mSheets[aType].RemoveObject(aSheet);
|
|
|
|
if (!mSheets[aType].AppendObject(aSheet))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
if (!mBatching)
|
|
|
|
return GatherRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDirty |= 1 << aType;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::PrependStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-01-08 01:30:53 +03:00
|
|
|
NS_PRECONDITION(aSheet, "null arg");
|
2010-05-14 23:05:14 +04:00
|
|
|
NS_ASSERTION(aSheet->IsApplicable(),
|
2010-05-13 00:18:47 +04:00
|
|
|
"Inapplicable sheet being placed in style set");
|
2004-01-08 01:30:53 +03:00
|
|
|
mSheets[aType].RemoveObject(aSheet);
|
|
|
|
if (!mSheets[aType].InsertObjectAt(aSheet, 0))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
if (!mBatching)
|
|
|
|
return GatherRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDirty |= 1 << aType;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::RemoveStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-01-08 01:30:53 +03:00
|
|
|
NS_PRECONDITION(aSheet, "null arg");
|
2010-05-14 23:05:14 +04:00
|
|
|
NS_ASSERTION(aSheet->IsComplete(),
|
2010-05-13 00:18:47 +04:00
|
|
|
"Incomplete sheet being removed from style set");
|
2004-01-08 01:30:53 +03:00
|
|
|
mSheets[aType].RemoveObject(aSheet);
|
|
|
|
if (!mBatching)
|
|
|
|
return GatherRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDirty |= 1 << aType;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::ReplaceSheets(sheetType aType,
|
|
|
|
const nsCOMArray<nsIStyleSheet> &aNewSheets)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-01-08 01:30:53 +03:00
|
|
|
mSheets[aType].Clear();
|
2004-01-08 22:23:12 +03:00
|
|
|
if (!mSheets[aType].AppendObjects(aNewSheets))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
if (!mBatching)
|
|
|
|
return GatherRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDirty |= 1 << aType;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2004-08-05 15:38:42 +04:00
|
|
|
nsStyleSet::GetAuthorStyleDisabled()
|
|
|
|
{
|
|
|
|
return mAuthorStyleDisabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-09-29 10:19:26 +04:00
|
|
|
nsStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled)
|
2004-08-05 15:38:42 +04:00
|
|
|
{
|
|
|
|
if (aStyleDisabled == !mAuthorStyleDisabled) {
|
|
|
|
mAuthorStyleDisabled = aStyleDisabled;
|
|
|
|
BeginUpdate();
|
|
|
|
mDirty |= 1 << eDocSheet |
|
2011-01-15 05:14:41 +03:00
|
|
|
1 << ePresHintSheet |
|
2004-08-05 15:38:42 +04:00
|
|
|
1 << eStyleAttrSheet;
|
|
|
|
return EndUpdate();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// -------- Doc Sheets
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-01-08 22:23:12 +03:00
|
|
|
NS_PRECONDITION(aSheet && aDocument, "null arg");
|
2010-05-14 23:05:14 +04:00
|
|
|
NS_ASSERTION(aSheet->IsApplicable(),
|
2010-05-13 00:18:47 +04:00
|
|
|
"Inapplicable sheet being placed in style set");
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
nsCOMArray<nsIStyleSheet>& docSheets = mSheets[eDocSheet];
|
|
|
|
|
|
|
|
docSheets.RemoveObject(aSheet);
|
2004-07-28 11:08:41 +04:00
|
|
|
// lowest index first
|
2004-01-08 01:30:53 +03:00
|
|
|
PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet);
|
|
|
|
PRInt32 count = docSheets.Count();
|
2004-07-28 11:08:41 +04:00
|
|
|
PRInt32 index;
|
|
|
|
for (index = 0; index < count; index++) {
|
2004-01-08 01:30:53 +03:00
|
|
|
nsIStyleSheet* sheet = docSheets.ObjectAt(index);
|
|
|
|
PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
|
2004-07-28 11:08:41 +04:00
|
|
|
if (sheetDocIndex > newDocIndex)
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2004-07-28 11:08:41 +04:00
|
|
|
if (!docSheets.InsertObjectAt(aSheet, index))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-01-08 01:30:53 +03:00
|
|
|
if (!mBatching)
|
|
|
|
return GatherRuleProcessors(eDocSheet);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDirty |= 1 << eDocSheet;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Batching
|
2001-11-06 13:04:05 +03:00
|
|
|
void
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleSet::BeginUpdate()
|
2001-11-06 13:04:05 +03:00
|
|
|
{
|
2004-01-08 22:23:12 +03:00
|
|
|
++mBatching;
|
2001-11-06 13:04:05 +03:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
|
|
|
nsStyleSet::EndUpdate()
|
2001-11-06 13:04:05 +03:00
|
|
|
{
|
2004-01-08 22:23:12 +03:00
|
|
|
NS_ASSERTION(mBatching > 0, "Unbalanced EndUpdate");
|
|
|
|
if (--mBatching) {
|
|
|
|
// We're not completely done yet.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
for (int i = 0; i < eSheetTypeCount; ++i) {
|
2004-01-08 22:23:12 +03:00
|
|
|
if (mDirty & (1 << i)) {
|
2004-07-28 11:08:41 +04:00
|
|
|
nsresult rv = GatherRuleProcessors(sheetType(i));
|
2004-01-08 01:30:53 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2001-11-06 13:04:05 +03:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDirty = 0;
|
|
|
|
return NS_OK;
|
2001-11-06 13:04:05 +03:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsStyleSet::EnableQuirkStyleSheet(bool aEnable)
|
2000-06-03 01:45:06 +04:00
|
|
|
{
|
2008-08-06 21:42:56 +04:00
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool oldEnabled;
|
2008-11-26 00:27:54 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMCSSStyleSheet> domSheet =
|
|
|
|
do_QueryInterface(mQuirkStyleSheet);
|
|
|
|
domSheet->GetDisabled(&oldEnabled);
|
|
|
|
oldEnabled = !oldEnabled;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mQuirkStyleSheet->SetEnabled(aEnable);
|
|
|
|
#ifdef DEBUG
|
|
|
|
// This should always be OK, since SetEnabled should call
|
|
|
|
// ClearRuleCascades.
|
|
|
|
// Note that we can hit this codepath multiple times when document.open()
|
|
|
|
// (potentially implied) happens multiple times.
|
|
|
|
if (mRuleProcessors[eAgentSheet] && aEnable != oldEnabled) {
|
2008-11-03 05:29:51 +03:00
|
|
|
static_cast<nsCSSRuleProcessor*>(static_cast<nsIStyleRuleProcessor*>(
|
|
|
|
mRuleProcessors[eAgentSheet]))->AssertQuirksChangeOK();
|
|
|
|
}
|
2008-08-06 21:42:56 +04:00
|
|
|
#endif
|
2000-06-03 01:45:06 +04:00
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
template<class T>
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2004-01-08 01:30:53 +03:00
|
|
|
EnumRulesMatching(nsIStyleRuleProcessor* aProcessor, void* aData)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2009-12-11 10:37:40 +03:00
|
|
|
T* data = static_cast<T*>(aData);
|
2004-08-05 22:26:14 +04:00
|
|
|
aProcessor->RulesMatching(data);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2011-05-01 02:16:19 +04:00
|
|
|
static inline bool
|
|
|
|
IsMoreSpecificThanAnimation(nsRuleNode *aRuleNode)
|
|
|
|
{
|
|
|
|
return !aRuleNode->IsRoot() &&
|
|
|
|
(aRuleNode->GetLevel() == nsStyleSet::eTransitionSheet ||
|
|
|
|
(aRuleNode->IsImportantRule() &&
|
|
|
|
(aRuleNode->GetLevel() == nsStyleSet::eAgentSheet ||
|
|
|
|
aRuleNode->GetLevel() == nsStyleSet::eUserSheet)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsIStyleRule*
|
|
|
|
GetAnimationRule(nsRuleNode *aRuleNode)
|
|
|
|
{
|
|
|
|
nsRuleNode *n = aRuleNode;
|
|
|
|
while (IsMoreSpecificThanAnimation(n)) {
|
|
|
|
n = n->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n->IsRoot() || n->GetLevel() != nsStyleSet::eAnimationSheet) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n->GetRule();
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsRuleNode*
|
|
|
|
ReplaceAnimationRule(nsRuleNode *aOldRuleNode,
|
|
|
|
nsIStyleRule *aOldAnimRule,
|
|
|
|
nsIStyleRule *aNewAnimRule)
|
|
|
|
{
|
|
|
|
nsTArray<nsRuleNode*> moreSpecificNodes;
|
|
|
|
|
|
|
|
nsRuleNode *n = aOldRuleNode;
|
|
|
|
while (IsMoreSpecificThanAnimation(n)) {
|
|
|
|
moreSpecificNodes.AppendElement(n);
|
|
|
|
n = n->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aOldAnimRule) {
|
|
|
|
NS_ABORT_IF_FALSE(n->GetRule() == aOldAnimRule, "wrong rule");
|
|
|
|
NS_ABORT_IF_FALSE(n->GetLevel() == nsStyleSet::eAnimationSheet,
|
|
|
|
"wrong level");
|
|
|
|
n = n->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(!IsMoreSpecificThanAnimation(n) &&
|
|
|
|
n->GetLevel() != nsStyleSet::eAnimationSheet,
|
|
|
|
"wrong level");
|
|
|
|
|
|
|
|
if (aNewAnimRule) {
|
2011-10-17 18:59:28 +04:00
|
|
|
n = n->Transition(aNewAnimRule, nsStyleSet::eAnimationSheet, false);
|
2011-05-01 02:16:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (PRUint32 i = moreSpecificNodes.Length(); i-- != 0; ) {
|
|
|
|
nsRuleNode *oldNode = moreSpecificNodes[i];
|
|
|
|
n = n->Transition(oldNode->GetRule(), oldNode->GetLevel(),
|
|
|
|
oldNode->IsImportantRule());
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2002-03-08 02:48:26 +03:00
|
|
|
/**
|
|
|
|
* |GetContext| implements sharing of style contexts (not just the data
|
|
|
|
* on the rule nodes) between siblings and cousins of the same
|
|
|
|
* generation. (It works for cousins of the same generation since
|
|
|
|
* |aParentContext| could itself be a shared context.)
|
|
|
|
*/
|
2003-02-22 03:32:13 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-02 10:07:42 +04:00
|
|
|
nsStyleSet::GetContext(nsStyleContext* aParentContext,
|
2009-10-03 01:06:42 +04:00
|
|
|
nsRuleNode* aRuleNode,
|
2010-04-03 05:58:27 +04:00
|
|
|
// aVisitedRuleNode may be null; if it is null
|
|
|
|
// it means that we don't need to force creation
|
|
|
|
// of a StyleIfVisited. (But if we make one
|
|
|
|
// because aParentContext has one, then aRuleNode
|
|
|
|
// should be used.)
|
|
|
|
nsRuleNode* aVisitedRuleNode,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsLink,
|
|
|
|
bool aIsVisitedLink,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsIAtom* aPseudoTag,
|
2011-04-12 10:18:44 +04:00
|
|
|
nsCSSPseudoElements::Type aPseudoType,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDoAnimations,
|
2011-04-12 10:18:44 +04:00
|
|
|
Element* aElementForAnimation)
|
1998-05-19 01:05:52 +04:00
|
|
|
{
|
2009-12-11 10:37:40 +03:00
|
|
|
NS_PRECONDITION((!aPseudoTag &&
|
|
|
|
aPseudoType ==
|
|
|
|
nsCSSPseudoElements::ePseudo_NotPseudoElement) ||
|
|
|
|
(aPseudoTag &&
|
|
|
|
nsCSSPseudoElements::GetPseudoType(aPseudoTag) ==
|
|
|
|
aPseudoType),
|
|
|
|
"Pseudo mismatch");
|
|
|
|
|
2010-06-15 00:06:48 +04:00
|
|
|
if (aVisitedRuleNode == aRuleNode) {
|
|
|
|
// No need to force creation of a visited style in this case.
|
|
|
|
aVisitedRuleNode = nsnull;
|
|
|
|
}
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
// Ensure |aVisitedRuleNode != nsnull| corresponds to the need to
|
|
|
|
// create an if-visited style context, and that in that case, we have
|
|
|
|
// parentIfVisited set correctly.
|
|
|
|
nsStyleContext *parentIfVisited =
|
|
|
|
aParentContext ? aParentContext->GetStyleIfVisited() : nsnull;
|
|
|
|
if (parentIfVisited) {
|
|
|
|
if (!aVisitedRuleNode) {
|
|
|
|
aVisitedRuleNode = aRuleNode;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aVisitedRuleNode) {
|
|
|
|
parentIfVisited = aParentContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIsLink) {
|
|
|
|
// If this node is a link, we want its visited's style context's
|
|
|
|
// parent to be the regular style context of its parent, because
|
|
|
|
// only the visitedness of the relevant link should influence style.
|
|
|
|
parentIfVisited = aParentContext;
|
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
nsRefPtr<nsStyleContext> result;
|
2002-03-31 20:59:00 +04:00
|
|
|
if (aParentContext)
|
2010-04-03 05:58:26 +04:00
|
|
|
result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode,
|
2010-04-03 05:58:27 +04:00
|
|
|
aVisitedRuleNode,
|
2010-04-03 05:58:27 +04:00
|
|
|
aIsVisitedLink);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
2000-06-22 00:44:59 +04:00
|
|
|
#ifdef NOISY_DEBUG
|
2002-03-31 20:59:00 +04:00
|
|
|
if (result)
|
2000-10-29 02:17:53 +04:00
|
|
|
fprintf(stdout, "--- SharedSC %d ---\n", ++gSharedCount);
|
2002-03-31 20:59:00 +04:00
|
|
|
else
|
|
|
|
fprintf(stdout, "+++ NewSC %d +++\n", ++gNewCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
2003-03-06 22:14:17 +03:00
|
|
|
if (!result) {
|
2009-12-11 10:37:40 +03:00
|
|
|
result = NS_NewStyleContext(aParentContext, aPseudoTag, aPseudoType,
|
2010-04-03 05:58:27 +04:00
|
|
|
aRuleNode, PresContext());
|
|
|
|
if (!result)
|
|
|
|
return nsnull;
|
|
|
|
if (aVisitedRuleNode) {
|
|
|
|
nsRefPtr<nsStyleContext> resultIfVisited =
|
|
|
|
NS_NewStyleContext(parentIfVisited, aPseudoTag, aPseudoType,
|
|
|
|
aVisitedRuleNode, PresContext());
|
|
|
|
if (!resultIfVisited) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
2010-04-30 05:15:44 +04:00
|
|
|
if (!parentIfVisited) {
|
|
|
|
mRoots.AppendElement(resultIfVisited);
|
|
|
|
}
|
2010-04-06 23:42:41 +04:00
|
|
|
resultIfVisited->SetIsStyleIfVisited();
|
2010-04-03 05:58:27 +04:00
|
|
|
result->SetStyleIfVisited(resultIfVisited.forget());
|
2010-04-03 05:58:27 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool relevantLinkVisited =
|
2010-04-03 05:58:27 +04:00
|
|
|
aIsLink ? aIsVisitedLink
|
|
|
|
: (aParentContext && aParentContext->RelevantLinkVisited());
|
|
|
|
if (relevantLinkVisited) {
|
|
|
|
result->AddStyleBit(NS_STYLE_RELEVANT_LINK_VISITED);
|
|
|
|
}
|
2010-04-03 05:58:27 +04:00
|
|
|
}
|
|
|
|
if (!aParentContext)
|
2003-03-06 22:14:17 +03:00
|
|
|
mRoots.AppendElement(result);
|
|
|
|
}
|
2009-12-11 10:37:40 +03:00
|
|
|
else {
|
|
|
|
NS_ASSERTION(result->GetPseudoType() == aPseudoType, "Unexpected type");
|
|
|
|
NS_ASSERTION(result->GetPseudo() == aPseudoTag, "Unexpected pseudo");
|
|
|
|
}
|
2002-03-31 20:59:00 +04:00
|
|
|
|
2011-04-12 10:18:44 +04:00
|
|
|
if (aDoAnimations) {
|
|
|
|
// Normally the animation manager has already added the correct
|
|
|
|
// style rule. However, if the animation-name just changed, it
|
|
|
|
// might have been wrong. So ask it to double-check based on the
|
|
|
|
// resulting style context.
|
2011-05-01 02:16:19 +04:00
|
|
|
nsIStyleRule *oldAnimRule = GetAnimationRule(aRuleNode);
|
2011-04-12 10:18:44 +04:00
|
|
|
nsIStyleRule *animRule = PresContext()->AnimationManager()->
|
|
|
|
CheckAnimationRule(result, aElementForAnimation);
|
|
|
|
NS_ABORT_IF_FALSE(result->GetRuleNode() == aRuleNode,
|
|
|
|
"unexpected rule node");
|
|
|
|
NS_ABORT_IF_FALSE(!result->GetStyleIfVisited() == !aVisitedRuleNode,
|
|
|
|
"unexpected visited rule node");
|
|
|
|
NS_ABORT_IF_FALSE(!aVisitedRuleNode ||
|
|
|
|
result->GetStyleIfVisited()->GetRuleNode() ==
|
|
|
|
aVisitedRuleNode,
|
|
|
|
"unexpected visited rule node");
|
2011-05-01 02:16:19 +04:00
|
|
|
if (oldAnimRule != animRule) {
|
|
|
|
nsRuleNode *ruleNode =
|
|
|
|
ReplaceAnimationRule(aRuleNode, oldAnimRule, animRule);
|
|
|
|
nsRuleNode *visitedRuleNode = aVisitedRuleNode
|
|
|
|
? ReplaceAnimationRule(aVisitedRuleNode, oldAnimRule, animRule)
|
|
|
|
: nsnull;
|
2011-04-12 10:18:44 +04:00
|
|
|
result = GetContext(aParentContext, ruleNode, visitedRuleNode,
|
|
|
|
aIsLink, aIsVisitedLink,
|
2011-10-17 18:59:28 +04:00
|
|
|
aPseudoTag, aPseudoType, false, nsnull);
|
2011-04-12 10:18:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-01 15:43:31 +04:00
|
|
|
if (aElementForAnimation && aElementForAnimation->IsHTML(nsGkAtoms::body) &&
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement &&
|
|
|
|
PresContext()->CompatibilityMode() == eCompatibility_NavQuirks) {
|
|
|
|
nsIDocument* doc = aElementForAnimation->GetCurrentDoc();
|
|
|
|
if (doc && doc->GetBodyElement() == aElementForAnimation) {
|
|
|
|
// Update the prescontext's body color
|
|
|
|
PresContext()->SetBodyTextColor(result->GetStyleColor()->mColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return result.forget();
|
1998-05-19 01:05:52 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
void
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleSet::AddImportantRules(nsRuleNode* aCurrLevelNode,
|
2009-10-03 01:06:42 +04:00
|
|
|
nsRuleNode* aLastPrevLevelNode,
|
|
|
|
nsRuleWalker* aRuleWalker)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-12-12 09:36:34 +03:00
|
|
|
NS_ASSERTION(aCurrLevelNode &&
|
|
|
|
aCurrLevelNode != aLastPrevLevelNode, "How did we get here?");
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2009-12-11 01:36:02 +03:00
|
|
|
nsAutoTArray<nsIStyleRule*, 16> importantRules;
|
2008-07-14 00:57:38 +04:00
|
|
|
for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode;
|
|
|
|
node = node->GetParent()) {
|
2009-12-11 01:36:02 +03:00
|
|
|
// We guarantee that we never walk the root node here, so no need
|
2011-05-24 00:45:43 +04:00
|
|
|
// to null-check GetRule(). Furthermore, it must be a CSS rule.
|
|
|
|
NS_ASSERTION(nsRefPtr<css::StyleRule>(do_QueryObject(node->GetRule())),
|
|
|
|
"Unexpected non-CSS rule");
|
|
|
|
|
|
|
|
nsIStyleRule* impRule =
|
|
|
|
static_cast<css::StyleRule*>(node->GetRule())->GetImportantRule();
|
2009-12-11 01:36:02 +03:00
|
|
|
if (impRule)
|
|
|
|
importantRules.AppendElement(impRule);
|
2008-07-14 00:57:38 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2009-12-11 01:36:02 +03:00
|
|
|
NS_ASSERTION(importantRules.Length() != 0,
|
|
|
|
"Why did we think there were important rules?");
|
|
|
|
|
2008-07-14 00:57:38 +04:00
|
|
|
for (PRUint32 i = importantRules.Length(); i-- != 0; ) {
|
2009-10-03 01:06:42 +04:00
|
|
|
aRuleWalker->Forward(importantRules[i]);
|
1998-09-11 06:05:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-16 00:30:30 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsStyleSet::AssertNoImportantRules(nsRuleNode* aCurrLevelNode,
|
|
|
|
nsRuleNode* aLastPrevLevelNode)
|
|
|
|
{
|
2008-07-14 00:57:38 +04:00
|
|
|
if (!aCurrLevelNode)
|
2004-07-16 00:30:30 +04:00
|
|
|
return;
|
|
|
|
|
2008-07-14 00:57:38 +04:00
|
|
|
for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode;
|
|
|
|
node = node->GetParent()) {
|
2011-05-24 00:45:43 +04:00
|
|
|
nsRefPtr<css::StyleRule> rule(do_QueryObject(node->GetRule()));
|
|
|
|
NS_ASSERTION(rule, "Unexpected non-CSS rule");
|
|
|
|
|
|
|
|
NS_ASSERTION(!rule->GetImportantRule(), "Unexpected important rule");
|
2004-07-16 00:30:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSet::AssertNoCSSRules(nsRuleNode* aCurrLevelNode,
|
|
|
|
nsRuleNode* aLastPrevLevelNode)
|
|
|
|
{
|
2008-07-14 00:57:38 +04:00
|
|
|
if (!aCurrLevelNode)
|
2004-07-16 00:30:30 +04:00
|
|
|
return;
|
|
|
|
|
2008-07-14 00:57:38 +04:00
|
|
|
for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode;
|
|
|
|
node = node->GetParent()) {
|
|
|
|
nsIStyleRule *rule = node->GetRule();
|
2011-05-24 00:45:43 +04:00
|
|
|
nsRefPtr<css::StyleRule> cssRule(do_QueryObject(rule));
|
2008-07-14 00:57:38 +04:00
|
|
|
NS_ASSERTION(!cssRule || !cssRule->Selector(), "Unexpected CSS rule");
|
|
|
|
}
|
2004-07-16 00:30:30 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-11-11 02:51:45 +03:00
|
|
|
// Enumerate the rules in a way that cares about the order of the rules.
|
2001-11-06 13:04:05 +03:00
|
|
|
void
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
2009-12-11 10:37:40 +03:00
|
|
|
void* aData, nsIContent* aContent,
|
|
|
|
nsRuleWalker* aRuleWalker)
|
2001-11-06 13:04:05 +03:00
|
|
|
{
|
|
|
|
// Cascading order:
|
|
|
|
// [least important]
|
2004-07-16 00:30:30 +04:00
|
|
|
// 1. UA normal rules = Agent normal
|
2011-01-15 05:14:41 +03:00
|
|
|
// 2. User normal rules = User normal
|
2011-01-15 05:14:41 +03:00
|
|
|
// 3. Presentation hints = PresHint normal
|
2011-01-15 05:14:41 +03:00
|
|
|
// 4. Author normal rules = Document normal
|
|
|
|
// 5. Override normal rules = Override normal
|
|
|
|
// 6. Author !important rules = Document !important
|
|
|
|
// 7. Override !important rules = Override !important
|
2011-05-01 02:16:19 +04:00
|
|
|
// -. animation rules = Animation normal
|
2011-01-15 05:14:41 +03:00
|
|
|
// 8. User !important rules = User !important
|
|
|
|
// 9. UA !important rules = Agent !important
|
2011-05-01 02:16:19 +04:00
|
|
|
// -. transition rules = Transition normal
|
2001-11-06 13:04:05 +03:00
|
|
|
// [most important]
|
|
|
|
|
2011-05-24 00:45:42 +04:00
|
|
|
// Save off the last rule before we start walking our agent sheets;
|
|
|
|
// this will be either the root or one of the restriction rules.
|
|
|
|
nsRuleNode* lastRestrictionRN = aRuleWalker->CurrentNode();
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eAgentSheet, false, true);
|
2004-07-28 11:08:41 +04:00
|
|
|
if (mRuleProcessors[eAgentSheet])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[eAgentSheet], aData);
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode* lastAgentRN = aRuleWalker->CurrentNode();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveImportantUARules = !aRuleWalker->GetCheckForImportantRules();
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eUserSheet, false, true);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool skipUserStyles =
|
2009-12-11 10:37:40 +03:00
|
|
|
aContent && aContent->IsInNativeAnonymousSubtree();
|
2007-05-05 10:47:09 +04:00
|
|
|
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
2004-07-28 11:08:41 +04:00
|
|
|
(*aCollectorFunc)(mRuleProcessors[eUserSheet], aData);
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode* lastUserRN = aRuleWalker->CurrentNode();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveImportantUserRules = !aRuleWalker->GetCheckForImportantRules();
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(ePresHintSheet, false, false);
|
2011-01-15 05:14:41 +03:00
|
|
|
if (mRuleProcessors[ePresHintSheet])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[ePresHintSheet], aData);
|
|
|
|
nsRuleNode* lastPresHintRN = aRuleWalker->CurrentNode();
|
2004-05-05 04:30:57 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eDocSheet, false, true);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool cutOffInheritance = false;
|
2009-12-11 10:37:40 +03:00
|
|
|
if (mBindingManager && aContent) {
|
2001-11-06 13:04:05 +03:00
|
|
|
// We can supply additional document-level sheets that should be walked.
|
2009-12-11 10:37:40 +03:00
|
|
|
mBindingManager->WalkRules(aCollectorFunc,
|
|
|
|
static_cast<RuleProcessorData*>(aData),
|
|
|
|
&cutOffInheritance);
|
2001-11-06 13:04:05 +03:00
|
|
|
}
|
2007-05-05 10:47:09 +04:00
|
|
|
if (!skipUserStyles && !cutOffInheritance &&
|
|
|
|
mRuleProcessors[eDocSheet]) // NOTE: different
|
2004-07-28 11:08:41 +04:00
|
|
|
(*aCollectorFunc)(mRuleProcessors[eDocSheet], aData);
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eStyleAttrSheet, false,
|
2009-12-11 01:36:02 +03:00
|
|
|
aRuleWalker->GetCheckForImportantRules());
|
2004-07-28 11:08:41 +04:00
|
|
|
if (mRuleProcessors[eStyleAttrSheet])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode* lastDocRN = aRuleWalker->CurrentNode();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveImportantDocRules = !aRuleWalker->GetCheckForImportantRules();
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eOverrideSheet, false, true);
|
2004-07-28 11:08:41 +04:00
|
|
|
if (mRuleProcessors[eOverrideSheet])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[eOverrideSheet], aData);
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode* lastOvrRN = aRuleWalker->CurrentNode();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveImportantOverrideRules = !aRuleWalker->GetCheckForImportantRules();
|
2009-12-11 01:36:02 +03:00
|
|
|
|
|
|
|
if (haveImportantDocRules) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eDocSheet, true, false);
|
2011-01-15 05:14:41 +03:00
|
|
|
AddImportantRules(lastDocRN, lastPresHintRN, aRuleWalker); // doc
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2011-01-15 05:14:41 +03:00
|
|
|
AssertNoImportantRules(lastDocRN, lastPresHintRN);
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (haveImportantOverrideRules) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eOverrideSheet, true, false);
|
2009-12-11 01:36:02 +03:00
|
|
|
AddImportantRules(lastOvrRN, lastDocRN, aRuleWalker); // override
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
|
|
|
AssertNoImportantRules(lastOvrRN, lastDocRN);
|
|
|
|
}
|
|
|
|
#endif
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2011-05-01 02:16:19 +04:00
|
|
|
// This needs to match IsMoreSpecificThanAnimation() above.
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eAnimationSheet, false, false);
|
2011-05-01 02:16:19 +04:00
|
|
|
(*aCollectorFunc)(mRuleProcessors[eAnimationSheet], aData);
|
|
|
|
|
2004-07-16 00:30:30 +04:00
|
|
|
#ifdef DEBUG
|
2011-01-15 05:14:41 +03:00
|
|
|
AssertNoCSSRules(lastPresHintRN, lastUserRN);
|
2004-07-16 00:30:30 +04:00
|
|
|
#endif
|
2009-12-11 01:36:02 +03:00
|
|
|
|
|
|
|
if (haveImportantUserRules) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eUserSheet, true, false);
|
2011-01-15 05:14:41 +03:00
|
|
|
AddImportantRules(lastUserRN, lastAgentRN, aRuleWalker); //user
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2011-01-15 05:14:41 +03:00
|
|
|
AssertNoImportantRules(lastUserRN, lastAgentRN);
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (haveImportantUARules) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eAgentSheet, true, false);
|
2011-05-24 00:45:42 +04:00
|
|
|
AddImportantRules(lastAgentRN, lastRestrictionRN, aRuleWalker); //agent
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2011-05-24 00:45:42 +04:00
|
|
|
AssertNoImportantRules(lastAgentRN, lastRestrictionRN);
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2011-05-24 00:45:42 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
AssertNoCSSRules(lastRestrictionRN, mRuleTree);
|
|
|
|
#endif
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
#ifdef DEBUG
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode *lastImportantRN = aRuleWalker->CurrentNode();
|
2009-10-08 07:22:42 +04:00
|
|
|
#endif
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eTransitionSheet, false, false);
|
2009-10-08 07:22:42 +04:00
|
|
|
(*aCollectorFunc)(mRuleProcessors[eTransitionSheet], aData);
|
|
|
|
#ifdef DEBUG
|
2009-12-12 09:36:34 +03:00
|
|
|
AssertNoCSSRules(aRuleWalker->CurrentNode(), lastImportantRN);
|
2009-10-08 07:22:42 +04:00
|
|
|
#endif
|
|
|
|
|
2001-11-06 13:04:05 +03:00
|
|
|
}
|
|
|
|
|
2001-11-11 02:51:45 +03:00
|
|
|
// Enumerate all the rules in a way that doesn't care about the order
|
2004-01-14 04:36:35 +03:00
|
|
|
// of the rules and doesn't walk !important-rules.
|
2001-11-11 02:51:45 +03:00
|
|
|
void
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
2010-03-25 12:22:58 +03:00
|
|
|
RuleProcessorData* aData,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aWalkAllXBLStylesheets)
|
2001-11-11 02:51:45 +03:00
|
|
|
{
|
2004-07-28 11:08:41 +04:00
|
|
|
if (mRuleProcessors[eAgentSheet])
|
|
|
|
(*aFunc)(mRuleProcessors[eAgentSheet], aData);
|
2007-05-05 10:47:09 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool skipUserStyles = aData->mElement->IsInNativeAnonymousSubtree();
|
2007-05-05 10:47:09 +04:00
|
|
|
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
2004-07-28 11:08:41 +04:00
|
|
|
(*aFunc)(mRuleProcessors[eUserSheet], aData);
|
2007-05-05 10:47:09 +04:00
|
|
|
|
2011-01-15 05:14:41 +03:00
|
|
|
if (mRuleProcessors[ePresHintSheet])
|
|
|
|
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
|
2004-05-05 04:30:57 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool cutOffInheritance = false;
|
2007-02-17 02:02:08 +03:00
|
|
|
if (mBindingManager) {
|
2001-11-11 02:51:45 +03:00
|
|
|
// We can supply additional document-level sheets that should be walked.
|
2010-03-25 12:22:58 +03:00
|
|
|
if (aWalkAllXBLStylesheets) {
|
|
|
|
mBindingManager->WalkAllRules(aFunc, aData);
|
|
|
|
} else {
|
|
|
|
mBindingManager->WalkRules(aFunc, aData, &cutOffInheritance);
|
|
|
|
}
|
2001-11-11 02:51:45 +03:00
|
|
|
}
|
2007-05-05 10:47:09 +04:00
|
|
|
if (!skipUserStyles && !cutOffInheritance &&
|
|
|
|
mRuleProcessors[eDocSheet]) // NOTE: different
|
2004-07-28 11:08:41 +04:00
|
|
|
(*aFunc)(mRuleProcessors[eDocSheet], aData);
|
|
|
|
if (mRuleProcessors[eStyleAttrSheet])
|
|
|
|
(*aFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
|
|
|
if (mRuleProcessors[eOverrideSheet])
|
|
|
|
(*aFunc)(mRuleProcessors[eOverrideSheet], aData);
|
2011-04-12 10:18:44 +04:00
|
|
|
(*aFunc)(mRuleProcessors[eAnimationSheet], aData);
|
2011-05-01 02:16:19 +04:00
|
|
|
(*aFunc)(mRuleProcessors[eTransitionSheet], aData);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleSet::BuildDefaultStyleData(nsPresContext* aPresContext)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!mDefaultStyleData.mResetData &&
|
|
|
|
!mDefaultStyleData.mInheritedData,
|
|
|
|
"leaking default style data");
|
|
|
|
mDefaultStyleData.mResetData = new (aPresContext) nsResetStyleData;
|
|
|
|
if (!mDefaultStyleData.mResetData)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2003-03-13 18:29:36 +03:00
|
|
|
mDefaultStyleData.mInheritedData = new (aPresContext) nsInheritedStyleData;
|
|
|
|
if (!mDefaultStyleData.mInheritedData)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2003-03-13 18:29:36 +03:00
|
|
|
|
|
|
|
#define SSARG_PRESCONTEXT aPresContext
|
|
|
|
|
|
|
|
#define CREATE_DATA(name, type, args) \
|
2011-03-18 06:14:32 +03:00
|
|
|
if (!(mDefaultStyleData.m##type##Data->mStyleStructs[eStyleStruct_##name] = \
|
2003-03-13 18:29:36 +03:00
|
|
|
new (aPresContext) nsStyle##name args)) \
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2003-03-13 18:29:36 +03:00
|
|
|
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
|
|
|
CREATE_DATA(name, Inherited, ctor_args)
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
|
|
|
CREATE_DATA(name, Reset, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef SSARG_PRESCONTEXT
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2003-03-13 18:29:36 +03:00
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 17:12:06 +04:00
|
|
|
nsStyleSet::ResolveStyleFor(Element* aElement,
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleContext* aParentContext)
|
2011-03-29 21:29:21 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aElement->OwnerDoc());
|
2011-03-29 21:29:21 +04:00
|
|
|
return ResolveStyleFor(aElement, aParentContext, treeContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveStyleFor(Element* aElement,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2005-06-03 05:51:15 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
2010-04-30 17:12:06 +04:00
|
|
|
NS_ASSERTION(aElement, "aElement must not be null");
|
1998-05-19 01:05:52 +04:00
|
|
|
|
2010-04-02 10:07:42 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
2011-03-29 21:29:21 +04:00
|
|
|
aTreeMatchContext.ResetForUnvisitedMatching();
|
2011-03-29 21:29:21 +04:00
|
|
|
ElementRuleProcessorData data(PresContext(), aElement, &ruleWalker,
|
2011-03-29 21:29:21 +04:00
|
|
|
aTreeMatchContext);
|
2010-04-30 17:12:06 +04:00
|
|
|
FileRules(EnumRulesMatching<ElementRuleProcessorData>, &data, aElement,
|
2010-04-02 10:07:42 +04:00
|
|
|
&ruleWalker);
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
nsRuleNode *ruleNode = ruleWalker.CurrentNode();
|
|
|
|
nsRuleNode *visitedRuleNode = nsnull;
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
if (aTreeMatchContext.HaveRelevantLink()) {
|
|
|
|
aTreeMatchContext.ResetForVisitedMatching();
|
2011-03-29 21:29:21 +04:00
|
|
|
ruleWalker.Reset();
|
2010-04-30 17:12:06 +04:00
|
|
|
FileRules(EnumRulesMatching<ElementRuleProcessorData>, &data, aElement,
|
2010-04-03 05:58:27 +04:00
|
|
|
&ruleWalker);
|
|
|
|
visitedRuleNode = ruleWalker.CurrentNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2011-03-29 21:29:21 +04:00
|
|
|
nsCSSRuleProcessor::IsLink(aElement),
|
2012-03-30 10:16:22 +04:00
|
|
|
nsCSSRuleProcessor::GetContentState(aElement, aTreeMatchContext).
|
2011-03-29 21:29:21 +04:00
|
|
|
HasState(NS_EVENT_STATE_VISITED),
|
2011-04-12 10:18:44 +04:00
|
|
|
nsnull, nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
2011-10-17 18:59:28 +04:00
|
|
|
true, aElement);
|
1998-05-19 01:05:52 +04:00
|
|
|
}
|
|
|
|
|
2007-07-25 22:21:34 +04:00
|
|
|
already_AddRefed<nsStyleContext>
|
2009-08-11 02:52:29 +04:00
|
|
|
nsStyleSet::ResolveStyleForRules(nsStyleContext* aParentContext,
|
|
|
|
const nsCOMArray<nsIStyleRule> &aRules)
|
2007-07-25 22:21:34 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
2010-04-02 10:07:42 +04:00
|
|
|
|
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
|
|
|
// FIXME: Perhaps this should be passed in, but it probably doesn't
|
|
|
|
// matter.
|
2011-10-17 18:59:28 +04:00
|
|
|
ruleWalker.SetLevel(eDocSheet, false, false);
|
2010-04-02 10:07:42 +04:00
|
|
|
for (PRInt32 i = 0; i < aRules.Count(); i++) {
|
2011-05-26 00:54:30 +04:00
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
|
2007-07-25 22:21:34 +04:00
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aParentContext, ruleWalker.CurrentNode(), nsnull,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false,
|
2011-04-12 10:18:44 +04:00
|
|
|
nsnull, nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, nsnull);
|
2010-04-03 05:58:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
|
|
|
const nsCOMArray<nsIStyleRule> &aRules)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
|
|
|
|
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
|
|
|
ruleWalker.SetCurrentNode(aBaseContext->GetRuleNode());
|
|
|
|
// FIXME: Perhaps this should be passed in, but it probably doesn't
|
|
|
|
// matter.
|
2011-10-17 18:59:28 +04:00
|
|
|
ruleWalker.SetLevel(eDocSheet, false, false);
|
2010-04-03 05:58:25 +04:00
|
|
|
for (PRInt32 i = 0; i < aRules.Count(); i++) {
|
2011-05-26 00:54:30 +04:00
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
|
2010-04-03 05:58:25 +04:00
|
|
|
}
|
2010-04-03 05:58:27 +04:00
|
|
|
|
|
|
|
nsRuleNode *ruleNode = ruleWalker.CurrentNode();
|
|
|
|
nsRuleNode *visitedRuleNode = nsnull;
|
|
|
|
|
|
|
|
if (aBaseContext->GetStyleIfVisited()) {
|
|
|
|
ruleWalker.SetCurrentNode(aBaseContext->GetStyleIfVisited()->GetRuleNode());
|
|
|
|
for (PRInt32 i = 0; i < aRules.Count(); i++) {
|
2011-05-26 00:54:30 +04:00
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
|
2010-04-03 05:58:27 +04:00
|
|
|
}
|
|
|
|
visitedRuleNode = ruleWalker.CurrentNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetContext(aBaseContext->GetParent(), ruleNode, visitedRuleNode,
|
2010-06-08 23:58:26 +04:00
|
|
|
aBaseContext->IsLinkContext(),
|
|
|
|
aBaseContext->RelevantLinkVisited(),
|
2010-04-03 05:58:25 +04:00
|
|
|
aBaseContext->GetPseudo(),
|
2011-04-12 10:18:44 +04:00
|
|
|
aBaseContext->GetPseudoType(),
|
2011-10-17 18:59:28 +04:00
|
|
|
false, nsnull);
|
2007-07-25 22:21:34 +04:00
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2004-01-28 03:18:22 +03:00
|
|
|
nsStyleSet::ResolveStyleForNonElement(nsStyleContext* aParentContext)
|
2001-10-30 09:02:05 +03:00
|
|
|
{
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aParentContext, mRuleTree, nsnull,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false,
|
2010-04-02 10:07:42 +04:00
|
|
|
nsCSSAnonBoxes::mozNonElement,
|
2011-10-17 18:59:28 +04:00
|
|
|
nsCSSPseudoElements::ePseudo_AnonBox, false, nsnull);
|
2001-10-30 09:02:05 +03:00
|
|
|
}
|
|
|
|
|
2008-12-12 21:59:03 +03:00
|
|
|
void
|
2009-12-11 10:37:40 +03:00
|
|
|
nsStyleSet::WalkRestrictionRule(nsCSSPseudoElements::Type aPseudoType,
|
2009-10-03 01:06:42 +04:00
|
|
|
nsRuleWalker* aRuleWalker)
|
2008-12-12 21:59:03 +03:00
|
|
|
{
|
|
|
|
// This needs to match GetPseudoRestriction in nsRuleNode.cpp.
|
2011-10-17 18:59:28 +04:00
|
|
|
aRuleWalker->SetLevel(eAgentSheet, false, false);
|
2009-12-11 10:37:40 +03:00
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLetter)
|
|
|
|
aRuleWalker->Forward(mFirstLetterRule);
|
|
|
|
else if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLine)
|
|
|
|
aRuleWalker->Forward(mFirstLineRule);
|
2009-12-11 05:28:08 +03:00
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 17:12:06 +04:00
|
|
|
nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsCSSPseudoElements::Type aType,
|
|
|
|
nsStyleContext* aParentContext)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
|
|
|
|
|
|
|
NS_ASSERTION(aType < nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"must have pseudo element type");
|
2010-04-30 17:12:06 +04:00
|
|
|
NS_ASSERTION(aParentElement, "Must have parent element");
|
2009-12-11 10:37:40 +03:00
|
|
|
|
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aParentElement->OwnerDoc());
|
2010-04-30 17:12:06 +04:00
|
|
|
PseudoElementRuleProcessorData data(PresContext(), aParentElement,
|
2011-03-29 21:29:21 +04:00
|
|
|
&ruleWalker, aType, treeContext);
|
2009-12-11 10:37:40 +03:00
|
|
|
WalkRestrictionRule(aType, &ruleWalker);
|
2009-12-11 10:37:40 +03:00
|
|
|
FileRules(EnumRulesMatching<PseudoElementRuleProcessorData>, &data,
|
2010-04-30 17:12:06 +04:00
|
|
|
aParentElement, &ruleWalker);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
nsRuleNode *ruleNode = ruleWalker.CurrentNode();
|
|
|
|
nsRuleNode *visitedRuleNode = nsnull;
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
if (treeContext.HaveRelevantLink()) {
|
|
|
|
treeContext.ResetForVisitedMatching();
|
|
|
|
ruleWalker.Reset();
|
2011-05-24 00:45:42 +04:00
|
|
|
WalkRestrictionRule(aType, &ruleWalker);
|
2010-04-03 05:58:27 +04:00
|
|
|
FileRules(EnumRulesMatching<PseudoElementRuleProcessorData>, &data,
|
2010-04-30 17:12:06 +04:00
|
|
|
aParentElement, &ruleWalker);
|
2010-04-03 05:58:27 +04:00
|
|
|
visitedRuleNode = ruleWalker.CurrentNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2010-04-03 05:58:27 +04:00
|
|
|
// For pseudos, |data.IsLink()| being true means that
|
|
|
|
// our parent node is a link.
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false,
|
2011-04-12 10:18:44 +04:00
|
|
|
nsCSSPseudoElements::GetPseudoAtom(aType), aType,
|
|
|
|
aType == nsCSSPseudoElements::ePseudo_before ||
|
|
|
|
aType == nsCSSPseudoElements::ePseudo_after,
|
|
|
|
aParentElement);
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 17:12:06 +04:00
|
|
|
nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsCSSPseudoElements::Type aType,
|
|
|
|
nsStyleContext* aParentContext)
|
2011-03-29 21:29:21 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aParentElement->OwnerDoc());
|
2011-03-29 21:29:21 +04:00
|
|
|
return ProbePseudoElementStyle(aParentElement, aType, aParentContext,
|
|
|
|
treeContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
|
|
|
|
nsCSSPseudoElements::Type aType,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
1998-05-19 01:05:52 +04:00
|
|
|
{
|
2005-06-03 05:51:15 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
NS_ASSERTION(aType < nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"must have pseudo element type");
|
2010-04-30 17:12:06 +04:00
|
|
|
NS_ASSERTION(aParentElement, "aParentElement must not be null");
|
2009-12-11 05:28:08 +03:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
nsIAtom* pseudoTag = nsCSSPseudoElements::GetPseudoAtom(aType);
|
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
2011-03-29 21:29:21 +04:00
|
|
|
aTreeMatchContext.ResetForUnvisitedMatching();
|
2010-04-30 17:12:06 +04:00
|
|
|
PseudoElementRuleProcessorData data(PresContext(), aParentElement,
|
2011-03-29 21:29:21 +04:00
|
|
|
&ruleWalker, aType, aTreeMatchContext);
|
2009-12-11 10:37:40 +03:00
|
|
|
WalkRestrictionRule(aType, &ruleWalker);
|
|
|
|
// not the root if there was a restriction rule
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode *adjustedRoot = ruleWalker.CurrentNode();
|
2009-12-11 10:37:40 +03:00
|
|
|
FileRules(EnumRulesMatching<PseudoElementRuleProcessorData>, &data,
|
2010-04-30 17:12:06 +04:00
|
|
|
aParentElement, &ruleWalker);
|
2009-12-11 05:28:08 +03:00
|
|
|
|
2009-12-12 09:36:34 +03:00
|
|
|
nsRuleNode *ruleNode = ruleWalker.CurrentNode();
|
2009-12-11 10:37:40 +03:00
|
|
|
if (ruleNode == adjustedRoot) {
|
|
|
|
return nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2003-02-23 20:28:25 +03:00
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
nsRuleNode *visitedRuleNode = nsnull;
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
if (aTreeMatchContext.HaveRelevantLink()) {
|
|
|
|
aTreeMatchContext.ResetForVisitedMatching();
|
2011-03-29 21:29:21 +04:00
|
|
|
ruleWalker.Reset();
|
2011-05-24 00:45:42 +04:00
|
|
|
WalkRestrictionRule(aType, &ruleWalker);
|
2010-04-03 05:58:27 +04:00
|
|
|
FileRules(EnumRulesMatching<PseudoElementRuleProcessorData>, &data,
|
2010-04-30 17:12:06 +04:00
|
|
|
aParentElement, &ruleWalker);
|
2010-04-03 05:58:27 +04:00
|
|
|
visitedRuleNode = ruleWalker.CurrentNode();
|
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
nsRefPtr<nsStyleContext> result =
|
2010-04-03 05:58:27 +04:00
|
|
|
GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2010-04-03 05:58:27 +04:00
|
|
|
// For pseudos, |data.IsLink()| being true means that
|
|
|
|
// our parent node is a link.
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false,
|
2011-04-12 10:18:44 +04:00
|
|
|
pseudoTag, aType,
|
|
|
|
aType == nsCSSPseudoElements::ePseudo_before ||
|
|
|
|
aType == nsCSSPseudoElements::ePseudo_after,
|
|
|
|
aParentElement);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2003-02-23 20:28:25 +03:00
|
|
|
// For :before and :after pseudo-elements, having display: none or no
|
|
|
|
// 'content' property is equivalent to not having the pseudo-element
|
|
|
|
// at all.
|
|
|
|
if (result &&
|
2009-12-11 10:37:40 +03:00
|
|
|
(pseudoTag == nsCSSPseudoElements::before ||
|
|
|
|
pseudoTag == nsCSSPseudoElements::after)) {
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleDisplay *display = result->GetStyleDisplay();
|
|
|
|
const nsStyleContent *content = result->GetStyleContent();
|
2003-02-23 20:28:25 +03:00
|
|
|
// XXXldb What is contentCount for |content: ""|?
|
|
|
|
if (display->mDisplay == NS_STYLE_DISPLAY_NONE ||
|
|
|
|
content->ContentCount() == 0) {
|
|
|
|
result = nsnull;
|
|
|
|
}
|
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
return result.forget();
|
2009-12-11 01:36:06 +03:00
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag,
|
|
|
|
nsStyleContext* aParentContext)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isAnonBox = nsCSSAnonBoxes::IsAnonBox(aPseudoTag)
|
2009-12-11 10:37:40 +03:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
&& !nsCSSAnonBoxes::IsTreePseudoElement(aPseudoTag)
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
NS_PRECONDITION(isAnonBox, "Unexpected pseudo");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
2010-04-02 10:07:42 +04:00
|
|
|
AnonBoxRuleProcessorData data(PresContext(), aPseudoTag, &ruleWalker);
|
2009-12-11 10:37:40 +03:00
|
|
|
FileRules(EnumRulesMatching<AnonBoxRuleProcessorData>, &data, nsnull,
|
|
|
|
&ruleWalker);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aParentContext, ruleWalker.CurrentNode(), nsnull,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false,
|
2011-04-12 10:18:44 +04:00
|
|
|
aPseudoTag, nsCSSPseudoElements::ePseudo_AnonBox,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, nsnull);
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 17:12:06 +04:00
|
|
|
nsStyleSet::ResolveXULTreePseudoStyle(Element* aParentElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
nsICSSPseudoComparator* aComparator)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, nsnull);
|
|
|
|
|
|
|
|
NS_ASSERTION(aPseudoTag, "must have pseudo tag");
|
|
|
|
NS_ASSERTION(nsCSSAnonBoxes::IsTreePseudoElement(aPseudoTag),
|
|
|
|
"Unexpected pseudo");
|
|
|
|
|
|
|
|
nsRuleWalker ruleWalker(mRuleTree);
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aParentElement->OwnerDoc());
|
2010-04-30 17:12:06 +04:00
|
|
|
XULTreeRuleProcessorData data(PresContext(), aParentElement, &ruleWalker,
|
2011-03-29 21:29:21 +04:00
|
|
|
aPseudoTag, aComparator, treeContext);
|
2010-04-30 17:12:06 +04:00
|
|
|
FileRules(EnumRulesMatching<XULTreeRuleProcessorData>, &data, aParentElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
&ruleWalker);
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
nsRuleNode *ruleNode = ruleWalker.CurrentNode();
|
|
|
|
nsRuleNode *visitedRuleNode = nsnull;
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
if (treeContext.HaveRelevantLink()) {
|
|
|
|
treeContext.ResetForVisitedMatching();
|
|
|
|
ruleWalker.Reset();
|
2010-04-03 05:58:27 +04:00
|
|
|
FileRules(EnumRulesMatching<XULTreeRuleProcessorData>, &data,
|
2010-04-30 17:12:06 +04:00
|
|
|
aParentElement, &ruleWalker);
|
2010-04-03 05:58:27 +04:00
|
|
|
visitedRuleNode = ruleWalker.CurrentNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2010-04-03 05:58:27 +04:00
|
|
|
// For pseudos, |data.IsLink()| being true means that
|
|
|
|
// our parent node is a link.
|
2011-10-17 18:59:28 +04:00
|
|
|
false, false,
|
2011-04-12 10:18:44 +04:00
|
|
|
aPseudoTag, nsCSSPseudoElements::ePseudo_XULTree,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, nsnull);
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-11-26 02:22:38 +03:00
|
|
|
nsStyleSet::AppendFontFaceRules(nsPresContext* aPresContext,
|
2008-11-27 06:50:16 +03:00
|
|
|
nsTArray<nsFontFaceRuleContainer>& aArray)
|
2008-11-26 02:22:38 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, false);
|
2008-11-26 02:22:38 +03:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
2008-11-26 02:22:38 +03:00
|
|
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
|
|
|
if (ruleProc && !ruleProc->AppendFontFaceRules(aPresContext, aArray))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-11-26 02:22:38 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-11-26 02:22:38 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-12 10:18:43 +04:00
|
|
|
nsStyleSet::AppendKeyframesRules(nsPresContext* aPresContext,
|
|
|
|
nsTArray<nsCSSKeyframesRule*>& aArray)
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, false);
|
2011-04-12 10:18:43 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
2011-04-12 10:18:43 +04:00
|
|
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
|
|
|
if (ruleProc && !ruleProc->AppendKeyframesRules(aPresContext, aArray))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-04-12 10:18:43 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-04-12 10:18:43 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleSet::BeginShutdown(nsPresContext* aPresContext)
|
2003-03-06 22:14:17 +03:00
|
|
|
{
|
2004-01-08 01:30:53 +03:00
|
|
|
mInShutdown = 1;
|
2003-03-06 22:14:17 +03:00
|
|
|
mRoots.Clear(); // no longer valid, since we won't keep it up to date
|
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleSet::Shutdown(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-01-08 01:30:53 +03:00
|
|
|
mRuleTree->Destroy();
|
|
|
|
mRuleTree = nsnull;
|
2003-03-13 18:29:36 +03:00
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
// We can have old rule trees either because:
|
|
|
|
// (1) we failed the assertions in EndReconstruct, or
|
|
|
|
// (2) we're shutting down within a reconstruct (see bug 462392)
|
|
|
|
for (PRUint32 i = mOldRuleTrees.Length(); i > 0; ) {
|
|
|
|
--i;
|
|
|
|
mOldRuleTrees[i]->Destroy();
|
|
|
|
}
|
|
|
|
mOldRuleTrees.Clear();
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mDefaultStyleData.Destroy(0, aPresContext);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2009-09-29 23:24:18 +04:00
|
|
|
static const PRUint32 kGCInterval = 300;
|
2003-03-06 22:14:17 +03:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleSet::NotifyStyleContextDestroyed(nsPresContext* aPresContext,
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleContext* aStyleContext)
|
2003-03-06 22:14:17 +03:00
|
|
|
{
|
|
|
|
if (mInShutdown)
|
2004-01-08 01:30:53 +03:00
|
|
|
return;
|
2003-03-06 22:14:17 +03:00
|
|
|
|
2007-11-15 09:13:48 +03:00
|
|
|
// Remove style contexts from mRoots even if mOldRuleTree is non-null. This
|
|
|
|
// could be a style context from the new ruletree!
|
2003-03-06 22:14:17 +03:00
|
|
|
if (!aStyleContext->GetParent()) {
|
|
|
|
mRoots.RemoveElement(aStyleContext);
|
|
|
|
}
|
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
if (mInReconstruct)
|
2007-11-15 09:13:48 +03:00
|
|
|
return;
|
|
|
|
|
2011-01-19 05:20:35 +03:00
|
|
|
if (mUnusedRuleNodeCount >= kGCInterval) {
|
2009-01-30 07:39:23 +03:00
|
|
|
GCRuleTrees();
|
|
|
|
}
|
|
|
|
}
|
2009-01-29 23:39:19 +03:00
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
void
|
|
|
|
nsStyleSet::GCRuleTrees()
|
|
|
|
{
|
2009-09-24 21:59:43 +04:00
|
|
|
mUnusedRuleNodeCount = 0;
|
2009-01-30 07:39:23 +03:00
|
|
|
|
|
|
|
// Mark the style context tree by marking all style contexts which
|
|
|
|
// have no parent, which will mark all descendants. This will reach
|
|
|
|
// style contexts in the undisplayed map and "additional style
|
|
|
|
// contexts" since they are descendants of the roots.
|
|
|
|
for (PRInt32 i = mRoots.Length() - 1; i >= 0; --i) {
|
|
|
|
mRoots[i]->Mark();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sweep the rule tree.
|
2004-01-08 01:30:53 +03:00
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool deleted =
|
2004-01-08 01:30:53 +03:00
|
|
|
#endif
|
2009-01-30 07:39:23 +03:00
|
|
|
mRuleTree->Sweep();
|
|
|
|
NS_ASSERTION(!deleted, "Root node must not be gc'd");
|
|
|
|
|
|
|
|
// Sweep the old rule trees.
|
|
|
|
for (PRUint32 i = mOldRuleTrees.Length(); i > 0; ) {
|
|
|
|
--i;
|
|
|
|
if (mOldRuleTrees[i]->Sweep()) {
|
|
|
|
// It was deleted, as it should be.
|
|
|
|
mOldRuleTrees.RemoveElementAt(i);
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("old rule tree still referenced");
|
|
|
|
}
|
2004-01-08 01:30:53 +03:00
|
|
|
}
|
2003-03-06 22:14:17 +03:00
|
|
|
}
|
|
|
|
|
2010-06-23 08:46:27 +04:00
|
|
|
static inline nsRuleNode*
|
2011-09-29 10:19:26 +04:00
|
|
|
SkipAnimationRules(nsRuleNode* aRuleNode, Element* aElement, bool isPseudo)
|
2010-06-23 08:46:27 +04:00
|
|
|
{
|
|
|
|
nsRuleNode* ruleNode = aRuleNode;
|
|
|
|
while (!ruleNode->IsRoot() &&
|
2011-09-21 07:52:44 +04:00
|
|
|
(ruleNode->GetLevel() == nsStyleSet::eTransitionSheet ||
|
|
|
|
ruleNode->GetLevel() == nsStyleSet::eAnimationSheet)) {
|
2010-06-23 08:46:27 +04:00
|
|
|
ruleNode = ruleNode->GetParent();
|
|
|
|
}
|
|
|
|
if (ruleNode != aRuleNode) {
|
|
|
|
NS_ASSERTION(aElement, "How can we have transition rules but no element?");
|
|
|
|
// Need to do an animation restyle, just like
|
2011-09-21 07:52:44 +04:00
|
|
|
// nsTransitionManager::WalkTransitionRule and
|
|
|
|
// nsAnimationManager::GetAnimationRule would.
|
2010-07-01 05:54:29 +04:00
|
|
|
nsRestyleHint hint = isPseudo ? eRestyle_Subtree : eRestyle_Self;
|
|
|
|
aRuleNode->GetPresContext()->PresShell()->RestyleForAnimation(aElement,
|
|
|
|
hint);
|
2010-06-23 08:46:27 +04:00
|
|
|
}
|
|
|
|
return ruleNode;
|
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-02 10:07:42 +04:00
|
|
|
nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
|
2010-06-23 08:46:27 +04:00
|
|
|
nsStyleContext* aNewParentContext,
|
|
|
|
Element* aElement)
|
1999-09-04 03:35:41 +04:00
|
|
|
{
|
2010-04-02 10:07:42 +04:00
|
|
|
if (!aStyleContext) {
|
|
|
|
NS_NOTREACHED("must have style context");
|
|
|
|
return nsnull;
|
|
|
|
}
|
1999-09-04 03:35:41 +04:00
|
|
|
|
2010-06-23 08:46:27 +04:00
|
|
|
// This short-circuit is OK because we don't call TryStartingTransition
|
|
|
|
// during style reresolution if the style context pointer hasn't changed.
|
2010-04-02 10:07:42 +04:00
|
|
|
if (aStyleContext->GetParent() == aNewParentContext) {
|
|
|
|
aStyleContext->AddRef();
|
|
|
|
return aStyleContext;
|
1999-09-04 03:35:41 +04:00
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
|
|
|
nsIAtom* pseudoTag = aStyleContext->GetPseudo();
|
|
|
|
nsCSSPseudoElements::Type pseudoType = aStyleContext->GetPseudoType();
|
|
|
|
nsRuleNode* ruleNode = aStyleContext->GetRuleNode();
|
2010-06-23 08:46:27 +04:00
|
|
|
|
|
|
|
// Skip transition rules as needed just like
|
|
|
|
// nsTransitionManager::WalkTransitionRule would.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool skipAnimationRules = PresContext()->IsProcessingRestyles() &&
|
2010-06-23 08:46:27 +04:00
|
|
|
!PresContext()->IsProcessingAnimationStyleChange();
|
2011-09-21 07:52:44 +04:00
|
|
|
if (skipAnimationRules) {
|
|
|
|
// Make sure that we're not using transition rules or animation rules for
|
|
|
|
// our new style context. If we need them, an animation restyle will
|
|
|
|
// provide.
|
2010-07-01 05:54:29 +04:00
|
|
|
ruleNode =
|
2011-09-21 07:52:44 +04:00
|
|
|
SkipAnimationRules(ruleNode, aElement,
|
|
|
|
pseudoType !=
|
|
|
|
nsCSSPseudoElements::ePseudo_NotPseudoElement);
|
2010-06-23 08:46:27 +04:00
|
|
|
}
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
nsRuleNode* visitedRuleNode = nsnull;
|
|
|
|
nsStyleContext* visitedContext = aStyleContext->GetStyleIfVisited();
|
2010-06-08 23:58:26 +04:00
|
|
|
// Reparenting a style context just changes where we inherit from,
|
|
|
|
// not what rules we match or what our DOM looks like. In
|
|
|
|
// particular, it doesn't change whether this is a style context for
|
|
|
|
// a link.
|
2010-04-03 05:58:27 +04:00
|
|
|
if (visitedContext) {
|
|
|
|
visitedRuleNode = visitedContext->GetRuleNode();
|
2010-06-23 08:46:27 +04:00
|
|
|
// Again, skip transition rules as needed
|
2011-09-21 07:52:44 +04:00
|
|
|
if (skipAnimationRules) {
|
2011-04-12 10:18:44 +04:00
|
|
|
// FIXME do something here for animations?
|
2010-07-01 05:54:29 +04:00
|
|
|
visitedRuleNode =
|
2011-09-21 07:52:44 +04:00
|
|
|
SkipAnimationRules(visitedRuleNode, aElement,
|
|
|
|
pseudoType !=
|
|
|
|
nsCSSPseudoElements::ePseudo_NotPseudoElement);
|
2010-06-23 08:46:27 +04:00
|
|
|
}
|
2010-04-03 05:58:27 +04:00
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2011-05-21 00:21:27 +04:00
|
|
|
// If we're a style context for a link, then we already know whether
|
|
|
|
// our relevant link is visited, since that does not depend on our
|
|
|
|
// parent. Otherwise, we need to match aNewParentContext.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool relevantLinkVisited = aStyleContext->IsLinkContext() ?
|
2011-05-21 00:21:27 +04:00
|
|
|
aStyleContext->RelevantLinkVisited() :
|
|
|
|
aNewParentContext->RelevantLinkVisited();
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aNewParentContext, ruleNode, visitedRuleNode,
|
2010-06-08 23:58:26 +04:00
|
|
|
aStyleContext->IsLinkContext(),
|
2011-05-21 00:21:27 +04:00
|
|
|
relevantLinkVisited,
|
2011-04-12 10:18:44 +04:00
|
|
|
pseudoTag, pseudoType,
|
|
|
|
pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
|
|
|
pseudoType == nsCSSPseudoElements::ePseudo_before ||
|
|
|
|
pseudoType == nsCSSPseudoElements::ePseudo_after,
|
|
|
|
aElement);
|
1999-09-04 03:35:41 +04:00
|
|
|
}
|
|
|
|
|
2001-11-11 02:51:45 +03:00
|
|
|
struct StatefulData : public StateRuleProcessorData {
|
2011-03-29 21:29:21 +04:00
|
|
|
StatefulData(nsPresContext* aPresContext, Element* aElement,
|
|
|
|
nsEventStates aStateMask, TreeMatchContext& aTreeMatchContext)
|
|
|
|
: StateRuleProcessorData(aPresContext, aElement, aStateMask,
|
|
|
|
aTreeMatchContext),
|
2010-04-01 04:43:32 +04:00
|
|
|
mHint(nsRestyleHint(0))
|
1999-04-20 04:02:22 +04:00
|
|
|
{}
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint mHint;
|
2010-03-17 20:10:57 +03:00
|
|
|
};
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool SheetHasDocumentStateStyle(nsIStyleRuleProcessor* aProcessor,
|
2010-03-17 20:10:57 +03:00
|
|
|
void *aData)
|
|
|
|
{
|
|
|
|
StatefulData* data = (StatefulData*)aData;
|
|
|
|
if (aProcessor->HasDocumentStateDependentStyle(data)) {
|
2010-04-01 04:43:32 +04:00
|
|
|
data->mHint = eRestyle_Self;
|
2011-10-17 18:59:28 +04:00
|
|
|
return false; // don't continue
|
2010-03-17 20:10:57 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true; // continue
|
2010-03-17 20:10:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test if style is dependent on a document state.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-03-17 20:10:57 +03:00
|
|
|
nsStyleSet::HasDocumentStateDependentStyle(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
2010-10-20 15:26:32 +04:00
|
|
|
nsEventStates aStateMask)
|
2010-03-17 20:10:57 +03:00
|
|
|
{
|
2010-04-30 17:12:06 +04:00
|
|
|
if (!aContent || !aContent->IsElement())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-03-17 20:10:57 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aContent->OwnerDoc());
|
2011-03-29 21:29:21 +04:00
|
|
|
StatefulData data(aPresContext, aContent->AsElement(), aStateMask,
|
|
|
|
treeContext);
|
2011-10-17 18:59:28 +04:00
|
|
|
WalkRuleProcessors(SheetHasDocumentStateStyle, &data, true);
|
2010-03-17 20:10:57 +03:00
|
|
|
return data.mHint != 0;
|
|
|
|
}
|
1999-04-20 04:02:22 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool SheetHasStatefulStyle(nsIStyleRuleProcessor* aProcessor,
|
2004-01-08 01:30:53 +03:00
|
|
|
void *aData)
|
1999-04-20 04:02:22 +04:00
|
|
|
{
|
|
|
|
StatefulData* data = (StatefulData*)aData;
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint hint = aProcessor->HasStateDependentStyle(data);
|
|
|
|
data->mHint = nsRestyleHint(data->mHint | hint);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true; // continue
|
1999-04-20 04:02:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test if style is dependent on content state
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint
|
2010-10-20 15:26:32 +04:00
|
|
|
nsStyleSet::HasStateDependentStyle(nsPresContext* aPresContext,
|
|
|
|
Element* aElement,
|
|
|
|
nsEventStates aStateMask)
|
1999-04-20 04:02:22 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aElement->OwnerDoc());
|
2011-03-29 21:29:21 +04:00
|
|
|
StatefulData data(aPresContext, aElement, aStateMask, treeContext);
|
2011-10-17 18:59:28 +04:00
|
|
|
WalkRuleProcessors(SheetHasStatefulStyle, &data, false);
|
2010-05-14 21:04:51 +04:00
|
|
|
return data.mHint;
|
2003-02-22 19:10:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct AttributeData : public AttributeRuleProcessorData {
|
2004-08-01 03:15:21 +04:00
|
|
|
AttributeData(nsPresContext* aPresContext,
|
2010-04-30 17:12:06 +04:00
|
|
|
Element* aElement, nsIAtom* aAttribute, PRInt32 aModType,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAttrHasChanged, TreeMatchContext& aTreeMatchContext)
|
2010-04-30 17:12:06 +04:00
|
|
|
: AttributeRuleProcessorData(aPresContext, aElement, aAttribute, aModType,
|
2011-03-29 21:29:21 +04:00
|
|
|
aAttrHasChanged, aTreeMatchContext),
|
2010-04-01 04:43:32 +04:00
|
|
|
mHint(nsRestyleHint(0))
|
2003-02-22 19:10:53 +03:00
|
|
|
{}
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint mHint;
|
2003-02-22 19:10:53 +03:00
|
|
|
};
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2004-01-08 01:30:53 +03:00
|
|
|
SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData)
|
2003-02-22 19:10:53 +03:00
|
|
|
{
|
|
|
|
AttributeData* data = (AttributeData*)aData;
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint hint = aProcessor->HasAttributeDependentStyle(data);
|
|
|
|
data->mHint = nsRestyleHint(data->mHint | hint);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true; // continue
|
2003-02-22 19:10:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test if style is dependent on content state
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext,
|
2010-05-14 21:04:51 +04:00
|
|
|
Element* aElement,
|
2007-07-13 00:05:45 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAttrHasChanged)
|
2003-02-22 19:10:53 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aElement->OwnerDoc());
|
2010-05-14 21:04:51 +04:00
|
|
|
AttributeData data(aPresContext, aElement, aAttribute,
|
2011-03-29 21:29:21 +04:00
|
|
|
aModType, aAttrHasChanged, treeContext);
|
2011-10-17 18:59:28 +04:00
|
|
|
WalkRuleProcessors(SheetHasAttributeStyle, &data, false);
|
2010-05-14 21:04:51 +04:00
|
|
|
return data.mHint;
|
2000-03-31 11:08:36 +04:00
|
|
|
}
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-07-26 20:14:48 +04:00
|
|
|
nsStyleSet::MediumFeaturesChanged(nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// We can't use WalkRuleProcessors without a content node.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool stylesChanged = false;
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(mRuleProcessors); ++i) {
|
2008-07-26 20:14:48 +04:00
|
|
|
nsIStyleRuleProcessor *processor = mRuleProcessors[i];
|
|
|
|
if (!processor) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool thisChanged = processor->MediumFeaturesChanged(aPresContext);
|
2008-07-26 20:14:48 +04:00
|
|
|
stylesChanged = stylesChanged || thisChanged;
|
|
|
|
}
|
|
|
|
|
2008-07-26 20:14:49 +04:00
|
|
|
if (mBindingManager) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool thisChanged = false;
|
2008-07-26 20:14:49 +04:00
|
|
|
mBindingManager->MediumFeaturesChanged(aPresContext, &thisChanged);
|
|
|
|
stylesChanged = stylesChanged || thisChanged;
|
|
|
|
}
|
|
|
|
|
2008-07-26 20:14:48 +04:00
|
|
|
return stylesChanged;
|
|
|
|
}
|
2009-12-31 18:56:33 +03:00
|
|
|
|
|
|
|
nsCSSStyleSheet::EnsureUniqueInnerResult
|
|
|
|
nsStyleSet::EnsureUniqueInnerOnCSSSheets()
|
|
|
|
{
|
|
|
|
nsAutoTArray<nsCSSStyleSheet*, 32> queue;
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
2009-12-31 18:56:33 +03:00
|
|
|
nsCOMArray<nsIStyleSheet> &sheets = mSheets[gCSSSheetTypes[i]];
|
|
|
|
for (PRUint32 j = 0, j_end = sheets.Count(); j < j_end; ++j) {
|
|
|
|
nsCSSStyleSheet *sheet = static_cast<nsCSSStyleSheet*>(sheets[j]);
|
|
|
|
if (!queue.AppendElement(sheet)) {
|
|
|
|
return nsCSSStyleSheet::eUniqueInner_CloneFailed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-17 09:36:34 +04:00
|
|
|
if (mBindingManager) {
|
|
|
|
mBindingManager->AppendAllSheets(queue);
|
|
|
|
}
|
|
|
|
|
2009-12-31 18:56:33 +03:00
|
|
|
nsCSSStyleSheet::EnsureUniqueInnerResult res =
|
|
|
|
nsCSSStyleSheet::eUniqueInner_AlreadyUnique;
|
|
|
|
while (!queue.IsEmpty()) {
|
|
|
|
PRUint32 idx = queue.Length() - 1;
|
|
|
|
nsCSSStyleSheet *sheet = queue[idx];
|
|
|
|
queue.RemoveElementAt(idx);
|
|
|
|
|
|
|
|
nsCSSStyleSheet::EnsureUniqueInnerResult sheetRes =
|
|
|
|
sheet->EnsureUniqueInner();
|
|
|
|
if (sheetRes == nsCSSStyleSheet::eUniqueInner_CloneFailed) {
|
|
|
|
return sheetRes;
|
|
|
|
}
|
|
|
|
if (sheetRes == nsCSSStyleSheet::eUniqueInner_ClonedInner) {
|
|
|
|
res = sheetRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enqueue all the sheet's children.
|
|
|
|
if (!sheet->AppendAllChildSheets(queue)) {
|
|
|
|
return nsCSSStyleSheet::eUniqueInner_CloneFailed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2011-08-23 03:34:12 +04:00
|
|
|
|
|
|
|
nsIStyleRule*
|
|
|
|
nsStyleSet::InitialStyleRule()
|
|
|
|
{
|
|
|
|
if (!mInitialStyleRule) {
|
|
|
|
mInitialStyleRule = new nsInitialStyleRule;
|
|
|
|
}
|
|
|
|
return mInitialStyleRule;
|
|
|
|
}
|