Bug 1436782: Insert the prefs sheet at the UA level. r=bholley
☠☠ backed out by 0e78aca3e8f0 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 09 Feb 2018 22:46:06 +0100
changeset 403271 87a3fe2c7e9b5d6d395f3f94a203a442baaf9b64
parent 403270 06f87ee5bbbb1b9e7d33dab08885aa0e0a7a4ac7
child 403272 d5600caa9de5e01a037418bbadb74f7351b728b7
push id99755
push userbtara@mozilla.com
push dateSat, 10 Feb 2018 10:02:59 +0000
treeherdermozilla-inbound@0417e1acfc10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1436782
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436782: Insert the prefs sheet at the UA level. r=bholley Since that's what it's effectively happening anyway. MozReview-Commit-ID: AZGONTbCTNa
layout/base/PresShell.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1297,16 +1297,19 @@ PresShell::Destroy()
   }
 
   if (mAccessibleCaretEventHub) {
     mAccessibleCaretEventHub->Terminate();
     mAccessibleCaretEventHub = nullptr;
   }
 
   // release our pref style sheet, if we have one still
+  //
+  // FIXME(emilio): Why do we need to do this? The stylist is getting nixed with
+  // us anyway.
   RemovePreferenceStyles();
 
   mIsDestroying = true;
 
   // We can't release all the event content in
   // mCurrentEventContentStack here since there might be code on the
   // stack that will release the event content too. Double release
   // bad!
@@ -1487,27 +1490,31 @@ PresShell::UpdatePreferenceStyles()
   if (mPrefStyleSheet == newPrefSheet) {
     return;
   }
 
   mStyleSet->BeginUpdate();
 
   RemovePreferenceStyles();
 
-  mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet);
+  // NOTE(emilio): This sheet is added as an agent sheet, because we don't want
+  // it to be modifiable from devtools and similar, see bugs 1239336 and
+  // 1436782. I think it conceptually should be a user sheet, and could be
+  // without too much trouble I'd think.
+  mStyleSet->AppendStyleSheet(SheetType::Agent, newPrefSheet);
   mPrefStyleSheet = newPrefSheet;
 
   mStyleSet->EndUpdate();
 }
 
 void
 PresShell::RemovePreferenceStyles()
 {
   if (mPrefStyleSheet) {
-    mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet);
+    mStyleSet->RemoveStyleSheet(SheetType::Agent, mPrefStyleSheet);
     mPrefStyleSheet = nullptr;
   }
 }
 
 void
 PresShell::AddUserSheet(StyleSheet* aSheet)
 {
   // Make sure this does what nsDocumentViewer::CreateStyleSet does wrt