Backed out 2 changesets (bug 1470163) for math failures in layout/mathml/tests/test_disabled.html on a CLOSED TREE

Backed out changeset e34a6bdac37a (bug 1470163)
Backed out changeset e2e97e7a605f (bug 1470163)
This commit is contained in:
shindli 2018-06-24 06:56:44 +03:00
Родитель 53db39a155
Коммит 7fd12b01a4
4 изменённых файлов: 123 добавлений и 10 удалений

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

@ -1632,7 +1632,7 @@ nsDocument::~nsDocument()
Accumulate(Telemetry::CSP_UNSAFE_EVAL_DOCUMENTS_COUNT, 1);
}
if (MOZ_UNLIKELY(mMathMLEnabled)) {
if (MOZ_UNLIKELY(GetMathMLEnabled())) {
ScalarAdd(Telemetry::ScalarID::MATHML_DOC_COUNT, 1);
}
}
@ -1695,6 +1695,7 @@ nsDocument::~nsDocument()
if (mAttrStyleSheet) {
mAttrStyleSheet->SetOwningDocument(nullptr);
}
// We don't own the mOnDemandBuiltInUASheets, so we don't need to reset them.
if (mListenerManager) {
mListenerManager->Disconnect();
@ -1917,6 +1918,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
// Traverse all our nsCOMArrays.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheets)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnDemandBuiltInUASheets)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPreloadingImages)
for (uint32_t i = 0; i < tmp->mFrameRequestCallbacks.Length(); ++i) {
@ -2455,6 +2457,7 @@ nsIDocument::ResetStylesheetsToURI(nsIURI* aURI)
// filled the style set. (This allows us to avoid calling
// GetStyleBackendType() too early.)
RemoveDocStyleSheetsFromStyleSets();
RemoveStyleSheetsFromStyleSets(mOnDemandBuiltInUASheets, SheetType::Agent);
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAgentSheet], SheetType::Agent);
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eUserSheet], SheetType::User);
RemoveStyleSheetsFromStyleSets(mAdditionalSheets[eAuthorSheet], SheetType::Doc);
@ -2469,6 +2472,7 @@ nsIDocument::ResetStylesheetsToURI(nsIURI* aURI)
// Release all the sheets
mStyleSheets.Clear();
mOnDemandBuiltInUASheets.Clear();
for (auto& sheets : mAdditionalSheets) {
sheets.Clear();
}
@ -2532,6 +2536,13 @@ nsIDocument::FillStyleSet(ServoStyleSet* aStyleSet)
}
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
}
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAgentSheet],
SheetType::Agent);
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eUserSheet],
@ -4120,6 +4131,43 @@ nsIDocument::RemoveChildNode(nsIContent* aKid, bool aNotify)
"(maybe somebody called GetRootElement() too early?)");
}
void
nsIDocument::EnsureOnDemandBuiltInUASheet(StyleSheet* aSheet)
{
if (mOnDemandBuiltInUASheets.Contains(aSheet)) {
return;
}
AddOnDemandBuiltInUASheet(aSheet);
}
void
nsIDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet)
{
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(aSheet));
// Prepend here so that we store the sheets in mOnDemandBuiltInUASheets in
// the same order that they should end up in the style set.
mOnDemandBuiltInUASheets.InsertElementAt(0, aSheet);
if (aSheet->IsApplicable()) {
// This is like |AddStyleSheetToStyleSets|, but for an agent sheet.
if (nsIPresShell* shell = GetShell()) {
// Note that prepending here is necessary to make sure that html.css etc.
// does not override Firefox OS/Mobile's content.css sheet.
//
// Maybe we should have an insertion point to match the order of
// nsDocumentViewer::CreateStyleSet though?
//
// FIXME(emilio): We probably should, randomly prepending stuff here is
// very prone to subtle bugs, behavior differences...
shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet);
shell->ApplicableStylesChanged();
}
}
NotifyStyleSheetAdded(aSheet, false);
}
void
nsIDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
{
@ -9494,6 +9542,21 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
}
}
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<StyleSheet> clonedSheet =
sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
}
}
}
}
}
}
mCreatingStaticClone = false;
@ -11698,6 +11761,11 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const
aWindowSizes.mLayoutStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(mStyleSheets,
aWindowSizes.mState.mMallocSizeOf);
// Note that we do not own the sheets pointed to by mOnDemandBuiltInUASheets
// (the nsLayoutStyleSheetCache singleton does).
aWindowSizes.mLayoutStyleSheetsSize +=
mOnDemandBuiltInUASheets.ShallowSizeOfExcludingThis(
aWindowSizes.mState.mMallocSizeOf);
for (auto& sheetArray : mAdditionalSheets) {
aWindowSizes.mLayoutStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(sheetArray,

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

@ -836,6 +836,14 @@ public:
mBidiEnabled = true;
}
/**
* Check if the document contains (or has contained) any MathML elements.
*/
bool GetMathMLEnabled() const
{
return mMathMLEnabled;
}
void SetMathMLEnabled()
{
mMathMLEnabled = true;
@ -1460,6 +1468,28 @@ public:
* Style sheets are ordered, most significant last.
*/
/**
* These exists to allow us to on-demand load user-agent style sheets that
* would otherwise be loaded by nsDocumentViewer::CreateStyleSet. This allows
* us to keep the memory used by a document's rule cascade data (the stuff in
* its nsStyleSet's nsCSSRuleProcessors) - which can be considerable - lower
* than it would be if we loaded all built-in user-agent style sheets up
* front.
*
* By "built-in" user-agent style sheets we mean the user-agent style sheets
* that gecko itself supplies (such as html.css and svg.css) as opposed to
* user-agent level style sheets inserted by add-ons or the like.
*
* This function prepends the given style sheet to the document's style set
* in order to make sure that it does not override user-agent style sheets
* supplied by add-ons or by the app (Firefox OS or Firefox Mobile, for
* example), since their sheets should override built-in sheets.
*
* TODO We can get rid of the whole concept of delayed loading if we fix
* bug 77999.
*/
void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet);
mozilla::dom::StyleSheetList* StyleSheets()
{
return &DocumentOrShadowRoot::EnsureDOMStyleSheets();
@ -3586,6 +3616,7 @@ protected:
void UpdateDocumentStates(mozilla::EventStates);
void AddOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet);
void RemoveDocStyleSheetsFromStyleSets();
void RemoveStyleSheetsFromStyleSets(
const nsTArray<RefPtr<mozilla::StyleSheet>>& aSheets,
@ -4387,6 +4418,7 @@ protected:
nsCOMPtr<nsIRunnable> mMaybeEndOutermostXBLUpdateRunner;
nsCOMPtr<nsIRequest> mOnloadBlocker;
nsTArray<RefPtr<mozilla::StyleSheet>> mOnDemandBuiltInUASheets;
nsTArray<RefPtr<mozilla::StyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];
// Member to store out last-selected stylesheet set.

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

@ -106,9 +106,25 @@ nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
aDocument->RegisterPendingLinkUpdate(this);
}
// Set the bit in the document for telemetry.
if (nsIDocument* doc = GetComposedDoc()) {
doc->SetMathMLEnabled();
nsIDocument* doc = GetComposedDoc();
if (doc) {
if (!doc->GetMathMLEnabled()) {
// Enable MathML and setup the style sheet during binding, not element
// construction, because we could move a MathML element from the document
// that created it to another document.
auto cache = nsLayoutStylesheetCache::Singleton();
doc->SetMathMLEnabled();
doc->EnsureOnDemandBuiltInUASheet(cache->MathMLSheet());
// Rebuild style data for the presshell, because style system
// optimizations may have taken place assuming MathML was disabled.
// (See nsRuleNode::CheckSpecifiedProperties.)
RefPtr<nsPresContext> presContext = doc->GetPresContext();
if (presContext) {
presContext->
PostRebuildAllStyleDataEvent(nsChangeHint(0), eRestyle_Subtree);
}
}
}
return rv;

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

@ -2512,12 +2512,9 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
if (MOZ_LIKELY(mDocument->NodeInfoManager()->SVGEnabled())) {
styleSet->PrependStyleSheet(SheetType::Agent, cache->SVGSheet());
}
if (MOZ_LIKELY(mDocument->NodeInfoManager()->MathMLEnabled())) {
styleSet->PrependStyleSheet(SheetType::Agent, cache->MathMLSheet());
sheet = cache->SVGSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
styleSet->PrependStyleSheet(SheetType::Agent, cache->UASheet());