2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
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
|
|
|
|
*/
|
|
|
|
|
2014-06-20 14:32:49 +04:00
|
|
|
#include "nsStyleSet.h"
|
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheetInlines.h"
|
2016-01-13 01:54:55 +03:00
|
|
|
#include "mozilla/EffectCompositor.h"
|
2015-10-20 02:16:20 +03:00
|
|
|
#include "mozilla/EnumeratedRange.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2015-06-26 06:52:48 +03:00
|
|
|
#include "mozilla/RuleProcessorCache.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheetInlines.h"
|
2013-01-13 01:53:01 +04:00
|
|
|
#include "nsIDocumentInlines.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"
|
2013-01-09 03:25:47 +04:00
|
|
|
#include "nsDataHashtable.h"
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsIContent.h"
|
2011-08-23 03:34:12 +04:00
|
|
|
#include "nsRuleData.h"
|
2009-08-01 19:53:40 +04:00
|
|
|
#include "nsRuleProcessorData.h"
|
2011-04-12 10:18:44 +04:00
|
|
|
#include "nsAnimationManager.h"
|
2012-10-16 23:45:50 +04:00
|
|
|
#include "nsStyleSheetService.h"
|
2010-05-05 22:18:05 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-03-18 18:25:50 +04:00
|
|
|
#include "GeckoProfiler.h"
|
2013-06-14 09:34:37 +04:00
|
|
|
#include "nsHTMLCSSStyleSheet.h"
|
|
|
|
#include "nsHTMLStyleSheet.h"
|
2014-09-13 17:17:35 +04:00
|
|
|
#include "SVGAttrAnimationRuleProcessor.h"
|
2013-09-16 05:06:52 +04:00
|
|
|
#include "nsCSSRules.h"
|
2014-08-03 06:37:44 +04:00
|
|
|
#include "nsPrintfCString.h"
|
2014-08-03 06:37:45 +04:00
|
|
|
#include "nsIFrame.h"
|
2016-02-24 10:01:12 +03:00
|
|
|
#include "mozilla/RestyleManagerHandle.h"
|
|
|
|
#include "mozilla/RestyleManagerHandleInlines.h"
|
2015-04-15 19:47:03 +03:00
|
|
|
#include "nsQueryObject.h"
|
2010-04-30 17:12:06 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
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
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsEmptyStyleRule, nsIStyleRule)
|
2008-12-12 21:59:03 +03:00
|
|
|
|
2010-05-20 06:28:00 +04:00
|
|
|
/* virtual */ void
|
2008-12-12 21:59:03 +03:00
|
|
|
nsEmptyStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-11-17 07:09:55 +03:00
|
|
|
/* virtual */ bool
|
|
|
|
nsEmptyStyleRule::MightMapInheritedStyleData()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-16 08:29:21 +03:00
|
|
|
/* virtual */ bool
|
2016-08-17 04:37:48 +03:00
|
|
|
nsEmptyStyleRule::GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
|
2016-08-16 08:29:21 +03:00
|
|
|
nsCSSValue* aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-12 21:59:03 +03:00
|
|
|
#ifdef DEBUG
|
2010-05-20 06:28:00 +04:00
|
|
|
/* virtual */ void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsEmptyStyleRule::List(FILE* out, int32_t aIndent) const
|
2008-12-12 21:59:03 +03:00
|
|
|
{
|
2014-11-27 09:29:44 +03:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 09:29:44 +03:00
|
|
|
for (int32_t index = aIndent; --index >= 0; ) {
|
2014-11-27 09:29:44 +03:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 09:29:44 +03:00
|
|
|
}
|
2014-11-27 09:29:44 +03:00
|
|
|
fprintf_stderr(out, "%s[empty style rule] {}\n", indentStr.get());
|
2008-12-12 21:59:03 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsInitialStyleRule, nsIStyleRule)
|
2011-08-23 03:34:12 +04:00
|
|
|
|
|
|
|
/* 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(
|
2016-12-21 10:16:50 +03:00
|
|
|
eCSSProperty__moz_script_level) ||
|
2011-08-23 03:34:12 +04:00
|
|
|
index == nsCSSProps::PropertyIndexInStruct(
|
2016-12-21 10:16:50 +03:00
|
|
|
eCSSProperty__moz_script_size_multiplier) ||
|
2011-08-23 03:34:12 +04:00
|
|
|
index == nsCSSProps::PropertyIndexInStruct(
|
2016-12-21 10:16:50 +03:00
|
|
|
eCSSProperty__moz_script_min_size) ||
|
2013-12-02 20:49:00 +04:00
|
|
|
index == nsCSSProps::PropertyIndexInStruct(
|
2016-12-21 10:16:50 +03:00
|
|
|
eCSSProperty__moz_math_variant) ||
|
2014-01-14 18:39:50 +04:00
|
|
|
index == nsCSSProps::PropertyIndexInStruct(
|
2016-12-21 10:16:50 +03:00
|
|
|
eCSSProperty__moz_math_display)) {
|
2011-08-23 03:34:12 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value->GetUnit() == eCSSUnit_Null) {
|
|
|
|
value->SetInitialValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-17 07:09:55 +03:00
|
|
|
/* virtual */ bool
|
|
|
|
nsInitialStyleRule::MightMapInheritedStyleData()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-16 08:29:21 +03:00
|
|
|
/* virtual */ bool
|
2016-08-17 04:37:48 +03:00
|
|
|
nsInitialStyleRule::GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
|
2016-08-16 08:29:21 +03:00
|
|
|
nsCSSValue* aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-23 03:34:12 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* virtual */ void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsInitialStyleRule::List(FILE* out, int32_t aIndent) const
|
2011-08-23 03:34:12 +04:00
|
|
|
{
|
2014-11-27 09:29:44 +03:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 09:29:44 +03:00
|
|
|
for (int32_t index = aIndent; --index >= 0; ) {
|
2014-11-27 09:29:44 +03:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 09:29:44 +03:00
|
|
|
}
|
2014-11-27 09:29:44 +03:00
|
|
|
fprintf_stderr(out, "%s[initial style rule] {}\n", indentStr.get());
|
2011-08-23 03:34:12 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsDisableTextZoomStyleRule, nsIStyleRule)
|
2013-06-29 07:28:50 +04:00
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsDisableTextZoomStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
if (!(aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Font)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCSSValue* value = aRuleData->ValueForTextZoom();
|
|
|
|
if (value->GetUnit() == eCSSUnit_Null)
|
|
|
|
value->SetNoneValue();
|
|
|
|
}
|
|
|
|
|
2015-11-17 07:09:55 +03:00
|
|
|
/* virtual */ bool
|
|
|
|
nsDisableTextZoomStyleRule::MightMapInheritedStyleData()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-16 08:29:21 +03:00
|
|
|
/* virtual */ bool
|
|
|
|
nsDisableTextZoomStyleRule::
|
2016-08-17 04:37:48 +03:00
|
|
|
GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty, nsCSSValue* aValue)
|
2016-08-16 08:29:21 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-29 07:28:50 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* virtual */ void
|
|
|
|
nsDisableTextZoomStyleRule::List(FILE* out, int32_t aIndent) const
|
|
|
|
{
|
2014-11-27 09:29:44 +03:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 09:29:44 +03:00
|
|
|
for (int32_t index = aIndent; --index >= 0; ) {
|
2014-11-27 09:29:44 +03:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 09:29:44 +03:00
|
|
|
}
|
2014-11-27 09:29:44 +03:00
|
|
|
fprintf_stderr(out, "%s[disable text zoom style rule] {}\n", indentStr.get());
|
2013-06-29 07:28:50 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
static const SheetType gCSSSheetTypes[] = {
|
2013-08-15 08:58:37 +04:00
|
|
|
// From lowest to highest in cascading order.
|
2015-10-20 02:16:20 +03:00
|
|
|
SheetType::Agent,
|
|
|
|
SheetType::User,
|
|
|
|
SheetType::Doc,
|
|
|
|
SheetType::ScopedDoc,
|
|
|
|
SheetType::Override
|
2008-11-26 02:22:38 +03:00
|
|
|
};
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
/* static */ bool
|
|
|
|
nsStyleSet::IsCSSSheetType(SheetType aSheetType)
|
2015-06-26 06:49:58 +03:00
|
|
|
{
|
2015-10-20 02:16:20 +03:00
|
|
|
for (SheetType type : gCSSSheetTypes) {
|
2015-06-26 06:49:58 +03:00
|
|
|
if (type == aSheetType) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleSet::nsStyleSet()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mRuleTree(nullptr),
|
2004-01-08 22:23:12 +03:00
|
|
|
mBatching(0),
|
2011-10-17 18:59:28 +04:00
|
|
|
mInShutdown(false),
|
2016-03-25 04:40:40 +03:00
|
|
|
mInGC(false),
|
2011-10-17 18:59:28 +04:00
|
|
|
mAuthorStyleDisabled(false),
|
|
|
|
mInReconstruct(false),
|
2013-05-20 06:59:20 +04:00
|
|
|
mInitFontFeatureValuesLookup(true),
|
2015-06-26 06:49:58 +03:00
|
|
|
mNeedsRestyleAfterEnsureUniqueInner(false),
|
2012-04-17 23:22:49 +04:00
|
|
|
mDirty(0),
|
2016-03-25 04:40:40 +03:00
|
|
|
mRootStyleContextCount(0),
|
|
|
|
#ifdef DEBUG
|
|
|
|
mOldRootNode(nullptr),
|
|
|
|
#endif
|
2012-04-17 23:22:49 +04:00
|
|
|
mUnusedRuleNodeCount(0)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
nsStyleSet::~nsStyleSet()
|
|
|
|
{
|
2015-10-20 02:16:20 +03:00
|
|
|
for (SheetType type : gCSSSheetTypes) {
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : mSheets[type]) {
|
|
|
|
sheet->DropStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-26 06:52:48 +03:00
|
|
|
|
|
|
|
// drop reference to cached rule processors
|
|
|
|
nsCSSRuleProcessor* rp;
|
2015-10-20 02:16:20 +03:00
|
|
|
rp = static_cast<nsCSSRuleProcessor*>(mRuleProcessors[SheetType::Agent].get());
|
2015-06-26 06:52:48 +03:00
|
|
|
if (rp) {
|
|
|
|
MOZ_ASSERT(rp->IsShared());
|
|
|
|
rp->ReleaseStyleSetRef();
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
rp = static_cast<nsCSSRuleProcessor*>(mRuleProcessors[SheetType::User].get());
|
2015-06-26 06:52:48 +03:00
|
|
|
if (rp) {
|
|
|
|
MOZ_ASSERT(rp->IsShared());
|
|
|
|
rp->ReleaseStyleSetRef();
|
|
|
|
}
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
|
2011-08-01 22:24:38 +04:00
|
|
|
size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
nsStyleSet::SizeOfIncludingThis(MallocSizeOf 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
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
for (SheetType type : MakeEnumeratedRange(SheetType::Count)) {
|
|
|
|
if (mRuleProcessors[type]) {
|
2015-06-26 06:52:48 +03:00
|
|
|
bool shared = false;
|
2015-10-20 02:16:20 +03:00
|
|
|
if (type == SheetType::Agent || type == SheetType::User) {
|
2015-06-26 06:52:48 +03:00
|
|
|
// The only two origins we consider caching rule processors for.
|
|
|
|
nsCSSRuleProcessor* rp =
|
2015-10-20 02:16:20 +03:00
|
|
|
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[type].get());
|
2015-06-26 06:52:48 +03:00
|
|
|
shared = rp->IsShared();
|
|
|
|
}
|
|
|
|
if (!shared) {
|
2015-10-20 02:16:20 +03:00
|
|
|
n += mRuleProcessors[type]->SizeOfIncludingThis(aMallocSizeOf);
|
2015-06-26 06:52:48 +03:00
|
|
|
}
|
2011-08-01 22:25:20 +04:00
|
|
|
}
|
2015-11-17 09:04:09 +03:00
|
|
|
// We don't own the sheets (either the nsLayoutStyleSheetCache singleton
|
|
|
|
// or our document owns them).
|
|
|
|
n += mSheets[type].ShallowSizeOfExcludingThis(aMallocSizeOf);
|
2011-08-01 22:25:20 +04:00
|
|
|
}
|
|
|
|
|
2013-02-12 05:27:14 +04:00
|
|
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
2013-02-12 04:48:44 +04:00
|
|
|
n += mScopedDocSheetRuleProcessors[i]->SizeOfIncludingThis(aMallocSizeOf);
|
|
|
|
}
|
2015-07-29 09:24:24 +03:00
|
|
|
n += mScopedDocSheetRuleProcessors.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
2013-02-12 04:48:44 +04:00
|
|
|
|
2011-08-01 22:25:20 +04:00
|
|
|
return n;
|
2011-08-01 22:24:38 +04:00
|
|
|
}
|
|
|
|
|
2013-04-01 02:08:29 +04:00
|
|
|
void
|
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;
|
2012-11-09 14:25:52 +04:00
|
|
|
mPlaceholderRule = new nsEmptyStyleRule;
|
2013-06-29 07:28:50 +04:00
|
|
|
mDisableTextZoomStyleRule = new nsDisableTextZoomStyleRule;
|
2008-12-12 21:59:03 +03:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mRuleTree = nsRuleNode::CreateRootNode(aPresContext);
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2014-09-13 17:17:35 +04:00
|
|
|
// Make an explicit GatherRuleProcessors call for the levels that
|
|
|
|
// don't have style sheets. The other levels will have their calls
|
2015-11-05 10:24:22 +03:00
|
|
|
// triggered by DirtyRuleProcessors.
|
|
|
|
GatherRuleProcessors(SheetType::PresHint);
|
|
|
|
GatherRuleProcessors(SheetType::SVGAttrAnimation);
|
|
|
|
GatherRuleProcessors(SheetType::StyleAttr);
|
2015-10-20 02:16:20 +03:00
|
|
|
GatherRuleProcessors(SheetType::Animation);
|
|
|
|
GatherRuleProcessors(SheetType::Transition);
|
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?");
|
2016-03-25 04:40:40 +03:00
|
|
|
mInReconstruct = true;
|
2007-07-25 21:14:13 +04:00
|
|
|
|
2015-09-17 05:08:20 +03:00
|
|
|
// Clear any ArenaRefPtr-managed style contexts, as we don't want them
|
|
|
|
// held on to after the rule tree has been reconstructed.
|
|
|
|
PresContext()->PresShell()->ClearArenaRefPtrs(eArenaObjectID_nsStyleContext);
|
|
|
|
|
2016-03-25 04:40:40 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
MOZ_ASSERT(!mOldRootNode);
|
|
|
|
mOldRootNode = mRuleTree;
|
|
|
|
#endif
|
2009-01-30 07:39:23 +03:00
|
|
|
|
2016-03-25 04:40:40 +03:00
|
|
|
// Create a new rule tree root, dropping the reference to our old rule tree.
|
|
|
|
// After reconstruction, we will re-enable GC, and allow everything to be
|
|
|
|
// collected.
|
|
|
|
mRuleTree = nsRuleNode::CreateRootNode(mRuleTree->PresContext());
|
2007-07-25 21:14:13 +04:00
|
|
|
|
|
|
|
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-30 07:39:23 +03:00
|
|
|
GCRuleTrees();
|
2007-07-25 21:14:13 +04:00
|
|
|
}
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
typedef nsDataHashtable<nsPtrHashKey<nsINode>, uint32_t> ScopeDepthCache;
|
|
|
|
|
|
|
|
// Returns the depth of a style scope element, with 1 being the depth of
|
|
|
|
// a style scope element that has no ancestor style scope elements. The
|
|
|
|
// depth does not count intervening non-scope elements.
|
|
|
|
static uint32_t
|
|
|
|
GetScopeDepth(nsINode* aScopeElement, ScopeDepthCache& aCache)
|
|
|
|
{
|
|
|
|
nsINode* parent = aScopeElement->GetParent();
|
|
|
|
if (!parent || !parent->IsElementInStyleScope()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t depth = aCache.Get(aScopeElement);
|
|
|
|
if (!depth) {
|
|
|
|
for (nsINode* n = parent; n; n = n->GetParent()) {
|
|
|
|
if (n->IsScopedStyleRoot()) {
|
|
|
|
depth = GetScopeDepth(n, aCache) + 1;
|
|
|
|
aCache.Put(aScopeElement, depth);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ScopedSheetOrder
|
|
|
|
{
|
2014-06-20 14:32:49 +04:00
|
|
|
CSSStyleSheet* mSheet;
|
2013-01-09 03:25:47 +04:00
|
|
|
uint32_t mDepth;
|
|
|
|
uint32_t mOrder;
|
|
|
|
|
|
|
|
bool operator==(const ScopedSheetOrder& aRHS) const
|
|
|
|
{
|
|
|
|
return mDepth == aRHS.mDepth &&
|
|
|
|
mOrder == aRHS.mOrder;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const ScopedSheetOrder& aRHS) const
|
|
|
|
{
|
|
|
|
if (mDepth != aRHS.mDepth) {
|
|
|
|
return mDepth < aRHS.mDepth;
|
|
|
|
}
|
|
|
|
return mOrder < aRHS.mOrder;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Sorts aSheets such that style sheets for ancestor scopes come
|
|
|
|
// before those for descendant scopes, and with sheets for a single
|
|
|
|
// scope in document order.
|
|
|
|
static void
|
2014-06-20 14:32:49 +04:00
|
|
|
SortStyleSheetsByScope(nsTArray<CSSStyleSheet*>& aSheets)
|
2013-01-09 03:25:47 +04:00
|
|
|
{
|
|
|
|
uint32_t n = aSheets.Length();
|
|
|
|
if (n == 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScopeDepthCache cache;
|
|
|
|
|
|
|
|
nsTArray<ScopedSheetOrder> sheets;
|
|
|
|
sheets.SetLength(n);
|
|
|
|
|
|
|
|
// For each sheet, record the depth of its scope element and its original
|
|
|
|
// document order.
|
|
|
|
for (uint32_t i = 0; i < n; i++) {
|
|
|
|
sheets[i].mSheet = aSheets[i];
|
|
|
|
sheets[i].mDepth = GetScopeDepth(aSheets[i]->GetScopeElement(), cache);
|
|
|
|
sheets[i].mOrder = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort by depth first, then document order.
|
|
|
|
sheets.Sort();
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < n; i++) {
|
|
|
|
aSheets[i] = sheets[i].mSheet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
nsresult
|
2015-10-20 02:16:20 +03:00
|
|
|
nsStyleSet::GatherRuleProcessors(SheetType aType)
|
1999-10-08 07:09:31 +04:00
|
|
|
{
|
2015-09-29 05:16:04 +03:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, NS_ERROR_FAILURE);
|
|
|
|
|
2015-08-05 15:42:21 +03:00
|
|
|
// We might be in GatherRuleProcessors because we are dropping a sheet,
|
|
|
|
// resulting in an nsCSSSelector being destroyed. Tell the
|
|
|
|
// RestyleManager for each document we're used in so that they can
|
|
|
|
// drop any nsCSSSelector pointers (used for eRestyle_SomeDescendants)
|
|
|
|
// in their mPendingRestyles.
|
|
|
|
if (IsCSSSheetType(aType)) {
|
|
|
|
ClearSelectors();
|
|
|
|
}
|
2014-12-06 02:50:00 +03:00
|
|
|
nsCOMPtr<nsIStyleRuleProcessor> oldRuleProcessor(mRuleProcessors[aType]);
|
|
|
|
nsTArray<nsCOMPtr<nsIStyleRuleProcessor>> oldScopedDocRuleProcessors;
|
2015-10-20 02:16:20 +03:00
|
|
|
if (aType == SheetType::Agent || aType == SheetType::User) {
|
2015-06-26 06:52:48 +03:00
|
|
|
// drop reference to cached rule processor
|
|
|
|
nsCSSRuleProcessor* rp =
|
|
|
|
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[aType].get());
|
|
|
|
if (rp) {
|
|
|
|
MOZ_ASSERT(rp->IsShared());
|
|
|
|
rp->ReleaseStyleSetRef();
|
|
|
|
}
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
mRuleProcessors[aType] = nullptr;
|
2015-10-20 02:16:20 +03:00
|
|
|
if (aType == SheetType::ScopedDoc) {
|
2013-01-10 22:40:53 +04:00
|
|
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
2013-01-09 03:25:47 +04:00
|
|
|
nsIStyleRuleProcessor* processor = mScopedDocSheetRuleProcessors[i].get();
|
|
|
|
Element* scope =
|
|
|
|
static_cast<nsCSSRuleProcessor*>(processor)->GetScopeElement();
|
|
|
|
scope->ClearIsScopedStyleRoot();
|
|
|
|
}
|
2014-12-06 02:50:00 +03:00
|
|
|
|
|
|
|
// Clear mScopedDocSheetRuleProcessors, but save it.
|
|
|
|
oldScopedDocRuleProcessors.SwapElements(mScopedDocSheetRuleProcessors);
|
2013-01-09 03:25:47 +04:00
|
|
|
}
|
2016-06-29 14:27:42 +03:00
|
|
|
if (mAuthorStyleDisabled && (aType == SheetType::Doc ||
|
2015-10-20 02:16:20 +03:00
|
|
|
aType == SheetType::ScopedDoc ||
|
|
|
|
aType == SheetType::StyleAttr)) {
|
2013-03-28 06:47:25 +04:00
|
|
|
// Don't regather if this level is disabled. Note that we gather
|
|
|
|
// preshint sheets no matter what, but then skip them for some
|
|
|
|
// elements later if mAuthorStyleDisabled.
|
2004-08-05 15:38:42 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-06-14 09:34:37 +04:00
|
|
|
switch (aType) {
|
2015-11-17 09:04:09 +03:00
|
|
|
// levels that do not contain CSS style sheets
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::Animation:
|
2014-09-13 17:17:35 +04:00
|
|
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
2016-01-15 09:15:47 +03:00
|
|
|
mRuleProcessors[aType] = PresContext()->EffectCompositor()->
|
|
|
|
RuleProcessor(EffectCompositor::CascadeLevel::Animations);
|
2013-06-14 09:34:37 +04:00
|
|
|
return NS_OK;
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::Transition:
|
2014-09-13 17:17:35 +04:00
|
|
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
2016-01-15 09:15:47 +03:00
|
|
|
mRuleProcessors[aType] = PresContext()->EffectCompositor()->
|
|
|
|
RuleProcessor(EffectCompositor::CascadeLevel::Transitions);
|
2013-06-14 09:34:37 +04:00
|
|
|
return NS_OK;
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::StyleAttr:
|
2014-09-13 17:17:35 +04:00
|
|
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
2013-06-14 09:34:37 +04:00
|
|
|
mRuleProcessors[aType] = PresContext()->Document()->GetInlineStyleSheet();
|
|
|
|
return NS_OK;
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::PresHint:
|
2014-09-13 17:17:35 +04:00
|
|
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
|
|
|
mRuleProcessors[aType] =
|
|
|
|
PresContext()->Document()->GetAttributeStyleSheet();
|
|
|
|
return NS_OK;
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::SVGAttrAnimation:
|
2014-09-13 17:17:35 +04:00
|
|
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
|
|
|
mRuleProcessors[aType] =
|
|
|
|
PresContext()->Document()->GetSVGAttrAnimationRuleProcessor();
|
2013-06-14 09:34:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
default:
|
|
|
|
// keep going
|
|
|
|
break;
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
2015-11-17 09:04:09 +03:00
|
|
|
MOZ_ASSERT(IsCSSSheetType(aType));
|
2015-10-20 02:16:20 +03:00
|
|
|
if (aType == SheetType::ScopedDoc) {
|
2013-01-09 03:25:47 +04:00
|
|
|
// Create a rule processor for each scope.
|
2015-11-17 09:04:09 +03:00
|
|
|
uint32_t count = mSheets[SheetType::ScopedDoc].Length();
|
2013-01-09 03:25:47 +04:00
|
|
|
if (count) {
|
|
|
|
// Gather the scoped style sheets into an array as
|
2014-06-20 14:32:49 +04:00
|
|
|
// CSSStyleSheets, and mark all of their scope elements
|
2013-01-09 03:25:47 +04:00
|
|
|
// as scoped style roots.
|
2014-06-20 14:32:49 +04:00
|
|
|
nsTArray<CSSStyleSheet*> sheets(count);
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : mSheets[SheetType::ScopedDoc]) {
|
2013-01-09 03:25:47 +04:00
|
|
|
sheets.AppendElement(sheet);
|
|
|
|
|
|
|
|
Element* scope = sheet->GetScopeElement();
|
|
|
|
scope->SetIsScopedStyleRoot();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the scoped style sheets so that those for the same scope are
|
|
|
|
// adjacent and that ancestor scopes come before descendent scopes.
|
|
|
|
SortStyleSheetsByScope(sheets);
|
|
|
|
|
2014-12-06 02:50:00 +03:00
|
|
|
// Put the old scoped rule processors in a hashtable so that we
|
|
|
|
// can retrieve them efficiently, even in edge cases like the
|
|
|
|
// simultaneous removal and addition of a large number of elements
|
|
|
|
// with scoped sheets.
|
|
|
|
nsDataHashtable<nsPtrHashKey<Element>,
|
|
|
|
nsCSSRuleProcessor*> oldScopedRuleProcessorHash;
|
|
|
|
for (size_t i = oldScopedDocRuleProcessors.Length(); i-- != 0; ) {
|
|
|
|
nsCSSRuleProcessor* oldRP =
|
|
|
|
static_cast<nsCSSRuleProcessor*>(oldScopedDocRuleProcessors[i].get());
|
|
|
|
Element* scope = oldRP->GetScopeElement();
|
|
|
|
MOZ_ASSERT(!oldScopedRuleProcessorHash.Get(scope),
|
|
|
|
"duplicate rule processors for same scope element?");
|
|
|
|
oldScopedRuleProcessorHash.Put(scope, oldRP);
|
|
|
|
}
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
uint32_t start = 0, end;
|
|
|
|
do {
|
|
|
|
// Find the range of style sheets with the same scope.
|
|
|
|
Element* scope = sheets[start]->GetScopeElement();
|
|
|
|
end = start + 1;
|
|
|
|
while (end < count && sheets[end]->GetScopeElement() == scope) {
|
|
|
|
end++;
|
|
|
|
}
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
scope->SetIsScopedStyleRoot();
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
// Create a rule processor for the scope.
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<CSSStyleSheet>> sheetsForScope;
|
2013-01-09 03:25:47 +04:00
|
|
|
sheetsForScope.AppendElements(sheets.Elements() + start, end - start);
|
2014-12-06 02:50:00 +03:00
|
|
|
nsCSSRuleProcessor* oldRP = oldScopedRuleProcessorHash.Get(scope);
|
2013-01-09 03:25:47 +04:00
|
|
|
mScopedDocSheetRuleProcessors.AppendElement
|
2016-04-14 09:02:44 +03:00
|
|
|
(new nsCSSRuleProcessor(Move(sheetsForScope), aType, scope, oldRP));
|
2013-01-09 03:25:47 +04:00
|
|
|
|
|
|
|
start = end;
|
|
|
|
} while (start < count);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-11-17 09:04:09 +03:00
|
|
|
if (!mSheets[aType].IsEmpty()) {
|
2004-07-28 11:08:41 +04:00
|
|
|
switch (aType) {
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::Agent:
|
|
|
|
case SheetType::User: {
|
2015-06-26 06:52:48 +03:00
|
|
|
// levels containing non-scoped CSS style sheets whose rule processors
|
|
|
|
// we want to re-use
|
2015-11-17 09:04:09 +03:00
|
|
|
nsTArray<CSSStyleSheet*> sheets(mSheets[aType].Length());
|
|
|
|
for (CSSStyleSheet* sheet : mSheets[aType]) {
|
|
|
|
sheets.AppendElement(sheet);
|
2015-06-26 06:52:48 +03:00
|
|
|
}
|
|
|
|
nsCSSRuleProcessor* rp =
|
2015-11-17 09:04:09 +03:00
|
|
|
RuleProcessorCache::GetRuleProcessor(sheets, PresContext());
|
2015-06-26 06:52:48 +03:00
|
|
|
if (!rp) {
|
2015-11-17 09:04:09 +03:00
|
|
|
rp = new nsCSSRuleProcessor(mSheets[aType], aType, nullptr,
|
2015-06-26 06:52:48 +03:00
|
|
|
static_cast<nsCSSRuleProcessor*>(
|
|
|
|
oldRuleProcessor.get()),
|
|
|
|
true /* aIsShared */);
|
|
|
|
nsTArray<css::DocumentRule*> documentRules;
|
|
|
|
nsDocumentRuleResultCacheKey cacheKey;
|
|
|
|
rp->TakeDocumentRulesAndCacheKey(PresContext(),
|
|
|
|
documentRules, cacheKey);
|
2015-11-17 09:04:09 +03:00
|
|
|
RuleProcessorCache::PutRuleProcessor(sheets,
|
2015-06-26 06:52:48 +03:00
|
|
|
Move(documentRules),
|
|
|
|
cacheKey, rp);
|
|
|
|
}
|
|
|
|
mRuleProcessors[aType] = rp;
|
|
|
|
rp->AddStyleSetRef();
|
|
|
|
break;
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::Doc:
|
|
|
|
case SheetType::Override: {
|
2015-06-26 06:52:48 +03:00
|
|
|
// levels containing non-scoped CSS stylesheets whose rule processors
|
|
|
|
// we don't want to re-use
|
2013-01-09 03:25:47 +04:00
|
|
|
mRuleProcessors[aType] =
|
2015-11-17 09:04:09 +03:00
|
|
|
new nsCSSRuleProcessor(mSheets[aType], aType, nullptr,
|
2014-12-06 02:50:00 +03:00
|
|
|
static_cast<nsCSSRuleProcessor*>(
|
|
|
|
oldRuleProcessor.get()));
|
2004-07-28 11:08:41 +04:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
2015-11-17 09:04:09 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("non-CSS sheet types should be handled above");
|
2004-07-28 11:08:41 +04:00
|
|
|
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
|
2015-11-17 09:04:09 +03:00
|
|
|
nsStyleSet::AppendStyleSheet(SheetType aType, CSSStyleSheet* 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");
|
2015-11-17 09:04:09 +03:00
|
|
|
bool present = mSheets[aType].RemoveElement(aSheet);
|
|
|
|
mSheets[aType].AppendElement(aSheet);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
if (!present && IsCSSSheetType(aType)) {
|
2015-11-17 09:04:09 +03:00
|
|
|
aSheet->AddStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
return DirtyRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
2015-11-17 09:04:09 +03:00
|
|
|
nsStyleSet::PrependStyleSheet(SheetType aType, CSSStyleSheet* 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");
|
2015-11-17 09:04:09 +03:00
|
|
|
bool present = mSheets[aType].RemoveElement(aSheet);
|
|
|
|
mSheets[aType].InsertElementAt(0, aSheet);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
if (!present && IsCSSSheetType(aType)) {
|
2015-11-17 09:04:09 +03:00
|
|
|
aSheet->AddStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
return DirtyRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
2015-11-17 09:04:09 +03:00
|
|
|
nsStyleSet::RemoveStyleSheet(SheetType aType, CSSStyleSheet* 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");
|
2015-11-17 09:04:09 +03:00
|
|
|
if (mSheets[aType].RemoveElement(aSheet)) {
|
2015-06-26 06:49:58 +03:00
|
|
|
if (IsCSSSheetType(aType)) {
|
2015-11-17 09:04:09 +03:00
|
|
|
aSheet->DropStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
return DirtyRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
nsresult
|
2015-10-20 02:16:20 +03:00
|
|
|
nsStyleSet::ReplaceSheets(SheetType aType,
|
2015-11-17 09:04:09 +03:00
|
|
|
const nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2015-06-26 06:49:58 +03:00
|
|
|
bool cssSheetType = IsCSSSheetType(aType);
|
|
|
|
if (cssSheetType) {
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : mSheets[aType]) {
|
|
|
|
sheet->DropStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
mSheets[aType].Clear();
|
2015-11-17 09:04:09 +03:00
|
|
|
mSheets[aType].AppendElements(aNewSheets);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
if (cssSheetType) {
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : mSheets[aType]) {
|
|
|
|
sheet->AddStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
return DirtyRuleProcessors(aType);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2012-10-29 15:21:15 +04:00
|
|
|
nsresult
|
2015-11-17 09:04:09 +03:00
|
|
|
nsStyleSet::InsertStyleSheetBefore(SheetType aType, CSSStyleSheet* aNewSheet,
|
|
|
|
CSSStyleSheet* aReferenceSheet)
|
2012-10-29 15:21:15 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewSheet && aReferenceSheet, "null arg");
|
|
|
|
NS_ASSERTION(aNewSheet->IsApplicable(),
|
|
|
|
"Inapplicable sheet being placed in style set");
|
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
bool present = mSheets[aType].RemoveElement(aNewSheet);
|
2012-10-29 15:21:15 +04:00
|
|
|
int32_t idx = mSheets[aType].IndexOf(aReferenceSheet);
|
|
|
|
if (idx < 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2013-06-14 09:34:37 +04:00
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
mSheets[aType].InsertElementAt(idx, aNewSheet);
|
2012-10-29 15:21:15 +04:00
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
if (!present && IsCSSSheetType(aType)) {
|
2015-11-17 09:04:09 +03:00
|
|
|
aNewSheet->AddStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
return DirtyRuleProcessors(aType);
|
|
|
|
}
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
static inline uint32_t
|
|
|
|
DirtyBit(SheetType aType)
|
|
|
|
{
|
|
|
|
return 1 << uint32_t(aType);
|
|
|
|
}
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
nsresult
|
2015-10-20 02:16:20 +03:00
|
|
|
nsStyleSet::DirtyRuleProcessors(SheetType aType)
|
2013-06-14 09:34:37 +04:00
|
|
|
{
|
2012-10-29 15:21:15 +04:00
|
|
|
if (!mBatching)
|
|
|
|
return GatherRuleProcessors(aType);
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
mDirty |= DirtyBit(aType);
|
2012-10-29 15:21:15 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-01-21 08:21:23 +03:00
|
|
|
nsStyleSet::GetAuthorStyleDisabled() const
|
2004-08-05 15:38:42 +04:00
|
|
|
{
|
|
|
|
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();
|
2015-10-20 02:16:20 +03:00
|
|
|
mDirty |= DirtyBit(SheetType::Doc) |
|
|
|
|
DirtyBit(SheetType::ScopedDoc) |
|
|
|
|
DirtyBit(SheetType::StyleAttr);
|
2004-08-05 15:38:42 +04:00
|
|
|
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
|
2015-11-17 09:04:09 +03:00
|
|
|
nsStyleSet::AddDocStyleSheet(CSSStyleSheet* 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
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
SheetType type = aSheet->GetScopeElement() ?
|
2015-10-20 02:16:20 +03:00
|
|
|
SheetType::ScopedDoc :
|
|
|
|
SheetType::Doc;
|
2015-11-17 09:04:09 +03:00
|
|
|
nsTArray<RefPtr<CSSStyleSheet>>& sheets = mSheets[type];
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
bool present = sheets.RemoveElement(aSheet);
|
|
|
|
|
2016-04-29 07:01:44 +03:00
|
|
|
size_t index = aDocument->FindDocStyleSheetInsertionPoint(sheets, aSheet);
|
2015-11-17 09:04:09 +03:00
|
|
|
sheets.InsertElementAt(index, aSheet);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
if (!present) {
|
2015-11-17 09:04:09 +03:00
|
|
|
aSheet->AddStyleSet(this);
|
2015-06-26 06:49:58 +03:00
|
|
|
}
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
return DirtyRuleProcessors(type);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2016-02-24 10:01:12 +03:00
|
|
|
void
|
|
|
|
nsStyleSet::AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) const
|
|
|
|
{
|
|
|
|
if (mBindingManager) {
|
|
|
|
// XXXheycam stylo: AppendAllSheets will need to be able to return either
|
|
|
|
// CSSStyleSheets or ServoStyleSheets, on request (and then here requesting
|
|
|
|
// CSSStyleSheets).
|
2016-09-26 15:03:25 +03:00
|
|
|
AutoTArray<StyleSheet*, 32> sheets;
|
2016-02-24 10:01:12 +03:00
|
|
|
mBindingManager->AppendAllSheets(sheets);
|
2016-09-26 15:03:25 +03:00
|
|
|
for (StyleSheet* handle : sheets) {
|
2016-02-24 10:01:12 +03:00
|
|
|
MOZ_ASSERT(handle->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
|
|
|
|
"ServoStyleSheets yet");
|
|
|
|
aArray.AppendElement(handle->AsGecko());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
nsresult
|
2015-11-17 09:04:09 +03:00
|
|
|
nsStyleSet::RemoveDocStyleSheet(CSSStyleSheet* aSheet)
|
2013-01-09 03:25:47 +04:00
|
|
|
{
|
2015-11-17 09:04:09 +03:00
|
|
|
bool isScoped = aSheet->GetScopeElement();
|
2015-10-20 02:16:20 +03:00
|
|
|
return RemoveStyleSheet(isScoped ? SheetType::ScopedDoc : SheetType::Doc,
|
|
|
|
aSheet);
|
2013-01-09 03:25:47 +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;
|
|
|
|
}
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
for (SheetType type : MakeEnumeratedRange(SheetType::Count)) {
|
|
|
|
if (mDirty & DirtyBit(type)) {
|
|
|
|
nsresult rv = GatherRuleProcessors(type);
|
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
|
|
|
}
|
|
|
|
|
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() &&
|
2015-10-20 02:16:20 +03:00
|
|
|
(aRuleNode->GetLevel() == SheetType::Transition ||
|
2012-08-30 05:27:01 +04:00
|
|
|
aRuleNode->IsImportantRule());
|
2011-05-01 02:16:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsIStyleRule*
|
|
|
|
GetAnimationRule(nsRuleNode *aRuleNode)
|
|
|
|
{
|
|
|
|
nsRuleNode *n = aRuleNode;
|
|
|
|
while (IsMoreSpecificThanAnimation(n)) {
|
|
|
|
n = n->GetParent();
|
|
|
|
}
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
if (n->IsRoot() || n->GetLevel() != SheetType::Animation) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-05-01 02:16:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(n->GetRule() == aOldAnimRule, "wrong rule");
|
2015-10-20 02:16:20 +03:00
|
|
|
MOZ_ASSERT(n->GetLevel() == SheetType::Animation,
|
2015-02-10 01:34:50 +03:00
|
|
|
"wrong level");
|
2011-05-01 02:16:19 +04:00
|
|
|
n = n->GetParent();
|
|
|
|
}
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!IsMoreSpecificThanAnimation(n) &&
|
2015-10-20 02:16:20 +03:00
|
|
|
(n->IsRoot() || n->GetLevel() != SheetType::Animation),
|
2015-02-10 01:34:50 +03:00
|
|
|
"wrong level");
|
2011-05-01 02:16:19 +04:00
|
|
|
|
|
|
|
if (aNewAnimRule) {
|
2015-10-20 02:16:20 +03:00
|
|
|
n = n->Transition(aNewAnimRule, SheetType::Animation, false);
|
2015-07-27 09:43:44 +03:00
|
|
|
n->SetIsAnimationRule();
|
2011-05-01 02:16:19 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = moreSpecificNodes.Length(); i-- != 0; ) {
|
2011-05-01 02:16:19 +04:00
|
|
|
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,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsIAtom* aPseudoTag,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2013-02-01 20:02:29 +04:00
|
|
|
Element* aElementForAnimation,
|
|
|
|
uint32_t aFlags)
|
1998-05-19 01:05:52 +04:00
|
|
|
{
|
2009-12-11 10:37:40 +03:00
|
|
|
NS_PRECONDITION((!aPseudoTag &&
|
|
|
|
aPseudoType ==
|
2016-02-17 01:07:00 +03:00
|
|
|
CSSPseudoElementType::NotPseudo) ||
|
2009-12-11 10:37:40 +03:00
|
|
|
(aPseudoTag &&
|
2016-05-10 11:44:05 +03:00
|
|
|
nsCSSPseudoElements::GetPseudoType(
|
|
|
|
aPseudoTag, CSSEnabledState::eIgnoreEnabledState) ==
|
|
|
|
aPseudoType),
|
2009-12-11 10:37:40 +03:00
|
|
|
"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.
|
2012-07-30 18:20:58 +04:00
|
|
|
aVisitedRuleNode = nullptr;
|
2010-06-15 00:06:48 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
// Ensure |aVisitedRuleNode != nullptr| corresponds to the need to
|
2010-04-03 05:58:27 +04:00
|
|
|
// create an if-visited style context, and that in that case, we have
|
|
|
|
// parentIfVisited set correctly.
|
|
|
|
nsStyleContext *parentIfVisited =
|
2012-07-30 18:20:58 +04:00
|
|
|
aParentContext ? aParentContext->GetStyleIfVisited() : nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
if (parentIfVisited) {
|
|
|
|
if (!aVisitedRuleNode) {
|
|
|
|
aVisitedRuleNode = aRuleNode;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (aVisitedRuleNode) {
|
|
|
|
parentIfVisited = aParentContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
if (aFlags & eIsLink) {
|
2010-04-03 05:58:27 +04:00
|
|
|
// 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
|
|
|
|
2014-08-03 06:37:42 +04:00
|
|
|
bool relevantLinkVisited = (aFlags & eIsLink) ?
|
|
|
|
(aFlags & eIsVisitedLink) :
|
|
|
|
(aParentContext && aParentContext->RelevantLinkVisited());
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> result;
|
2015-05-04 00:52:53 +03:00
|
|
|
if (aParentContext)
|
2010-04-03 05:58:26 +04:00
|
|
|
result = aParentContext->FindChildWithRules(aPseudoTag, aRuleNode,
|
2015-05-04 00:52:53 +03:00
|
|
|
aVisitedRuleNode,
|
|
|
|
relevantLinkVisited);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
2003-03-06 22:14:17 +03:00
|
|
|
if (!result) {
|
2016-07-08 07:17:42 +03:00
|
|
|
// |aVisitedRuleNode| may have a ref-count of zero since we are yet
|
|
|
|
// to create the style context that will hold an owning reference to it.
|
|
|
|
// As a result, we need to make sure it stays alive until that point
|
|
|
|
// in case something in the first call to NS_NewStyleContext triggers a
|
|
|
|
// GC sweep of rule nodes.
|
|
|
|
RefPtr<nsRuleNode> kungFuDeathGrip{aVisitedRuleNode};
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
result = NS_NewStyleContext(aParentContext, aPseudoTag, aPseudoType,
|
2014-05-03 17:42:33 +04:00
|
|
|
aRuleNode,
|
2014-06-16 17:55:00 +04:00
|
|
|
aFlags & eSkipParentDisplayBasedStyleFixup);
|
2010-04-03 05:58:27 +04:00
|
|
|
if (aVisitedRuleNode) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> resultIfVisited =
|
2010-04-03 05:58:27 +04:00
|
|
|
NS_NewStyleContext(parentIfVisited, aPseudoTag, aPseudoType,
|
2013-02-21 11:34:58 +04:00
|
|
|
aVisitedRuleNode,
|
2014-06-16 17:55:00 +04:00
|
|
|
aFlags & eSkipParentDisplayBasedStyleFixup);
|
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
|
|
|
|
|
|
|
if (relevantLinkVisited) {
|
|
|
|
result->AddStyleBit(NS_STYLE_RELEVANT_LINK_VISITED);
|
|
|
|
}
|
2010-04-03 05:58:27 +04:00
|
|
|
}
|
2003-03-06 22:14:17 +03:00
|
|
|
}
|
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
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
if (aFlags & eDoAnimation) {
|
2016-02-15 10:08:33 +03:00
|
|
|
|
2011-05-01 02:16:19 +04:00
|
|
|
nsIStyleRule *oldAnimRule = GetAnimationRule(aRuleNode);
|
2016-02-15 10:08:33 +03:00
|
|
|
nsIStyleRule *animRule = nullptr;
|
|
|
|
|
|
|
|
// Ignore animations for print or print preview, and for elements
|
|
|
|
// that are not attached to the document tree.
|
|
|
|
if (PresContext()->IsDynamic() &&
|
|
|
|
aElementForAnimation->IsInComposedDoc()) {
|
|
|
|
// Update CSS animations in case the animation-name has just changed.
|
|
|
|
PresContext()->AnimationManager()->UpdateAnimations(result,
|
|
|
|
aElementForAnimation);
|
2016-04-01 03:31:51 +03:00
|
|
|
PresContext()->EffectCompositor()->UpdateEffectProperties(
|
|
|
|
result, aElementForAnimation, result->GetPseudoType());
|
2016-02-15 10:08:33 +03:00
|
|
|
|
|
|
|
animRule = PresContext()->EffectCompositor()->
|
|
|
|
GetAnimationRule(aElementForAnimation,
|
|
|
|
result->GetPseudoType(),
|
2016-07-11 11:28:14 +03:00
|
|
|
EffectCompositor::CascadeLevel::Animations,
|
|
|
|
result);
|
2016-02-15 10:08:33 +03:00
|
|
|
}
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(result->RuleNode() == aRuleNode,
|
|
|
|
"unexpected rule node");
|
|
|
|
MOZ_ASSERT(!result->GetStyleIfVisited() == !aVisitedRuleNode,
|
|
|
|
"unexpected visited rule node");
|
|
|
|
MOZ_ASSERT(!aVisitedRuleNode ||
|
|
|
|
result->GetStyleIfVisited()->RuleNode() == aVisitedRuleNode,
|
|
|
|
"unexpected visited rule node");
|
|
|
|
MOZ_ASSERT(!aVisitedRuleNode ||
|
|
|
|
oldAnimRule == GetAnimationRule(aVisitedRuleNode),
|
|
|
|
"animation rule mismatch between rule nodes");
|
2011-05-01 02:16:19 +04:00
|
|
|
if (oldAnimRule != animRule) {
|
|
|
|
nsRuleNode *ruleNode =
|
|
|
|
ReplaceAnimationRule(aRuleNode, oldAnimRule, animRule);
|
|
|
|
nsRuleNode *visitedRuleNode = aVisitedRuleNode
|
|
|
|
? ReplaceAnimationRule(aVisitedRuleNode, oldAnimRule, animRule)
|
2012-07-30 18:20:58 +04:00
|
|
|
: nullptr;
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!visitedRuleNode ||
|
|
|
|
GetAnimationRule(ruleNode) ==
|
|
|
|
GetAnimationRule(visitedRuleNode),
|
|
|
|
"animation rule mismatch between rule nodes");
|
2011-04-12 10:18:44 +04:00
|
|
|
result = GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2013-02-01 20:02:29 +04:00
|
|
|
aPseudoTag, aPseudoType, nullptr,
|
|
|
|
aFlags & ~eDoAnimation);
|
2011-04-12 10:18:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (aElementForAnimation &&
|
|
|
|
aElementForAnimation->IsHTMLElement(nsGkAtoms::body) &&
|
2016-02-17 01:07:00 +03:00
|
|
|
aPseudoType == CSSPseudoElementType::NotPseudo &&
|
2011-06-01 15:43:31 +04:00
|
|
|
PresContext()->CompatibilityMode() == eCompatibility_NavQuirks) {
|
2016-03-31 14:46:32 +03:00
|
|
|
nsIDocument* doc = aElementForAnimation->GetUncomposedDoc();
|
2011-06-01 15:43:31 +04:00
|
|
|
if (doc && doc->GetBodyElement() == aElementForAnimation) {
|
|
|
|
// Update the prescontext's body color
|
2013-02-17 01:51:02 +04:00
|
|
|
PresContext()->SetBodyTextColor(result->StyleColor()->mColor);
|
2011-06-01 15:43:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<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.
|
2015-11-05 11:44:10 +03:00
|
|
|
NS_ASSERTION(RefPtr<css::Declaration>(do_QueryObject(node->GetRule())),
|
2011-05-24 00:45:43 +04:00
|
|
|
"Unexpected non-CSS rule");
|
|
|
|
|
|
|
|
nsIStyleRule* impRule =
|
2015-11-05 11:44:10 +03:00
|
|
|
static_cast<css::Declaration*>(node->GetRule())->GetImportantStyleData();
|
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?");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t 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()) {
|
2015-11-05 11:44:10 +03:00
|
|
|
RefPtr<css::Declaration> declaration(do_QueryObject(node->GetRule()));
|
|
|
|
NS_ASSERTION(declaration, "Unexpected non-CSS rule");
|
2011-05-24 00:45:43 +04:00
|
|
|
|
2015-11-05 11:44:10 +03:00
|
|
|
NS_ASSERTION(!declaration->GetImportantStyleData(),
|
|
|
|
"Unexpected important style source");
|
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();
|
2015-11-05 11:44:10 +03:00
|
|
|
RefPtr<css::Declaration> declaration(do_QueryObject(rule));
|
|
|
|
if (declaration) {
|
|
|
|
RefPtr<css::StyleRule> cssRule =
|
|
|
|
do_QueryObject(declaration->GetOwningRule());
|
|
|
|
NS_ASSERTION(!cssRule || !cssRule->Selector(),
|
|
|
|
"Unexpected CSS rule");
|
|
|
|
}
|
2008-07-14 00:57:38 +04:00
|
|
|
}
|
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
|
2016-06-29 14:27:42 +03:00
|
|
|
nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
2013-01-09 03:25:47 +04:00
|
|
|
RuleProcessorData* aData, Element* aElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsRuleWalker* aRuleWalker)
|
2001-11-06 13:04:05 +03:00
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("nsStyleSet", "FileRules",
|
|
|
|
js::ProfileEntry::Category::CSS);
|
2012-09-15 01:12:34 +04:00
|
|
|
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
|
|
|
|
2001-11-06 13:04:05 +03:00
|
|
|
// Cascading order:
|
|
|
|
// [least important]
|
2012-08-30 05:27:01 +04:00
|
|
|
// - UA normal rules = Agent normal
|
|
|
|
// - User normal rules = User normal
|
|
|
|
// - Presentation hints = PresHint normal
|
2014-09-13 17:17:35 +04:00
|
|
|
// - SVG Animation (highest pres hint) = SVGAttrAnimation normal
|
2012-08-30 05:27:01 +04:00
|
|
|
// - Author normal rules = Document normal
|
|
|
|
// - Override normal rules = Override normal
|
|
|
|
// - animation rules = Animation normal
|
|
|
|
// - Author !important rules = Document !important
|
|
|
|
// - Override !important rules = Override !important
|
|
|
|
// - User !important rules = User !important
|
|
|
|
// - UA !important rules = Agent !important
|
|
|
|
// - 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();
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Agent, false, true);
|
|
|
|
if (mRuleProcessors[SheetType::Agent])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Agent], 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
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::User, false, true);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool skipUserStyles =
|
2013-01-09 03:25:47 +04:00
|
|
|
aElement && aElement->IsInNativeAnonymousSubtree();
|
2015-10-20 02:16:20 +03:00
|
|
|
if (!skipUserStyles && mRuleProcessors[SheetType::User]) // NOTE: different
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::User], 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
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::PresHint, false, false);
|
|
|
|
if (mRuleProcessors[SheetType::PresHint])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::PresHint], aData);
|
2014-09-13 17:17:35 +04:00
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::SVGAttrAnimation, false, false);
|
|
|
|
if (mRuleProcessors[SheetType::SVGAttrAnimation])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::SVGAttrAnimation], aData);
|
2014-09-13 17:17:35 +04:00
|
|
|
nsRuleNode* lastSVGAttrAnimationRN = aRuleWalker->CurrentNode();
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Doc, false, true);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool cutOffInheritance = false;
|
2013-01-09 03:25:47 +04:00
|
|
|
if (mBindingManager && aElement) {
|
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,
|
2012-11-14 23:09:01 +04:00
|
|
|
static_cast<ElementDependentRuleProcessorData*>(aData),
|
2009-12-11 10:37:40 +03:00
|
|
|
&cutOffInheritance);
|
2001-11-06 13:04:05 +03:00
|
|
|
}
|
2013-01-09 03:25:47 +04:00
|
|
|
if (!skipUserStyles && !cutOffInheritance && // NOTE: different
|
2015-10-20 02:16:20 +03:00
|
|
|
mRuleProcessors[SheetType::Doc])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Doc], aData);
|
2013-01-08 12:36:21 +04:00
|
|
|
nsRuleNode* lastDocRN = aRuleWalker->CurrentNode();
|
|
|
|
bool haveImportantDocRules = !aRuleWalker->GetCheckForImportantRules();
|
2013-01-09 03:25:47 +04:00
|
|
|
nsTArray<nsRuleNode*> lastScopedRNs;
|
|
|
|
nsTArray<bool> haveImportantScopedRules;
|
|
|
|
bool haveAnyImportantScopedRules = false;
|
|
|
|
if (!skipUserStyles && !cutOffInheritance &&
|
|
|
|
aElement && aElement->IsElementInStyleScope()) {
|
|
|
|
lastScopedRNs.SetLength(mScopedDocSheetRuleProcessors.Length());
|
|
|
|
haveImportantScopedRules.SetLength(mScopedDocSheetRuleProcessors.Length());
|
2013-01-10 22:40:53 +04:00
|
|
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::ScopedDoc, false, true);
|
2013-01-09 03:25:47 +04:00
|
|
|
nsCSSRuleProcessor* processor =
|
|
|
|
static_cast<nsCSSRuleProcessor*>(mScopedDocSheetRuleProcessors[i].get());
|
2013-01-09 03:25:48 +04:00
|
|
|
aData->mScope = processor->GetScopeElement();
|
2013-01-09 03:25:47 +04:00
|
|
|
(*aCollectorFunc)(mScopedDocSheetRuleProcessors[i], aData);
|
|
|
|
lastScopedRNs[i] = aRuleWalker->CurrentNode();
|
|
|
|
haveImportantScopedRules[i] = !aRuleWalker->GetCheckForImportantRules();
|
|
|
|
haveAnyImportantScopedRules = haveAnyImportantScopedRules || haveImportantScopedRules[i];
|
|
|
|
}
|
2013-01-09 03:25:48 +04:00
|
|
|
aData->mScope = nullptr;
|
2013-01-09 03:25:47 +04:00
|
|
|
}
|
|
|
|
nsRuleNode* lastScopedRN = aRuleWalker->CurrentNode();
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::StyleAttr, false, true);
|
|
|
|
if (mRuleProcessors[SheetType::StyleAttr])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::StyleAttr], aData);
|
2013-01-09 03:25:47 +04:00
|
|
|
nsRuleNode* lastStyleAttrRN = aRuleWalker->CurrentNode();
|
|
|
|
bool haveImportantStyleAttrRules = !aRuleWalker->GetCheckForImportantRules();
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Override, false, true);
|
|
|
|
if (mRuleProcessors[SheetType::Override])
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Override], 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
|
|
|
|
2012-08-30 05:27:01 +04:00
|
|
|
// This needs to match IsMoreSpecificThanAnimation() above.
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Animation, false, false);
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Animation], aData);
|
2012-08-30 05:27:01 +04:00
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
if (haveAnyImportantScopedRules) {
|
|
|
|
for (uint32_t i = lastScopedRNs.Length(); i-- != 0; ) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::ScopedDoc, true, false);
|
2013-01-09 03:25:47 +04:00
|
|
|
nsRuleNode* startRN = lastScopedRNs[i];
|
|
|
|
nsRuleNode* endRN = i == 0 ? lastDocRN : lastScopedRNs[i - 1];
|
|
|
|
if (haveImportantScopedRules[i]) {
|
|
|
|
AddImportantRules(startRN, endRN, aRuleWalker); // scoped
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
|
|
|
AssertNoImportantRules(startRN, endRN);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
|
|
|
AssertNoImportantRules(lastScopedRN, lastDocRN);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-11 01:36:02 +03:00
|
|
|
if (haveImportantDocRules) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Doc, true, false);
|
2014-09-13 17:17:35 +04:00
|
|
|
AddImportantRules(lastDocRN, lastSVGAttrAnimationRN, aRuleWalker); // doc
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2014-09-13 17:17:35 +04:00
|
|
|
AssertNoImportantRules(lastDocRN, lastSVGAttrAnimationRN);
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
if (haveImportantStyleAttrRules) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::StyleAttr, true, false);
|
2013-01-09 03:25:47 +04:00
|
|
|
AddImportantRules(lastStyleAttrRN, lastScopedRN, aRuleWalker); // style attr
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
|
|
|
AssertNoImportantRules(lastStyleAttrRN, lastScopedRN);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-11 01:36:02 +03:00
|
|
|
if (haveImportantOverrideRules) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Override, true, false);
|
2013-01-09 03:25:47 +04:00
|
|
|
AddImportantRules(lastOvrRN, lastStyleAttrRN, aRuleWalker); // override
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
2013-01-09 03:25:47 +04:00
|
|
|
AssertNoImportantRules(lastOvrRN, lastStyleAttrRN);
|
2009-12-11 01:36:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
2001-11-06 13:04:05 +03:00
|
|
|
|
2004-07-16 00:30:30 +04:00
|
|
|
#ifdef DEBUG
|
2014-09-13 17:17:35 +04:00
|
|
|
AssertNoCSSRules(lastSVGAttrAnimationRN, lastUserRN);
|
2004-07-16 00:30:30 +04:00
|
|
|
#endif
|
2009-12-11 01:36:02 +03:00
|
|
|
|
|
|
|
if (haveImportantUserRules) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::User, 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) {
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Agent, 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
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Transition, false, false);
|
|
|
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Transition], aData);
|
2009-10-08 07:22:42 +04:00
|
|
|
#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,
|
2012-11-14 23:09:01 +04:00
|
|
|
ElementDependentRuleProcessorData* aData,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aWalkAllXBLStylesheets)
|
2001-11-11 02:51:45 +03:00
|
|
|
{
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
if (mRuleProcessors[SheetType::Agent])
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::Agent], aData);
|
2007-05-05 10:47:09 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool skipUserStyles = aData->mElement->IsInNativeAnonymousSubtree();
|
2015-10-20 02:16:20 +03:00
|
|
|
if (!skipUserStyles && mRuleProcessors[SheetType::User]) // NOTE: different
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::User], aData);
|
2007-05-05 10:47:09 +04:00
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
if (mRuleProcessors[SheetType::PresHint])
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::PresHint], aData);
|
2013-05-20 06:59:20 +04:00
|
|
|
|
2015-10-20 02:16:20 +03:00
|
|
|
if (mRuleProcessors[SheetType::SVGAttrAnimation])
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::SVGAttrAnimation], aData);
|
2014-09-13 17:17:35 +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
|
|
|
}
|
2013-01-09 03:25:47 +04:00
|
|
|
if (!skipUserStyles && !cutOffInheritance) {
|
2015-10-20 02:16:20 +03:00
|
|
|
if (mRuleProcessors[SheetType::Doc]) // NOTE: different
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::Doc], aData);
|
2013-01-09 03:25:47 +04:00
|
|
|
if (aData->mElement->IsElementInStyleScope()) {
|
2013-01-10 22:40:53 +04:00
|
|
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++)
|
2013-01-09 03:25:47 +04:00
|
|
|
(*aFunc)(mScopedDocSheetRuleProcessors[i], aData);
|
|
|
|
}
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
if (mRuleProcessors[SheetType::StyleAttr])
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::StyleAttr], aData);
|
|
|
|
if (mRuleProcessors[SheetType::Override])
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::Override], aData);
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::Animation], aData);
|
|
|
|
(*aFunc)(mRuleProcessors[SheetType::Transition], aData);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2013-10-11 03:28:49 +04:00
|
|
|
static void
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(TreeMatchContext& aTreeContext, Element* aElement)
|
2013-10-11 03:28:49 +04:00
|
|
|
{
|
|
|
|
if (aElement->IsElementInStyleScope()) {
|
2014-07-24 12:12:38 +04:00
|
|
|
aTreeContext.InitStyleScopes(aElement->GetParentElementCrossingShadowRoot());
|
2013-10-11 03:28:49 +04: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());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aElement);
|
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
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2010-04-30 17:12:06 +04:00
|
|
|
NS_ASSERTION(aElement, "aElement must not be null");
|
1998-05-19 01:05:52 +04:00
|
|
|
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
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);
|
2013-06-29 07:28:50 +04:00
|
|
|
WalkDisableTextZoomRule(aElement, &ruleWalker);
|
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();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRuleNode *visitedRuleNode = nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
uint32_t flags = eDoAnimation;
|
|
|
|
if (nsCSSRuleProcessor::IsLink(aElement)) {
|
|
|
|
flags |= eIsLink;
|
|
|
|
}
|
|
|
|
if (nsCSSRuleProcessor::GetContentState(aElement, aTreeMatchContext).
|
|
|
|
HasState(NS_EVENT_STATE_VISITED)) {
|
|
|
|
flags |= eIsVisitedLink;
|
|
|
|
}
|
2014-06-16 17:55:00 +04:00
|
|
|
if (aTreeMatchContext.mSkippingParentDisplayBasedStyleFixup) {
|
|
|
|
flags |= eSkipParentDisplayBasedStyleFixup;
|
2013-02-21 11:35:03 +04:00
|
|
|
}
|
2013-02-01 20:02:29 +04:00
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2016-02-17 01:07:00 +03:00
|
|
|
nullptr, CSSPseudoElementType::NotPseudo,
|
2013-02-01 20:02:29 +04:00
|
|
|
aElement, flags);
|
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,
|
2012-10-18 01:01:56 +04:00
|
|
|
const nsTArray< nsCOMPtr<nsIStyleRule> > &aRules)
|
2007-07-25 22:21:34 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
2010-04-02 10:07:42 +04:00
|
|
|
// FIXME: Perhaps this should be passed in, but it probably doesn't
|
|
|
|
// matter.
|
2015-10-20 02:16:20 +03:00
|
|
|
ruleWalker.SetLevel(SheetType::Doc, false, false);
|
2012-10-18 01:01:56 +04:00
|
|
|
for (uint32_t i = 0; i < aRules.Length(); i++) {
|
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ElementAt(i));
|
2007-07-25 22:21:34 +04:00
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return GetContext(aParentContext, ruleWalker.CurrentNode(), nullptr,
|
2016-02-17 01:07:00 +03:00
|
|
|
nullptr, CSSPseudoElementType::NotPseudo,
|
2013-02-01 20:02:29 +04:00
|
|
|
nullptr, eNoFlags);
|
2010-04-03 05:58:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
|
|
|
const nsCOMArray<nsIStyleRule> &aRules)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2010-04-03 05:58:25 +04:00
|
|
|
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
2013-02-17 01:04:53 +04:00
|
|
|
ruleWalker.SetCurrentNode(aBaseContext->RuleNode());
|
2014-11-17 22:39:14 +03:00
|
|
|
// This needs to be the transition sheet because that is the highest
|
|
|
|
// level of the cascade, and thus the only thing that makes sense if
|
|
|
|
// we are ever going to call ResolveStyleWithReplacement on the
|
|
|
|
// resulting context. It's also the right thing for the one case (the
|
|
|
|
// transition manager's cover rule) where we put the result of this
|
|
|
|
// function in the style context tree.
|
2015-10-20 02:16:20 +03:00
|
|
|
ruleWalker.SetLevel(SheetType::Transition, false, false);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t 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();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRuleNode *visitedRuleNode = nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
|
|
|
|
if (aBaseContext->GetStyleIfVisited()) {
|
2013-02-17 01:04:53 +04:00
|
|
|
ruleWalker.SetCurrentNode(aBaseContext->GetStyleIfVisited()->RuleNode());
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t 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();
|
|
|
|
}
|
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
uint32_t flags = eNoFlags;
|
|
|
|
if (aBaseContext->IsLinkContext()) {
|
|
|
|
flags |= eIsLink;
|
2014-08-03 06:37:42 +04:00
|
|
|
|
|
|
|
// GetContext handles propagating RelevantLinkVisited state from the
|
|
|
|
// parent in non-link cases; all we need to pass in is if this link
|
|
|
|
// is visited.
|
|
|
|
if (aBaseContext->RelevantLinkVisited()) {
|
|
|
|
flags |= eIsVisitedLink;
|
|
|
|
}
|
2013-02-01 20:02:29 +04:00
|
|
|
}
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aBaseContext->GetParent(), ruleNode, visitedRuleNode,
|
2010-04-03 05:58:25 +04:00
|
|
|
aBaseContext->GetPseudo(),
|
2011-04-12 10:18:44 +04:00
|
|
|
aBaseContext->GetPseudoType(),
|
2013-02-01 20:02:29 +04:00
|
|
|
nullptr, flags);
|
2007-07-25 22:21:34 +04:00
|
|
|
}
|
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
struct RuleNodeInfo {
|
|
|
|
nsIStyleRule* mRule;
|
2015-10-20 02:16:20 +03:00
|
|
|
SheetType mLevel;
|
2014-08-03 06:37:44 +04:00
|
|
|
bool mIsImportant;
|
2015-07-27 09:43:44 +03:00
|
|
|
bool mIsAnimationRule;
|
2014-08-03 06:37:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CascadeLevel {
|
2015-10-20 02:16:20 +03:00
|
|
|
SheetType mLevel;
|
2014-08-03 06:37:44 +04:00
|
|
|
bool mIsImportant;
|
2014-09-13 17:17:36 +04:00
|
|
|
bool mCheckForImportantRules;
|
2014-08-03 06:37:44 +04:00
|
|
|
nsRestyleHint mLevelReplacementHint;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const CascadeLevel gCascadeLevels[] = {
|
2015-10-20 02:16:20 +03:00
|
|
|
{ SheetType::Agent, false, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::User, false, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::PresHint, false, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::SVGAttrAnimation, false, false, eRestyle_SVGAttrAnimations },
|
|
|
|
{ SheetType::Doc, false, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::ScopedDoc, false, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::StyleAttr, false, true, eRestyle_StyleAttribute |
|
|
|
|
eRestyle_StyleAttribute_Animations },
|
|
|
|
{ SheetType::Override, false, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::Animation, false, false, eRestyle_CSSAnimations },
|
|
|
|
{ SheetType::ScopedDoc, true, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::Doc, true, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::StyleAttr, true, false, eRestyle_StyleAttribute |
|
|
|
|
eRestyle_StyleAttribute_Animations },
|
|
|
|
{ SheetType::Override, true, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::User, true, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::Agent, true, false, nsRestyleHint(0) },
|
|
|
|
{ SheetType::Transition, false, false, eRestyle_CSSTransitions },
|
2014-08-03 06:37:44 +04:00
|
|
|
};
|
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
nsRuleNode*
|
|
|
|
nsStyleSet::RuleNodeWithReplacement(Element* aElement,
|
2015-02-17 01:15:05 +03:00
|
|
|
Element* aPseudoElement,
|
2014-08-03 06:37:44 +04:00
|
|
|
nsRuleNode* aOldRuleNode,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2014-08-03 06:37:44 +04:00
|
|
|
nsRestyleHint aReplacements)
|
2014-08-03 06:37:43 +04:00
|
|
|
{
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
|
|
|
|
2015-02-17 01:15:05 +03:00
|
|
|
MOZ_ASSERT(!aPseudoElement ==
|
2016-02-17 01:07:00 +03:00
|
|
|
(aPseudoType >= CSSPseudoElementType::Count ||
|
2015-02-17 01:15:05 +03:00
|
|
|
!(nsCSSPseudoElements::PseudoElementSupportsStyleAttribute(aPseudoType) ||
|
|
|
|
nsCSSPseudoElements::PseudoElementSupportsUserActionState(aPseudoType))),
|
|
|
|
"should have aPseudoElement only for certain pseudo elements");
|
|
|
|
|
2015-02-10 04:05:37 +03:00
|
|
|
MOZ_ASSERT(!(aReplacements & ~(eRestyle_CSSTransitions |
|
|
|
|
eRestyle_CSSAnimations |
|
|
|
|
eRestyle_SVGAttrAnimations |
|
|
|
|
eRestyle_StyleAttribute |
|
2015-02-19 11:22:05 +03:00
|
|
|
eRestyle_StyleAttribute_Animations |
|
2015-02-10 04:05:37 +03:00
|
|
|
eRestyle_Force |
|
|
|
|
eRestyle_ForceDescendants)),
|
|
|
|
"unexpected replacement bits");
|
2014-08-03 06:37:44 +04:00
|
|
|
|
2014-08-03 06:37:46 +04:00
|
|
|
// FIXME (perf): This should probably not rebuild the whole path, but
|
|
|
|
// only the path from the last change in the rule tree, like
|
|
|
|
// ReplaceAnimationRule in nsStyleSet.cpp does. (That could then
|
|
|
|
// perhaps share this code, too?)
|
2014-08-04 00:11:55 +04:00
|
|
|
// But if we do that, we'll need to pass whether we are rebuilding the
|
|
|
|
// rule tree from ElementRestyler::RestyleSelf to avoid taking that
|
|
|
|
// path when we're rebuilding the rule tree.
|
2014-08-03 06:37:46 +04:00
|
|
|
|
2016-01-21 02:01:25 +03:00
|
|
|
// This array can be hot and often grows to ~20 elements, so inline storage
|
|
|
|
// is best.
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<RuleNodeInfo, 30> rules;
|
2014-08-03 06:37:44 +04:00
|
|
|
for (nsRuleNode* ruleNode = aOldRuleNode; !ruleNode->IsRoot();
|
2014-08-03 06:37:44 +04:00
|
|
|
ruleNode = ruleNode->GetParent()) {
|
|
|
|
RuleNodeInfo* curRule = rules.AppendElement();
|
|
|
|
curRule->mRule = ruleNode->GetRule();
|
|
|
|
curRule->mLevel = ruleNode->GetLevel();
|
|
|
|
curRule->mIsImportant = ruleNode->IsImportantRule();
|
2015-07-27 09:43:44 +03:00
|
|
|
curRule->mIsAnimationRule = ruleNode->IsAnimationRule();
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
2014-08-03 06:37:43 +04:00
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
|
|
|
auto rulesIndex = rules.Length();
|
|
|
|
|
2014-09-13 17:17:36 +04:00
|
|
|
// We need to transfer this information between the non-!important and
|
|
|
|
// !important phases for the style attribute level.
|
|
|
|
nsRuleNode* lastScopedRN = nullptr;
|
|
|
|
nsRuleNode* lastStyleAttrRN = nullptr;
|
|
|
|
bool haveImportantStyleAttrRules = false;
|
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
for (const CascadeLevel *level = gCascadeLevels,
|
|
|
|
*levelEnd = ArrayEnd(gCascadeLevels);
|
|
|
|
level != levelEnd; ++level) {
|
|
|
|
|
|
|
|
bool doReplace = level->mLevelReplacementHint & aReplacements;
|
2014-09-13 17:17:36 +04:00
|
|
|
|
|
|
|
ruleWalker.SetLevel(level->mLevel, level->mIsImportant,
|
|
|
|
level->mCheckForImportantRules && doReplace);
|
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
if (doReplace) {
|
2015-02-19 11:22:05 +03:00
|
|
|
switch (level->mLevel) {
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::Animation: {
|
2016-02-17 01:07:00 +03:00
|
|
|
if (aPseudoType == CSSPseudoElementType::NotPseudo ||
|
|
|
|
aPseudoType == CSSPseudoElementType::before ||
|
|
|
|
aPseudoType == CSSPseudoElementType::after) {
|
2016-01-13 01:54:55 +03:00
|
|
|
nsIStyleRule* rule = PresContext()->EffectCompositor()->
|
|
|
|
GetAnimationRule(aElement, aPseudoType,
|
2016-07-11 11:28:14 +03:00
|
|
|
EffectCompositor::CascadeLevel::Animations,
|
|
|
|
nullptr);
|
2014-11-12 02:42:57 +03:00
|
|
|
if (rule) {
|
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(rule);
|
2015-07-27 09:43:44 +03:00
|
|
|
ruleWalker.CurrentNode()->SetIsAnimationRule();
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::Transition: {
|
2016-02-17 01:07:00 +03:00
|
|
|
if (aPseudoType == CSSPseudoElementType::NotPseudo ||
|
|
|
|
aPseudoType == CSSPseudoElementType::before ||
|
|
|
|
aPseudoType == CSSPseudoElementType::after) {
|
2016-01-13 01:54:55 +03:00
|
|
|
nsIStyleRule* rule = PresContext()->EffectCompositor()->
|
|
|
|
GetAnimationRule(aElement, aPseudoType,
|
2016-07-11 11:28:14 +03:00
|
|
|
EffectCompositor::CascadeLevel::Transitions,
|
|
|
|
nullptr);
|
2014-11-20 05:48:41 +03:00
|
|
|
if (rule) {
|
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(rule);
|
2015-07-27 09:43:44 +03:00
|
|
|
ruleWalker.CurrentNode()->SetIsAnimationRule();
|
2014-11-20 05:48:41 +03:00
|
|
|
}
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::SVGAttrAnimation: {
|
2014-09-13 17:17:35 +04:00
|
|
|
SVGAttrAnimationRuleProcessor* ruleProcessor =
|
|
|
|
static_cast<SVGAttrAnimationRuleProcessor*>(
|
2015-10-20 02:16:20 +03:00
|
|
|
mRuleProcessors[SheetType::SVGAttrAnimation].get());
|
2014-09-13 17:17:35 +04:00
|
|
|
if (ruleProcessor &&
|
2016-02-17 01:07:00 +03:00
|
|
|
aPseudoType == CSSPseudoElementType::NotPseudo) {
|
2014-09-13 17:17:35 +04:00
|
|
|
ruleProcessor->ElementRulesMatching(aElement, &ruleWalker);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
case SheetType::StyleAttr: {
|
2014-09-13 17:17:36 +04:00
|
|
|
if (!level->mIsImportant) {
|
|
|
|
// First time through, we handle the non-!important rule.
|
|
|
|
nsHTMLCSSStyleSheet* ruleProcessor =
|
|
|
|
static_cast<nsHTMLCSSStyleSheet*>(
|
2015-10-20 02:16:20 +03:00
|
|
|
mRuleProcessors[SheetType::StyleAttr].get());
|
2015-02-17 01:15:05 +03:00
|
|
|
if (ruleProcessor) {
|
2014-09-13 17:17:36 +04:00
|
|
|
lastScopedRN = ruleWalker.CurrentNode();
|
2015-02-17 01:15:05 +03:00
|
|
|
if (aPseudoType ==
|
2016-02-17 01:07:00 +03:00
|
|
|
CSSPseudoElementType::NotPseudo) {
|
2015-02-17 01:15:05 +03:00
|
|
|
ruleProcessor->ElementRulesMatching(PresContext(),
|
|
|
|
aElement,
|
|
|
|
&ruleWalker);
|
|
|
|
} else if (aPseudoType <
|
2016-02-17 01:07:00 +03:00
|
|
|
CSSPseudoElementType::Count &&
|
2015-02-17 01:15:05 +03:00
|
|
|
nsCSSPseudoElements::
|
|
|
|
PseudoElementSupportsStyleAttribute(aPseudoType)) {
|
|
|
|
ruleProcessor->PseudoElementRulesMatching(aPseudoElement,
|
|
|
|
aPseudoType,
|
|
|
|
&ruleWalker);
|
|
|
|
}
|
2014-09-13 17:17:36 +04:00
|
|
|
lastStyleAttrRN = ruleWalker.CurrentNode();
|
|
|
|
haveImportantStyleAttrRules =
|
|
|
|
!ruleWalker.GetCheckForImportantRules();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Second time through, we handle the !important rule(s).
|
|
|
|
if (haveImportantStyleAttrRules) {
|
|
|
|
AddImportantRules(lastStyleAttrRN, lastScopedRN, &ruleWalker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-08-03 06:37:44 +04:00
|
|
|
default:
|
2014-09-13 17:17:36 +04:00
|
|
|
MOZ_ASSERT(false, "unexpected result from gCascadeLevels lookup");
|
2014-08-03 06:37:44 +04:00
|
|
|
break;
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
2014-08-03 06:37:43 +04:00
|
|
|
}
|
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
while (rulesIndex != 0) {
|
|
|
|
--rulesIndex;
|
|
|
|
const RuleNodeInfo& ruleInfo = rules[rulesIndex];
|
|
|
|
|
|
|
|
if (ruleInfo.mLevel != level->mLevel ||
|
|
|
|
ruleInfo.mIsImportant != level->mIsImportant) {
|
|
|
|
++rulesIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!doReplace) {
|
|
|
|
ruleWalker.ForwardOnPossiblyCSSRule(ruleInfo.mRule);
|
2015-07-27 09:43:44 +03:00
|
|
|
if (ruleInfo.mIsAnimationRule) {
|
|
|
|
ruleWalker.CurrentNode()->SetIsAnimationRule();
|
|
|
|
}
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
2014-08-03 06:37:43 +04:00
|
|
|
}
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
2014-08-03 06:37:43 +04:00
|
|
|
|
2014-11-17 22:39:14 +03:00
|
|
|
NS_ASSERTION(rulesIndex == 0,
|
|
|
|
"rules are in incorrect cascading order, "
|
|
|
|
"which means we replaced them incorrectly");
|
|
|
|
|
2014-08-03 06:37:44 +04:00
|
|
|
return ruleWalker.CurrentNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveStyleWithReplacement(Element* aElement,
|
2015-02-17 01:15:05 +03:00
|
|
|
Element* aPseudoElement,
|
2014-08-03 06:37:44 +04:00
|
|
|
nsStyleContext* aNewParentContext,
|
|
|
|
nsStyleContext* aOldStyleContext,
|
2015-02-17 01:15:00 +03:00
|
|
|
nsRestyleHint aReplacements,
|
|
|
|
uint32_t aFlags)
|
2014-08-03 06:37:44 +04:00
|
|
|
{
|
|
|
|
nsRuleNode* ruleNode =
|
2015-02-17 01:15:05 +03:00
|
|
|
RuleNodeWithReplacement(aElement, aPseudoElement,
|
|
|
|
aOldStyleContext->RuleNode(),
|
2014-08-03 06:37:44 +04:00
|
|
|
aOldStyleContext->GetPseudoType(), aReplacements);
|
|
|
|
|
2014-08-03 06:37:45 +04:00
|
|
|
nsRuleNode* visitedRuleNode = nullptr;
|
|
|
|
nsStyleContext* oldStyleIfVisited = aOldStyleContext->GetStyleIfVisited();
|
|
|
|
if (oldStyleIfVisited) {
|
|
|
|
if (oldStyleIfVisited->RuleNode() == aOldStyleContext->RuleNode()) {
|
|
|
|
visitedRuleNode = ruleNode;
|
|
|
|
} else {
|
|
|
|
visitedRuleNode =
|
2015-02-17 01:15:05 +03:00
|
|
|
RuleNodeWithReplacement(aElement, aPseudoElement,
|
|
|
|
oldStyleIfVisited->RuleNode(),
|
2014-08-03 06:37:45 +04:00
|
|
|
oldStyleIfVisited->GetPseudoType(),
|
|
|
|
aReplacements);
|
|
|
|
}
|
|
|
|
}
|
2014-08-03 06:37:44 +04:00
|
|
|
|
|
|
|
uint32_t flags = eNoFlags;
|
|
|
|
if (aOldStyleContext->IsLinkContext()) {
|
|
|
|
flags |= eIsLink;
|
2014-08-03 06:37:44 +04:00
|
|
|
|
|
|
|
// GetContext handles propagating RelevantLinkVisited state from the
|
|
|
|
// parent in non-link cases; all we need to pass in is if this link
|
|
|
|
// is visited.
|
|
|
|
if (aOldStyleContext->RelevantLinkVisited()) {
|
|
|
|
flags |= eIsVisitedLink;
|
|
|
|
}
|
2014-08-03 06:37:44 +04:00
|
|
|
}
|
|
|
|
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType pseudoType = aOldStyleContext->GetPseudoType();
|
2014-08-03 06:37:45 +04:00
|
|
|
Element* elementForAnimation = nullptr;
|
2015-02-17 01:15:00 +03:00
|
|
|
if (!(aFlags & eSkipStartingAnimations) &&
|
2016-02-17 01:07:00 +03:00
|
|
|
(pseudoType == CSSPseudoElementType::NotPseudo ||
|
|
|
|
pseudoType == CSSPseudoElementType::before ||
|
|
|
|
pseudoType == CSSPseudoElementType::after)) {
|
2014-08-03 06:37:45 +04:00
|
|
|
// We want to compute a correct elementForAnimation to pass in
|
|
|
|
// because at this point the parameter is more than just the element
|
|
|
|
// for animation; it's also used for the SetBodyTextColor call when
|
|
|
|
// it's the body element.
|
|
|
|
// However, we only want to set the flag to call CheckAnimationRule
|
|
|
|
// if we're dealing with a replacement (such as style attribute
|
|
|
|
// replacement) that could lead to the animation property changing,
|
|
|
|
// and we explicitly do NOT want to call CheckAnimationRule when
|
|
|
|
// we're trying to do an animation-only update.
|
|
|
|
if (aReplacements & ~(eRestyle_CSSTransitions | eRestyle_CSSAnimations)) {
|
|
|
|
flags |= eDoAnimation;
|
|
|
|
}
|
|
|
|
elementForAnimation = aElement;
|
2016-02-13 09:54:26 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsIFrame* styleFrame = nsLayoutUtils::GetStyleFrame(elementForAnimation);
|
2016-02-17 01:07:00 +03:00
|
|
|
NS_ASSERTION(pseudoType == CSSPseudoElementType::NotPseudo ||
|
2016-02-13 09:54:26 +03:00
|
|
|
!styleFrame ||
|
|
|
|
styleFrame->StyleContext()->GetPseudoType() ==
|
2016-02-17 01:07:00 +03:00
|
|
|
CSSPseudoElementType::NotPseudo,
|
2016-02-13 09:54:26 +03:00
|
|
|
"aElement should be the element and not the pseudo-element");
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-03 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
2014-08-03 06:37:46 +04:00
|
|
|
if (aElement && aElement->IsRootOfAnonymousSubtree()) {
|
|
|
|
// For anonymous subtree roots, don't tweak "display" value based on whether
|
|
|
|
// or not the parent is styled as a flex/grid container. (If the parent
|
|
|
|
// has anonymous-subtree kids, then we know it's not actually going to get
|
|
|
|
// a flex/grid container frame, anyway.)
|
|
|
|
flags |= eSkipParentDisplayBasedStyleFixup;
|
|
|
|
}
|
|
|
|
|
2014-08-03 06:37:45 +04:00
|
|
|
return GetContext(aNewParentContext, ruleNode, visitedRuleNode,
|
2014-08-03 06:37:45 +04:00
|
|
|
aOldStyleContext->GetPseudo(), pseudoType,
|
|
|
|
elementForAnimation, flags);
|
2014-08-03 06:37:43 +04:00
|
|
|
}
|
|
|
|
|
2015-02-17 01:15:01 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveStyleWithoutAnimation(dom::Element* aTarget,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsRestyleHint aWhichToRemove)
|
|
|
|
{
|
2015-02-17 01:15:05 +03:00
|
|
|
#ifdef DEBUG
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
|
2015-02-17 01:15:05 +03:00
|
|
|
#endif
|
2016-02-17 01:07:00 +03:00
|
|
|
MOZ_ASSERT(pseudoType == CSSPseudoElementType::NotPseudo ||
|
|
|
|
pseudoType == CSSPseudoElementType::before ||
|
|
|
|
pseudoType == CSSPseudoElementType::after,
|
2015-02-17 01:15:05 +03:00
|
|
|
"unexpected type for animations");
|
2016-02-24 10:01:12 +03:00
|
|
|
MOZ_ASSERT(PresContext()->RestyleManager()->IsGecko(),
|
|
|
|
"stylo: the style set and restyle manager must have the same "
|
|
|
|
"StyleBackendType");
|
|
|
|
RestyleManager* restyleManager = PresContext()->RestyleManager()->AsGecko();
|
2015-02-17 01:15:01 +03:00
|
|
|
|
|
|
|
bool oldSkipAnimationRules = restyleManager->SkipAnimationRules();
|
|
|
|
restyleManager->SetSkipAnimationRules(true);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> result =
|
2015-02-17 01:15:05 +03:00
|
|
|
ResolveStyleWithReplacement(aTarget, nullptr, aStyleContext->GetParent(),
|
2015-02-17 01:15:01 +03:00
|
|
|
aStyleContext, aWhichToRemove,
|
|
|
|
eSkipStartingAnimations);
|
|
|
|
|
|
|
|
restyleManager->SetSkipAnimationRules(oldSkipAnimationRules);
|
|
|
|
|
|
|
|
return result.forget();
|
|
|
|
}
|
2014-08-03 06:37:43 +04:00
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2016-04-29 07:01:44 +03:00
|
|
|
nsStyleSet::ResolveStyleForText(nsIContent* aTextNode,
|
|
|
|
nsStyleContext* aParentContext)
|
2001-10-30 09:02:05 +03:00
|
|
|
{
|
2016-04-29 07:01:44 +03:00
|
|
|
MOZ_ASSERT(aTextNode && aTextNode->IsNodeOfType(nsINode::eTEXT));
|
|
|
|
return GetContext(aParentContext, mRuleTree, nullptr,
|
|
|
|
nsCSSAnonBoxes::mozText,
|
|
|
|
CSSPseudoElementType::AnonBox, nullptr, eNoFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ResolveStyleForOtherNonElement(nsStyleContext* aParentContext)
|
|
|
|
{
|
|
|
|
return GetContext(aParentContext, mRuleTree, nullptr,
|
|
|
|
nsCSSAnonBoxes::mozOtherNonElement,
|
2016-04-22 02:18:41 +03:00
|
|
|
CSSPseudoElementType::AnonBox, nullptr, eNoFlags);
|
2001-10-30 09:02:05 +03:00
|
|
|
}
|
|
|
|
|
2008-12-12 21:59:03 +03:00
|
|
|
void
|
2016-02-17 23:37:00 +03:00
|
|
|
nsStyleSet::WalkRestrictionRule(CSSPseudoElementType 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.
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Agent, false, false);
|
2016-02-17 01:07:00 +03:00
|
|
|
if (aPseudoType == CSSPseudoElementType::firstLetter)
|
2009-12-11 10:37:40 +03:00
|
|
|
aRuleWalker->Forward(mFirstLetterRule);
|
2016-02-17 01:07:00 +03:00
|
|
|
else if (aPseudoType == CSSPseudoElementType::firstLine)
|
2009-12-11 10:37:40 +03:00
|
|
|
aRuleWalker->Forward(mFirstLineRule);
|
2016-09-08 02:38:38 +03:00
|
|
|
else if (aPseudoType == CSSPseudoElementType::placeholder)
|
2012-11-09 14:25:52 +04:00
|
|
|
aRuleWalker->Forward(mPlaceholderRule);
|
2009-12-11 05:28:08 +03:00
|
|
|
}
|
|
|
|
|
2013-06-29 07:28:50 +04:00
|
|
|
void
|
|
|
|
nsStyleSet::WalkDisableTextZoomRule(Element* aElement, nsRuleWalker* aRuleWalker)
|
|
|
|
{
|
2015-10-20 02:16:20 +03:00
|
|
|
aRuleWalker->SetLevel(SheetType::Agent, false, false);
|
2015-03-03 14:08:59 +03:00
|
|
|
if (aElement->IsSVGElement(nsGkAtoms::text))
|
2013-06-29 07:28:50 +04:00
|
|
|
aRuleWalker->Forward(mDisableTextZoomStyleRule);
|
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 17:12:06 +04:00
|
|
|
nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aType,
|
2013-07-10 02:25:27 +04:00
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
Element* aPseudoElement)
|
2009-12-11 10:37:40 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
NS_ASSERTION(aType < CSSPseudoElementType::Count,
|
2009-12-11 10:37:40 +03:00
|
|
|
"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
|
|
|
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aParentElement->OwnerDoc());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aParentElement);
|
2010-04-30 17:12:06 +04:00
|
|
|
PseudoElementRuleProcessorData data(PresContext(), aParentElement,
|
2013-07-10 02:25:27 +04:00
|
|
|
&ruleWalker, aType, treeContext,
|
|
|
|
aPseudoElement);
|
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();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRuleNode *visitedRuleNode = nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
// For pseudos, |data.IsLink()| being true means that
|
|
|
|
// our parent node is a link.
|
2013-05-03 01:04:47 +04:00
|
|
|
uint32_t flags = eNoFlags;
|
2016-02-17 01:07:00 +03:00
|
|
|
if (aType == CSSPseudoElementType::before ||
|
|
|
|
aType == CSSPseudoElementType::after) {
|
2013-02-01 20:02:29 +04:00
|
|
|
flags |= eDoAnimation;
|
2013-05-03 01:04:47 +04:00
|
|
|
} else {
|
2014-05-03 17:42:33 +04:00
|
|
|
// Flex and grid containers don't expect to have any pseudo-element children
|
|
|
|
// aside from ::before and ::after. So if we have such a child, we're not
|
|
|
|
// actually in a flex/grid container, and we should skip flex/grid item
|
|
|
|
// style fixup.
|
2014-06-16 17:55:00 +04:00
|
|
|
flags |= eSkipParentDisplayBasedStyleFixup;
|
2013-02-01 20:02:29 +04:00
|
|
|
}
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2011-04-12 10:18:44 +04:00
|
|
|
nsCSSPseudoElements::GetPseudoAtom(aType), aType,
|
2013-02-01 20:02:29 +04:00
|
|
|
aParentElement, flags);
|
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,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aType,
|
2009-12-11 10:37:40 +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
|
|
|
aParentElement->OwnerDoc());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aParentElement);
|
2011-03-29 21:29:21 +04:00
|
|
|
return ProbePseudoElementStyle(aParentElement, aType, aParentContext,
|
|
|
|
treeContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aType,
|
2011-03-29 21:29:21 +04:00
|
|
|
nsStyleContext* aParentContext,
|
2013-07-10 02:25:27 +04:00
|
|
|
TreeMatchContext& aTreeMatchContext,
|
|
|
|
Element* aPseudoElement)
|
1998-05-19 01:05:52 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
NS_ASSERTION(aType < CSSPseudoElementType::Count,
|
2009-12-11 10:37:40 +03:00
|
|
|
"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);
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
2011-03-29 21:29:21 +04:00
|
|
|
aTreeMatchContext.ResetForUnvisitedMatching();
|
2010-04-30 17:12:06 +04:00
|
|
|
PseudoElementRuleProcessorData data(PresContext(), aParentElement,
|
2013-07-10 02:25:27 +04:00
|
|
|
&ruleWalker, aType, aTreeMatchContext,
|
|
|
|
aPseudoElement);
|
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) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2003-02-23 20:28:25 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRuleNode *visitedRuleNode = nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
// For pseudos, |data.IsLink()| being true means that
|
|
|
|
// our parent node is a link.
|
2013-05-03 01:04:47 +04:00
|
|
|
uint32_t flags = eNoFlags;
|
2016-02-17 01:07:00 +03:00
|
|
|
if (aType == CSSPseudoElementType::before ||
|
|
|
|
aType == CSSPseudoElementType::after) {
|
2013-02-01 20:02:29 +04:00
|
|
|
flags |= eDoAnimation;
|
2013-05-03 01:04:47 +04:00
|
|
|
} else {
|
2014-05-03 17:42:33 +04:00
|
|
|
// Flex and grid containers don't expect to have any pseudo-element children
|
|
|
|
// aside from ::before and ::after. So if we have such a child, we're not
|
|
|
|
// actually in a flex/grid container, and we should skip flex/grid item
|
|
|
|
// style fixup.
|
2014-06-16 17:55:00 +04:00
|
|
|
flags |= eSkipParentDisplayBasedStyleFixup;
|
2013-02-01 20:02:29 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> result =
|
2010-04-03 05:58:27 +04:00
|
|
|
GetContext(aParentContext, ruleNode, visitedRuleNode,
|
2011-04-12 10:18:44 +04:00
|
|
|
pseudoTag, aType,
|
2013-02-01 20:02:29 +04:00
|
|
|
aParentElement, flags);
|
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)) {
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay *display = result->StyleDisplay();
|
|
|
|
const nsStyleContent *content = result->StyleContent();
|
2003-02-23 20:28:25 +03:00
|
|
|
// XXXldb What is contentCount for |content: ""|?
|
2016-09-03 21:46:58 +03:00
|
|
|
if (display->mDisplay == StyleDisplay::None ||
|
2003-02-23 20:28:25 +03:00
|
|
|
content->ContentCount() == 0) {
|
2012-07-30 18:20:58 +04:00
|
|
|
result = nullptr;
|
2003-02-23 20:28:25 +03:00
|
|
|
}
|
|
|
|
}
|
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,
|
2015-05-28 01:18:36 +03:00
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
uint32_t aFlags)
|
2009-12-11 10:37:40 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
2010-04-02 10:07:42 +04:00
|
|
|
AnonBoxRuleProcessorData data(PresContext(), aPseudoTag, &ruleWalker);
|
2012-07-30 18:20:58 +04:00
|
|
|
FileRules(EnumRulesMatching<AnonBoxRuleProcessorData>, &data, nullptr,
|
2009-12-11 10:37:40 +03:00
|
|
|
&ruleWalker);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2012-09-01 01:21:28 +04:00
|
|
|
if (aPseudoTag == nsCSSAnonBoxes::pageContent) {
|
|
|
|
// Add any @page rules that are specified.
|
|
|
|
nsTArray<nsCSSPageRule*> rules;
|
2015-11-05 11:44:08 +03:00
|
|
|
nsTArray<css::ImportantStyleData*> importantRules;
|
2016-01-22 01:24:27 +03:00
|
|
|
AppendPageRules(rules);
|
2012-09-01 01:21:28 +04:00
|
|
|
for (uint32_t i = 0, i_end = rules.Length(); i != i_end; ++i) {
|
2015-11-05 11:44:10 +03:00
|
|
|
css::Declaration* declaration = rules[i]->Declaration();
|
|
|
|
declaration->SetImmutable();
|
|
|
|
ruleWalker.Forward(declaration);
|
|
|
|
css::ImportantStyleData* importantRule =
|
|
|
|
declaration->GetImportantStyleData();
|
2012-09-01 01:21:28 +04:00
|
|
|
if (importantRule) {
|
|
|
|
importantRules.AppendElement(importantRule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0, i_end = importantRules.Length(); i != i_end; ++i) {
|
|
|
|
ruleWalker.Forward(importantRules[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return GetContext(aParentContext, ruleWalker.CurrentNode(), nullptr,
|
2016-02-17 01:07:00 +03:00
|
|
|
aPseudoTag, CSSPseudoElementType::AnonBox,
|
2015-05-28 01:18:36 +03:00
|
|
|
nullptr, aFlags);
|
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)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(aPseudoTag, "must have pseudo tag");
|
|
|
|
NS_ASSERTION(nsCSSAnonBoxes::IsTreePseudoElement(aPseudoTag),
|
|
|
|
"Unexpected pseudo");
|
|
|
|
|
2013-03-28 06:47:25 +04:00
|
|
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
2011-10-17 18:59:28 +04:00
|
|
|
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
|
2011-10-18 14:53:36 +04:00
|
|
|
aParentElement->OwnerDoc());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aParentElement);
|
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();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRuleNode *visitedRuleNode = nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
|
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.
|
2016-02-17 01:07:00 +03:00
|
|
|
aPseudoTag, CSSPseudoElementType::XULTree,
|
2013-02-01 20:02:29 +04:00
|
|
|
nullptr, eNoFlags);
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
|
2008-11-26 02:22:38 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, false);
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
2008-11-26 02:22:38 +03:00
|
|
|
|
2015-04-17 04:09:59 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
2015-10-20 02:16:20 +03:00
|
|
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
2013-01-09 03:25:47 +04:00
|
|
|
continue;
|
2008-11-26 02:22:38 +03:00
|
|
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
2015-04-17 04:09:59 +03:00
|
|
|
if (ruleProc && !ruleProc->AppendFontFaceRules(presContext, 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
|
|
|
}
|
|
|
|
|
2013-08-15 08:58:37 +04:00
|
|
|
nsCSSKeyframesRule*
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::KeyframesRuleForName(const nsString& aName)
|
2011-04-12 10:18:43 +04:00
|
|
|
{
|
2013-08-15 08:58:37 +04:00
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
2011-04-12 10:18:43 +04:00
|
|
|
|
2015-04-17 04:09:59 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
2013-08-15 08:58:37 +04:00
|
|
|
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
2015-10-20 02:16:20 +03:00
|
|
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
2013-01-09 03:25:47 +04:00
|
|
|
continue;
|
2011-04-12 10:18:43 +04:00
|
|
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
2013-08-15 08:58:37 +04:00
|
|
|
if (!ruleProc)
|
|
|
|
continue;
|
|
|
|
nsCSSKeyframesRule* result =
|
2015-04-17 04:09:59 +03:00
|
|
|
ruleProc->KeyframesRuleForName(presContext, aName);
|
2013-08-15 08:58:37 +04:00
|
|
|
if (result)
|
|
|
|
return result;
|
2011-04-12 10:18:43 +04:00
|
|
|
}
|
2013-08-15 08:58:37 +04:00
|
|
|
return nullptr;
|
2011-04-12 10:18:43 +04:00
|
|
|
}
|
|
|
|
|
2014-06-12 05:10:00 +04:00
|
|
|
nsCSSCounterStyleRule*
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::CounterStyleRuleForName(const nsAString& aName)
|
2014-06-12 05:10:00 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
2014-06-12 05:10:00 +04:00
|
|
|
|
2015-04-17 04:09:59 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
2014-06-12 05:10:00 +04:00
|
|
|
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
2015-10-20 02:16:20 +03:00
|
|
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
2014-06-12 05:10:00 +04:00
|
|
|
continue;
|
|
|
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
|
|
|
if (!ruleProc)
|
|
|
|
continue;
|
|
|
|
nsCSSCounterStyleRule *result =
|
2015-04-17 04:09:59 +03:00
|
|
|
ruleProc->CounterStyleRuleForName(presContext, aName);
|
2014-06-12 05:10:00 +04:00
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-05-20 06:59:20 +04:00
|
|
|
bool
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::AppendFontFeatureValuesRules(
|
2013-05-20 06:59:20 +04:00
|
|
|
nsTArray<nsCSSFontFeatureValuesRule*>& aArray)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, false);
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
2013-05-20 06:59:20 +04:00
|
|
|
|
2015-04-17 04:09:59 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
2014-01-30 22:26:54 +04:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
2013-05-20 06:59:20 +04:00
|
|
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
|
|
|
if (ruleProc &&
|
2015-04-17 04:09:59 +03:00
|
|
|
!ruleProc->AppendFontFeatureValuesRules(presContext, aArray))
|
2013-05-20 06:59:20 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<gfxFontFeatureValueSet>
|
|
|
|
nsStyleSet::GetFontFeatureValuesLookup()
|
|
|
|
{
|
|
|
|
if (mInitFontFeatureValuesLookup) {
|
|
|
|
mInitFontFeatureValuesLookup = false;
|
|
|
|
|
|
|
|
nsTArray<nsCSSFontFeatureValuesRule*> rules;
|
2015-04-17 04:09:59 +03:00
|
|
|
AppendFontFeatureValuesRules(rules);
|
2013-05-20 06:59:20 +04:00
|
|
|
|
|
|
|
mFontFeatureValuesLookup = new gfxFontFeatureValueSet();
|
|
|
|
|
|
|
|
uint32_t i, numRules = rules.Length();
|
|
|
|
for (i = 0; i < numRules; i++) {
|
|
|
|
nsCSSFontFeatureValuesRule *rule = rules[i];
|
|
|
|
|
2014-06-06 10:09:23 +04:00
|
|
|
const nsTArray<FontFamilyName>& familyList = rule->GetFamilyList().GetFontlist();
|
2013-05-20 06:59:20 +04:00
|
|
|
const nsTArray<gfxFontFeatureValueSet::FeatureValues>&
|
|
|
|
featureValues = rule->GetFeatureValues();
|
|
|
|
|
|
|
|
// for each family
|
2014-06-06 10:09:23 +04:00
|
|
|
size_t f, numFam;
|
2013-05-20 06:59:20 +04:00
|
|
|
|
|
|
|
numFam = familyList.Length();
|
|
|
|
for (f = 0; f < numFam; f++) {
|
2014-06-06 10:09:23 +04:00
|
|
|
mFontFeatureValuesLookup->AddFontFeatureValues(familyList[f].mName,
|
|
|
|
featureValues);
|
2013-05-20 06:59:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxFontFeatureValueSet> lookup = mFontFeatureValuesLookup;
|
2013-05-20 06:59:20 +04:00
|
|
|
return lookup.forget();
|
|
|
|
}
|
|
|
|
|
2012-09-01 01:21:28 +04:00
|
|
|
bool
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::AppendPageRules(nsTArray<nsCSSPageRule*>& aArray)
|
2012-09-01 01:21:28 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInShutdown, false);
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
2012-09-01 01:21:28 +04:00
|
|
|
|
2015-04-17 04:09:59 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
2014-01-30 22:26:54 +04:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
2015-10-20 02:16:20 +03:00
|
|
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
2013-01-09 03:25:47 +04:00
|
|
|
continue;
|
2012-09-01 01:21:28 +04:00
|
|
|
nsCSSRuleProcessor* ruleProc = static_cast<nsCSSRuleProcessor*>
|
|
|
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
2015-04-17 04:09:59 +03:00
|
|
|
if (ruleProc && !ruleProc->AppendPageRules(presContext, aArray))
|
2012-09-01 01:21:28 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
void
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::BeginShutdown()
|
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
|
|
|
}
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
void
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::Shutdown()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mRuleTree = nullptr;
|
2016-03-25 04:40:40 +03:00
|
|
|
GCRuleTrees();
|
|
|
|
MOZ_ASSERT(mUnusedRuleNodeList.isEmpty());
|
|
|
|
MOZ_ASSERT(mUnusedRuleNodeCount == 0);
|
2016-03-15 06:26:53 +03:00
|
|
|
}
|
|
|
|
|
2009-01-29 23:39:19 +03:00
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
void
|
|
|
|
nsStyleSet::GCRuleTrees()
|
|
|
|
{
|
2016-03-25 04:40:40 +03:00
|
|
|
MOZ_ASSERT(!mInReconstruct);
|
|
|
|
MOZ_ASSERT(!mInGC);
|
|
|
|
mInGC = true;
|
2009-01-30 07:39:23 +03:00
|
|
|
|
2016-03-25 04:40:40 +03:00
|
|
|
while (!mUnusedRuleNodeList.isEmpty()) {
|
|
|
|
nsRuleNode* node = mUnusedRuleNodeList.popFirst();
|
2004-01-08 01:30:53 +03:00
|
|
|
#ifdef DEBUG
|
2016-03-25 04:40:40 +03:00
|
|
|
if (node == mOldRootNode) {
|
|
|
|
// Flag that we've GCed the old root, if any.
|
|
|
|
mOldRootNode = nullptr;
|
2009-01-30 07:39:23 +03:00
|
|
|
}
|
2016-03-25 04:40:40 +03:00
|
|
|
#endif
|
|
|
|
node->Destroy();
|
2004-01-08 01:30:53 +03:00
|
|
|
}
|
2016-03-25 04:40:40 +03:00
|
|
|
|
2016-04-21 23:53:04 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_ASSERTION(!mOldRootNode, "Should have GCed old root node");
|
|
|
|
mOldRootNode = nullptr;
|
|
|
|
#endif
|
2016-03-25 04:40:40 +03:00
|
|
|
mUnusedRuleNodeCount = 0;
|
|
|
|
mInGC = false;
|
2003-03-06 22:14:17 +03:00
|
|
|
}
|
|
|
|
|
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,
|
2015-02-17 01:15:05 +03:00
|
|
|
Element* aElement)
|
1999-09-04 03:35:41 +04:00
|
|
|
{
|
2013-08-03 08:11:05 +04:00
|
|
|
MOZ_ASSERT(aStyleContext, "aStyleContext must not be null");
|
1999-09-04 03:35:41 +04:00
|
|
|
|
2016-10-19 09:16:52 +03:00
|
|
|
// This short-circuit is OK because we don't call TryInitatingTransition
|
2010-06-23 08:46:27 +04:00
|
|
|
// during style reresolution if the style context pointer hasn't changed.
|
2010-04-02 10:07:42 +04:00
|
|
|
if (aStyleContext->GetParent() == aNewParentContext) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> ret = aStyleContext;
|
2013-04-22 15:15:59 +04:00
|
|
|
return ret.forget();
|
1999-09-04 03:35:41 +04:00
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
|
|
|
nsIAtom* pseudoTag = aStyleContext->GetPseudo();
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
|
2013-02-17 01:04:53 +04:00
|
|
|
nsRuleNode* ruleNode = aStyleContext->RuleNode();
|
2010-06-23 08:46:27 +04:00
|
|
|
|
2016-02-24 10:01:12 +03:00
|
|
|
MOZ_ASSERT(PresContext()->RestyleManager()->IsGecko(),
|
|
|
|
"stylo: the style set and restyle manager must have the same "
|
|
|
|
"StyleBackendType");
|
|
|
|
NS_ASSERTION(!PresContext()->RestyleManager()->AsGecko()->SkipAnimationRules(),
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-17 01:15:05 +03:00
|
|
|
"we no longer handle SkipAnimationRules()");
|
2010-06-23 08:46:27 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRuleNode* visitedRuleNode = nullptr;
|
2010-04-03 05:58:27 +04:00
|
|
|
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) {
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-17 01:15:05 +03:00
|
|
|
visitedRuleNode = visitedContext->RuleNode();
|
2010-04-03 05:58:27 +04:00
|
|
|
}
|
2010-04-02 10:07:42 +04:00
|
|
|
|
2013-02-01 20:02:29 +04:00
|
|
|
uint32_t flags = eNoFlags;
|
|
|
|
if (aStyleContext->IsLinkContext()) {
|
|
|
|
flags |= eIsLink;
|
2011-05-21 00:21:27 +04:00
|
|
|
|
2014-08-03 06:37:42 +04:00
|
|
|
// GetContext handles propagating RelevantLinkVisited state from the
|
|
|
|
// parent in non-link cases; all we need to pass in is if this link
|
|
|
|
// is visited.
|
|
|
|
if (aStyleContext->RelevantLinkVisited()) {
|
|
|
|
flags |= eIsVisitedLink;
|
|
|
|
}
|
2013-02-01 20:02:29 +04:00
|
|
|
}
|
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
if (pseudoType == CSSPseudoElementType::NotPseudo ||
|
|
|
|
pseudoType == CSSPseudoElementType::before ||
|
|
|
|
pseudoType == CSSPseudoElementType::after) {
|
2013-02-01 20:02:29 +04:00
|
|
|
flags |= eDoAnimation;
|
|
|
|
}
|
|
|
|
|
2013-04-16 19:33:41 +04:00
|
|
|
if (aElement && aElement->IsRootOfAnonymousSubtree()) {
|
2014-05-03 17:42:33 +04:00
|
|
|
// For anonymous subtree roots, don't tweak "display" value based on whether
|
|
|
|
// or not the parent is styled as a flex/grid container. (If the parent
|
2013-04-16 19:33:41 +04:00
|
|
|
// has anonymous-subtree kids, then we know it's not actually going to get
|
2014-05-03 17:42:33 +04:00
|
|
|
// a flex/grid container frame, anyway.)
|
2014-06-16 17:55:00 +04:00
|
|
|
flags |= eSkipParentDisplayBasedStyleFixup;
|
2013-04-16 19:33:41 +04:00
|
|
|
}
|
|
|
|
|
2010-04-03 05:58:27 +04:00
|
|
|
return GetContext(aNewParentContext, ruleNode, visitedRuleNode,
|
2011-04-12 10:18:44 +04:00
|
|
|
pseudoTag, pseudoType,
|
2013-02-01 20:02:29 +04:00
|
|
|
aElement, flags);
|
1999-09-04 03:35:41 +04:00
|
|
|
}
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS StatefulData : public StateRuleProcessorData {
|
2011-03-29 21:29:21 +04:00
|
|
|
StatefulData(nsPresContext* aPresContext, Element* aElement,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates aStateMask, TreeMatchContext& aTreeMatchContext)
|
2011-03-29 21:29:21 +04:00
|
|
|
: 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
|
|
|
};
|
|
|
|
|
2013-11-28 10:46:39 +04:00
|
|
|
struct MOZ_STACK_CLASS StatefulPseudoElementData : public PseudoElementStateRuleProcessorData {
|
|
|
|
StatefulPseudoElementData(nsPresContext* aPresContext, Element* aElement,
|
2016-02-17 23:37:00 +03:00
|
|
|
EventStates aStateMask, CSSPseudoElementType aPseudoType,
|
2013-11-28 10:46:39 +04:00
|
|
|
TreeMatchContext& aTreeMatchContext, Element* aPseudoElement)
|
|
|
|
: PseudoElementStateRuleProcessorData(aPresContext, aElement, aStateMask,
|
|
|
|
aPseudoType, aTreeMatchContext,
|
|
|
|
aPseudoElement),
|
|
|
|
mHint(nsRestyleHint(0))
|
|
|
|
{}
|
|
|
|
nsRestyleHint mHint;
|
|
|
|
};
|
|
|
|
|
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
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::HasDocumentStateDependentStyle(nsIContent* aContent,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates 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());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aContent->AsElement());
|
2015-04-17 04:09:59 +03:00
|
|
|
StatefulData data(PresContext(), aContent->AsElement(), aStateMask,
|
2011-03-29 21:29:21 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-11-28 10:46:39 +04:00
|
|
|
static bool SheetHasStatefulPseudoElementStyle(nsIStyleRuleProcessor* aProcessor,
|
|
|
|
void *aData)
|
|
|
|
{
|
|
|
|
StatefulPseudoElementData* data = (StatefulPseudoElementData*)aData;
|
|
|
|
nsRestyleHint hint = aProcessor->HasStateDependentStyle(data);
|
|
|
|
data->mHint = nsRestyleHint(data->mHint | hint);
|
|
|
|
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
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::HasStateDependentStyle(Element* aElement,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates 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());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aElement);
|
2015-04-17 04:09:59 +03:00
|
|
|
StatefulData data(PresContext(), 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
|
|
|
}
|
|
|
|
|
2013-11-28 10:46:39 +04:00
|
|
|
nsRestyleHint
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::HasStateDependentStyle(Element* aElement,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2013-11-28 10:46:39 +04:00
|
|
|
Element* aPseudoElement,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates aStateMask)
|
2013-11-28 10:46:39 +04:00
|
|
|
{
|
|
|
|
TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
|
|
|
|
aElement->OwnerDoc());
|
|
|
|
InitStyleScopes(treeContext, aElement);
|
2015-04-17 04:09:59 +03:00
|
|
|
StatefulPseudoElementData data(PresContext(), aElement, aStateMask,
|
2013-11-28 10:46:39 +04:00
|
|
|
aPseudoType, treeContext, aPseudoElement);
|
|
|
|
WalkRuleProcessors(SheetHasStatefulPseudoElementStyle, &data, false);
|
|
|
|
return data.mHint;
|
|
|
|
}
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS AttributeData : public AttributeRuleProcessorData {
|
2015-12-05 09:09:13 +03:00
|
|
|
AttributeData(nsPresContext* aPresContext, Element* aElement,
|
|
|
|
int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType,
|
2015-07-22 06:54:07 +03:00
|
|
|
bool aAttrHasChanged, const nsAttrValue* aOtherValue,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2015-12-05 09:09:13 +03:00
|
|
|
: AttributeRuleProcessorData(aPresContext, aElement, aNameSpaceID,
|
|
|
|
aAttribute, aModType, aAttrHasChanged,
|
|
|
|
aOtherValue, aTreeMatchContext),
|
2010-04-01 04:43:32 +04:00
|
|
|
mHint(nsRestyleHint(0))
|
2003-02-22 19:10:53 +03:00
|
|
|
{}
|
2015-08-05 15:42:21 +03:00
|
|
|
nsRestyleHint mHint;
|
|
|
|
RestyleHintData mHintData;
|
2013-05-20 06:59:20 +04:00
|
|
|
};
|
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;
|
2015-08-05 15:42:21 +03:00
|
|
|
nsRestyleHint hint =
|
|
|
|
aProcessor->HasAttributeDependentStyle(data, data->mHintData);
|
2010-04-01 04:43:32 +04:00
|
|
|
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
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::HasAttributeDependentStyle(Element* aElement,
|
2015-12-05 09:09:13 +03:00
|
|
|
int32_t aNameSpaceID,
|
2007-07-13 00:05:45 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType,
|
2015-07-22 06:54:07 +03:00
|
|
|
bool aAttrHasChanged,
|
2015-08-05 15:42:21 +03:00
|
|
|
const nsAttrValue* aOtherValue,
|
|
|
|
mozilla::RestyleHintData&
|
|
|
|
aRestyleHintDataResult)
|
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());
|
2013-11-01 06:44:40 +04:00
|
|
|
InitStyleScopes(treeContext, aElement);
|
2015-12-05 09:09:13 +03:00
|
|
|
AttributeData data(PresContext(), aElement, aNameSpaceID, aAttribute,
|
2015-07-22 06:54:07 +03:00
|
|
|
aModType, aAttrHasChanged, aOtherValue, treeContext);
|
2011-10-17 18:59:28 +04:00
|
|
|
WalkRuleProcessors(SheetHasAttributeStyle, &data, false);
|
2015-08-05 15:42:21 +03:00
|
|
|
if (!(data.mHint & eRestyle_Subtree)) {
|
|
|
|
// No point keeping the list of selectors around if we are going to
|
|
|
|
// restyle the whole subtree unconditionally.
|
|
|
|
aRestyleHintDataResult = Move(data.mHintData);
|
|
|
|
}
|
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
|
2015-04-17 04:09:59 +03:00
|
|
|
nsStyleSet::MediumFeaturesChanged()
|
2008-07-26 20:14:48 +04:00
|
|
|
{
|
2014-12-06 02:50:00 +03:00
|
|
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
|
|
|
|
2008-07-26 20:14:48 +04:00
|
|
|
// We can't use WalkRuleProcessors without a content node.
|
2015-04-17 04:09:59 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool stylesChanged = false;
|
2015-10-20 02:16:20 +03:00
|
|
|
for (nsIStyleRuleProcessor* processor : mRuleProcessors) {
|
2008-07-26 20:14:48 +04:00
|
|
|
if (!processor) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-04-17 04:09:59 +03:00
|
|
|
bool thisChanged = processor->MediumFeaturesChanged(presContext);
|
2008-07-26 20:14:48 +04:00
|
|
|
stylesChanged = stylesChanged || thisChanged;
|
|
|
|
}
|
2015-10-20 02:16:20 +03:00
|
|
|
for (nsIStyleRuleProcessor* processor : mScopedDocSheetRuleProcessors) {
|
2015-04-17 04:09:59 +03:00
|
|
|
bool thisChanged = processor->MediumFeaturesChanged(presContext);
|
2013-02-12 04:48:44 +04:00
|
|
|
stylesChanged = stylesChanged || thisChanged;
|
|
|
|
}
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2008-07-26 20:14:49 +04:00
|
|
|
if (mBindingManager) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool thisChanged = false;
|
2015-04-17 04:09:59 +03:00
|
|
|
mBindingManager->MediumFeaturesChanged(presContext, &thisChanged);
|
2008-07-26 20:14:49 +04:00
|
|
|
stylesChanged = stylesChanged || thisChanged;
|
|
|
|
}
|
|
|
|
|
2008-07-26 20:14:48 +04:00
|
|
|
return stylesChanged;
|
|
|
|
}
|
2009-12-31 18:56:33 +03:00
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
bool
|
2009-12-31 18:56:33 +03:00
|
|
|
nsStyleSet::EnsureUniqueInnerOnCSSSheets()
|
|
|
|
{
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<CSSStyleSheet*, 32> queue;
|
2015-11-17 09:04:09 +03:00
|
|
|
for (SheetType type : gCSSSheetTypes) {
|
|
|
|
for (CSSStyleSheet* sheet : mSheets[type]) {
|
2013-11-11 12:00:18 +04:00
|
|
|
queue.AppendElement(sheet);
|
2009-12-31 18:56:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-17 09:36:34 +04:00
|
|
|
if (mBindingManager) {
|
2016-09-26 15:03:25 +03:00
|
|
|
AutoTArray<StyleSheet*, 32> sheets;
|
2016-02-24 10:01:12 +03:00
|
|
|
// XXXheycam stylo: AppendAllSheets will need to be able to return either
|
|
|
|
// CSSStyleSheets or ServoStyleSheets, on request (and then here requesting
|
|
|
|
// CSSStyleSheets).
|
|
|
|
mBindingManager->AppendAllSheets(sheets);
|
2016-09-26 15:03:25 +03:00
|
|
|
for (StyleSheet* sheet : sheets) {
|
2016-02-24 10:01:12 +03:00
|
|
|
MOZ_ASSERT(sheet->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
|
|
|
|
"ServoStyleSheets yet");
|
|
|
|
queue.AppendElement(sheet->AsGecko());
|
|
|
|
}
|
2010-07-17 09:36:34 +04:00
|
|
|
}
|
|
|
|
|
2009-12-31 18:56:33 +03:00
|
|
|
while (!queue.IsEmpty()) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t idx = queue.Length() - 1;
|
2014-06-20 14:32:49 +04:00
|
|
|
CSSStyleSheet* sheet = queue[idx];
|
2009-12-31 18:56:33 +03:00
|
|
|
queue.RemoveElementAt(idx);
|
|
|
|
|
2015-06-26 06:49:58 +03:00
|
|
|
sheet->EnsureUniqueInner();
|
2009-12-31 18:56:33 +03:00
|
|
|
|
|
|
|
// Enqueue all the sheet's children.
|
2013-11-11 11:59:58 +04:00
|
|
|
sheet->AppendAllChildSheets(queue);
|
2009-12-31 18:56:33 +03:00
|
|
|
}
|
2015-06-26 06:49:58 +03:00
|
|
|
|
|
|
|
bool res = mNeedsRestyleAfterEnsureUniqueInner;
|
|
|
|
mNeedsRestyleAfterEnsureUniqueInner = false;
|
2009-12-31 18:56:33 +03:00
|
|
|
return res;
|
|
|
|
}
|
2011-08-23 03:34:12 +04:00
|
|
|
|
|
|
|
nsIStyleRule*
|
|
|
|
nsStyleSet::InitialStyleRule()
|
|
|
|
{
|
|
|
|
if (!mInitialStyleRule) {
|
|
|
|
mInitialStyleRule = new nsInitialStyleRule;
|
|
|
|
}
|
|
|
|
return mInitialStyleRule;
|
|
|
|
}
|
2015-07-08 08:57:31 +03:00
|
|
|
|
|
|
|
bool
|
2015-10-20 02:16:20 +03:00
|
|
|
nsStyleSet::HasRuleProcessorUsedByMultipleStyleSets(SheetType aSheetType)
|
2015-07-08 08:57:31 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(size_t(aSheetType) < ArrayLength(mRuleProcessors));
|
|
|
|
if (!IsCSSSheetType(aSheetType) || !mRuleProcessors[aSheetType]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCSSRuleProcessor* rp =
|
|
|
|
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[aSheetType].get());
|
|
|
|
return rp->IsUsedByMultipleStyleSets();
|
|
|
|
}
|
2015-08-05 15:42:21 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSet::ClearSelectors()
|
|
|
|
{
|
|
|
|
// We might be called before we've done our first rule tree construction.
|
|
|
|
if (!mRuleTree) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-24 10:01:12 +03:00
|
|
|
MOZ_ASSERT(PresContext()->RestyleManager()->IsGecko(),
|
|
|
|
"stylo: the style set and restyle manager must have the same "
|
|
|
|
"StyleBackendType");
|
|
|
|
PresContext()->RestyleManager()->AsGecko()->ClearSelectors();
|
2015-08-05 15:42:21 +03:00
|
|
|
}
|