author | Samael Wang <freesamael@gmail.com> |
Fri, 15 Dec 2017 14:14:06 -0600 | |
changeset 449706 | 3165c7f9db20917c367ee15fb0c17776087714d2 |
parent 449705 | 7e15efd425a6102baef1c968a2167e1b0ba30ef8 |
child 449707 | 33cb29987d2093b92a84dac9fb9bb9907811a3a8 |
push id | 8527 |
push user | Callek@gmail.com |
push date | Thu, 11 Jan 2018 21:05:50 +0000 |
treeherder | mozilla-beta@95342d212a7a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 1406161 |
milestone | 59.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
|
docshell/base/nsDocShell.cpp | file | annotate | diff | comparison | revisions | |
docshell/base/nsDocShell.h | file | annotate | diff | comparison | revisions |
--- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3,301 +3,279 @@ /* 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/. */ #include "nsDocShell.h" #include <algorithm> +#ifdef XP_WIN +#include <process.h> +#define getpid _getpid +#else +#include <unistd.h> // for getpid() +#endif + #include "mozilla/ArrayUtils.h" #include "mozilla/Attributes.h" #include "mozilla/AutoRestore.h" #include "mozilla/BasePrincipal.h" #include "mozilla/Casting.h" -#include "mozilla/dom/ClientChannelHelper.h" -#include "mozilla/dom/ClientHandle.h" -#include "mozilla/dom/ClientInfo.h" -#include "mozilla/dom/ClientManager.h" -#include "mozilla/dom/ClientSource.h" -#include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/Element.h" -#include "mozilla/dom/HTMLAnchorElement.h" -#include "mozilla/dom/PendingGlobalHistoryEntry.h" -#include "mozilla/dom/TabChild.h" -#include "mozilla/dom/ProfileTimelineMarkerBinding.h" -#include "mozilla/dom/ScreenOrientation.h" -#include "mozilla/dom/ToJSValue.h" -#include "mozilla/dom/PermissionMessageUtils.h" -#include "mozilla/dom/workers/ServiceWorkerManager.h" +#include "mozilla/Encoding.h" #include "mozilla/EventStateManager.h" +#include "mozilla/HTMLEditor.h" #include "mozilla/LoadInfo.h" -#include "mozilla/HTMLEditor.h" +#include "mozilla/Logging.h" #include "mozilla/Preferences.h" #include "mozilla/ResultExtensions.h" #include "mozilla/Services.h" #include "mozilla/StartupTimeline.h" #include "mozilla/Telemetry.h" #include "mozilla/Unused.h" -#include "Navigator.h" -#include "URIUtils.h" + +#include "mozilla/dom/ClientChannelHelper.h" +#include "mozilla/dom/ClientHandle.h" +#include "mozilla/dom/ClientInfo.h" +#include "mozilla/dom/ClientManager.h" +#include "mozilla/dom/ClientSource.h" +#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/DocGroup.h" +#include "mozilla/dom/Element.h" +#include "mozilla/dom/HTMLAnchorElement.h" +#include "mozilla/dom/PendingGlobalHistoryEntry.h" +#include "mozilla/dom/PerformanceNavigation.h" +#include "mozilla/dom/PermissionMessageUtils.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" +#include "mozilla/dom/ScreenOrientation.h" +#include "mozilla/dom/ScriptSettings.h" +#include "mozilla/dom/TabChild.h" #include "mozilla/dom/TabGroup.h" - +#include "mozilla/dom/ToJSValue.h" + +#include "mozilla/dom/workers/ServiceWorkerManager.h" + +#include "mozilla/net/ReferrerPolicy.h" + +#include "nsIApplicationCacheChannel.h" +#include "nsIApplicationCacheContainer.h" +#include "nsIAppShell.h" +#include "nsIAsyncVerifyRedirectCallback.h" +#include "nsIAuthPrompt.h" +#include "nsIAuthPrompt2.h" +#include "nsICachingChannel.h" +#include "nsICaptivePortalService.h" +#include "nsIChannel.h" +#include "nsIChannelEventSink.h" +#include "nsIClassOfService.h" +#include "nsICommandManager.h" +#include "nsIConsoleReportCollector.h" #include "nsIContent.h" #include "nsIContentInlines.h" +#include "nsIContentSecurityPolicy.h" +#include "nsIContentViewer.h" +#include "nsIController.h" +#include "nsICookieService.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeOwner.h" #include "nsIDocument.h" +#include "nsIDocumentLoaderFactory.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" +#include "nsIDOMNode.h" +#include "nsIDOMStorage.h" +#include "nsIDOMWindow.h" +#include "nsIEditingSession.h" +#include "nsIExternalProtocolService.h" +#include "nsIFormPOSTActionChannel.h" +#include "nsIFrame.h" +#include "nsIGlobalHistory2.h" +#include "nsIGlobalObject.h" +#include "nsIHttpChannel.h" +#include "nsIHttpChannelInternal.h" +#include "nsIIDNService.h" +#include "nsIInputStreamChannel.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsIJARChannel.h" +#include "nsILayoutHistoryState.h" +#include "nsILoadInfo.h" +#include "nsIMultiPartChannel.h" +#include "nsINestedURI.h" +#include "nsINetworkPredictor.h" +#include "nsINode.h" +#include "nsINSSErrorsService.h" +#include "nsIObserverService.h" +#include "nsIOService.h" +#include "nsIPrincipal.h" +#include "nsIPrivacyTransitionObserver.h" +#include "nsIPrompt.h" +#include "nsIPromptFactory.h" +#include "nsIReflowObserver.h" +#include "nsIScriptChannel.h" +#include "nsIScriptError.h" +#include "nsIScriptObjectPrincipal.h" +#include "nsIScriptSecurityManager.h" +#include "nsIScrollableFrame.h" +#include "nsIScrollObserver.h" +#include "nsISecureBrowserUI.h" +#include "nsISecurityUITelemetry.h" +#include "nsISeekableStream.h" +#include "nsISelectionDisplay.h" +#include "nsISHContainer.h" +#include "nsISHEntry.h" +#include "nsISHistory.h" +#include "nsISHistoryInternal.h" +#include "nsISiteSecurityService.h" +#include "nsISocketProvider.h" +#include "nsIStringBundle.h" +#include "nsIStructuredCloneContainer.h" +#include "nsISupportsPrimitives.h" +#include "nsITabChild.h" +#include "nsITextToSubURI.h" +#include "nsITimedChannel.h" +#include "nsITimer.h" +#include "nsITransportSecurityInfo.h" +#include "nsIUploadChannel.h" +#include "nsIUploadChannel2.h" +#include "nsIURIFixup.h" +#include "nsIURILoader.h" +#include "nsIURL.h" +#include "nsIViewSourceChannel.h" +#include "nsIWebBrowserChrome.h" +#include "nsIWebBrowserChrome3.h" +#include "nsIWebBrowserChromeFocus.h" +#include "nsIWebBrowserFind.h" +#include "nsIWebProgress.h" +#include "nsIWidget.h" +#include "nsIWindowWatcher.h" +#include "nsIWritablePropertyBag2.h" +#include "nsIWyciwygChannel.h" + +#include "nsPICommandUpdater.h" +#include "nsPIDOMWindow.h" +#include "nsPILoadGroupInternal.h" +#include "nsPIWindowRoot.h" + +#include "IHistory.h" +#include "IUrlClassifierUITelemetry.h" + +#include "mozIThirdPartyUtil.h" #include "nsArray.h" #include "nsArrayUtils.h" +#include "nsAutoPtr.h" +#include "nsCDefaultURIFixup.h" +#include "nsCExternalHandlerService.h" +#include "nsContentDLF.h" +#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...) #include "nsContentSecurityManager.h" -#include "nsICaptivePortalService.h" -#include "nsIDOMStorage.h" -#include "nsIContentViewer.h" -#include "nsIDocumentLoaderFactory.h" +#include "nsContentUtils.h" #include "nsCURILoader.h" -#include "nsContentDLF.h" #include "nsDocShellCID.h" +#include "nsDocShellEditorData.h" +#include "nsDocShellEnumerator.h" +#include "nsDocShellLoadInfo.h" +#include "nsDocShellLoadTypes.h" +#include "nsDocShellTransferableHooks.h" #include "nsDOMCID.h" +#include "nsDOMNavigationTiming.h" +#include "nsDSURIContentListener.h" +#include "nsError.h" +#include "nsEscape.h" +#include "nsFocusManager.h" +#include "nsGlobalWindow.h" +#include "nsJSEnvironment.h" #include "nsNetCID.h" #include "nsNetUtil.h" -#include "mozilla/net/ReferrerPolicy.h" -#include "nsRect.h" -#include "prenv.h" -#include "nsIDOMWindow.h" -#include "nsIGlobalObject.h" -#include "nsIViewSourceChannel.h" -#include "nsIWebBrowserChrome.h" +#include "nsObjectLoadingContent.h" #include "nsPoint.h" -#include "nsIObserverService.h" -#include "nsIPrompt.h" -#include "nsIAuthPrompt.h" -#include "nsIAuthPrompt2.h" -#include "nsIChannelEventSink.h" -#include "nsIAsyncVerifyRedirectCallback.h" -#include "nsIScriptSecurityManager.h" -#include "nsIScriptObjectPrincipal.h" -#include "nsIScrollableFrame.h" -#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...) -#include "nsISeekableStream.h" -#include "nsAutoPtr.h" #include "nsQueryObject.h" -#include "nsIWritablePropertyBag2.h" -#include "nsIAppShell.h" -#include "nsWidgetsCID.h" -#include "nsIInterfaceRequestorUtils.h" +#include "nsRect.h" +#include "nsSandboxFlags.h" +#include "nsSHistory.h" +#include "nsStreamUtils.h" +#include "nsStringStream.h" +#include "nsStructuredCloneContainer.h" +#include "nsSubDocumentFrame.h" #include "nsView.h" #include "nsViewManager.h" -#include "nsIScriptChannel.h" -#include "nsITimedChannel.h" -#include "nsIPrivacyTransitionObserver.h" -#include "nsIReflowObserver.h" -#include "nsIScrollObserver.h" -#include "nsIDocShellTreeItem.h" -#include "nsIChannel.h" -#include "IHistory.h" #include "nsViewSourceHandler.h" #include "nsWhitespaceTokenizer.h" -#include "nsICookieService.h" -#include "nsIConsoleReportCollector.h" -#include "nsObjectLoadingContent.h" -#include "nsStringStream.h" - -// we want to explore making the document own the load group -// so we can associate the document URI with the load group. -// until this point, we have an evil hack: -#include "nsIHttpChannelInternal.h" -#include "nsPILoadGroupInternal.h" - -// Local Includes -#include "nsDocShellLoadInfo.h" -#include "nsCDefaultURIFixup.h" -#include "nsDocShellEnumerator.h" -#include "nsSHistory.h" -#include "nsDocShellEditorData.h" +#include "nsWidgetsCID.h" +#include "nsXULAppAPI.h" + #include "GeckoProfiler.h" +#include "Navigator.h" +#include "NullPrincipal.h" +#include "prenv.h" +#include "URIUtils.h" + #include "timeline/JavascriptTimelineMarker.h" -// Helper Classes -#include "nsError.h" -#include "nsEscape.h" - -// Interfaces Needed -#include "nsIFormPOSTActionChannel.h" -#include "nsIUploadChannel.h" -#include "nsIUploadChannel2.h" -#include "nsIWebProgress.h" -#include "nsILayoutHistoryState.h" -#include "nsITimer.h" -#include "nsISHistoryInternal.h" -#include "nsIPrincipal.h" -#include "NullPrincipal.h" -#include "nsISHEntry.h" -#include "nsIWindowWatcher.h" -#include "nsIPromptFactory.h" -#include "nsITransportSecurityInfo.h" -#include "nsINode.h" -#include "nsINSSErrorsService.h" -#include "nsIApplicationCacheChannel.h" -#include "nsIApplicationCacheContainer.h" -#include "nsStreamUtils.h" -#include "nsIController.h" -#include "nsPICommandUpdater.h" -#include "nsIWebBrowserChrome3.h" -#include "nsITabChild.h" -#include "nsISiteSecurityService.h" -#include "nsStructuredCloneContainer.h" -#include "nsIStructuredCloneContainer.h" -#include "nsISupportsPrimitives.h" #ifdef MOZ_PLACES #include "nsIFaviconService.h" #include "mozIPlacesPendingOperation.h" #include "mozIAsyncFavicons.h" #endif -#include "nsINetworkPredictor.h" - -// Editor-related -#include "nsIEditingSession.h" - -#include "nsPIDOMWindow.h" -#include "nsGlobalWindow.h" -#include "nsPIWindowRoot.h" -#include "nsICachingChannel.h" -#include "nsIMultiPartChannel.h" -#include "nsIWyciwygChannel.h" - -// For reporting errors with the console service. -// These can go away if error reporting is propagated up past nsDocShell. -#include "nsIScriptError.h" - -// used to dispatch urls to default protocol handlers -#include "nsCExternalHandlerService.h" -#include "nsIExternalProtocolService.h" - -#include "nsFocusManager.h" - -#include "nsITextToSubURI.h" - -#include "nsIJARChannel.h" - -#include "mozilla/Logging.h" - -#include "nsISelectionDisplay.h" - -#include "nsIGlobalHistory2.h" - -#include "nsIFrame.h" -#include "nsSubDocumentFrame.h" - -// for embedding -#include "nsIWebBrowserChromeFocus.h" #if NS_PRINT_PREVIEW #include "nsIDocumentViewerPrint.h" #include "nsIWebBrowserPrint.h" #endif -#include "nsContentUtils.h" -#include "nsIContentSecurityPolicy.h" -#include "nsILoadInfo.h" -#include "nsSandboxFlags.h" -#include "nsXULAppAPI.h" -#include "nsDOMNavigationTiming.h" -#include "nsISecurityUITelemetry.h" -#include "nsDSURIContentListener.h" -#include "nsDocShellLoadTypes.h" -#include "nsDocShellTransferableHooks.h" -#include "nsICommandManager.h" -#include "nsIDOMNode.h" -#include "nsIClassOfService.h" -#include "nsIDocShellTreeOwner.h" -#include "nsIHttpChannel.h" -#include "nsIIDNService.h" -#include "nsIInputStreamChannel.h" -#include "nsINestedURI.h" -#include "nsIOService.h" -#include "nsISHContainer.h" -#include "nsISHistory.h" -#include "nsISecureBrowserUI.h" -#include "nsISocketProvider.h" -#include "nsIStringBundle.h" -#include "nsIURIFixup.h" -#include "nsIURILoader.h" -#include "nsIURL.h" -#include "nsIWebBrowserFind.h" -#include "nsIWidget.h" -#include "mozilla/dom/PerformanceNavigation.h" -#include "mozilla/dom/ScriptSettings.h" -#include "mozilla/Encoding.h" -#include "nsJSEnvironment.h" -#include "IUrlClassifierUITelemetry.h" - #ifdef MOZ_TOOLKIT_SEARCH #include "nsIBrowserSearchService.h" #endif -#include "mozIThirdPartyUtil.h" - -static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); - -#if defined(DEBUG_bryner) || defined(DEBUG_chb) -//#define DEBUG_DOCSHELL_FOCUS -#define DEBUG_PAGE_CACHE -#endif - -#ifdef XP_WIN -#include <process.h> -#define getpid _getpid -#else -#include <unistd.h> // for getpid() -#endif - using namespace mozilla; using namespace mozilla::dom; using mozilla::dom::workers::ServiceWorkerManager; +// Threshold value in ms for META refresh based redirects +#define REFRESH_REDIRECT_TIMER 15000 + +// Hint for native dispatch of events on how long to delay after +// all documents have loaded in milliseconds before favoring normal +// native event dispatch priorites over performance +// Can be overridden with docshell.event_starvation_delay_hint pref. +#define NS_EVENT_STARVATION_DELAY_HINT 2000 + +static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); + // True means sUseErrorPages has been added to // preferences var cache. static bool gAddedPreferencesVarCache = false; -bool nsDocShell::sUseErrorPages = false; - // Number of documents currently loading static int32_t gNumberOfDocumentsLoading = 0; // Global count of existing docshells. static int32_t gDocShellCount = 0; // Global count of docshells with the private attribute set static uint32_t gNumberOfPrivateDocShells = 0; -// Global reference to the URI fixup service. -nsIURIFixup* nsDocShell::sURIFixup = 0; - // True means we validate window targets to prevent frameset // spoofing. Initialize this to a non-bolean value so we know to check // the pref on the creation of the first docshell. static uint32_t gValidateOrigin = 0xffffffff; -// Hint for native dispatch of events on how long to delay after -// all documents have loaded in milliseconds before favoring normal -// native event dispatch priorites over performance -// Can be overridden with docshell.event_starvation_delay_hint pref. -#define NS_EVENT_STARVATION_DELAY_HINT 2000 - #ifdef DEBUG static mozilla::LazyLogModule gDocShellLog("nsDocShell"); #endif static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak");; const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties"; const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties"; +bool nsDocShell::sUseErrorPages = false; + +// Global reference to the URI fixup service. +nsIURIFixup* nsDocShell::sURIFixup = nullptr; + static void FavorPerformanceHint(bool aPerfOverStarvation) { nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID); if (appShell) { appShell->FavorPerformanceHint( aPerfOverStarvation, Preferences::GetUint("docshell.event_starvation_delay_hint",
--- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -2,114 +2,116 @@ /* 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 nsDocShell_h__ #define nsDocShell_h__ -#include "nsITimer.h" -#include "nsContentPolicyUtils.h" -#include "nsIDocShell.h" -#include "nsIDocShellTreeItem.h" -#include "nsIBaseWindow.h" -#include "nsINetworkInterceptController.h" -#include "nsIScrollable.h" -#include "nsITextScroll.h" -#include "nsIContentViewerContainer.h" -#include "nsIDOMStorageManager.h" -#include "nsDocLoader.h" #include "mozilla/BasePrincipal.h" +#include "mozilla/LinkedList.h" #include "mozilla/Maybe.h" #include "mozilla/Move.h" +#include "mozilla/TimeStamp.h" #include "mozilla/UniquePtr.h" #include "mozilla/WeakPtr.h" -#include "mozilla/TimeStamp.h" -#include "GeckoProfiler.h" + #include "mozilla/dom/ProfileTimelineMarkerBinding.h" -#include "mozilla/LinkedList.h" -#include "jsapi.h" -// Helper Classes +#include "nsIAuthPromptProvider.h" +#include "nsIBaseWindow.h" +#include "nsIClipboardCommands.h" +#include "nsIContentViewerContainer.h" +#include "nsIDeprecationWarner.h" +#include "nsIDocCharset.h" +#include "nsIDocShell.h" +#include "nsIDocShellLoadInfo.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDOMStorageManager.h" +#include "nsIInterfaceRequestor.h" +#include "nsILinkHandler.h" +#include "nsILoadContext.h" +#include "nsILoadURIDelegate.h" +#include "nsINamed.h" +#include "nsINetworkInterceptController.h" +#include "nsIRefreshURI.h" +#include "nsIScrollable.h" +#include "nsITabParent.h" +#include "nsITextScroll.h" +#include "nsITimer.h" +#include "nsIWebNavigation.h" +#include "nsIWebPageDescriptor.h" +#include "nsIWebProgressListener.h" +#include "nsIWebShellServices.h" + +#include "nsAutoPtr.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 "nsAutoPtr.h" #include "nsThreadUtils.h" -#include "nsContentUtils.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" -// Threshold value in ms for META refresh based redirects -#define REFRESH_REDIRECT_TIMER 15000 - // Interfaces Needed -#include "nsIDocCharset.h" -#include "nsIInterfaceRequestor.h" -#include "nsINamed.h" -#include "nsIRefreshURI.h" -#include "nsIWebNavigation.h" -#include "nsIWebPageDescriptor.h" -#include "nsIWebProgressListener.h" -#include "nsIDocShellLoadInfo.h" -#include "nsIAuthPromptProvider.h" -#include "nsILoadContext.h" -#include "nsIWebShellServices.h" -#include "nsILinkHandler.h" -#include "nsIClipboardCommands.h" -#include "nsITabParent.h" -#include "nsCRT.h" -#include "prtime.h" -#include "nsRect.h" -#include "Units.h" -#include "nsIDeprecationWarner.h" -#include "nsILoadURIDelegate.h" namespace mozilla { class Encoding; class HTMLEditor; enum class TaskCategory; namespace dom { class ClientInfo; class ClientSource; class EventTarget; class PendingGlobalHistoryEntry; typedef uint32_t ScreenOrientationInternal; } // namespace dom } // namespace mozilla -class nsDocShell; -class nsDOMNavigationTiming; -class nsGlobalWindowOuter; -class nsGlobalWindowInner; -class nsIController; -class nsIScrollableFrame; -class OnLinkClickEvent; -class nsDSURIContentListener; -class nsDocShellEditorData; class nsIClipboardDragDropHookList; class nsICommandManager; class nsIContentViewer; +class nsIController; +class nsIDocShellTreeOwner; class nsIDocument; class nsIDOMNode; -class nsIDocShellTreeOwner; class nsIGlobalHistory2; class nsIHttpChannel; class nsIMutableArray; class nsIPrompt; +class nsIScrollableFrame; +class nsISecureBrowserUI; class nsISHistory; -class nsISecureBrowserUI; class nsIStringBundle; class nsIURIFixup; class nsIURILoader; class nsIWebBrowserFind; class nsIWidget; + +class nsDocShell; +class nsDocShellEditorData; +class nsDOMNavigationTiming; +class nsDSURIContentListener; +class nsGlobalWindowInner; +class nsGlobalWindowOuter; + class FramingChecker; +class OnLinkClickEvent; /* internally used ViewMode types */ enum ViewMode { viewNormal = 0x0, viewSource = 0x1 };