Bug 1480628 - Remove nsIWebShellServices; r=nika
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 02 Aug 2018 16:42:00 -0700
changeset 430462 c629114f55f0c9120f58e4fb2747d4ac96464bef
parent 430461 6897f3935cc77f531ce4b1ac5f5b6febdb010c58
child 430463 e05eb5161a5d5ea3b722b99ed2f1318a67481de8
push id106172
push userkmachulis@mozilla.com
push dateTue, 07 Aug 2018 22:13:37 +0000
treeherdermozilla-inbound@82e7fc398926 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1480628
milestone63.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 1480628 - Remove nsIWebShellServices; r=nika Summary: nsIWebShellServices is only implemented by nsDocShell, and only used in one place in C++. Move definitions to nsIDocShell, and rename functions to show they are only used as part of Charset changes. MozReview-Commit-ID: DOSeE3Doc51 Test Plan: Try run Reviewers: nika Tags: #secure-revision Bug #: 1480628 Differential Revision: https://phabricator.services.mozilla.com/D2692
docshell/base/moz.build
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIWebShellServices.h
dom/html/nsHTMLDocument.cpp
parser/html/nsHtml5TreeOpExecutor.cpp
--- a/docshell/base/moz.build
+++ b/docshell/base/moz.build
@@ -57,22 +57,22 @@ XPIDL_SOURCES += [
     'nsIWebNavigationInfo.idl',
     'nsIWebPageDescriptor.idl',
 ]
 
 XPIDL_MODULE = 'docshell'
 
 EXPORTS += [
     'nsCTooltipTextProvider.h',
+    'nsDocShell.h',
     'nsDocShellLoadInfo.h',
     'nsDocShellLoadTypes.h',
     'nsDocShellTreeOwner.h',
     'nsILinkHandler.h',
     'nsIScrollObserver.h',
-    'nsIWebShellServices.h',
     'SerializedLoadContext.h',
 ]
 
 EXPORTS.mozilla += [
     'IHistory.h',
     'LoadContext.h',
 ]
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -522,17 +522,16 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsIScrollable)
   NS_INTERFACE_MAP_ENTRY(nsITextScroll)
   NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
   NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIWebPageDescriptor)
   NS_INTERFACE_MAP_ENTRY(nsIAuthPromptProvider)
   NS_INTERFACE_MAP_ENTRY(nsILoadContext)
-  NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
   NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
   NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
   NS_INTERFACE_MAP_ENTRY(nsIDOMStorageManager)
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsINetworkInterceptController,
                                      mInterceptController)
   NS_INTERFACE_MAP_ENTRY(nsIDeprecationWarner)
 NS_INTERFACE_MAP_END_INHERITING(nsDocLoader)
 
@@ -13779,19 +13778,19 @@ nsDocShell::PluginsAllowedInCurrentDoc()
 
   return doc->GetAllowPlugins();
 }
 
 //----------------------------------------------------------------------
 // Web Shell Services API
 
 // This functions is only called when a new charset is detected in loading a
-// document. Its name should be changed to "CharsetReloadDocument"
-NS_IMETHODIMP
-nsDocShell::ReloadDocument(const char* aCharset, int32_t aSource)
+// document.
+nsresult
+nsDocShell::CharsetChangeReloadDocument(const char* aCharset, int32_t aSource)
 {
   // XXX hack. keep the aCharset and aSource wait to pick it up
   nsCOMPtr<nsIContentViewer> cv;
   NS_ENSURE_SUCCESS(GetContentViewer(getter_AddRefs(cv)), NS_ERROR_FAILURE);
   if (cv) {
     int32_t hint;
     cv->GetHintCharacterSetSource(&hint);
     if (aSource > hint) {
@@ -13813,18 +13812,18 @@ nsDocShell::ReloadDocument(const char* a
         }
       }
     }
   }
   // return failure if this request is not accepted due to mCharsetReloadState
   return NS_ERROR_DOCSHELL_REQUEST_REJECTED;
 }
 
-NS_IMETHODIMP
-nsDocShell::StopDocumentLoad(void)
+nsresult
+nsDocShell::CharsetChangeStopDocumentLoad()
 {
   if (eCharsetReloadRequested != mCharsetReloadState) {
     Stop(nsIWebNavigation::STOP_ALL);
     return NS_OK;
   }
   // return failer if this request is not accepted due to mCharsetReloadState
   return NS_ERROR_DOCSHELL_REQUEST_REJECTED;
 }
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -34,37 +34,37 @@
 #include "nsINetworkInterceptController.h"
 #include "nsIRefreshURI.h"
 #include "nsIScrollable.h"
 #include "nsITabParent.h"
 #include "nsITextScroll.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebPageDescriptor.h"
 #include "nsIWebProgressListener.h"
-#include "nsIWebShellServices.h"
 
 #include "nsAutoPtr.h"
+#include "nsCharsetSource.h"
 #include "nsCOMPtr.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsCRT.h"
 #include "nsDocLoader.h"
 #include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
 #include "nsRect.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 
 #include "GeckoProfiler.h"
 #include "jsapi.h"
 #include "prtime.h"
 #include "Units.h"
 
-#include "timeline/ObservedDocShell.h"
-#include "timeline/TimelineConsumers.h"
-#include "timeline/TimelineMarker.h"
+#include "mozilla/ObservedDocShell.h"
+#include "mozilla/TimelineConsumers.h"
+#include "mozilla/TimelineMarker.h"
 
 // Interfaces Needed
 
 namespace mozilla {
 class Encoding;
 class HTMLEditor;
 enum class TaskCategory;
 namespace dom {
@@ -123,17 +123,16 @@ class nsDocShell final
   , public nsIBaseWindow
   , public nsIScrollable
   , public nsITextScroll
   , public nsIRefreshURI
   , public nsIWebProgressListener
   , public nsIWebPageDescriptor
   , public nsIAuthPromptProvider
   , public nsILoadContext
-  , public nsIWebShellServices
   , public nsILinkHandler
   , public nsIClipboardCommands
   , public nsIDOMStorageManager
   , public nsINetworkInterceptController
   , public nsIDeprecationWarner
   , public mozilla::SupportsWeakPtr<nsDocShell>
 {
 public:
@@ -175,17 +174,16 @@ public:
   NS_DECL_NSISCROLLABLE
   NS_DECL_NSITEXTSCROLL
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_NSIREFRESHURI
   NS_DECL_NSIWEBPAGEDESCRIPTOR
   NS_DECL_NSIAUTHPROMPTPROVIDER
   NS_DECL_NSICLIPBOARDCOMMANDS
-  NS_DECL_NSIWEBSHELLSERVICES
   NS_DECL_NSINETWORKINTERCEPTCONTROLLER
   NS_DECL_NSIDEPRECATIONWARNER
 
   NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
 
   // Need to implement (and forward) nsISecurityEventSink, because
   // nsIWebProgressListener has methods with identical names...
   NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::)
@@ -278,16 +276,21 @@ public:
   }
   bool InFrameSwap();
 
   const mozilla::Encoding* GetForcedCharset() { return mForcedCharset; }
 
   mozilla::HTMLEditor* GetHTMLEditorInternal();
   nsresult SetHTMLEditorInternal(mozilla::HTMLEditor* aHTMLEditor);
 
+  // Handle page navigation due to charset changes
+  nsresult CharsetChangeReloadDocument(const char* aCharset = nullptr,
+                                               int32_t aSource = kCharsetUninitialized);
+  nsresult CharsetChangeStopDocumentLoad();
+
   nsDOMNavigationTiming* GetNavigationTiming() const;
 
   nsresult SetOriginAttributes(const mozilla::OriginAttributes& aAttrs);
 
   /**
    * Get the list of ancestor principals for this docshell.  The list is meant
    * to be the list of principals of the documents this docshell is "nested
    * through" in the sense of
deleted file mode 100644
--- a/docshell/base/nsIWebShellServices.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-#ifndef nsIWebShellServices_h___
-#define nsIWebShellServices_h___
-
-#include "nsISupports.h"
-#include "nsCharsetSource.h"
-
-/* 0c628af0-5638-4703-8f99-ed6134c9de18 */
-#define NS_IWEB_SHELL_SERVICES_IID \
-{ 0x0c628af0, 0x5638, 0x4703, {0x8f, 0x99, 0xed, 0x61, 0x34, 0xc9, 0xde, 0x18} }
-
-class nsIWebShellServices : public nsISupports
-{
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
-
-  NS_IMETHOD ReloadDocument(const char* aCharset = nullptr,
-                            int32_t aSource = kCharsetUninitialized) = 0;
-  NS_IMETHOD StopDocumentLoad(void) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
-
-/* Use this macro when declaring classes that implement this interface. */
-#define NS_DECL_NSIWEBSHELLSERVICES \
-  NS_IMETHOD ReloadDocument(const char* aCharset = nullptr, \
-                            int32_t aSource = kCharsetUninitialized) override; \
-  NS_IMETHOD StopDocumentLoad(void) override;
-
-#endif /* nsIWebShellServices_h___ */
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -30,17 +30,16 @@
 #include "nsIIOService.h"
 #include "nsNetUtil.h"
 #include "nsIPrivateBrowsingChannel.h"
 #include "nsIContentViewer.h"
 #include "nsDocShell.h"
 #include "nsDocShellLoadTypes.h"
 #include "nsIWebNavigation.h"
 #include "nsIBaseWindow.h"
-#include "nsIWebShellServices.h"
 #include "nsIScriptContext.h"
 #include "nsIXPConnect.h"
 #include "nsContentList.h"
 #include "nsError.h"
 #include "nsIPrincipal.h"
 #include "nsJSPrincipals.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsAttrName.h"
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -11,16 +11,17 @@
 
 #include "GeckoProfiler.h"
 #include "mozAutoDocUpdate.h"
 #include "mozilla/IdleTaskRunner.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/css/Loader.h"
 #include "nsContentUtils.h"
+#include "nsDocShell.h"
 #include "nsError.h"
 #include "nsHtml5AutoPauseUpdate.h"
 #include "nsHtml5Parser.h"
 #include "nsHtml5StreamParser.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "nsIContentSecurityPolicy.h"
@@ -28,17 +29,16 @@
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIHTMLDocument.h"
 #include "nsINestedURI.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptError.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIViewSourceChannel.h"
-#include "nsIWebShellServices.h"
 #include "nsNetUtil.h"
 #include "xpcpublic.h"
 
 using namespace mozilla;
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsHtml5TreeOpExecutor,
                                              nsHtml5DocumentBuilder,
                                              nsIContentSink)
@@ -765,28 +765,28 @@ nsHtml5TreeOpExecutor::NeedsCharsetSwitc
                                             uint32_t aLineNumber)
 {
   nsHtml5AutoPauseUpdate autoPause(this);
   if (MOZ_UNLIKELY(!mParser)) {
     // got terminate
     return;
   }
 
-  nsCOMPtr<nsIWebShellServices> wss = do_QueryInterface(mDocShell);
-  if (!wss) {
+  if (!mDocShell) {
     return;
   }
 
-  // ask the webshellservice to load the URL
-  if (NS_SUCCEEDED(wss->StopDocumentLoad())) {
+  nsDocShell* docShell = static_cast<nsDocShell*>(mDocShell.get());
+
+  if (NS_SUCCEEDED(docShell->CharsetChangeStopDocumentLoad())) {
     nsAutoCString charset;
     aEncoding->Name(charset);
-    wss->ReloadDocument(charset.get(), aSource);
+    docShell->CharsetChangeReloadDocument(charset.get(), aSource);
   }
-  // if the charset switch was accepted, wss has called Terminate() on the
+  // if the charset switch was accepted, mDocShell has called Terminate() on the
   // parser by now
 
   if (!mParser) {
     // success
     if (aSource == kCharsetFromMetaTag) {
       MaybeComplainAboutCharset("EncLateMetaReload", false, aLineNumber);
     }
     return;