Bug 1216043 - Rename nsStyleSheet::sheetType and make it an enum class. r=dbaron
The only substantive change here, apart from a few variables changing in size from uint16_t to uint8_t, is FontFaceSet's use of SheetType::Unknown (0xFF) instead of 0 for FontFaceRecords for script-created FontFaces.
This commit is contained in:
@@ -3196,7 +3196,7 @@ convertSheetType(uint32_t aSheetType)
|
|||||||
default:
|
default:
|
||||||
NS_ASSERTION(false, "wrong type");
|
NS_ASSERTION(false, "wrong type");
|
||||||
// we must return something although this should never happen
|
// we must return something although this should never happen
|
||||||
return nsIDocument::SheetTypeCount;
|
return nsIDocument::AdditionalSheetTypeCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2413,7 +2413,7 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDocument::RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, nsStyleSet::sheetType aType)
|
nsDocument::RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, SheetType aType)
|
||||||
{
|
{
|
||||||
// The stylesheets should forget us
|
// The stylesheets should forget us
|
||||||
int32_t indx = aSheets.Count();
|
int32_t indx = aSheets.Count();
|
||||||
@@ -2440,16 +2440,17 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
|||||||
|
|
||||||
mozAutoDocUpdate upd(this, UPDATE_STYLE, true);
|
mozAutoDocUpdate upd(this, UPDATE_STYLE, true);
|
||||||
RemoveDocStyleSheetsFromStyleSets();
|
RemoveDocStyleSheetsFromStyleSets();
|
||||||
RemoveStyleSheetsFromStyleSets(mOnDemandBuiltInUASheets, nsStyleSet::eAgentSheet);
|
RemoveStyleSheetsFromStyleSets(mOnDemandBuiltInUASheets, SheetType::Agent);
|
||||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAgentSheet], nsStyleSet::eAgentSheet);
|
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAgentSheet], SheetType::Agent);
|
||||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eUserSheet], nsStyleSet::eUserSheet);
|
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eUserSheet], SheetType::User);
|
||||||
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAuthorSheet], nsStyleSet::eDocSheet);
|
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAuthorSheet], SheetType::Doc);
|
||||||
|
|
||||||
// Release all the sheets
|
// Release all the sheets
|
||||||
mStyleSheets.Clear();
|
mStyleSheets.Clear();
|
||||||
mOnDemandBuiltInUASheets.Clear();
|
mOnDemandBuiltInUASheets.Clear();
|
||||||
for (uint32_t i = 0; i < SheetTypeCount; ++i)
|
for (auto& sheets : mAdditionalSheets) {
|
||||||
mAdditionalSheets[i].Clear();
|
sheets.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: We don't release the catalog sheets. It doesn't really matter
|
// NOTE: We don't release the catalog sheets. It doesn't really matter
|
||||||
// now, but it could in the future -- in which case not releasing them
|
// now, but it could in the future -- in which case not releasing them
|
||||||
@@ -2483,14 +2484,14 @@ static bool
|
|||||||
AppendAuthorSheet(nsIStyleSheet *aSheet, void *aData)
|
AppendAuthorSheet(nsIStyleSheet *aSheet, void *aData)
|
||||||
{
|
{
|
||||||
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
||||||
styleSet->AppendStyleSheet(nsStyleSet::eDocSheet, aSheet);
|
styleSet->AppendStyleSheet(SheetType::Doc, aSheet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
|
AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
|
||||||
const nsCOMArray<nsIStyleSheet>& aSheets,
|
const nsCOMArray<nsIStyleSheet>& aSheets,
|
||||||
nsStyleSet::sheetType aType)
|
SheetType aType)
|
||||||
{
|
{
|
||||||
for (int32_t i = aSheets.Count() - 1; i >= 0; --i) {
|
for (int32_t i = aSheets.Count() - 1; i >= 0; --i) {
|
||||||
aStyleSet->AppendStyleSheet(aType, aSheets[i]);
|
aStyleSet->AppendStyleSheet(aType, aSheets[i]);
|
||||||
@@ -2502,13 +2503,13 @@ void
|
|||||||
nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aStyleSet, "Must have a style set");
|
NS_PRECONDITION(aStyleSet, "Must have a style set");
|
||||||
NS_PRECONDITION(aStyleSet->SheetCount(nsStyleSet::eDocSheet) == 0,
|
NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
|
||||||
"Style set already has document sheets?");
|
"Style set already has document sheets?");
|
||||||
|
|
||||||
// We could consider moving this to nsStyleSet::Init, to match its
|
// We could consider moving this to nsStyleSet::Init, to match its
|
||||||
// handling of the eAnimationSheet and eTransitionSheet levels.
|
// handling of the eAnimationSheet and eTransitionSheet levels.
|
||||||
aStyleSet->DirtyRuleProcessors(nsStyleSet::ePresHintSheet);
|
aStyleSet->DirtyRuleProcessors(SheetType::PresHint);
|
||||||
aStyleSet->DirtyRuleProcessors(nsStyleSet::eStyleAttrSheet);
|
aStyleSet->DirtyRuleProcessors(SheetType::StyleAttr);
|
||||||
|
|
||||||
int32_t i;
|
int32_t i;
|
||||||
for (i = mStyleSheets.Count() - 1; i >= 0; --i) {
|
for (i = mStyleSheets.Count() - 1; i >= 0; --i) {
|
||||||
@@ -2528,16 +2529,16 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
|||||||
for (i = mOnDemandBuiltInUASheets.Count() - 1; i >= 0; --i) {
|
for (i = mOnDemandBuiltInUASheets.Count() - 1; i >= 0; --i) {
|
||||||
nsIStyleSheet* sheet = mOnDemandBuiltInUASheets[i];
|
nsIStyleSheet* sheet = mOnDemandBuiltInUASheets[i];
|
||||||
if (sheet->IsApplicable()) {
|
if (sheet->IsApplicable()) {
|
||||||
aStyleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAgentSheet],
|
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAgentSheet],
|
||||||
nsStyleSet::eAgentSheet);
|
SheetType::Agent);
|
||||||
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eUserSheet],
|
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eUserSheet],
|
||||||
nsStyleSet::eUserSheet);
|
SheetType::User);
|
||||||
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAuthorSheet],
|
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAuthorSheet],
|
||||||
nsStyleSet::eDocSheet);
|
SheetType::Doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4141,7 +4142,7 @@ nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
|||||||
// do not override Firefox OS/Mobile's content.css sheet. Maybe we should
|
// do not override Firefox OS/Mobile's content.css sheet. Maybe we should
|
||||||
// have an insertion point to match the order of
|
// have an insertion point to match the order of
|
||||||
// nsDocumentViewer::CreateStyleSet though?
|
// nsDocumentViewer::CreateStyleSet though?
|
||||||
shell->StyleSet()->PrependStyleSheet(nsStyleSet::eAgentSheet, aSheet);
|
shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4373,20 +4374,20 @@ nsDocument::NotifyStyleSheetApplicableStateChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsStyleSet::sheetType
|
static SheetType
|
||||||
ConvertAdditionalSheetType(nsIDocument::additionalSheetType aType)
|
ConvertAdditionalSheetType(nsIDocument::additionalSheetType aType)
|
||||||
{
|
{
|
||||||
switch(aType) {
|
switch(aType) {
|
||||||
case nsIDocument::eAgentSheet:
|
case nsIDocument::eAgentSheet:
|
||||||
return nsStyleSet::eAgentSheet;
|
return SheetType::Agent;
|
||||||
case nsIDocument::eUserSheet:
|
case nsIDocument::eUserSheet:
|
||||||
return nsStyleSet::eUserSheet;
|
return SheetType::User;
|
||||||
case nsIDocument::eAuthorSheet:
|
case nsIDocument::eAuthorSheet:
|
||||||
return nsStyleSet::eDocSheet;
|
return SheetType::Doc;
|
||||||
default:
|
default:
|
||||||
NS_ASSERTION(false, "wrong type");
|
MOZ_ASSERT(false, "wrong type");
|
||||||
// we must return something although this should never happen
|
// we must return something although this should never happen
|
||||||
return nsStyleSet::eSheetTypeCount;
|
return SheetType::Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4460,7 +4461,7 @@ nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aS
|
|||||||
BeginUpdate(UPDATE_STYLE);
|
BeginUpdate(UPDATE_STYLE);
|
||||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||||
if (shell) {
|
if (shell) {
|
||||||
nsStyleSet::sheetType type = ConvertAdditionalSheetType(aType);
|
SheetType type = ConvertAdditionalSheetType(aType);
|
||||||
shell->StyleSet()->AppendStyleSheet(type, aSheet);
|
shell->StyleSet()->AppendStyleSheet(type, aSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4488,7 +4489,7 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
|||||||
MOZ_ASSERT(sheetRef->IsApplicable());
|
MOZ_ASSERT(sheetRef->IsApplicable());
|
||||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||||
if (shell) {
|
if (shell) {
|
||||||
nsStyleSet::sheetType type = ConvertAdditionalSheetType(aType);
|
SheetType type = ConvertAdditionalSheetType(aType);
|
||||||
shell->StyleSet()->RemoveStyleSheet(type, sheetRef);
|
shell->StyleSet()->RemoveStyleSheet(type, sheetRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1516,7 +1516,7 @@ protected:
|
|||||||
|
|
||||||
void RemoveDocStyleSheetsFromStyleSets();
|
void RemoveDocStyleSheetsFromStyleSets();
|
||||||
void RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets,
|
void RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets,
|
||||||
nsStyleSet::sheetType aType);
|
mozilla::SheetType aType);
|
||||||
void ResetStylesheetsToURI(nsIURI* aURI);
|
void ResetStylesheetsToURI(nsIURI* aURI);
|
||||||
void FillStyleSet(nsStyleSet* aStyleSet);
|
void FillStyleSet(nsStyleSet* aStyleSet);
|
||||||
|
|
||||||
@@ -1571,7 +1571,7 @@ protected:
|
|||||||
|
|
||||||
nsCOMArray<nsIStyleSheet> mStyleSheets;
|
nsCOMArray<nsIStyleSheet> mStyleSheets;
|
||||||
nsCOMArray<nsIStyleSheet> mOnDemandBuiltInUASheets;
|
nsCOMArray<nsIStyleSheet> mOnDemandBuiltInUASheets;
|
||||||
nsCOMArray<nsIStyleSheet> mAdditionalSheets[SheetTypeCount];
|
nsCOMArray<nsIStyleSheet> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||||
|
|
||||||
// Array of observers
|
// Array of observers
|
||||||
nsTObserverArray<nsIDocumentObserver*> mObservers;
|
nsTObserverArray<nsIDocumentObserver*> mObservers;
|
||||||
|
|||||||
@@ -944,7 +944,7 @@ public:
|
|||||||
eAgentSheet,
|
eAgentSheet,
|
||||||
eUserSheet,
|
eUserSheet,
|
||||||
eAuthorSheet,
|
eAuthorSheet,
|
||||||
SheetTypeCount
|
AdditionalSheetTypeCount
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) = 0;
|
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) = 0;
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ void
|
|||||||
nsXBLPrototypeResources::GatherRuleProcessor()
|
nsXBLPrototypeResources::GatherRuleProcessor()
|
||||||
{
|
{
|
||||||
mRuleProcessor = new nsCSSRuleProcessor(mStyleSheetList,
|
mRuleProcessor = new nsCSSRuleProcessor(mStyleSheetList,
|
||||||
nsStyleSet::eDocSheet,
|
SheetType::Doc,
|
||||||
nullptr,
|
nullptr,
|
||||||
mRuleProcessor);
|
mRuleProcessor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2176,7 +2176,7 @@ static bool
|
|||||||
AppendAgentSheet(nsIStyleSheet *aSheet, void *aData)
|
AppendAgentSheet(nsIStyleSheet *aSheet, void *aData)
|
||||||
{
|
{
|
||||||
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
||||||
styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, aSheet);
|
styleSet->AppendStyleSheet(SheetType::Agent, aSheet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2184,7 +2184,7 @@ static bool
|
|||||||
PrependUserSheet(nsIStyleSheet *aSheet, void *aData)
|
PrependUserSheet(nsIStyleSheet *aSheet, void *aData)
|
||||||
{
|
{
|
||||||
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eUserSheet, aSheet);
|
styleSet->PrependStyleSheet(SheetType::User, aSheet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2227,7 +2227,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sheet)
|
if (sheet)
|
||||||
styleSet->AppendStyleSheet(nsStyleSet::eUserSheet, sheet);
|
styleSet->AppendStyleSheet(SheetType::User, sheet);
|
||||||
|
|
||||||
// Append chrome sheets (scrollbars + forms).
|
// Append chrome sheets (scrollbars + forms).
|
||||||
bool shouldOverride = false;
|
bool shouldOverride = false;
|
||||||
@@ -2263,7 +2263,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
cssLoader->LoadSheetSync(uri, getter_AddRefs(csssheet));
|
cssLoader->LoadSheetSync(uri, getter_AddRefs(csssheet));
|
||||||
if (!csssheet) continue;
|
if (!csssheet) continue;
|
||||||
|
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, csssheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, csssheet);
|
||||||
shouldOverride = true;
|
shouldOverride = true;
|
||||||
}
|
}
|
||||||
free(str);
|
free(str);
|
||||||
@@ -2274,7 +2274,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
if (!shouldOverride) {
|
if (!shouldOverride) {
|
||||||
sheet = nsLayoutStylesheetCache::ScrollbarsSheet();
|
sheet = nsLayoutStylesheetCache::ScrollbarsSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2290,12 +2290,12 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
|
|
||||||
sheet = nsLayoutStylesheetCache::NumberControlSheet();
|
sheet = nsLayoutStylesheetCache::NumberControlSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet = nsLayoutStylesheetCache::FormsSheet();
|
sheet = nsLayoutStylesheetCache::FormsSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aDocument->LoadsFullXULStyleSheetUpFront()) {
|
if (aDocument->LoadsFullXULStyleSheetUpFront()) {
|
||||||
@@ -2303,7 +2303,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
// up-front here.
|
// up-front here.
|
||||||
sheet = nsLayoutStylesheetCache::XULSheet();
|
sheet = nsLayoutStylesheetCache::XULSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2311,25 +2311,25 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
if (sheet) {
|
if (sheet) {
|
||||||
// Load the minimal XUL rules for scrollbars and a few other XUL things
|
// Load the minimal XUL rules for scrollbars and a few other XUL things
|
||||||
// that non-XUL (typically HTML) documents commonly use.
|
// that non-XUL (typically HTML) documents commonly use.
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet = nsLayoutStylesheetCache::CounterStylesSheet();
|
sheet = nsLayoutStylesheetCache::CounterStylesSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsLayoutUtils::ShouldUseNoScriptSheet(aDocument)) {
|
if (nsLayoutUtils::ShouldUseNoScriptSheet(aDocument)) {
|
||||||
sheet = nsLayoutStylesheetCache::NoScriptSheet();
|
sheet = nsLayoutStylesheetCache::NoScriptSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsLayoutUtils::ShouldUseNoFramesSheet(aDocument)) {
|
if (nsLayoutUtils::ShouldUseNoFramesSheet(aDocument)) {
|
||||||
sheet = nsLayoutStylesheetCache::NoFramesSheet();
|
sheet = nsLayoutStylesheetCache::NoFramesSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2338,16 +2338,16 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||||||
|
|
||||||
sheet = nsLayoutStylesheetCache::HTMLSheet();
|
sheet = nsLayoutStylesheetCache::HTMLSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet,
|
styleSet->PrependStyleSheet(SheetType::Agent,
|
||||||
nsLayoutStylesheetCache::UASheet());
|
nsLayoutStylesheetCache::UASheet());
|
||||||
} else {
|
} else {
|
||||||
// SVG documents may have scrollbars and need the scrollbar styling.
|
// SVG documents may have scrollbars and need the scrollbar styling.
|
||||||
sheet = nsLayoutStylesheetCache::MinimalXULSheet();
|
sheet = nsLayoutStylesheetCache::MinimalXULSheet();
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1381,11 +1381,11 @@ nsPresContext::CompatibilityModeChanged()
|
|||||||
if (needsQuirkSheet) {
|
if (needsQuirkSheet) {
|
||||||
// quirk.css needs to come after html.css; we just keep it at the end.
|
// quirk.css needs to come after html.css; we just keep it at the end.
|
||||||
DebugOnly<nsresult> rv =
|
DebugOnly<nsresult> rv =
|
||||||
styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
|
||||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to insert quirk.css");
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to insert quirk.css");
|
||||||
} else {
|
} else {
|
||||||
DebugOnly<nsresult> rv =
|
DebugOnly<nsresult> rv =
|
||||||
styleSet->RemoveStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
styleSet->RemoveStyleSheet(SheetType::Agent, sheet);
|
||||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to remove quirk.css");
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to remove quirk.css");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1409,7 +1409,7 @@ PresShell::UpdatePreferenceStyles()
|
|||||||
|
|
||||||
RemovePreferenceStyles();
|
RemovePreferenceStyles();
|
||||||
|
|
||||||
mStyleSet->AppendStyleSheet(nsStyleSet::eUserSheet, newPrefSheet);
|
mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet);
|
||||||
mPrefStyleSheet = newPrefSheet;
|
mPrefStyleSheet = newPrefSheet;
|
||||||
|
|
||||||
mStyleSet->EndUpdate();
|
mStyleSet->EndUpdate();
|
||||||
@@ -1419,7 +1419,7 @@ void
|
|||||||
PresShell::RemovePreferenceStyles()
|
PresShell::RemovePreferenceStyles()
|
||||||
{
|
{
|
||||||
if (mPrefStyleSheet) {
|
if (mPrefStyleSheet) {
|
||||||
mStyleSet->RemoveStyleSheet(nsStyleSet::eUserSheet, mPrefStyleSheet);
|
mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet);
|
||||||
mPrefStyleSheet = nullptr;
|
mPrefStyleSheet = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1443,13 +1443,13 @@ PresShell::AddUserSheet(nsISupports* aSheet)
|
|||||||
// Iterate forwards when removing so the searches for RemoveStyleSheet are as
|
// Iterate forwards when removing so the searches for RemoveStyleSheet are as
|
||||||
// short as possible.
|
// short as possible.
|
||||||
for (i = 0; i < userSheets.Count(); ++i) {
|
for (i = 0; i < userSheets.Count(); ++i) {
|
||||||
mStyleSet->RemoveStyleSheet(nsStyleSet::eUserSheet, userSheets[i]);
|
mStyleSet->RemoveStyleSheet(SheetType::User, userSheets[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now iterate backwards, so that the order of userSheets will be the same as
|
// Now iterate backwards, so that the order of userSheets will be the same as
|
||||||
// the order of sheets from it in the style set.
|
// the order of sheets from it in the style set.
|
||||||
for (i = userSheets.Count() - 1; i >= 0; --i) {
|
for (i = userSheets.Count() - 1; i >= 0; --i) {
|
||||||
mStyleSet->PrependStyleSheet(nsStyleSet::eUserSheet, userSheets[i]);
|
mStyleSet->PrependStyleSheet(SheetType::User, userSheets[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mStyleSet->EndUpdate();
|
mStyleSet->EndUpdate();
|
||||||
@@ -1467,7 +1467,7 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStyleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
mStyleSet->AppendStyleSheet(SheetType::Agent, sheet);
|
||||||
ReconstructStyleData();
|
ReconstructStyleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1483,16 +1483,16 @@ PresShell::AddAuthorSheet(nsISupports* aSheet)
|
|||||||
// added with the StyleSheetService.
|
// added with the StyleSheetService.
|
||||||
nsIStyleSheet* firstAuthorSheet = mDocument->FirstAdditionalAuthorSheet();
|
nsIStyleSheet* firstAuthorSheet = mDocument->FirstAdditionalAuthorSheet();
|
||||||
if (firstAuthorSheet) {
|
if (firstAuthorSheet) {
|
||||||
mStyleSet->InsertStyleSheetBefore(nsStyleSet::eDocSheet, sheet, firstAuthorSheet);
|
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet, firstAuthorSheet);
|
||||||
} else {
|
} else {
|
||||||
mStyleSet->AppendStyleSheet(nsStyleSet::eDocSheet, sheet);
|
mStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReconstructStyleData();
|
ReconstructStyleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PresShell::RemoveSheet(nsStyleSet::sheetType aType, nsISupports* aSheet)
|
PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
|
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
|
||||||
if (!sheet) {
|
if (!sheet) {
|
||||||
@@ -8665,10 +8665,10 @@ nsresult
|
|||||||
PresShell::GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets)
|
PresShell::GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets)
|
||||||
{
|
{
|
||||||
aSheets.Clear();
|
aSheets.Clear();
|
||||||
int32_t sheetCount = mStyleSet->SheetCount(nsStyleSet::eAgentSheet);
|
int32_t sheetCount = mStyleSet->SheetCount(SheetType::Agent);
|
||||||
|
|
||||||
for (int32_t i = 0; i < sheetCount; ++i) {
|
for (int32_t i = 0; i < sheetCount; ++i) {
|
||||||
nsIStyleSheet *sheet = mStyleSet->StyleSheetAt(nsStyleSet::eAgentSheet, i);
|
nsIStyleSheet *sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i);
|
||||||
if (!aSheets.AppendObject(sheet))
|
if (!aSheets.AppendObject(sheet))
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -8679,19 +8679,19 @@ PresShell::GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets)
|
|||||||
nsresult
|
nsresult
|
||||||
PresShell::SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets)
|
PresShell::SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets)
|
||||||
{
|
{
|
||||||
return mStyleSet->ReplaceSheets(nsStyleSet::eAgentSheet, aSheets);
|
return mStyleSet->ReplaceSheets(SheetType::Agent, aSheets);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
PresShell::AddOverrideStyleSheet(nsIStyleSheet *aSheet)
|
PresShell::AddOverrideStyleSheet(nsIStyleSheet *aSheet)
|
||||||
{
|
{
|
||||||
return mStyleSet->PrependStyleSheet(nsStyleSet::eOverrideSheet, aSheet);
|
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
PresShell::RemoveOverrideStyleSheet(nsIStyleSheet *aSheet)
|
PresShell::RemoveOverrideStyleSheet(nsIStyleSheet *aSheet)
|
||||||
{
|
{
|
||||||
return mStyleSet->RemoveStyleSheet(nsStyleSet::eOverrideSheet, aSheet);
|
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -9437,17 +9437,17 @@ PresShell::Observe(nsISupports* aSubject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!nsCRT::strcmp(aTopic, "agent-sheet-removed") && mStyleSet) {
|
if (!nsCRT::strcmp(aTopic, "agent-sheet-removed") && mStyleSet) {
|
||||||
RemoveSheet(nsStyleSet::eAgentSheet, aSubject);
|
RemoveSheet(SheetType::Agent, aSubject);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nsCRT::strcmp(aTopic, "user-sheet-removed") && mStyleSet) {
|
if (!nsCRT::strcmp(aTopic, "user-sheet-removed") && mStyleSet) {
|
||||||
RemoveSheet(nsStyleSet::eUserSheet, aSubject);
|
RemoveSheet(SheetType::User, aSubject);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nsCRT::strcmp(aTopic, "author-sheet-removed") && mStyleSet) {
|
if (!nsCRT::strcmp(aTopic, "author-sheet-removed") && mStyleSet) {
|
||||||
RemoveSheet(nsStyleSet::eDocSheet, aSubject);
|
RemoveSheet(SheetType::Doc, aSubject);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9790,35 +9790,35 @@ PresShell::CloneStyleSet(nsStyleSet* aSet)
|
|||||||
{
|
{
|
||||||
nsStyleSet *clone = new nsStyleSet();
|
nsStyleSet *clone = new nsStyleSet();
|
||||||
|
|
||||||
int32_t i, n = aSet->SheetCount(nsStyleSet::eOverrideSheet);
|
int32_t i, n = aSet->SheetCount(SheetType::Override);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
nsIStyleSheet* ss = aSet->StyleSheetAt(nsStyleSet::eOverrideSheet, i);
|
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::Override, i);
|
||||||
if (ss)
|
if (ss)
|
||||||
clone->AppendStyleSheet(nsStyleSet::eOverrideSheet, ss);
|
clone->AppendStyleSheet(SheetType::Override, ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The document expects to insert document stylesheets itself
|
// The document expects to insert document stylesheets itself
|
||||||
#if 0
|
#if 0
|
||||||
n = aSet->SheetCount(nsStyleSet::eDocSheet);
|
n = aSet->SheetCount(SheetType::Doc);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
nsIStyleSheet* ss = aSet->StyleSheetAt(nsStyleSet::eDocSheet, i);
|
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::Doc, i);
|
||||||
if (ss)
|
if (ss)
|
||||||
clone->AddDocStyleSheet(ss, mDocument);
|
clone->AddDocStyleSheet(ss, mDocument);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
n = aSet->SheetCount(nsStyleSet::eUserSheet);
|
n = aSet->SheetCount(SheetType::User);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
nsIStyleSheet* ss = aSet->StyleSheetAt(nsStyleSet::eUserSheet, i);
|
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::User, i);
|
||||||
if (ss)
|
if (ss)
|
||||||
clone->AppendStyleSheet(nsStyleSet::eUserSheet, ss);
|
clone->AppendStyleSheet(SheetType::User, ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = aSet->SheetCount(nsStyleSet::eAgentSheet);
|
n = aSet->SheetCount(SheetType::Agent);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
nsIStyleSheet* ss = aSet->StyleSheetAt(nsStyleSet::eAgentSheet, i);
|
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::Agent, i);
|
||||||
if (ss)
|
if (ss)
|
||||||
clone->AppendStyleSheet(nsStyleSet::eAgentSheet, ss);
|
clone->AppendStyleSheet(SheetType::Agent, ss);
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
@@ -9947,9 +9947,9 @@ PresShell::ListStyleContexts(nsIFrame *aRootFrame, FILE *out, int32_t aIndent)
|
|||||||
void
|
void
|
||||||
PresShell::ListStyleSheets(FILE *out, int32_t aIndent)
|
PresShell::ListStyleSheets(FILE *out, int32_t aIndent)
|
||||||
{
|
{
|
||||||
int32_t sheetCount = mStyleSet->SheetCount(nsStyleSet::eDocSheet);
|
int32_t sheetCount = mStyleSet->SheetCount(SheetType::Doc);
|
||||||
for (int32_t i = 0; i < sheetCount; ++i) {
|
for (int32_t i = 0; i < sheetCount; ++i) {
|
||||||
mStyleSet->StyleSheetAt(nsStyleSet::eDocSheet, i)->List(out, aIndent);
|
mStyleSet->StyleSheetAt(SheetType::Doc, i)->List(out, aIndent);
|
||||||
fputs("\n", out);
|
fputs("\n", out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10930,16 +10930,16 @@ nsresult
|
|||||||
nsIPresShell::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
|
nsIPresShell::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
|
||||||
bool* aRetVal)
|
bool* aRetVal)
|
||||||
{
|
{
|
||||||
nsStyleSet::sheetType type;
|
SheetType type;
|
||||||
switch (aSheetType) {
|
switch (aSheetType) {
|
||||||
case nsIStyleSheetService::AGENT_SHEET:
|
case nsIStyleSheetService::AGENT_SHEET:
|
||||||
type = nsStyleSet::eAgentSheet;
|
type = SheetType::Agent;
|
||||||
break;
|
break;
|
||||||
case nsIStyleSheetService::USER_SHEET:
|
case nsIStyleSheetService::USER_SHEET:
|
||||||
type = nsStyleSet::eUserSheet;
|
type = SheetType::User;
|
||||||
break;
|
break;
|
||||||
case nsIStyleSheetService::AUTHOR_SHEET:
|
case nsIStyleSheetService::AUTHOR_SHEET:
|
||||||
type = nsStyleSet::eDocSheet;
|
type = SheetType::Doc;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MOZ_ASSERT(false, "unexpected aSheetType value");
|
MOZ_ASSERT(false, "unexpected aSheetType value");
|
||||||
|
|||||||
@@ -564,7 +564,7 @@ protected:
|
|||||||
void AddUserSheet(nsISupports* aSheet);
|
void AddUserSheet(nsISupports* aSheet);
|
||||||
void AddAgentSheet(nsISupports* aSheet);
|
void AddAgentSheet(nsISupports* aSheet);
|
||||||
void AddAuthorSheet(nsISupports* aSheet);
|
void AddAuthorSheet(nsISupports* aSheet);
|
||||||
void RemoveSheet(nsStyleSet::sheetType aType, nsISupports* aSheet);
|
void RemoveSheet(mozilla::SheetType aType, nsISupports* aSheet);
|
||||||
|
|
||||||
// Hide a view if it is a popup
|
// Hide a view if it is a popup
|
||||||
void HideViewIfPopup(nsView* aView);
|
void HideViewIfPopup(nsView* aView);
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
|||||||
nsIPresShell* presShell = document->GetShell();
|
nsIPresShell* presShell = document->GetShell();
|
||||||
if (presShell) {
|
if (presShell) {
|
||||||
nsStyleSet* styleSet = presShell->StyleSet();
|
nsStyleSet* styleSet = presShell->StyleSet();
|
||||||
nsStyleSet::sheetType sheetType = nsStyleSet::eAgentSheet;
|
SheetType sheetType = SheetType::Agent;
|
||||||
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
|
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
|
||||||
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
||||||
}
|
}
|
||||||
sheetType = nsStyleSet::eUserSheet;
|
sheetType = SheetType::User;
|
||||||
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
|
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
|
||||||
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ FontFaceSet::Add(FontFace& aFontFace, ErrorResult& aRv)
|
|||||||
|
|
||||||
FontFaceRecord* rec = mNonRuleFaces.AppendElement();
|
FontFaceRecord* rec = mNonRuleFaces.AppendElement();
|
||||||
rec->mFontFace = &aFontFace;
|
rec->mFontFace = &aFontFace;
|
||||||
rec->mSheetType = 0; // unused for mNonRuleFaces
|
rec->mSheetType = SheetType::Unknown; // unused for mNonRuleFaces
|
||||||
rec->mLoadEventShouldFire =
|
rec->mLoadEventShouldFire =
|
||||||
aFontFace.Status() == FontFaceLoadStatus::Unloaded ||
|
aFontFace.Status() == FontFaceLoadStatus::Unloaded ||
|
||||||
aFontFace.Status() == FontFaceLoadStatus::Loading;
|
aFontFace.Status() == FontFaceLoadStatus::Loading;
|
||||||
@@ -828,7 +828,7 @@ FontFaceSet::InsertNonRuleFontFace(FontFace* aFontFace,
|
|||||||
// InsertRuleFontFace does?
|
// InsertRuleFontFace does?
|
||||||
RefPtr<gfxUserFontEntry> entry =
|
RefPtr<gfxUserFontEntry> entry =
|
||||||
FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace,
|
FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace,
|
||||||
nsStyleSet::eDocSheet);
|
SheetType::Doc);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -840,7 +840,7 @@ FontFaceSet::InsertNonRuleFontFace(FontFace* aFontFace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FontFaceSet::InsertRuleFontFace(FontFace* aFontFace, uint8_t aSheetType,
|
FontFaceSet::InsertRuleFontFace(FontFace* aFontFace, SheetType aSheetType,
|
||||||
nsTArray<FontFaceRecord>& aOldRecords,
|
nsTArray<FontFaceRecord>& aOldRecords,
|
||||||
bool& aFontSetModified)
|
bool& aFontSetModified)
|
||||||
{
|
{
|
||||||
@@ -951,13 +951,13 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(FontFace* aFontFace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace,
|
return FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace,
|
||||||
nsStyleSet::eDocSheet);
|
SheetType::Doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<gfxUserFontEntry>
|
already_AddRefed<gfxUserFontEntry>
|
||||||
FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
|
FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
|
||||||
FontFace* aFontFace,
|
FontFace* aFontFace,
|
||||||
uint8_t aSheetType)
|
SheetType aSheetType)
|
||||||
{
|
{
|
||||||
nsCSSValue val;
|
nsCSSValue val;
|
||||||
nsCSSUnit unit;
|
nsCSSUnit unit;
|
||||||
@@ -1094,8 +1094,8 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
|
|||||||
// the same-site origin check and access control headers are
|
// the same-site origin check and access control headers are
|
||||||
// enforced against the sheet principal rather than the document
|
// enforced against the sheet principal rather than the document
|
||||||
// principal to allow user stylesheets to include @font-face rules
|
// principal to allow user stylesheets to include @font-face rules
|
||||||
face->mUseOriginPrincipal = (aSheetType == nsStyleSet::eUserSheet ||
|
face->mUseOriginPrincipal = (aSheetType == SheetType::User ||
|
||||||
aSheetType == nsStyleSet::eAgentSheet);
|
aSheetType == SheetType::Agent);
|
||||||
|
|
||||||
face->mLocalName.Truncate();
|
face->mLocalName.Truncate();
|
||||||
face->mFormatFlags = 0;
|
face->mFormatFlags = 0;
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ private:
|
|||||||
// accordingly.
|
// accordingly.
|
||||||
struct FontFaceRecord {
|
struct FontFaceRecord {
|
||||||
RefPtr<FontFace> mFontFace;
|
RefPtr<FontFace> mFontFace;
|
||||||
uint8_t mSheetType; // only relevant for mRuleFaces entries
|
SheetType mSheetType; // only relevant for mRuleFaces entries
|
||||||
|
|
||||||
// When true, indicates that when finished loading, the FontFace should be
|
// When true, indicates that when finished loading, the FontFace should be
|
||||||
// included in the subsequent loadingdone/loadingerror event fired at the
|
// included in the subsequent loadingdone/loadingerror event fired at the
|
||||||
@@ -243,7 +243,7 @@ private:
|
|||||||
already_AddRefed<gfxUserFontEntry> FindOrCreateUserFontEntryFromFontFace(
|
already_AddRefed<gfxUserFontEntry> FindOrCreateUserFontEntryFromFontFace(
|
||||||
const nsAString& aFamilyName,
|
const nsAString& aFamilyName,
|
||||||
FontFace* aFontFace,
|
FontFace* aFontFace,
|
||||||
uint8_t aSheetType);
|
SheetType aSheetType);
|
||||||
|
|
||||||
// search for @font-face rule that matches a userfont font entry
|
// search for @font-face rule that matches a userfont font entry
|
||||||
nsCSSFontFaceRule* FindRuleForUserFontEntry(gfxUserFontEntry* aUserFontEntry);
|
nsCSSFontFaceRule* FindRuleForUserFontEntry(gfxUserFontEntry* aUserFontEntry);
|
||||||
@@ -264,7 +264,7 @@ private:
|
|||||||
nsresult aStatus);
|
nsresult aStatus);
|
||||||
void RebuildUserFontSet();
|
void RebuildUserFontSet();
|
||||||
|
|
||||||
void InsertRuleFontFace(FontFace* aFontFace, uint8_t aSheetType,
|
void InsertRuleFontFace(FontFace* aFontFace, SheetType aSheetType,
|
||||||
nsTArray<FontFaceRecord>& aOldRecords,
|
nsTArray<FontFaceRecord>& aOldRecords,
|
||||||
bool& aFontSetModified);
|
bool& aFontSetModified);
|
||||||
void InsertNonRuleFontFace(FontFace* aFontFace, bool& aFontSetModified);
|
void InsertNonRuleFontFace(FontFace* aFontFace, bool& aFontSetModified);
|
||||||
|
|||||||
36
layout/style/SheetType.h
Normal file
36
layout/style/SheetType.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
/* enum to represent a level in the cascade */
|
||||||
|
|
||||||
|
#ifndef mozilla_SheetType_h
|
||||||
|
#define mozilla_SheetType_h
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
// The "origins" of the CSS cascade, from lowest precedence to
|
||||||
|
// highest (for non-!important rules).
|
||||||
|
//
|
||||||
|
// Be sure to update NS_RULE_NODE_LEVEL_MASK when changing the number
|
||||||
|
// of sheet types; static assertions enforce this.
|
||||||
|
enum class SheetType : uint8_t {
|
||||||
|
Agent, // CSS
|
||||||
|
User, // CSS
|
||||||
|
PresHint,
|
||||||
|
SVGAttrAnimation,
|
||||||
|
Doc, // CSS
|
||||||
|
ScopedDoc,
|
||||||
|
StyleAttr,
|
||||||
|
Override, // CSS
|
||||||
|
Animation,
|
||||||
|
Transition,
|
||||||
|
|
||||||
|
Count,
|
||||||
|
Unknown = 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_SheetType_h
|
||||||
@@ -88,6 +88,7 @@ EXPORTS.mozilla += [
|
|||||||
'LayerAnimationInfo.h',
|
'LayerAnimationInfo.h',
|
||||||
'RuleNodeCacheConditions.h',
|
'RuleNodeCacheConditions.h',
|
||||||
'RuleProcessorCache.h',
|
'RuleProcessorCache.h',
|
||||||
|
'SheetType.h',
|
||||||
'StyleAnimationValue.h',
|
'StyleAnimationValue.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ MoveValue(nsCSSValue* aSource, nsCSSValue* aDest)
|
|||||||
static bool
|
static bool
|
||||||
ShouldIgnoreColors(nsRuleData *aRuleData)
|
ShouldIgnoreColors(nsRuleData *aRuleData)
|
||||||
{
|
{
|
||||||
return aRuleData->mLevel != nsStyleSet::eAgentSheet &&
|
return aRuleData->mLevel != SheetType::Agent &&
|
||||||
aRuleData->mLevel != nsStyleSet::eUserSheet &&
|
aRuleData->mLevel != SheetType::User &&
|
||||||
!aRuleData->mPresContext->UseDocumentColors();
|
!aRuleData->mPresContext->UseDocumentColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1014,7 +1014,7 @@ RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
|
|||||||
//
|
//
|
||||||
|
|
||||||
nsCSSRuleProcessor::nsCSSRuleProcessor(const sheet_array_type& aSheets,
|
nsCSSRuleProcessor::nsCSSRuleProcessor(const sheet_array_type& aSheets,
|
||||||
uint8_t aSheetType,
|
SheetType aSheetType,
|
||||||
Element* aScopeElement,
|
Element* aScopeElement,
|
||||||
nsCSSRuleProcessor*
|
nsCSSRuleProcessor*
|
||||||
aPreviousCSSRuleProcessor,
|
aPreviousCSSRuleProcessor,
|
||||||
@@ -1035,7 +1035,7 @@ nsCSSRuleProcessor::nsCSSRuleProcessor(const sheet_array_type& aSheets,
|
|||||||
, mDocumentRulesAndCacheKeyValid(false)
|
, mDocumentRulesAndCacheKeyValid(false)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NS_ASSERTION(!!mScopeElement == (aSheetType == nsStyleSet::eScopedDocSheet),
|
NS_ASSERTION(!!mScopeElement == (aSheetType == SheetType::ScopedDoc),
|
||||||
"aScopeElement must be specified iff aSheetType is "
|
"aScopeElement must be specified iff aSheetType is "
|
||||||
"eScopedDocSheet");
|
"eScopedDocSheet");
|
||||||
for (sheet_array_type::size_type i = mSheets.Length(); i-- != 0; ) {
|
for (sheet_array_type::size_type i = mSheets.Length(); i-- != 0; ) {
|
||||||
@@ -3551,7 +3551,7 @@ struct CascadeEnumData {
|
|||||||
nsTArray<css::DocumentRule*>& aDocumentRules,
|
nsTArray<css::DocumentRule*>& aDocumentRules,
|
||||||
nsMediaQueryResultCacheKey& aKey,
|
nsMediaQueryResultCacheKey& aKey,
|
||||||
nsDocumentRuleResultCacheKey& aDocumentKey,
|
nsDocumentRuleResultCacheKey& aDocumentKey,
|
||||||
uint8_t aSheetType,
|
SheetType aSheetType,
|
||||||
bool aMustGatherDocumentRules)
|
bool aMustGatherDocumentRules)
|
||||||
: mPresContext(aPresContext),
|
: mPresContext(aPresContext),
|
||||||
mFontFaceRules(aFontFaceRules),
|
mFontFaceRules(aFontFaceRules),
|
||||||
@@ -3589,7 +3589,7 @@ struct CascadeEnumData {
|
|||||||
// Hooray, a manual PLDHashTable since nsClassHashtable doesn't
|
// Hooray, a manual PLDHashTable since nsClassHashtable doesn't
|
||||||
// provide a getter that gives me a *reference* to the value.
|
// provide a getter that gives me a *reference* to the value.
|
||||||
PLDHashTable mRulesByWeight; // of PerWeightDataListItem linked lists
|
PLDHashTable mRulesByWeight; // of PerWeightDataListItem linked lists
|
||||||
uint8_t mSheetType;
|
SheetType mSheetType;
|
||||||
bool mMustGatherDocumentRules;
|
bool mMustGatherDocumentRules;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,15 @@
|
|||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/EventStates.h"
|
#include "mozilla/EventStates.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "nsIStyleRuleProcessor.h"
|
#include "mozilla/RefCountType.h"
|
||||||
#include "nsIMediaList.h"
|
#include "mozilla/SheetType.h"
|
||||||
#include "nsTArray.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsExpirationTracker.h"
|
#include "nsExpirationTracker.h"
|
||||||
|
#include "nsIMediaList.h"
|
||||||
|
#include "nsIStyleRuleProcessor.h"
|
||||||
#include "nsRuleWalker.h"
|
#include "nsRuleWalker.h"
|
||||||
#include "mozilla/RefCountType.h"
|
#include "nsTArray.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
|
||||||
|
|
||||||
struct CascadeEnumData;
|
struct CascadeEnumData;
|
||||||
struct ElementDependentRuleProcessorData;
|
struct ElementDependentRuleProcessorData;
|
||||||
@@ -59,11 +60,11 @@ public:
|
|||||||
typedef nsTArray<RefPtr<mozilla::CSSStyleSheet>> sheet_array_type;
|
typedef nsTArray<RefPtr<mozilla::CSSStyleSheet>> sheet_array_type;
|
||||||
|
|
||||||
// aScopeElement must be non-null iff aSheetType is
|
// aScopeElement must be non-null iff aSheetType is
|
||||||
// nsStyleSet::eScopedDocSheet.
|
// SheetType::ScopedDoc.
|
||||||
// aPreviousCSSRuleProcessor is the rule processor (if any) that this
|
// aPreviousCSSRuleProcessor is the rule processor (if any) that this
|
||||||
// one is replacing.
|
// one is replacing.
|
||||||
nsCSSRuleProcessor(const sheet_array_type& aSheets,
|
nsCSSRuleProcessor(const sheet_array_type& aSheets,
|
||||||
uint8_t aSheetType,
|
mozilla::SheetType aSheetType,
|
||||||
mozilla::dom::Element* aScopeElement,
|
mozilla::dom::Element* aScopeElement,
|
||||||
nsCSSRuleProcessor* aPreviousCSSRuleProcessor,
|
nsCSSRuleProcessor* aPreviousCSSRuleProcessor,
|
||||||
bool aIsShared = false);
|
bool aIsShared = false);
|
||||||
@@ -262,7 +263,7 @@ private:
|
|||||||
MozRefCountType mStyleSetRefCnt;
|
MozRefCountType mStyleSetRefCnt;
|
||||||
|
|
||||||
// type of stylesheet using this processor
|
// type of stylesheet using this processor
|
||||||
uint8_t mSheetType; // == nsStyleSet::sheetType
|
mozilla::SheetType mSheetType;
|
||||||
|
|
||||||
const bool mIsShared;
|
const bool mIsShared;
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,19 @@
|
|||||||
#ifndef nsCSSRules_h_
|
#ifndef nsCSSRules_h_
|
||||||
#define nsCSSRules_h_
|
#define nsCSSRules_h_
|
||||||
|
|
||||||
|
#include "Declaration.h"
|
||||||
|
#include "StyleRule.h"
|
||||||
|
#include "gfxFontFeatures.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/Move.h"
|
|
||||||
|
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
|
#include "mozilla/Move.h"
|
||||||
|
#include "mozilla/SheetType.h"
|
||||||
#include "mozilla/css/GroupRule.h"
|
#include "mozilla/css/GroupRule.h"
|
||||||
#include "mozilla/dom/FontFace.h"
|
#include "mozilla/dom/FontFace.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
|
#include "nsCSSProperty.h"
|
||||||
|
#include "nsCSSValue.h"
|
||||||
|
#include "nsDOMCSSDeclaration.h"
|
||||||
#include "nsIDOMCSSConditionRule.h"
|
#include "nsIDOMCSSConditionRule.h"
|
||||||
#include "nsIDOMCSSCounterStyleRule.h"
|
#include "nsIDOMCSSCounterStyleRule.h"
|
||||||
#include "nsIDOMCSSFontFaceRule.h"
|
#include "nsIDOMCSSFontFaceRule.h"
|
||||||
@@ -22,18 +29,11 @@
|
|||||||
#include "nsIDOMCSSGroupingRule.h"
|
#include "nsIDOMCSSGroupingRule.h"
|
||||||
#include "nsIDOMCSSMediaRule.h"
|
#include "nsIDOMCSSMediaRule.h"
|
||||||
#include "nsIDOMCSSMozDocumentRule.h"
|
#include "nsIDOMCSSMozDocumentRule.h"
|
||||||
|
#include "nsIDOMCSSPageRule.h"
|
||||||
#include "nsIDOMCSSSupportsRule.h"
|
#include "nsIDOMCSSSupportsRule.h"
|
||||||
#include "nsIDOMMozCSSKeyframeRule.h"
|
#include "nsIDOMMozCSSKeyframeRule.h"
|
||||||
#include "nsIDOMMozCSSKeyframesRule.h"
|
#include "nsIDOMMozCSSKeyframesRule.h"
|
||||||
#include "nsAutoPtr.h"
|
|
||||||
#include "nsCSSProperty.h"
|
|
||||||
#include "nsCSSValue.h"
|
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsDOMCSSDeclaration.h"
|
|
||||||
#include "Declaration.h"
|
|
||||||
#include "nsIDOMCSSPageRule.h"
|
|
||||||
#include "StyleRule.h"
|
|
||||||
#include "gfxFontFeatures.h"
|
|
||||||
|
|
||||||
class nsMediaList;
|
class nsMediaList;
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ protected:
|
|||||||
// specific @font-face rules
|
// specific @font-face rules
|
||||||
struct nsFontFaceRuleContainer {
|
struct nsFontFaceRuleContainer {
|
||||||
RefPtr<nsCSSFontFaceRule> mRule;
|
RefPtr<nsCSSFontFaceRule> mRule;
|
||||||
uint8_t mSheetType;
|
mozilla::SheetType mSheetType;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline nsCSSFontFaceRule*
|
inline nsCSSFontFaceRule*
|
||||||
|
|||||||
@@ -2538,7 +2538,7 @@ nsCSSValueGradient::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) con
|
|||||||
nsCSSValueTokenStream::nsCSSValueTokenStream()
|
nsCSSValueTokenStream::nsCSSValueTokenStream()
|
||||||
: mPropertyID(eCSSProperty_UNKNOWN)
|
: mPropertyID(eCSSProperty_UNKNOWN)
|
||||||
, mShorthandPropertyID(eCSSProperty_UNKNOWN)
|
, mShorthandPropertyID(eCSSProperty_UNKNOWN)
|
||||||
, mLevel(nsStyleSet::eSheetTypeCount)
|
, mLevel(SheetType::Count)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsCSSValueTokenStream);
|
MOZ_COUNT_CTOR(nsCSSValueTokenStream);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
|
#include "mozilla/SheetType.h"
|
||||||
|
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
@@ -1542,7 +1543,7 @@ public:
|
|||||||
// mozilla::CSSStyleSheet* mSheet;
|
// mozilla::CSSStyleSheet* mSheet;
|
||||||
uint32_t mLineNumber;
|
uint32_t mLineNumber;
|
||||||
uint32_t mLineOffset;
|
uint32_t mLineOffset;
|
||||||
uint16_t mLevel; // an nsStyleSet::sheetType
|
mozilla::SheetType mLevel;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCSSValueTokenStream(const nsCSSValueTokenStream& aOther) = delete;
|
nsCSSValueTokenStream(const nsCSSValueTokenStream& aOther) = delete;
|
||||||
|
|||||||
@@ -503,8 +503,8 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement,
|
|||||||
for (nsRuleNode* ruleNode = sc->RuleNode();
|
for (nsRuleNode* ruleNode = sc->RuleNode();
|
||||||
!ruleNode->IsRoot();
|
!ruleNode->IsRoot();
|
||||||
ruleNode = ruleNode->GetParent()) {
|
ruleNode = ruleNode->GetParent()) {
|
||||||
if (ruleNode->GetLevel() == nsStyleSet::eAgentSheet ||
|
if (ruleNode->GetLevel() == SheetType::Agent ||
|
||||||
ruleNode->GetLevel() == nsStyleSet::eUserSheet) {
|
ruleNode->GetLevel() == SheetType::User) {
|
||||||
rules.AppendElement(ruleNode->GetRule());
|
rules.AppendElement(ruleNode->GetRule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "mozilla/CSSVariableDeclarations.h"
|
#include "mozilla/CSSVariableDeclarations.h"
|
||||||
#include "mozilla/RuleNodeCacheConditions.h"
|
#include "mozilla/RuleNodeCacheConditions.h"
|
||||||
|
#include "mozilla/SheetType.h"
|
||||||
#include "nsCSSProps.h"
|
#include "nsCSSProps.h"
|
||||||
#include "nsCSSValue.h"
|
#include "nsCSSValue.h"
|
||||||
#include "nsStyleStructFwd.h"
|
#include "nsStyleStructFwd.h"
|
||||||
@@ -28,7 +29,7 @@ struct nsRuleData
|
|||||||
const uint32_t mSIDs;
|
const uint32_t mSIDs;
|
||||||
mozilla::RuleNodeCacheConditions mConditions;
|
mozilla::RuleNodeCacheConditions mConditions;
|
||||||
bool mIsImportantRule;
|
bool mIsImportantRule;
|
||||||
uint16_t mLevel; // an nsStyleSet::sheetType
|
mozilla::SheetType mLevel;
|
||||||
nsPresContext* const mPresContext;
|
nsPresContext* const mPresContext;
|
||||||
nsStyleContext* const mStyleContext;
|
nsStyleContext* const mStyleContext;
|
||||||
|
|
||||||
|
|||||||
@@ -1466,11 +1466,11 @@ nsRuleNode::DestroyInternal(nsRuleNode ***aDestroyQueueTail)
|
|||||||
nsRuleNode* nsRuleNode::CreateRootNode(nsPresContext* aPresContext)
|
nsRuleNode* nsRuleNode::CreateRootNode(nsPresContext* aPresContext)
|
||||||
{
|
{
|
||||||
return new (aPresContext)
|
return new (aPresContext)
|
||||||
nsRuleNode(aPresContext, nullptr, nullptr, 0xff, false);
|
nsRuleNode(aPresContext, nullptr, nullptr, SheetType::Unknown, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRuleNode::nsRuleNode(nsPresContext* aContext, nsRuleNode* aParent,
|
nsRuleNode::nsRuleNode(nsPresContext* aContext, nsRuleNode* aParent,
|
||||||
nsIStyleRule* aRule, uint8_t aLevel,
|
nsIStyleRule* aRule, SheetType aLevel,
|
||||||
bool aIsImportant)
|
bool aIsImportant)
|
||||||
: mPresContext(aContext),
|
: mPresContext(aContext),
|
||||||
mParent(aParent),
|
mParent(aParent),
|
||||||
@@ -1505,9 +1505,9 @@ nsRuleNode::nsRuleNode(nsPresContext* aContext, nsRuleNode* aParent,
|
|||||||
|
|
||||||
// nsStyleSet::GetContext depends on there being only one animation
|
// nsStyleSet::GetContext depends on there being only one animation
|
||||||
// rule.
|
// rule.
|
||||||
MOZ_ASSERT(IsRoot() || GetLevel() != nsStyleSet::eAnimationSheet ||
|
MOZ_ASSERT(IsRoot() || GetLevel() != SheetType::Animation ||
|
||||||
mParent->IsRoot() ||
|
mParent->IsRoot() ||
|
||||||
mParent->GetLevel() != nsStyleSet::eAnimationSheet,
|
mParent->GetLevel() != SheetType::Animation,
|
||||||
"must be only one rule at animation level");
|
"must be only one rule at animation level");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1522,7 +1522,7 @@ nsRuleNode::~nsRuleNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsRuleNode*
|
nsRuleNode*
|
||||||
nsRuleNode::Transition(nsIStyleRule* aRule, uint8_t aLevel,
|
nsRuleNode::Transition(nsIStyleRule* aRule, SheetType aLevel,
|
||||||
bool aIsImportantRule)
|
bool aIsImportantRule)
|
||||||
{
|
{
|
||||||
nsRuleNode* next = nullptr;
|
nsRuleNode* next = nullptr;
|
||||||
@@ -2180,10 +2180,10 @@ nsRuleNode::ResolveVariableReferences(const nsStyleStructID aSID,
|
|||||||
&aContext->StyleVariables()->mVariables;
|
&aContext->StyleVariables()->mVariables;
|
||||||
nsCSSValueTokenStream* tokenStream = value->GetTokenStreamValue();
|
nsCSSValueTokenStream* tokenStream = value->GetTokenStreamValue();
|
||||||
|
|
||||||
MOZ_ASSERT(tokenStream->mLevel != nsStyleSet::eSheetTypeCount,
|
MOZ_ASSERT(tokenStream->mLevel != SheetType::Count,
|
||||||
"Token stream should have a defined level");
|
"Token stream should have a defined level");
|
||||||
|
|
||||||
AutoRestore<uint16_t> saveLevel(aRuleData->mLevel);
|
AutoRestore<SheetType> saveLevel(aRuleData->mLevel);
|
||||||
aRuleData->mLevel = tokenStream->mLevel;
|
aRuleData->mLevel = tokenStream->mLevel;
|
||||||
|
|
||||||
// Note that ParsePropertyWithVariableReferences relies on the fact
|
// Note that ParsePropertyWithVariableReferences relies on the fact
|
||||||
@@ -9692,8 +9692,8 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
|
|||||||
|
|
||||||
rule->MapRuleInfoInto(&ruleData);
|
rule->MapRuleInfoInto(&ruleData);
|
||||||
|
|
||||||
if (ruleData.mLevel == nsStyleSet::eAgentSheet ||
|
if (ruleData.mLevel == SheetType::Agent ||
|
||||||
ruleData.mLevel == nsStyleSet::eUserSheet) {
|
ruleData.mLevel == SheetType::User) {
|
||||||
// This is a rule whose effect we want to ignore, so if any of
|
// This is a rule whose effect we want to ignore, so if any of
|
||||||
// the properties we care about were set, set them to the dummy
|
// the properties we care about were set, set them to the dummy
|
||||||
// value that they'll never otherwise get.
|
// value that they'll never otherwise get.
|
||||||
@@ -9815,7 +9815,7 @@ nsRuleNode::ComputePropertiesOverridingAnimation(
|
|||||||
// property) for transitions yet (which will make their
|
// property) for transitions yet (which will make their
|
||||||
// MapRuleInfoInto skip the properties that are currently
|
// MapRuleInfoInto skip the properties that are currently
|
||||||
// animating), we should skip them explicitly.
|
// animating), we should skip them explicitly.
|
||||||
if (ruleData.mLevel == nsStyleSet::eTransitionSheet) {
|
if (ruleData.mLevel == SheetType::Transition) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "mozilla/PodOperations.h"
|
#include "mozilla/PodOperations.h"
|
||||||
#include "mozilla/RangedArray.h"
|
#include "mozilla/RangedArray.h"
|
||||||
#include "mozilla/RuleNodeCacheConditions.h"
|
#include "mozilla/RuleNodeCacheConditions.h"
|
||||||
|
#include "mozilla/SheetType.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsStyleStruct.h"
|
#include "nsStyleStruct.h"
|
||||||
|
|
||||||
@@ -418,10 +419,10 @@ private:
|
|||||||
|
|
||||||
struct Key {
|
struct Key {
|
||||||
nsIStyleRule* mRule;
|
nsIStyleRule* mRule;
|
||||||
uint8_t mLevel;
|
mozilla::SheetType mLevel;
|
||||||
bool mIsImportantRule;
|
bool mIsImportantRule;
|
||||||
|
|
||||||
Key(nsIStyleRule* aRule, uint8_t aLevel, bool aIsImportantRule)
|
Key(nsIStyleRule* aRule, mozilla::SheetType aLevel, bool aIsImportantRule)
|
||||||
: mRule(aRule), mLevel(aLevel), mIsImportantRule(aIsImportantRule)
|
: mRule(aRule), mLevel(aLevel), mIsImportantRule(aIsImportantRule)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -800,7 +801,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
|
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
|
||||||
nsIStyleRule* aRule, uint8_t aLevel, bool aIsImportant);
|
nsIStyleRule* aRule, mozilla::SheetType aLevel, bool aIsImportant);
|
||||||
~nsRuleNode();
|
~nsRuleNode();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -812,7 +813,7 @@ public:
|
|||||||
static void EnsureInlineDisplay(uint8_t& display);
|
static void EnsureInlineDisplay(uint8_t& display);
|
||||||
|
|
||||||
// Transition never returns null; on out of memory it'll just return |this|.
|
// Transition never returns null; on out of memory it'll just return |this|.
|
||||||
nsRuleNode* Transition(nsIStyleRule* aRule, uint8_t aLevel,
|
nsRuleNode* Transition(nsIStyleRule* aRule, mozilla::SheetType aLevel,
|
||||||
bool aIsImportantRule);
|
bool aIsImportantRule);
|
||||||
nsRuleNode* GetParent() const { return mParent; }
|
nsRuleNode* GetParent() const { return mParent; }
|
||||||
bool IsRoot() const { return mParent == nullptr; }
|
bool IsRoot() const { return mParent == nullptr; }
|
||||||
@@ -823,11 +824,11 @@ public:
|
|||||||
return const_cast<nsRuleNode*>(this)->RuleTree();
|
return const_cast<nsRuleNode*>(this)->RuleTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
// These uint8_ts are really nsStyleSet::sheetType values.
|
mozilla::SheetType GetLevel() const {
|
||||||
uint8_t GetLevel() const {
|
|
||||||
NS_ASSERTION(!IsRoot(), "can't call on root");
|
NS_ASSERTION(!IsRoot(), "can't call on root");
|
||||||
return (mDependentBits & NS_RULE_NODE_LEVEL_MASK) >>
|
return mozilla::SheetType(
|
||||||
NS_RULE_NODE_LEVEL_SHIFT;
|
(mDependentBits & NS_RULE_NODE_LEVEL_MASK) >>
|
||||||
|
NS_RULE_NODE_LEVEL_SHIFT);
|
||||||
}
|
}
|
||||||
bool IsImportantRule() const {
|
bool IsImportantRule() const {
|
||||||
NS_ASSERTION(!IsRoot(), "can't call on root");
|
NS_ASSERTION(!IsRoot(), "can't call on root");
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
bool AtRoot() { return mCurrent == mRoot; }
|
bool AtRoot() { return mCurrent == mRoot; }
|
||||||
|
|
||||||
void SetLevel(uint8_t aLevel, bool aImportance,
|
void SetLevel(mozilla::SheetType aLevel, bool aImportance,
|
||||||
bool aCheckForImportantRules) {
|
bool aCheckForImportantRules) {
|
||||||
NS_ASSERTION(!aCheckForImportantRules || !aImportance,
|
NS_ASSERTION(!aCheckForImportantRules || !aImportance,
|
||||||
"Shouldn't be checking for important rules while walking "
|
"Shouldn't be checking for important rules while walking "
|
||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
mImportance = aImportance;
|
mImportance = aImportance;
|
||||||
mCheckForImportantRules = aCheckForImportantRules;
|
mCheckForImportantRules = aCheckForImportantRules;
|
||||||
}
|
}
|
||||||
uint8_t GetLevel() const { return mLevel; }
|
mozilla::SheetType GetLevel() const { return mLevel; }
|
||||||
bool GetImportance() const { return mImportance; }
|
bool GetImportance() const { return mImportance; }
|
||||||
bool GetCheckForImportantRules() const { return mCheckForImportantRules; }
|
bool GetCheckForImportantRules() const { return mCheckForImportantRules; }
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
nsRuleNode* mCurrent; // Our current position. Never null.
|
nsRuleNode* mCurrent; // Our current position. Never null.
|
||||||
nsRuleNode* mRoot; // The root of the tree we're walking.
|
nsRuleNode* mRoot; // The root of the tree we're walking.
|
||||||
uint8_t mLevel; // an nsStyleSet::sheetType
|
mozilla::SheetType mLevel;
|
||||||
bool mImportance;
|
bool mImportance;
|
||||||
bool mCheckForImportantRules; // If true, check for important rules as
|
bool mCheckForImportantRules; // If true, check for important rules as
|
||||||
// we walk and set to false if we find
|
// we walk and set to false if we find
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "mozilla/ArrayUtils.h"
|
#include "mozilla/ArrayUtils.h"
|
||||||
#include "mozilla/CSSStyleSheet.h"
|
#include "mozilla/CSSStyleSheet.h"
|
||||||
|
#include "mozilla/EnumeratedRange.h"
|
||||||
#include "mozilla/EventStates.h"
|
#include "mozilla/EventStates.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/RuleProcessorCache.h"
|
#include "mozilla/RuleProcessorCache.h"
|
||||||
@@ -143,18 +144,18 @@ nsDisableTextZoomStyleRule::List(FILE* out, int32_t aIndent) const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const nsStyleSet::sheetType gCSSSheetTypes[] = {
|
static const SheetType gCSSSheetTypes[] = {
|
||||||
// From lowest to highest in cascading order.
|
// From lowest to highest in cascading order.
|
||||||
nsStyleSet::eAgentSheet,
|
SheetType::Agent,
|
||||||
nsStyleSet::eUserSheet,
|
SheetType::User,
|
||||||
nsStyleSet::eDocSheet,
|
SheetType::Doc,
|
||||||
nsStyleSet::eScopedDocSheet,
|
SheetType::ScopedDoc,
|
||||||
nsStyleSet::eOverrideSheet
|
SheetType::Override
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool IsCSSSheetType(nsStyleSet::sheetType aSheetType)
|
static bool IsCSSSheetType(SheetType aSheetType)
|
||||||
{
|
{
|
||||||
for (nsStyleSet::sheetType type : gCSSSheetTypes) {
|
for (SheetType type : gCSSSheetTypes) {
|
||||||
if (type == aSheetType) {
|
if (type == aSheetType) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -177,7 +178,7 @@ nsStyleSet::nsStyleSet()
|
|||||||
|
|
||||||
nsStyleSet::~nsStyleSet()
|
nsStyleSet::~nsStyleSet()
|
||||||
{
|
{
|
||||||
for (sheetType type : gCSSSheetTypes) {
|
for (SheetType type : gCSSSheetTypes) {
|
||||||
for (uint32_t i = 0, n = mSheets[type].Length(); i < n; i++) {
|
for (uint32_t i = 0, n = mSheets[type].Length(); i < n; i++) {
|
||||||
static_cast<CSSStyleSheet*>(mSheets[type][i])->DropStyleSet(this);
|
static_cast<CSSStyleSheet*>(mSheets[type][i])->DropStyleSet(this);
|
||||||
}
|
}
|
||||||
@@ -185,12 +186,12 @@ nsStyleSet::~nsStyleSet()
|
|||||||
|
|
||||||
// drop reference to cached rule processors
|
// drop reference to cached rule processors
|
||||||
nsCSSRuleProcessor* rp;
|
nsCSSRuleProcessor* rp;
|
||||||
rp = static_cast<nsCSSRuleProcessor*>(mRuleProcessors[eAgentSheet].get());
|
rp = static_cast<nsCSSRuleProcessor*>(mRuleProcessors[SheetType::Agent].get());
|
||||||
if (rp) {
|
if (rp) {
|
||||||
MOZ_ASSERT(rp->IsShared());
|
MOZ_ASSERT(rp->IsShared());
|
||||||
rp->ReleaseStyleSetRef();
|
rp->ReleaseStyleSetRef();
|
||||||
}
|
}
|
||||||
rp = static_cast<nsCSSRuleProcessor*>(mRuleProcessors[eUserSheet].get());
|
rp = static_cast<nsCSSRuleProcessor*>(mRuleProcessors[SheetType::User].get());
|
||||||
if (rp) {
|
if (rp) {
|
||||||
MOZ_ASSERT(rp->IsShared());
|
MOZ_ASSERT(rp->IsShared());
|
||||||
rp->ReleaseStyleSetRef();
|
rp->ReleaseStyleSetRef();
|
||||||
@@ -202,17 +203,17 @@ nsStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|||||||
{
|
{
|
||||||
size_t n = aMallocSizeOf(this);
|
size_t n = aMallocSizeOf(this);
|
||||||
|
|
||||||
for (int i = 0; i < eSheetTypeCount; i++) {
|
for (SheetType type : MakeEnumeratedRange(SheetType::Count)) {
|
||||||
if (mRuleProcessors[i]) {
|
if (mRuleProcessors[type]) {
|
||||||
bool shared = false;
|
bool shared = false;
|
||||||
if (i == eAgentSheet || i == eUserSheet) {
|
if (type == SheetType::Agent || type == SheetType::User) {
|
||||||
// The only two origins we consider caching rule processors for.
|
// The only two origins we consider caching rule processors for.
|
||||||
nsCSSRuleProcessor* rp =
|
nsCSSRuleProcessor* rp =
|
||||||
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[i].get());
|
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[type].get());
|
||||||
shared = rp->IsShared();
|
shared = rp->IsShared();
|
||||||
}
|
}
|
||||||
if (!shared) {
|
if (!shared) {
|
||||||
n += mRuleProcessors[i]->SizeOfIncludingThis(aMallocSizeOf);
|
n += mRuleProcessors[type]->SizeOfIncludingThis(aMallocSizeOf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// mSheets is a C-style array of nsCOMArrays. We do not own the sheets in
|
// mSheets is a C-style array of nsCOMArrays. We do not own the sheets in
|
||||||
@@ -220,7 +221,7 @@ nsStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|||||||
// document owns them) so we do not count the sheets here (we pass nullptr
|
// document owns them) so we do not count the sheets here (we pass nullptr
|
||||||
// as the aSizeOfElementIncludingThis argument). All we're doing here is
|
// as the aSizeOfElementIncludingThis argument). All we're doing here is
|
||||||
// counting the size of the nsCOMArrays' buffers.
|
// counting the size of the nsCOMArrays' buffers.
|
||||||
n += mSheets[i].SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
n += mSheets[type].SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
||||||
@@ -247,11 +248,11 @@ nsStyleSet::Init(nsPresContext *aPresContext)
|
|||||||
// Make an explicit GatherRuleProcessors call for the levels that
|
// Make an explicit GatherRuleProcessors call for the levels that
|
||||||
// don't have style sheets. The other levels will have their calls
|
// don't have style sheets. The other levels will have their calls
|
||||||
// triggered by DirtyRuleProcessors. (We should probably convert the
|
// triggered by DirtyRuleProcessors. (We should probably convert the
|
||||||
// ePresHintSheet and eStyleAttrSheet levels to work like this as
|
// SheetType::PresHint and SheetType::StyleAttr levels to work like
|
||||||
// well, and not implement nsIStyleSheet.)
|
// this as well, and not implement nsIStyleSheet.)
|
||||||
GatherRuleProcessors(eAnimationSheet);
|
GatherRuleProcessors(SheetType::Animation);
|
||||||
GatherRuleProcessors(eTransitionSheet);
|
GatherRuleProcessors(SheetType::Transition);
|
||||||
GatherRuleProcessors(eSVGAttrAnimationSheet);
|
GatherRuleProcessors(SheetType::SVGAttrAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
@@ -387,7 +388,7 @@ SortStyleSheetsByScope(nsTArray<CSSStyleSheet*>& aSheets)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::GatherRuleProcessors(sheetType aType)
|
nsStyleSet::GatherRuleProcessors(SheetType aType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_FALSE(mInShutdown, NS_ERROR_FAILURE);
|
NS_ENSURE_FALSE(mInShutdown, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
@@ -401,7 +402,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
}
|
}
|
||||||
nsCOMPtr<nsIStyleRuleProcessor> oldRuleProcessor(mRuleProcessors[aType]);
|
nsCOMPtr<nsIStyleRuleProcessor> oldRuleProcessor(mRuleProcessors[aType]);
|
||||||
nsTArray<nsCOMPtr<nsIStyleRuleProcessor>> oldScopedDocRuleProcessors;
|
nsTArray<nsCOMPtr<nsIStyleRuleProcessor>> oldScopedDocRuleProcessors;
|
||||||
if (aType == eAgentSheet || aType == eUserSheet) {
|
if (aType == SheetType::Agent || aType == SheetType::User) {
|
||||||
// drop reference to cached rule processor
|
// drop reference to cached rule processor
|
||||||
nsCSSRuleProcessor* rp =
|
nsCSSRuleProcessor* rp =
|
||||||
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[aType].get());
|
static_cast<nsCSSRuleProcessor*>(mRuleProcessors[aType].get());
|
||||||
@@ -411,7 +412,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mRuleProcessors[aType] = nullptr;
|
mRuleProcessors[aType] = nullptr;
|
||||||
if (aType == eScopedDocSheet) {
|
if (aType == SheetType::ScopedDoc) {
|
||||||
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
||||||
nsIStyleRuleProcessor* processor = mScopedDocSheetRuleProcessors[i].get();
|
nsIStyleRuleProcessor* processor = mScopedDocSheetRuleProcessors[i].get();
|
||||||
Element* scope =
|
Element* scope =
|
||||||
@@ -422,9 +423,9 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
// Clear mScopedDocSheetRuleProcessors, but save it.
|
// Clear mScopedDocSheetRuleProcessors, but save it.
|
||||||
oldScopedDocRuleProcessors.SwapElements(mScopedDocSheetRuleProcessors);
|
oldScopedDocRuleProcessors.SwapElements(mScopedDocSheetRuleProcessors);
|
||||||
}
|
}
|
||||||
if (mAuthorStyleDisabled && (aType == eDocSheet ||
|
if (mAuthorStyleDisabled && (aType == SheetType::Doc ||
|
||||||
aType == eScopedDocSheet ||
|
aType == SheetType::ScopedDoc ||
|
||||||
aType == eStyleAttrSheet)) {
|
aType == SheetType::StyleAttr)) {
|
||||||
// Don't regather if this level is disabled. Note that we gather
|
// Don't regather if this level is disabled. Note that we gather
|
||||||
// preshint sheets no matter what, but then skip them for some
|
// preshint sheets no matter what, but then skip them for some
|
||||||
// elements later if mAuthorStyleDisabled.
|
// elements later if mAuthorStyleDisabled.
|
||||||
@@ -433,24 +434,24 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
switch (aType) {
|
switch (aType) {
|
||||||
// handle the types for which have a rule processor that does not
|
// handle the types for which have a rule processor that does not
|
||||||
// implement the style sheet interface.
|
// implement the style sheet interface.
|
||||||
case eAnimationSheet:
|
case SheetType::Animation:
|
||||||
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
||||||
mRuleProcessors[aType] = PresContext()->AnimationManager();
|
mRuleProcessors[aType] = PresContext()->AnimationManager();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case eTransitionSheet:
|
case SheetType::Transition:
|
||||||
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
||||||
mRuleProcessors[aType] = PresContext()->TransitionManager();
|
mRuleProcessors[aType] = PresContext()->TransitionManager();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case eStyleAttrSheet:
|
case SheetType::StyleAttr:
|
||||||
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
||||||
mRuleProcessors[aType] = PresContext()->Document()->GetInlineStyleSheet();
|
mRuleProcessors[aType] = PresContext()->Document()->GetInlineStyleSheet();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case ePresHintSheet:
|
case SheetType::PresHint:
|
||||||
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
||||||
mRuleProcessors[aType] =
|
mRuleProcessors[aType] =
|
||||||
PresContext()->Document()->GetAttributeStyleSheet();
|
PresContext()->Document()->GetAttributeStyleSheet();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case eSVGAttrAnimationSheet:
|
case SheetType::SVGAttrAnimation:
|
||||||
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
||||||
mRuleProcessors[aType] =
|
mRuleProcessors[aType] =
|
||||||
PresContext()->Document()->GetSVGAttrAnimationRuleProcessor();
|
PresContext()->Document()->GetSVGAttrAnimationRuleProcessor();
|
||||||
@@ -459,9 +460,9 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
// keep going
|
// keep going
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (aType == eScopedDocSheet) {
|
if (aType == SheetType::ScopedDoc) {
|
||||||
// Create a rule processor for each scope.
|
// Create a rule processor for each scope.
|
||||||
uint32_t count = mSheets[eScopedDocSheet].Count();
|
uint32_t count = mSheets[SheetType::ScopedDoc].Count();
|
||||||
if (count) {
|
if (count) {
|
||||||
// Gather the scoped style sheets into an array as
|
// Gather the scoped style sheets into an array as
|
||||||
// CSSStyleSheets, and mark all of their scope elements
|
// CSSStyleSheets, and mark all of their scope elements
|
||||||
@@ -469,7 +470,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
nsTArray<CSSStyleSheet*> sheets(count);
|
nsTArray<CSSStyleSheet*> sheets(count);
|
||||||
for (uint32_t i = 0; i < count; i++) {
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
RefPtr<CSSStyleSheet> sheet =
|
RefPtr<CSSStyleSheet> sheet =
|
||||||
do_QueryObject(mSheets[eScopedDocSheet].ObjectAt(i));
|
do_QueryObject(mSheets[SheetType::ScopedDoc].ObjectAt(i));
|
||||||
sheets.AppendElement(sheet);
|
sheets.AppendElement(sheet);
|
||||||
|
|
||||||
Element* scope = sheet->GetScopeElement();
|
Element* scope = sheet->GetScopeElement();
|
||||||
@@ -511,8 +512,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
sheetsForScope.AppendElements(sheets.Elements() + start, end - start);
|
sheetsForScope.AppendElements(sheets.Elements() + start, end - start);
|
||||||
nsCSSRuleProcessor* oldRP = oldScopedRuleProcessorHash.Get(scope);
|
nsCSSRuleProcessor* oldRP = oldScopedRuleProcessorHash.Get(scope);
|
||||||
mScopedDocSheetRuleProcessors.AppendElement
|
mScopedDocSheetRuleProcessors.AppendElement
|
||||||
(new nsCSSRuleProcessor(sheetsForScope, uint8_t(aType), scope,
|
(new nsCSSRuleProcessor(sheetsForScope, aType, scope, oldRP));
|
||||||
oldRP));
|
|
||||||
|
|
||||||
start = end;
|
start = end;
|
||||||
} while (start < count);
|
} while (start < count);
|
||||||
@@ -521,8 +521,8 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
}
|
}
|
||||||
if (mSheets[aType].Count()) {
|
if (mSheets[aType].Count()) {
|
||||||
switch (aType) {
|
switch (aType) {
|
||||||
case eAgentSheet:
|
case SheetType::Agent:
|
||||||
case eUserSheet: {
|
case SheetType::User: {
|
||||||
// levels containing non-scoped CSS style sheets whose rule processors
|
// levels containing non-scoped CSS style sheets whose rule processors
|
||||||
// we want to re-use
|
// we want to re-use
|
||||||
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
||||||
@@ -539,7 +539,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
nsCSSRuleProcessor* rp =
|
nsCSSRuleProcessor* rp =
|
||||||
RuleProcessorCache::GetRuleProcessor(cssSheetsRaw, PresContext());
|
RuleProcessorCache::GetRuleProcessor(cssSheetsRaw, PresContext());
|
||||||
if (!rp) {
|
if (!rp) {
|
||||||
rp = new nsCSSRuleProcessor(cssSheets, uint8_t(aType), nullptr,
|
rp = new nsCSSRuleProcessor(cssSheets, aType, nullptr,
|
||||||
static_cast<nsCSSRuleProcessor*>(
|
static_cast<nsCSSRuleProcessor*>(
|
||||||
oldRuleProcessor.get()),
|
oldRuleProcessor.get()),
|
||||||
true /* aIsShared */);
|
true /* aIsShared */);
|
||||||
@@ -555,8 +555,8 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
rp->AddStyleSetRef();
|
rp->AddStyleSetRef();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eDocSheet:
|
case SheetType::Doc:
|
||||||
case eOverrideSheet: {
|
case SheetType::Override: {
|
||||||
// levels containing non-scoped CSS stylesheets whose rule processors
|
// levels containing non-scoped CSS stylesheets whose rule processors
|
||||||
// we don't want to re-use
|
// we don't want to re-use
|
||||||
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
||||||
@@ -567,7 +567,7 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
|
|||||||
cssSheets.AppendElement(cssSheet);
|
cssSheets.AppendElement(cssSheet);
|
||||||
}
|
}
|
||||||
mRuleProcessors[aType] =
|
mRuleProcessors[aType] =
|
||||||
new nsCSSRuleProcessor(cssSheets, uint8_t(aType), nullptr,
|
new nsCSSRuleProcessor(cssSheets, aType, nullptr,
|
||||||
static_cast<nsCSSRuleProcessor*>(
|
static_cast<nsCSSRuleProcessor*>(
|
||||||
oldRuleProcessor.get()));
|
oldRuleProcessor.get()));
|
||||||
} break;
|
} break;
|
||||||
@@ -593,7 +593,7 @@ IsScopedStyleSheet(nsIStyleSheet* aSheet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
nsStyleSet::AppendStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aSheet, "null arg");
|
NS_PRECONDITION(aSheet, "null arg");
|
||||||
NS_ASSERTION(aSheet->IsApplicable(),
|
NS_ASSERTION(aSheet->IsApplicable(),
|
||||||
@@ -610,7 +610,7 @@ nsStyleSet::AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::PrependStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
nsStyleSet::PrependStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aSheet, "null arg");
|
NS_PRECONDITION(aSheet, "null arg");
|
||||||
NS_ASSERTION(aSheet->IsApplicable(),
|
NS_ASSERTION(aSheet->IsApplicable(),
|
||||||
@@ -627,7 +627,7 @@ nsStyleSet::PrependStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::RemoveStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
nsStyleSet::RemoveStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aSheet, "null arg");
|
NS_PRECONDITION(aSheet, "null arg");
|
||||||
NS_ASSERTION(aSheet->IsComplete(),
|
NS_ASSERTION(aSheet->IsComplete(),
|
||||||
@@ -642,7 +642,7 @@ nsStyleSet::RemoveStyleSheet(sheetType aType, nsIStyleSheet *aSheet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::ReplaceSheets(sheetType aType,
|
nsStyleSet::ReplaceSheets(SheetType aType,
|
||||||
const nsCOMArray<nsIStyleSheet> &aNewSheets)
|
const nsCOMArray<nsIStyleSheet> &aNewSheets)
|
||||||
{
|
{
|
||||||
bool cssSheetType = IsCSSSheetType(aType);
|
bool cssSheetType = IsCSSSheetType(aType);
|
||||||
@@ -666,7 +666,7 @@ nsStyleSet::ReplaceSheets(sheetType aType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::InsertStyleSheetBefore(sheetType aType, nsIStyleSheet *aNewSheet,
|
nsStyleSet::InsertStyleSheetBefore(SheetType aType, nsIStyleSheet *aNewSheet,
|
||||||
nsIStyleSheet *aReferenceSheet)
|
nsIStyleSheet *aReferenceSheet)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aNewSheet && aReferenceSheet, "null arg");
|
NS_PRECONDITION(aNewSheet && aReferenceSheet, "null arg");
|
||||||
@@ -688,13 +688,19 @@ nsStyleSet::InsertStyleSheetBefore(sheetType aType, nsIStyleSheet *aNewSheet,
|
|||||||
return DirtyRuleProcessors(aType);
|
return DirtyRuleProcessors(aType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
DirtyBit(SheetType aType)
|
||||||
|
{
|
||||||
|
return 1 << uint32_t(aType);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStyleSet::DirtyRuleProcessors(sheetType aType)
|
nsStyleSet::DirtyRuleProcessors(SheetType aType)
|
||||||
{
|
{
|
||||||
if (!mBatching)
|
if (!mBatching)
|
||||||
return GatherRuleProcessors(aType);
|
return GatherRuleProcessors(aType);
|
||||||
|
|
||||||
mDirty |= 1 << aType;
|
mDirty |= DirtyBit(aType);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,9 +716,9 @@ nsStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled)
|
|||||||
if (aStyleDisabled == !mAuthorStyleDisabled) {
|
if (aStyleDisabled == !mAuthorStyleDisabled) {
|
||||||
mAuthorStyleDisabled = aStyleDisabled;
|
mAuthorStyleDisabled = aStyleDisabled;
|
||||||
BeginUpdate();
|
BeginUpdate();
|
||||||
mDirty |= 1 << eDocSheet |
|
mDirty |= DirtyBit(SheetType::Doc) |
|
||||||
1 << eScopedDocSheet |
|
DirtyBit(SheetType::ScopedDoc) |
|
||||||
1 << eStyleAttrSheet;
|
DirtyBit(SheetType::StyleAttr);
|
||||||
return EndUpdate();
|
return EndUpdate();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -727,9 +733,9 @@ nsStyleSet::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
|||||||
NS_ASSERTION(aSheet->IsApplicable(),
|
NS_ASSERTION(aSheet->IsApplicable(),
|
||||||
"Inapplicable sheet being placed in style set");
|
"Inapplicable sheet being placed in style set");
|
||||||
|
|
||||||
sheetType type = IsScopedStyleSheet(aSheet) ?
|
SheetType type = IsScopedStyleSheet(aSheet) ?
|
||||||
eScopedDocSheet :
|
SheetType::ScopedDoc :
|
||||||
eDocSheet;
|
SheetType::Doc;
|
||||||
nsCOMArray<nsIStyleSheet>& sheets = mSheets[type];
|
nsCOMArray<nsIStyleSheet>& sheets = mSheets[type];
|
||||||
|
|
||||||
bool present = sheets.RemoveObject(aSheet);
|
bool present = sheets.RemoveObject(aSheet);
|
||||||
@@ -771,7 +777,8 @@ nsStyleSet::RemoveDocStyleSheet(nsIStyleSheet *aSheet)
|
|||||||
{
|
{
|
||||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet);
|
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet);
|
||||||
bool isScoped = cssSheet && cssSheet->GetScopeElement();
|
bool isScoped = cssSheet && cssSheet->GetScopeElement();
|
||||||
return RemoveStyleSheet(isScoped ? eScopedDocSheet : eDocSheet, aSheet);
|
return RemoveStyleSheet(isScoped ? SheetType::ScopedDoc : SheetType::Doc,
|
||||||
|
aSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Batching
|
// Batching
|
||||||
@@ -790,9 +797,9 @@ nsStyleSet::EndUpdate()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < eSheetTypeCount; ++i) {
|
for (SheetType type : MakeEnumeratedRange(SheetType::Count)) {
|
||||||
if (mDirty & (1 << i)) {
|
if (mDirty & DirtyBit(type)) {
|
||||||
nsresult rv = GatherRuleProcessors(sheetType(i));
|
nsresult rv = GatherRuleProcessors(type);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -814,7 +821,7 @@ static inline bool
|
|||||||
IsMoreSpecificThanAnimation(nsRuleNode *aRuleNode)
|
IsMoreSpecificThanAnimation(nsRuleNode *aRuleNode)
|
||||||
{
|
{
|
||||||
return !aRuleNode->IsRoot() &&
|
return !aRuleNode->IsRoot() &&
|
||||||
(aRuleNode->GetLevel() == nsStyleSet::eTransitionSheet ||
|
(aRuleNode->GetLevel() == SheetType::Transition ||
|
||||||
aRuleNode->IsImportantRule());
|
aRuleNode->IsImportantRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,7 +833,7 @@ GetAnimationRule(nsRuleNode *aRuleNode)
|
|||||||
n = n->GetParent();
|
n = n->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n->IsRoot() || n->GetLevel() != nsStyleSet::eAnimationSheet) {
|
if (n->IsRoot() || n->GetLevel() != SheetType::Animation) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,17 +855,17 @@ ReplaceAnimationRule(nsRuleNode *aOldRuleNode,
|
|||||||
|
|
||||||
if (aOldAnimRule) {
|
if (aOldAnimRule) {
|
||||||
MOZ_ASSERT(n->GetRule() == aOldAnimRule, "wrong rule");
|
MOZ_ASSERT(n->GetRule() == aOldAnimRule, "wrong rule");
|
||||||
MOZ_ASSERT(n->GetLevel() == nsStyleSet::eAnimationSheet,
|
MOZ_ASSERT(n->GetLevel() == SheetType::Animation,
|
||||||
"wrong level");
|
"wrong level");
|
||||||
n = n->GetParent();
|
n = n->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!IsMoreSpecificThanAnimation(n) &&
|
MOZ_ASSERT(!IsMoreSpecificThanAnimation(n) &&
|
||||||
(n->IsRoot() || n->GetLevel() != nsStyleSet::eAnimationSheet),
|
(n->IsRoot() || n->GetLevel() != SheetType::Animation),
|
||||||
"wrong level");
|
"wrong level");
|
||||||
|
|
||||||
if (aNewAnimRule) {
|
if (aNewAnimRule) {
|
||||||
n = n->Transition(aNewAnimRule, nsStyleSet::eAnimationSheet, false);
|
n = n->Transition(aNewAnimRule, SheetType::Animation, false);
|
||||||
n->SetIsAnimationRule();
|
n->SetIsAnimationRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,30 +1120,30 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
// this will be either the root or one of the restriction rules.
|
// this will be either the root or one of the restriction rules.
|
||||||
nsRuleNode* lastRestrictionRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastRestrictionRN = aRuleWalker->CurrentNode();
|
||||||
|
|
||||||
aRuleWalker->SetLevel(eAgentSheet, false, true);
|
aRuleWalker->SetLevel(SheetType::Agent, false, true);
|
||||||
if (mRuleProcessors[eAgentSheet])
|
if (mRuleProcessors[SheetType::Agent])
|
||||||
(*aCollectorFunc)(mRuleProcessors[eAgentSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Agent], aData);
|
||||||
nsRuleNode* lastAgentRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastAgentRN = aRuleWalker->CurrentNode();
|
||||||
bool haveImportantUARules = !aRuleWalker->GetCheckForImportantRules();
|
bool haveImportantUARules = !aRuleWalker->GetCheckForImportantRules();
|
||||||
|
|
||||||
aRuleWalker->SetLevel(eUserSheet, false, true);
|
aRuleWalker->SetLevel(SheetType::User, false, true);
|
||||||
bool skipUserStyles =
|
bool skipUserStyles =
|
||||||
aElement && aElement->IsInNativeAnonymousSubtree();
|
aElement && aElement->IsInNativeAnonymousSubtree();
|
||||||
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
if (!skipUserStyles && mRuleProcessors[SheetType::User]) // NOTE: different
|
||||||
(*aCollectorFunc)(mRuleProcessors[eUserSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::User], aData);
|
||||||
nsRuleNode* lastUserRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastUserRN = aRuleWalker->CurrentNode();
|
||||||
bool haveImportantUserRules = !aRuleWalker->GetCheckForImportantRules();
|
bool haveImportantUserRules = !aRuleWalker->GetCheckForImportantRules();
|
||||||
|
|
||||||
aRuleWalker->SetLevel(ePresHintSheet, false, false);
|
aRuleWalker->SetLevel(SheetType::PresHint, false, false);
|
||||||
if (mRuleProcessors[ePresHintSheet])
|
if (mRuleProcessors[SheetType::PresHint])
|
||||||
(*aCollectorFunc)(mRuleProcessors[ePresHintSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::PresHint], aData);
|
||||||
|
|
||||||
aRuleWalker->SetLevel(eSVGAttrAnimationSheet, false, false);
|
aRuleWalker->SetLevel(SheetType::SVGAttrAnimation, false, false);
|
||||||
if (mRuleProcessors[eSVGAttrAnimationSheet])
|
if (mRuleProcessors[SheetType::SVGAttrAnimation])
|
||||||
(*aCollectorFunc)(mRuleProcessors[eSVGAttrAnimationSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::SVGAttrAnimation], aData);
|
||||||
nsRuleNode* lastSVGAttrAnimationRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastSVGAttrAnimationRN = aRuleWalker->CurrentNode();
|
||||||
|
|
||||||
aRuleWalker->SetLevel(eDocSheet, false, true);
|
aRuleWalker->SetLevel(SheetType::Doc, false, true);
|
||||||
bool cutOffInheritance = false;
|
bool cutOffInheritance = false;
|
||||||
if (mBindingManager && aElement) {
|
if (mBindingManager && aElement) {
|
||||||
// We can supply additional document-level sheets that should be walked.
|
// We can supply additional document-level sheets that should be walked.
|
||||||
@@ -1145,8 +1152,8 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
&cutOffInheritance);
|
&cutOffInheritance);
|
||||||
}
|
}
|
||||||
if (!skipUserStyles && !cutOffInheritance && // NOTE: different
|
if (!skipUserStyles && !cutOffInheritance && // NOTE: different
|
||||||
mRuleProcessors[eDocSheet])
|
mRuleProcessors[SheetType::Doc])
|
||||||
(*aCollectorFunc)(mRuleProcessors[eDocSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Doc], aData);
|
||||||
nsRuleNode* lastDocRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastDocRN = aRuleWalker->CurrentNode();
|
||||||
bool haveImportantDocRules = !aRuleWalker->GetCheckForImportantRules();
|
bool haveImportantDocRules = !aRuleWalker->GetCheckForImportantRules();
|
||||||
nsTArray<nsRuleNode*> lastScopedRNs;
|
nsTArray<nsRuleNode*> lastScopedRNs;
|
||||||
@@ -1157,7 +1164,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
lastScopedRNs.SetLength(mScopedDocSheetRuleProcessors.Length());
|
lastScopedRNs.SetLength(mScopedDocSheetRuleProcessors.Length());
|
||||||
haveImportantScopedRules.SetLength(mScopedDocSheetRuleProcessors.Length());
|
haveImportantScopedRules.SetLength(mScopedDocSheetRuleProcessors.Length());
|
||||||
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
||||||
aRuleWalker->SetLevel(eScopedDocSheet, false, true);
|
aRuleWalker->SetLevel(SheetType::ScopedDoc, false, true);
|
||||||
nsCSSRuleProcessor* processor =
|
nsCSSRuleProcessor* processor =
|
||||||
static_cast<nsCSSRuleProcessor*>(mScopedDocSheetRuleProcessors[i].get());
|
static_cast<nsCSSRuleProcessor*>(mScopedDocSheetRuleProcessors[i].get());
|
||||||
aData->mScope = processor->GetScopeElement();
|
aData->mScope = processor->GetScopeElement();
|
||||||
@@ -1169,25 +1176,25 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
aData->mScope = nullptr;
|
aData->mScope = nullptr;
|
||||||
}
|
}
|
||||||
nsRuleNode* lastScopedRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastScopedRN = aRuleWalker->CurrentNode();
|
||||||
aRuleWalker->SetLevel(eStyleAttrSheet, false, true);
|
aRuleWalker->SetLevel(SheetType::StyleAttr, false, true);
|
||||||
if (mRuleProcessors[eStyleAttrSheet])
|
if (mRuleProcessors[SheetType::StyleAttr])
|
||||||
(*aCollectorFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::StyleAttr], aData);
|
||||||
nsRuleNode* lastStyleAttrRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastStyleAttrRN = aRuleWalker->CurrentNode();
|
||||||
bool haveImportantStyleAttrRules = !aRuleWalker->GetCheckForImportantRules();
|
bool haveImportantStyleAttrRules = !aRuleWalker->GetCheckForImportantRules();
|
||||||
|
|
||||||
aRuleWalker->SetLevel(eOverrideSheet, false, true);
|
aRuleWalker->SetLevel(SheetType::Override, false, true);
|
||||||
if (mRuleProcessors[eOverrideSheet])
|
if (mRuleProcessors[SheetType::Override])
|
||||||
(*aCollectorFunc)(mRuleProcessors[eOverrideSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Override], aData);
|
||||||
nsRuleNode* lastOvrRN = aRuleWalker->CurrentNode();
|
nsRuleNode* lastOvrRN = aRuleWalker->CurrentNode();
|
||||||
bool haveImportantOverrideRules = !aRuleWalker->GetCheckForImportantRules();
|
bool haveImportantOverrideRules = !aRuleWalker->GetCheckForImportantRules();
|
||||||
|
|
||||||
// This needs to match IsMoreSpecificThanAnimation() above.
|
// This needs to match IsMoreSpecificThanAnimation() above.
|
||||||
aRuleWalker->SetLevel(eAnimationSheet, false, false);
|
aRuleWalker->SetLevel(SheetType::Animation, false, false);
|
||||||
(*aCollectorFunc)(mRuleProcessors[eAnimationSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Animation], aData);
|
||||||
|
|
||||||
if (haveAnyImportantScopedRules) {
|
if (haveAnyImportantScopedRules) {
|
||||||
for (uint32_t i = lastScopedRNs.Length(); i-- != 0; ) {
|
for (uint32_t i = lastScopedRNs.Length(); i-- != 0; ) {
|
||||||
aRuleWalker->SetLevel(eScopedDocSheet, true, false);
|
aRuleWalker->SetLevel(SheetType::ScopedDoc, true, false);
|
||||||
nsRuleNode* startRN = lastScopedRNs[i];
|
nsRuleNode* startRN = lastScopedRNs[i];
|
||||||
nsRuleNode* endRN = i == 0 ? lastDocRN : lastScopedRNs[i - 1];
|
nsRuleNode* endRN = i == 0 ? lastDocRN : lastScopedRNs[i - 1];
|
||||||
if (haveImportantScopedRules[i]) {
|
if (haveImportantScopedRules[i]) {
|
||||||
@@ -1207,7 +1214,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (haveImportantDocRules) {
|
if (haveImportantDocRules) {
|
||||||
aRuleWalker->SetLevel(eDocSheet, true, false);
|
aRuleWalker->SetLevel(SheetType::Doc, true, false);
|
||||||
AddImportantRules(lastDocRN, lastSVGAttrAnimationRN, aRuleWalker); // doc
|
AddImportantRules(lastDocRN, lastSVGAttrAnimationRN, aRuleWalker); // doc
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1217,7 +1224,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (haveImportantStyleAttrRules) {
|
if (haveImportantStyleAttrRules) {
|
||||||
aRuleWalker->SetLevel(eStyleAttrSheet, true, false);
|
aRuleWalker->SetLevel(SheetType::StyleAttr, true, false);
|
||||||
AddImportantRules(lastStyleAttrRN, lastScopedRN, aRuleWalker); // style attr
|
AddImportantRules(lastStyleAttrRN, lastScopedRN, aRuleWalker); // style attr
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1227,7 +1234,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (haveImportantOverrideRules) {
|
if (haveImportantOverrideRules) {
|
||||||
aRuleWalker->SetLevel(eOverrideSheet, true, false);
|
aRuleWalker->SetLevel(SheetType::Override, true, false);
|
||||||
AddImportantRules(lastOvrRN, lastStyleAttrRN, aRuleWalker); // override
|
AddImportantRules(lastOvrRN, lastStyleAttrRN, aRuleWalker); // override
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1241,7 +1248,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (haveImportantUserRules) {
|
if (haveImportantUserRules) {
|
||||||
aRuleWalker->SetLevel(eUserSheet, true, false);
|
aRuleWalker->SetLevel(SheetType::User, true, false);
|
||||||
AddImportantRules(lastUserRN, lastAgentRN, aRuleWalker); //user
|
AddImportantRules(lastUserRN, lastAgentRN, aRuleWalker); //user
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1251,7 +1258,7 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (haveImportantUARules) {
|
if (haveImportantUARules) {
|
||||||
aRuleWalker->SetLevel(eAgentSheet, true, false);
|
aRuleWalker->SetLevel(SheetType::Agent, true, false);
|
||||||
AddImportantRules(lastAgentRN, lastRestrictionRN, aRuleWalker); //agent
|
AddImportantRules(lastAgentRN, lastRestrictionRN, aRuleWalker); //agent
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1267,8 +1274,8 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsRuleNode *lastImportantRN = aRuleWalker->CurrentNode();
|
nsRuleNode *lastImportantRN = aRuleWalker->CurrentNode();
|
||||||
#endif
|
#endif
|
||||||
aRuleWalker->SetLevel(eTransitionSheet, false, false);
|
aRuleWalker->SetLevel(SheetType::Transition, false, false);
|
||||||
(*aCollectorFunc)(mRuleProcessors[eTransitionSheet], aData);
|
(*aCollectorFunc)(mRuleProcessors[SheetType::Transition], aData);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
AssertNoCSSRules(aRuleWalker->CurrentNode(), lastImportantRN);
|
AssertNoCSSRules(aRuleWalker->CurrentNode(), lastImportantRN);
|
||||||
#endif
|
#endif
|
||||||
@@ -1284,18 +1291,18 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
||||||
|
|
||||||
if (mRuleProcessors[eAgentSheet])
|
if (mRuleProcessors[SheetType::Agent])
|
||||||
(*aFunc)(mRuleProcessors[eAgentSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::Agent], aData);
|
||||||
|
|
||||||
bool skipUserStyles = aData->mElement->IsInNativeAnonymousSubtree();
|
bool skipUserStyles = aData->mElement->IsInNativeAnonymousSubtree();
|
||||||
if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
|
if (!skipUserStyles && mRuleProcessors[SheetType::User]) // NOTE: different
|
||||||
(*aFunc)(mRuleProcessors[eUserSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::User], aData);
|
||||||
|
|
||||||
if (mRuleProcessors[ePresHintSheet])
|
if (mRuleProcessors[SheetType::PresHint])
|
||||||
(*aFunc)(mRuleProcessors[ePresHintSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::PresHint], aData);
|
||||||
|
|
||||||
if (mRuleProcessors[eSVGAttrAnimationSheet])
|
if (mRuleProcessors[SheetType::SVGAttrAnimation])
|
||||||
(*aFunc)(mRuleProcessors[eSVGAttrAnimationSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::SVGAttrAnimation], aData);
|
||||||
|
|
||||||
bool cutOffInheritance = false;
|
bool cutOffInheritance = false;
|
||||||
if (mBindingManager) {
|
if (mBindingManager) {
|
||||||
@@ -1307,19 +1314,19 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!skipUserStyles && !cutOffInheritance) {
|
if (!skipUserStyles && !cutOffInheritance) {
|
||||||
if (mRuleProcessors[eDocSheet]) // NOTE: different
|
if (mRuleProcessors[SheetType::Doc]) // NOTE: different
|
||||||
(*aFunc)(mRuleProcessors[eDocSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::Doc], aData);
|
||||||
if (aData->mElement->IsElementInStyleScope()) {
|
if (aData->mElement->IsElementInStyleScope()) {
|
||||||
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++)
|
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++)
|
||||||
(*aFunc)(mScopedDocSheetRuleProcessors[i], aData);
|
(*aFunc)(mScopedDocSheetRuleProcessors[i], aData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mRuleProcessors[eStyleAttrSheet])
|
if (mRuleProcessors[SheetType::StyleAttr])
|
||||||
(*aFunc)(mRuleProcessors[eStyleAttrSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::StyleAttr], aData);
|
||||||
if (mRuleProcessors[eOverrideSheet])
|
if (mRuleProcessors[SheetType::Override])
|
||||||
(*aFunc)(mRuleProcessors[eOverrideSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::Override], aData);
|
||||||
(*aFunc)(mRuleProcessors[eAnimationSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::Animation], aData);
|
||||||
(*aFunc)(mRuleProcessors[eTransitionSheet], aData);
|
(*aFunc)(mRuleProcessors[SheetType::Transition], aData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1393,7 +1400,7 @@ nsStyleSet::ResolveStyleForRules(nsStyleContext* aParentContext,
|
|||||||
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
|
||||||
// FIXME: Perhaps this should be passed in, but it probably doesn't
|
// FIXME: Perhaps this should be passed in, but it probably doesn't
|
||||||
// matter.
|
// matter.
|
||||||
ruleWalker.SetLevel(eDocSheet, false, false);
|
ruleWalker.SetLevel(SheetType::Doc, false, false);
|
||||||
for (uint32_t i = 0; i < aRules.Length(); i++) {
|
for (uint32_t i = 0; i < aRules.Length(); i++) {
|
||||||
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ElementAt(i));
|
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ElementAt(i));
|
||||||
}
|
}
|
||||||
@@ -1417,7 +1424,7 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
|||||||
// resulting context. It's also the right thing for the one case (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
|
// transition manager's cover rule) where we put the result of this
|
||||||
// function in the style context tree.
|
// function in the style context tree.
|
||||||
ruleWalker.SetLevel(eTransitionSheet, false, false);
|
ruleWalker.SetLevel(SheetType::Transition, false, false);
|
||||||
for (int32_t i = 0; i < aRules.Count(); i++) {
|
for (int32_t i = 0; i < aRules.Count(); i++) {
|
||||||
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
|
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
|
||||||
}
|
}
|
||||||
@@ -1452,37 +1459,37 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
|||||||
|
|
||||||
struct RuleNodeInfo {
|
struct RuleNodeInfo {
|
||||||
nsIStyleRule* mRule;
|
nsIStyleRule* mRule;
|
||||||
uint8_t mLevel;
|
SheetType mLevel;
|
||||||
bool mIsImportant;
|
bool mIsImportant;
|
||||||
bool mIsAnimationRule;
|
bool mIsAnimationRule;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CascadeLevel {
|
struct CascadeLevel {
|
||||||
uint8_t mLevel;
|
SheetType mLevel;
|
||||||
bool mIsImportant;
|
bool mIsImportant;
|
||||||
bool mCheckForImportantRules;
|
bool mCheckForImportantRules;
|
||||||
nsRestyleHint mLevelReplacementHint;
|
nsRestyleHint mLevelReplacementHint;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const CascadeLevel gCascadeLevels[] = {
|
static const CascadeLevel gCascadeLevels[] = {
|
||||||
{ nsStyleSet::eAgentSheet, false, false, nsRestyleHint(0) },
|
{ SheetType::Agent, false, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eUserSheet, false, false, nsRestyleHint(0) },
|
{ SheetType::User, false, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::ePresHintSheet, false, false, nsRestyleHint(0) },
|
{ SheetType::PresHint, false, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eSVGAttrAnimationSheet, false, false, eRestyle_SVGAttrAnimations },
|
{ SheetType::SVGAttrAnimation, false, false, eRestyle_SVGAttrAnimations },
|
||||||
{ nsStyleSet::eDocSheet, false, false, nsRestyleHint(0) },
|
{ SheetType::Doc, false, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eScopedDocSheet, false, false, nsRestyleHint(0) },
|
{ SheetType::ScopedDoc, false, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eStyleAttrSheet, false, true, eRestyle_StyleAttribute |
|
{ SheetType::StyleAttr, false, true, eRestyle_StyleAttribute |
|
||||||
eRestyle_StyleAttribute_Animations },
|
eRestyle_StyleAttribute_Animations },
|
||||||
{ nsStyleSet::eOverrideSheet, false, false, nsRestyleHint(0) },
|
{ SheetType::Override, false, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eAnimationSheet, false, false, eRestyle_CSSAnimations },
|
{ SheetType::Animation, false, false, eRestyle_CSSAnimations },
|
||||||
{ nsStyleSet::eScopedDocSheet, true, false, nsRestyleHint(0) },
|
{ SheetType::ScopedDoc, true, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eDocSheet, true, false, nsRestyleHint(0) },
|
{ SheetType::Doc, true, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eStyleAttrSheet, true, false, eRestyle_StyleAttribute |
|
{ SheetType::StyleAttr, true, false, eRestyle_StyleAttribute |
|
||||||
eRestyle_StyleAttribute_Animations },
|
eRestyle_StyleAttribute_Animations },
|
||||||
{ nsStyleSet::eOverrideSheet, true, false, nsRestyleHint(0) },
|
{ SheetType::Override, true, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eUserSheet, true, false, nsRestyleHint(0) },
|
{ SheetType::User, true, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eAgentSheet, true, false, nsRestyleHint(0) },
|
{ SheetType::Agent, true, false, nsRestyleHint(0) },
|
||||||
{ nsStyleSet::eTransitionSheet, false, false, eRestyle_CSSTransitions },
|
{ SheetType::Transition, false, false, eRestyle_CSSTransitions },
|
||||||
};
|
};
|
||||||
|
|
||||||
nsRuleNode*
|
nsRuleNode*
|
||||||
@@ -1547,7 +1554,7 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
|
|||||||
|
|
||||||
if (doReplace) {
|
if (doReplace) {
|
||||||
switch (level->mLevel) {
|
switch (level->mLevel) {
|
||||||
case nsStyleSet::eAnimationSheet: {
|
case SheetType::Animation: {
|
||||||
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
||||||
aPseudoType == nsCSSPseudoElements::ePseudo_before ||
|
aPseudoType == nsCSSPseudoElements::ePseudo_before ||
|
||||||
aPseudoType == nsCSSPseudoElements::ePseudo_after) {
|
aPseudoType == nsCSSPseudoElements::ePseudo_after) {
|
||||||
@@ -1560,7 +1567,7 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsStyleSet::eTransitionSheet: {
|
case SheetType::Transition: {
|
||||||
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
||||||
aPseudoType == nsCSSPseudoElements::ePseudo_before ||
|
aPseudoType == nsCSSPseudoElements::ePseudo_before ||
|
||||||
aPseudoType == nsCSSPseudoElements::ePseudo_after) {
|
aPseudoType == nsCSSPseudoElements::ePseudo_after) {
|
||||||
@@ -1573,22 +1580,22 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsStyleSet::eSVGAttrAnimationSheet: {
|
case SheetType::SVGAttrAnimation: {
|
||||||
SVGAttrAnimationRuleProcessor* ruleProcessor =
|
SVGAttrAnimationRuleProcessor* ruleProcessor =
|
||||||
static_cast<SVGAttrAnimationRuleProcessor*>(
|
static_cast<SVGAttrAnimationRuleProcessor*>(
|
||||||
mRuleProcessors[eSVGAttrAnimationSheet].get());
|
mRuleProcessors[SheetType::SVGAttrAnimation].get());
|
||||||
if (ruleProcessor &&
|
if (ruleProcessor &&
|
||||||
aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
||||||
ruleProcessor->ElementRulesMatching(aElement, &ruleWalker);
|
ruleProcessor->ElementRulesMatching(aElement, &ruleWalker);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsStyleSet::eStyleAttrSheet: {
|
case SheetType::StyleAttr: {
|
||||||
if (!level->mIsImportant) {
|
if (!level->mIsImportant) {
|
||||||
// First time through, we handle the non-!important rule.
|
// First time through, we handle the non-!important rule.
|
||||||
nsHTMLCSSStyleSheet* ruleProcessor =
|
nsHTMLCSSStyleSheet* ruleProcessor =
|
||||||
static_cast<nsHTMLCSSStyleSheet*>(
|
static_cast<nsHTMLCSSStyleSheet*>(
|
||||||
mRuleProcessors[eStyleAttrSheet].get());
|
mRuleProcessors[SheetType::StyleAttr].get());
|
||||||
if (ruleProcessor) {
|
if (ruleProcessor) {
|
||||||
lastScopedRN = ruleWalker.CurrentNode();
|
lastScopedRN = ruleWalker.CurrentNode();
|
||||||
if (aPseudoType ==
|
if (aPseudoType ==
|
||||||
@@ -1768,7 +1775,7 @@ nsStyleSet::WalkRestrictionRule(nsCSSPseudoElements::Type aPseudoType,
|
|||||||
nsRuleWalker* aRuleWalker)
|
nsRuleWalker* aRuleWalker)
|
||||||
{
|
{
|
||||||
// This needs to match GetPseudoRestriction in nsRuleNode.cpp.
|
// This needs to match GetPseudoRestriction in nsRuleNode.cpp.
|
||||||
aRuleWalker->SetLevel(eAgentSheet, false, false);
|
aRuleWalker->SetLevel(SheetType::Agent, false, false);
|
||||||
if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLetter)
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLetter)
|
||||||
aRuleWalker->Forward(mFirstLetterRule);
|
aRuleWalker->Forward(mFirstLetterRule);
|
||||||
else if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLine)
|
else if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLine)
|
||||||
@@ -1780,7 +1787,7 @@ nsStyleSet::WalkRestrictionRule(nsCSSPseudoElements::Type aPseudoType,
|
|||||||
void
|
void
|
||||||
nsStyleSet::WalkDisableTextZoomRule(Element* aElement, nsRuleWalker* aRuleWalker)
|
nsStyleSet::WalkDisableTextZoomRule(Element* aElement, nsRuleWalker* aRuleWalker)
|
||||||
{
|
{
|
||||||
aRuleWalker->SetLevel(eAgentSheet, false, false);
|
aRuleWalker->SetLevel(SheetType::Agent, false, false);
|
||||||
if (aElement->IsSVGElement(nsGkAtoms::text))
|
if (aElement->IsSVGElement(nsGkAtoms::text))
|
||||||
aRuleWalker->Forward(mDisableTextZoomStyleRule);
|
aRuleWalker->Forward(mDisableTextZoomStyleRule);
|
||||||
}
|
}
|
||||||
@@ -2021,7 +2028,7 @@ nsStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
|
|||||||
|
|
||||||
nsPresContext* presContext = PresContext();
|
nsPresContext* presContext = PresContext();
|
||||||
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
||||||
if (gCSSSheetTypes[i] == eScopedDocSheet)
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
||||||
continue;
|
continue;
|
||||||
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
||||||
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
||||||
@@ -2039,7 +2046,7 @@ nsStyleSet::KeyframesRuleForName(const nsString& aName)
|
|||||||
|
|
||||||
nsPresContext* presContext = PresContext();
|
nsPresContext* presContext = PresContext();
|
||||||
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
||||||
if (gCSSSheetTypes[i] == eScopedDocSheet)
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
||||||
continue;
|
continue;
|
||||||
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
||||||
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
||||||
@@ -2061,7 +2068,7 @@ nsStyleSet::CounterStyleRuleForName(const nsAString& aName)
|
|||||||
|
|
||||||
nsPresContext* presContext = PresContext();
|
nsPresContext* presContext = PresContext();
|
||||||
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
|
||||||
if (gCSSSheetTypes[i] == eScopedDocSheet)
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
||||||
continue;
|
continue;
|
||||||
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
|
||||||
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
||||||
@@ -2137,7 +2144,7 @@ nsStyleSet::AppendPageRules(nsTArray<nsCSSPageRule*>& aArray)
|
|||||||
|
|
||||||
nsPresContext* presContext = PresContext();
|
nsPresContext* presContext = PresContext();
|
||||||
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
||||||
if (gCSSSheetTypes[i] == eScopedDocSheet)
|
if (gCSSSheetTypes[i] == SheetType::ScopedDoc)
|
||||||
continue;
|
continue;
|
||||||
nsCSSRuleProcessor* ruleProc = static_cast<nsCSSRuleProcessor*>
|
nsCSSRuleProcessor* ruleProc = static_cast<nsCSSRuleProcessor*>
|
||||||
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
(mRuleProcessors[gCSSSheetTypes[i]].get());
|
||||||
@@ -2437,16 +2444,14 @@ nsStyleSet::MediumFeaturesChanged()
|
|||||||
// We can't use WalkRuleProcessors without a content node.
|
// We can't use WalkRuleProcessors without a content node.
|
||||||
nsPresContext* presContext = PresContext();
|
nsPresContext* presContext = PresContext();
|
||||||
bool stylesChanged = false;
|
bool stylesChanged = false;
|
||||||
for (uint32_t i = 0; i < ArrayLength(mRuleProcessors); ++i) {
|
for (nsIStyleRuleProcessor* processor : mRuleProcessors) {
|
||||||
nsIStyleRuleProcessor *processor = mRuleProcessors[i];
|
|
||||||
if (!processor) {
|
if (!processor) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool thisChanged = processor->MediumFeaturesChanged(presContext);
|
bool thisChanged = processor->MediumFeaturesChanged(presContext);
|
||||||
stylesChanged = stylesChanged || thisChanged;
|
stylesChanged = stylesChanged || thisChanged;
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); ++i) {
|
for (nsIStyleRuleProcessor* processor : mScopedDocSheetRuleProcessors) {
|
||||||
nsIStyleRuleProcessor *processor = mScopedDocSheetRuleProcessors[i];
|
|
||||||
bool thisChanged = processor->MediumFeaturesChanged(presContext);
|
bool thisChanged = processor->MediumFeaturesChanged(presContext);
|
||||||
stylesChanged = stylesChanged || thisChanged;
|
stylesChanged = stylesChanged || thisChanged;
|
||||||
}
|
}
|
||||||
@@ -2502,7 +2507,7 @@ nsStyleSet::InitialStyleRule()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsStyleSet::HasRuleProcessorUsedByMultipleStyleSets(sheetType aSheetType)
|
nsStyleSet::HasRuleProcessorUsedByMultipleStyleSets(SheetType aSheetType)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(size_t(aSheetType) < ArrayLength(mRuleProcessors));
|
MOZ_ASSERT(size_t(aSheetType) < ArrayLength(mRuleProcessors));
|
||||||
if (!IsCSSSheetType(aSheetType) || !mRuleProcessors[aSheetType]) {
|
if (!IsCSSSheetType(aSheetType) || !mRuleProcessors[aSheetType]) {
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/CSSStyleSheet.h"
|
#include "mozilla/CSSStyleSheet.h"
|
||||||
|
#include "mozilla/EnumeratedArray.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
|
#include "mozilla/SheetType.h"
|
||||||
|
|
||||||
#include "nsIStyleRuleProcessor.h"
|
#include "nsIStyleRuleProcessor.h"
|
||||||
#include "nsBindingManager.h"
|
#include "nsBindingManager.h"
|
||||||
@@ -304,46 +306,28 @@ class nsStyleSet final
|
|||||||
mBindingManager = aBindingManager;
|
mBindingManager = aBindingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The "origins" of the CSS cascade, from lowest precedence to
|
|
||||||
// highest (for non-!important rules).
|
|
||||||
enum sheetType {
|
|
||||||
eAgentSheet, // CSS
|
|
||||||
eUserSheet, // CSS
|
|
||||||
ePresHintSheet,
|
|
||||||
eSVGAttrAnimationSheet,
|
|
||||||
eDocSheet, // CSS
|
|
||||||
eScopedDocSheet,
|
|
||||||
eStyleAttrSheet,
|
|
||||||
eOverrideSheet, // CSS
|
|
||||||
eAnimationSheet,
|
|
||||||
eTransitionSheet,
|
|
||||||
eSheetTypeCount
|
|
||||||
// be sure to keep the number of bits in |mDirty| below and in
|
|
||||||
// NS_RULE_NODE_LEVEL_MASK updated when changing the number of sheet
|
|
||||||
// types
|
|
||||||
};
|
|
||||||
|
|
||||||
// APIs to manipulate the style sheet lists. The sheets in each
|
// APIs to manipulate the style sheet lists. The sheets in each
|
||||||
// list are stored with the most significant sheet last.
|
// list are stored with the most significant sheet last.
|
||||||
nsresult AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
|
nsresult AppendStyleSheet(mozilla::SheetType aType, nsIStyleSheet *aSheet);
|
||||||
nsresult PrependStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
|
nsresult PrependStyleSheet(mozilla::SheetType aType, nsIStyleSheet *aSheet);
|
||||||
nsresult RemoveStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
|
nsresult RemoveStyleSheet(mozilla::SheetType aType, nsIStyleSheet *aSheet);
|
||||||
nsresult ReplaceSheets(sheetType aType,
|
nsresult ReplaceSheets(mozilla::SheetType aType,
|
||||||
const nsCOMArray<nsIStyleSheet> &aNewSheets);
|
const nsCOMArray<nsIStyleSheet> &aNewSheets);
|
||||||
nsresult InsertStyleSheetBefore(sheetType aType, nsIStyleSheet *aNewSheet,
|
nsresult InsertStyleSheetBefore(mozilla::SheetType aType,
|
||||||
|
nsIStyleSheet *aNewSheet,
|
||||||
nsIStyleSheet *aReferenceSheet);
|
nsIStyleSheet *aReferenceSheet);
|
||||||
|
|
||||||
nsresult DirtyRuleProcessors(sheetType aType);
|
nsresult DirtyRuleProcessors(mozilla::SheetType aType);
|
||||||
|
|
||||||
// Enable/Disable entire author style level (Doc, ScopedDoc & PresHint levels)
|
// Enable/Disable entire author style level (Doc, ScopedDoc & PresHint levels)
|
||||||
bool GetAuthorStyleDisabled();
|
bool GetAuthorStyleDisabled();
|
||||||
nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
|
nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
|
||||||
|
|
||||||
int32_t SheetCount(sheetType aType) const {
|
int32_t SheetCount(mozilla::SheetType aType) const {
|
||||||
return mSheets[aType].Count();
|
return mSheets[aType].Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIStyleSheet* StyleSheetAt(sheetType aType, int32_t aIndex) const {
|
nsIStyleSheet* StyleSheetAt(mozilla::SheetType aType, int32_t aIndex) const {
|
||||||
return mSheets[aType].ObjectAt(aIndex);
|
return mSheets[aType].ObjectAt(aIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +387,7 @@ class nsStyleSet final
|
|||||||
|
|
||||||
nsIStyleRule* InitialStyleRule();
|
nsIStyleRule* InitialStyleRule();
|
||||||
|
|
||||||
bool HasRuleProcessorUsedByMultipleStyleSets(sheetType aSheetType);
|
bool HasRuleProcessorUsedByMultipleStyleSets(mozilla::SheetType aSheetType);
|
||||||
|
|
||||||
// Tells the RestyleManager for the document using this style set
|
// Tells the RestyleManager for the document using this style set
|
||||||
// to drop any nsCSSSelector pointers it has.
|
// to drop any nsCSSSelector pointers it has.
|
||||||
@@ -417,7 +401,7 @@ class nsStyleSet final
|
|||||||
void GCRuleTrees();
|
void GCRuleTrees();
|
||||||
|
|
||||||
// Update the rule processor list after a change to the style sheet list.
|
// Update the rule processor list after a change to the style sheet list.
|
||||||
nsresult GatherRuleProcessors(sheetType aType);
|
nsresult GatherRuleProcessors(mozilla::SheetType aType);
|
||||||
|
|
||||||
void AddImportantRules(nsRuleNode* aCurrLevelNode,
|
void AddImportantRules(nsRuleNode* aCurrLevelNode,
|
||||||
nsRuleNode* aLastPrevLevelNode,
|
nsRuleNode* aLastPrevLevelNode,
|
||||||
@@ -485,11 +469,13 @@ class nsStyleSet final
|
|||||||
// The arrays for ePresHintSheet, eStyleAttrSheet, eTransitionSheet,
|
// The arrays for ePresHintSheet, eStyleAttrSheet, eTransitionSheet,
|
||||||
// eAnimationSheet and eSVGAttrAnimationSheet are always empty.
|
// eAnimationSheet and eSVGAttrAnimationSheet are always empty.
|
||||||
// (FIXME: We should reduce the storage needed for them.)
|
// (FIXME: We should reduce the storage needed for them.)
|
||||||
nsCOMArray<nsIStyleSheet> mSheets[eSheetTypeCount];
|
mozilla::EnumeratedArray<mozilla::SheetType, mozilla::SheetType::Count,
|
||||||
|
nsCOMArray<nsIStyleSheet>> mSheets;
|
||||||
|
|
||||||
// mRuleProcessors[eScopedDocSheet] is always null; rule processors
|
// mRuleProcessors[eScopedDocSheet] is always null; rule processors
|
||||||
// for scoped style sheets are stored in mScopedDocSheetRuleProcessors.
|
// for scoped style sheets are stored in mScopedDocSheetRuleProcessors.
|
||||||
nsCOMPtr<nsIStyleRuleProcessor> mRuleProcessors[eSheetTypeCount];
|
mozilla::EnumeratedArray<mozilla::SheetType, mozilla::SheetType::Count,
|
||||||
|
nsCOMPtr<nsIStyleRuleProcessor>> mRuleProcessors;
|
||||||
|
|
||||||
// Rule processors for HTML5 scoped style sheets, one per scope.
|
// Rule processors for HTML5 scoped style sheets, one per scope.
|
||||||
nsTArray<nsCOMPtr<nsIStyleRuleProcessor> > mScopedDocSheetRuleProcessors;
|
nsTArray<nsCOMPtr<nsIStyleRuleProcessor> > mScopedDocSheetRuleProcessors;
|
||||||
@@ -507,7 +493,7 @@ class nsStyleSet final
|
|||||||
unsigned mInReconstruct : 1;
|
unsigned mInReconstruct : 1;
|
||||||
unsigned mInitFontFeatureValuesLookup : 1;
|
unsigned mInitFontFeatureValuesLookup : 1;
|
||||||
unsigned mNeedsRestyleAfterEnsureUniqueInner : 1;
|
unsigned mNeedsRestyleAfterEnsureUniqueInner : 1;
|
||||||
unsigned mDirty : 10; // one dirty bit is used per sheet type
|
unsigned mDirty : int(mozilla::SheetType::Count); // one bit per sheet type
|
||||||
|
|
||||||
uint32_t mUnusedRuleNodeCount; // used to batch rule node GC
|
uint32_t mUnusedRuleNodeCount; // used to batch rule node GC
|
||||||
nsTArray<nsStyleContext*> mRoots; // style contexts with no parent
|
nsTArray<nsStyleContext*> mRoots; // style contexts with no parent
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "mozilla/ArenaObjectID.h"
|
#include "mozilla/ArenaObjectID.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/CSSVariableValues.h"
|
#include "mozilla/CSSVariableValues.h"
|
||||||
|
#include "mozilla/SheetType.h"
|
||||||
#include "nsColor.h"
|
#include "nsColor.h"
|
||||||
#include "nsCoord.h"
|
#include "nsCoord.h"
|
||||||
#include "nsMargin.h"
|
#include "nsMargin.h"
|
||||||
@@ -89,6 +90,10 @@ class imgIContainer;
|
|||||||
// Additional bits for nsRuleNode's mNoneBits:
|
// Additional bits for nsRuleNode's mNoneBits:
|
||||||
#define NS_RULE_NODE_HAS_ANIMATION_DATA 0x80000000
|
#define NS_RULE_NODE_HAS_ANIMATION_DATA 0x80000000
|
||||||
|
|
||||||
|
static_assert(int(mozilla::SheetType::Count) - 1 <=
|
||||||
|
(NS_RULE_NODE_LEVEL_MASK >> NS_RULE_NODE_LEVEL_SHIFT),
|
||||||
|
"NS_RULE_NODE_LEVEL_MASK cannot fit SheetType");
|
||||||
|
|
||||||
// The lifetime of these objects is managed by the presshell's arena.
|
// The lifetime of these objects is managed by the presshell's arena.
|
||||||
|
|
||||||
struct nsStyleFont {
|
struct nsStyleFont {
|
||||||
|
|||||||
Reference in New Issue
Block a user