Bug 1436782: Insert the prefs sheet at the UA level. r=bholley
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 09 Feb 2018 22:46:06 +0100
changeset 468074 3692b02e7ca290d1098b42757e48d055458ba906
parent 468073 7d9c2c64313645b36b89de6c06e157b1e8fb5499
child 468075 072dc1504ce6cd2a9a2a1e13bf29bb574e9d9c62
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1436782
milestone61.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
@@ -1281,16 +1281,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!
@@ -1498,27 +1501,31 @@ PresShell::UpdatePreferenceStyles()
   if (mPrefStyleSheet == newPrefSheet) {
     return;
   }
 
   mStyleSet->BeginUpdate();
 
   RemovePreferenceStyles();
 
-  mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet->AsServo());
+  // 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->AsServo());
   mPrefStyleSheet = newPrefSheet;
 
   mStyleSet->EndUpdate();
 }
 
 void
 PresShell::RemovePreferenceStyles()
 {
   if (mPrefStyleSheet) {
-    mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet->AsServo());
+    mStyleSet->RemoveStyleSheet(SheetType::Agent, mPrefStyleSheet->AsServo());
     mPrefStyleSheet = nullptr;
   }
 }
 
 void
 PresShell::AddUserSheet(StyleSheet* aSheet)
 {
   // Make sure this does what nsDocumentViewer::CreateStyleSet does wrt